本文整理汇总了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();
}
}