當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.getUserData方法代碼示例

本文整理匯總了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();
	}
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:67,代碼來源:VersionChangeController.java


注:本文中的javafx.scene.control.Button.getUserData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。