本文整理匯總了Java中javafx.scene.control.Button.getUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.getUserData方法的具體用法?Java Button.getUserData怎麽用?Java Button.getUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Button
的用法示例。
在下文中一共展示了Button.getUserData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: installAction
import javafx.scene.control.Button; //導入方法依賴的package包/類
/**
* Triggers the installation of the chosen {@link SAMPVersion}.
*
* @param button
* the {@link Button} which was clicked.
*/
private void installAction(final Button button) {
final InstallationCandidate toInstall = (InstallationCandidate) button.getUserData();
final Optional<InstallationCandidate> installedVersion = GTAController.getInstalledVersion();
if (installedVersion.isPresent()) {
setAllButtonsDisabled(true);
button.setText(INSTALLING_TEXT);
GTAController.killSAMP();
GTAController.killGTA();
/*
* TODO Marcel 09.01.2018 I will keep the caching in here for a while, even though
* that'd mean
* duplicated all local installation candidates.
*/
if (CacheController.isVersionCached(toInstall)) {
installCachedVersion(toInstall);
finishInstalling();
}
else {
// TODO(MSC) Check JavaFX Threading API (Task / Service)
// Using a thread here, incase someone wants to keep using the app meanwhile
new Thread(() -> {
Optional<File> downloadedFile = Optional.empty();
try {
currentlyInstalling = Optional.of(toInstall);
final Optional<String> gtaPath = GTAController.getGtaPath();
switch (toInstall.getSourceType()) {
case FILE_SYSTEM:
FileUtility.unzip(new File(toInstall.getUrl()).toString(), gtaPath.get());
break;
case INTERNET:
downloadedFile = Optional.of(FileUtility.downloadFile(toInstall.getUrl(), PathConstants.OUTPUT_ZIP));
if (ClientPropertiesController.getPropertyAsBoolean(Property.ALLOW_CACHING_DOWNLOADS)) {
CacheController.addVersionToCache(toInstall, PathConstants.OUTPUT_ZIP);
}
FileUtility.unzip(PathConstants.OUTPUT_ZIP, gtaPath.get());
break;
case RESSOURCE:
// TODO (Marcel 10.01.2018): I am not quite sure, if i ever wanna
// ship with a samp version already installed.
break;
}
}
catch (final IOException | IllegalArgumentException exception) {
Logging.error("Error Updating client.", exception);
}
downloadedFile.ifPresent(File::delete);
finishInstalling();
}).start();
}
}
else {
GTAController.displayCantLocateGTANotification();
}
}