List of usage examples for javafx.scene.control ButtonType ButtonType
public ButtonType(@NamedArg("text") String text)
From source file:io.github.medinam.jcheesum.util.VersionChecker.java
public static void showDownloadLatestAlert() { Alert alert = new Alert(Alert.AlertType.INFORMATION); ResourceBundle resources = ResourceBundle.getBundle("i18n/Bundle", Locale.getDefault()); alert.setTitle(resources.getString("newVersion")); alert.setHeaderText(resources.getString("newVersionLooksLike")); alert.setContentText(resources.getString("youHave") + App.class.getPackage().getImplementationVersion() + " " + resources.getString("latestVersionIs") + getLatestStable() + "\n\n" + resources.getString("wannaDownload")); ButtonType yesBtn = new ButtonType(resources.getString("yes")); ButtonType noBtn = new ButtonType(resources.getString("no"), ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(yesBtn, noBtn); Optional<ButtonType> o = alert.showAndWait(); if (o.get() == yesBtn) { General.openLink(getLatestStableDownloadURL()); } else if (o.get() == noBtn) { alert.close();//from ww w .ja v a 2s. c om } }
From source file:editeurpanovisu.EquiCubeDialogController.java
/** * *///w w w.ja v a2s. com private void annulerE2C() { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); if ((lvListeFichier.getItems().size() != 0) && (!bTraitementEffectue)) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(rbLocalisation.getString("transformation.traiteImages")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("transformation.traiteImagesQuitte")); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if ((reponse == buttonTypeOui) || (reponse == null)) { bTraitementEffectue = false; stTransformations.hide(); } }
From source file:ubicrypt.UbiCrypt.java
@Override public void start(final Stage stage) throws Exception { setUserAgentStylesheet(STYLESHEET_MODENA); stage.setTitle("UbiCrypt"); anchor().setStage(stage);/*from w w w. j a va2 s . c o m*/ try { final PGPKeyPair kp = encryptionKey(); encrypt(Collections.singletonList(kp.getPublicKey()), new ByteArrayInputStream(StringUtils.repeat("ciao", 1).getBytes())); } catch (Exception e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Strong Encryption Required"); alert.setHeaderText("Install JCE Unlimited Strength Jurisdiction policy files"); alert.setContentText( "You can install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files, which are required to use strong encryption.\n" + "Download the files and instructions for Java 8.\n" + "Locate the jre\\lib\\security directory for the Java instance that the UbiCrypt is using.\n" + "For example, this location might be: C:\\Program Files\\Java\\jre8\\lib\\security.\n" + "Replace these two files with the .jar files included in the JCE Unlimited Strength Jurisdiction Policy Files download.\n" + "Stop and restart the UbiCrypt.\n\n\n\n\n\n"); ButtonType icePage = new ButtonType("Go to JCE download Page"); alert.getButtonTypes().addAll(icePage); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == icePage) { getHostServices().showDocument( "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html"); } Platform.exit(); } final File secFile = securityFile().toFile(); stage.setScene(anchor().show(secFile.exists() ? "login" : "createKey", getHostServices())); stage.show(); final UbiCrypt ubiCrypt = this; anchor().getPasswordStream().subscribeOn(Schedulers.io()).subscribe(pwd -> { final SpringApplication app = new SpringApplication(UbiConf.class, PathConf.class, UIConf.class); app.setRegisterShutdownHook(false); app.addInitializers(new FixPassPhraseInitializer(pwd)); app.setLogStartupInfo(true); ctx = app.run(); ctx.getAutowireCapableBeanFactory().autowireBean(ubiCrypt); ctx.getBeanFactory().registerSingleton("stage", stage); ctx.getBeanFactory().registerSingleton("hostService", getHostServices()); ctx.getBeanFactory().registerSingleton("osUtil", new OSUtil(getHostServices())); ControllerFactory cfactory = new ControllerFactory(ctx); StackNavigator navigator = new StackNavigator(null, "main", cfactory); stage.setScene(new Scene(navigator.open())); }); stage.setOnCloseRequest(windowEvent -> shutdown.run()); Runtime.getRuntime().addShutdownHook(new Thread(shutdown)); }
From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignController.java
public void addConfigFile(File file, boolean ask) { if (file != null) { // Check valid config if (!readConfig(file.getPath())) { getContext().send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.ERROR, DPFManagerProperties.getBundle().getString("errorReadingConfFile"))); file = null;/*w w w. jav a 2 s . co m*/ } } if (file != null && ask) { DPFManagerProperties.setDefaultDirConfig(file.getParent()); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(getBundle().getString("copyTitle")); alert.setHeaderText(getBundle().getString("copyHeader")); alert.setContentText(getBundle().getString("copyContent")); ButtonType buttonTypeYes = new ButtonType(getBundle().getString("yes")); ButtonType buttonTypeNo = new ButtonType(getBundle().getString("no")); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes) { // Copy the file boolean needAdd = true; boolean error = false; File configFile = new File(DPFManagerProperties.getConfigDir() + "/" + file.getName()); if (configFile.exists()) { configFile.delete(); needAdd = false; } try { FileUtils.copyFile(file, configFile); } catch (IOException e) { error = true; } if (error) { // Add source file String description = readDescription(file); getView().addConfigFile(file.getAbsolutePath(), description, false); getContext().send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.WARNING, getBundle().getString("errorCopyConfig"))); } else if (needAdd) { String description = readDescription(configFile); getView().addConfigFile(configFile.getName(), description, false); } } else { String description = readDescription(file); getView().addConfigFile(file.getAbsolutePath(), description, false); } } else if (file != null && !ask) { getView().addConfigFile(file.getAbsolutePath(), readDescription(file), false); } }
From source file:ui.main.MainViewController.java
@FXML public void handleFriendRequestButtonAction(ActionEvent event) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Confirmation"); alert.setHeaderText("Accept Friend Request!"); alert.setContentText("Are you sure to add the this user as a friend?"); ButtonType buttonTpeYes = new ButtonType("Yes"); ButtonType buttonTypeNo = new ButtonType("Not Now"); ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTpeYes, buttonTypeNo, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTpeYes) { contactsManager.acceptFriend(currentChat.getParticipant()); friendRequest.setVisible(false); } else if (result.get() == buttonTypeNo) { // ... no thing to do } else {// w w w.ja va 2s.c o m // ... user chose CANCEL or closed the dialog } }
From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java
public void addIsoFile(File file, boolean ask) { if (file == null) { return;// w w w . j a va2 s . c o m } // Check valid config ImplementationCheckerObjectType rules = ImplementationCheckerLoader.getRules(file.getPath()); if (rules == null) { context.send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.ERROR, DPFManagerProperties.getBundle().getString("w1errorReadingIso").replace("%1", file.getPath()))); return; } if (ask) { DPFManagerProperties.setDefaultDirConfig(file.getParent()); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(bundle.getString("w1copyTitle")); alert.setHeaderText(bundle.getString("w1copyHeader")); alert.setContentText(bundle.getString("w1copyContent")); ButtonType buttonTypeYes = new ButtonType(bundle.getString("yes")); ButtonType buttonTypeNo = new ButtonType(bundle.getString("no")); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes) { // Copy the file boolean needAdd = true, error = false; File configFile = new File(DPFManagerProperties.getIsosDir() + "/" + file.getName()); if (configFile.exists()) { configFile.delete(); needAdd = false; } try { FileUtils.copyFile(file, configFile); } catch (IOException e) { error = true; } if (error) { // Add source file addExternalCheckBox(file.getAbsolutePath(), true); context.send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.WARNING, bundle.getString("w1errorCopyConfig"))); } else if (needAdd) { addConfigCheckBox(configFile, true); } } else { addExternalCheckBox(file.getAbsolutePath(), true); } } else { addExternalCheckBox(file.getAbsolutePath(), true); } }
From source file:de.bayern.gdi.gui.Controller.java
/** * Handler to close the application./* w w w. j a v a 2 s . com*/ * * @param event The event. */ @FXML protected void handleCloseApp(ActionEvent event) { Alert closeDialog = new Alert(Alert.AlertType.CONFIRMATION); closeDialog.setTitle(I18n.getMsg("gui.confirm-exit")); closeDialog.setContentText(I18n.getMsg("gui.want-to-quit")); ButtonType confirm = new ButtonType(I18n.getMsg("gui.exit")); ButtonType cancel = new ButtonType(I18n.getMsg("gui.cancel"), ButtonData.CANCEL_CLOSE); closeDialog.getButtonTypes().setAll(confirm, cancel); Optional<ButtonType> res = closeDialog.showAndWait(); if (res.isPresent() && res.get() == confirm) { logToAppLog(I18n.format("dlc.stop")); Stage stage = (Stage) buttonClose.getScene().getWindow(); stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST)); } }
From source file:de.pixida.logtest.designer.MainWindow.java
private boolean handleCloseTab() { final Editor currentEditor = this.getCurrentEditor(); if (!currentEditor.hasUnsavedChanges()) { return true; }/*from ww w. j a v a 2 s .com*/ final Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Confirm close"); alert.setHeaderText("If the " + currentEditor.getTypeName() + " \"" + currentEditor.getTitleShort().get() + "\" is not saved, all changes are lost."); alert.setContentText("Do you want to save the " + currentEditor.getTypeName() + "?"); final ButtonType yes = new ButtonType("Yes"); final ButtonType no = new ButtonType("No"); final ButtonType cancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(yes, no, cancel); final Optional<ButtonType> choice = alert.showAndWait(); if (choice.get() == yes) { // Continue with saving if (!this.handleSaveDocument()) { return false; } } else if (choice.get() == no) { // Dispose document } else { // User closed dialog or chose cancel return false; } return true; }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
@FXML void handleBtnAccounts(ActionEvent event) { ArrayList<Account> accountsToGen = new ArrayList<>(); if ("Tous les comptes".equals(cbo_accounts.getSelectionModel().getSelectedItem())) { accountsToGen = accounts;/* www.jav a2s . c om*/ } else { accountsToGen.add(accounts.get(cbo_accounts.getSelectionModel().getSelectedIndex())); } getTransactionsFromWeb(); String fileName = ""; try { fileName = genOFXFile(accountsToGen); } catch (MyOwnException ex) { Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex); } Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Confirmation "); alert.setHeaderText(null); alert.setX(InvestiaGenOFX.getPrimaryStage().getX() + 100); alert.setY(InvestiaGenOFX.getPrimaryStage().getY() + 100); alert.setContentText("Fichier OFX gnr \rLance le fichier OFX?"); ButtonType buttonTypeYes = new ButtonType("Oui"); ButtonType buttonTypeNo = new ButtonType("Non"); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes) { try { Utilities.launchFile(fileName); } catch (IOException ex) { Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex); } new File(fileName).deleteOnExit(); } showAcountsInvestments(accountsToGen); }
From source file:com.properned.application.SystemController.java
public ButtonType askForSave() { logger.info("Save alert open"); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(MessageReader.getInstance().getMessage("popup.confirmation.warning")); alert.setHeaderText(MessageReader.getInstance().getMessage("popup.confirmation.close.title")); alert.setContentText(MessageReader.getInstance().getMessage("popup.confirmation.close.body")); ButtonType buttonTypeYes = new ButtonType(MessageReader.getInstance().getMessage("yes")); ButtonType buttonTypeNo = new ButtonType(MessageReader.getInstance().getMessage("no")); ButtonType buttonTypeCancel = new ButtonType("cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes) { logger.info("the user want to save current files"); this.save(); } else if (result.get() == buttonTypeNo) { // Nothing to do here logger.info("the user doesn't want to save current files"); } else {/*w ww. j a v a 2 s . co m*/ logger.info("Properned close cancelled"); } return result.get(); }