List of usage examples for javafx.scene.control ButtonType OK
ButtonType OK
To view the source code for javafx.scene.control ButtonType OK.
Click Source Link
From source file:be.makercafe.apps.makerbench.Main.java
private ContextMenu createViewerContextMenu() { ContextMenu rootContextMenu = new ContextMenu(); // Add Folder.. MenuItem addFolder = new MenuItem("Add folder.."); addFolder.setOnAction(new EventHandler<ActionEvent>() { @Override/* w ww. j av a2 s . c o m*/ public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfolder"); dialog.setTitle("New folder"); dialog.setHeaderText("Create a new folder"); dialog.setContentText("Folder name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { if (!file.mkdir()) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating folder"); alert.setContentText("Folder path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); // Delete folder MenuItem deleteFolder = new MenuItem("Delete folder.."); deleteFolder.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete folder"); alert.setContentText("Please confirm deleteion of selected folder and all it's contents ?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { try { FileUtils.deleteDirectory(file); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting folder"); alert.setContentText("Error messsage: " + e.getMessage()); alert.showAndWait(); } } } } }); // Add File.. MenuItem addFile = new MenuItem("Add file.."); addFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfile.txt"); dialog.setTitle("New file"); dialog.setHeaderText("Create a new file (.jfxscad, .jfxmill, .txt, .md, .xml, .gcode"); dialog.setContentText("File name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { try { file.createNewFile(); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating file"); alert.setContentText( "File path: " + file.getAbsolutePath() + "\nError message: " + e.getMessage()); alert.showAndWait(); } } } } }); // Delete file MenuItem deleteFile = new MenuItem("Delete file.."); deleteFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete file"); alert.setContentText("Please confirm deleteion of selected file"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { if (!file.delete()) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting file"); alert.setContentText("File path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); rootContextMenu.getItems().addAll(addFolder, deleteFolder, addFile, deleteFile); return rootContextMenu; }
From source file:cz.lbenda.rcp.DialogHelper.java
/** Open dialog with chooser when user can choose single option * @param question question which is show to user * @param items list of items which user can choose * @param <T> type of item/*from w w w . j a v a 2 s.com*/ * @return null if user click on cancel or don't choose anything, elsewhere choosed item */ @SuppressWarnings("unchecked") public static <T> T chooseSingOption(String question, T... items) { if (items.length == 0) { return null; } Dialog<T> dialog = new Dialog<>(); dialog.setResizable(false); dialog.setTitle(chooseSingleOption_title); dialog.setHeaderText(question); ComboBox<T> comboBox = new ComboBox<>(); comboBox.getItems().addAll(items); dialog.getDialogPane().setContent(comboBox); ButtonType btCancel = ButtonType.CANCEL; ButtonType btOk = ButtonType.OK; dialog.getDialogPane().getButtonTypes().addAll(btCancel, btOk); Optional<T> result = dialog.showAndWait(); if (result.isPresent()) { if (btCancel == result.get()) { return null; } if (btOk == result.get()) { return comboBox.getSelectionModel().getSelectedItem(); } } else { return null; } return result.get(); }
From source file:utilitybasedfx.MainGUIController.java
@FXML private void eventImportCompiled(ActionEvent event) { File selectedDir = Utils.dirChooser("Please choose the project classes root folder"); File classDir = new File(Prefs.getClassPath()); boolean shouldContinue = true; if (selectedDir != null) { if (classDir.isDirectory()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("This project already exists!"); alert.setHeaderText(/*w ww . java2 s. com*/ "This project already has a class folder meaning it already has files imported"); alert.setContentText( "Are you sure you want to import the new source?\nPressing OK will delete the files previous imported to this project and replace them with the new files."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { classDir.delete(); } else { shouldContinue = false; } } if (shouldContinue) { shouldRefreshFileTree = true; enableWorking(new Task<String>() { @Override protected String call() throws InterruptedException { updateMessage("Copying Files..."); try { FileUtils.copyDirectory(selectedDir, classDir); } catch (IOException e) { Utils.stackErrorDialog(e); } updateMessage(""); return ""; //[FIXME] find a way to do this inline function without a class as return type } }); } } }
From source file:eu.over9000.skadi.ui.MainWindow.java
private void setupToolbar(final Stage stage) { this.add = GlyphsDude.createIconButton(FontAwesomeIcons.PLUS); this.addName = new TextField(); this.addName.setOnAction(event -> this.add.fire()); this.add.setOnAction(event -> { final String name = this.addName.getText().trim(); if (name.isEmpty()) { return; }/*from w w w . ja v a2 s. c o m*/ final boolean result = this.channelHandler.addChannel(name, this.sb); if (result) { this.addName.clear(); } }); this.imprt = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD); this.imprt.setOnAction(event -> { final TextInputDialog dialog = new TextInputDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); dialog.setTitle("Import followed channels"); dialog.setHeaderText("Import followed channels from Twitch"); dialog.setGraphic(null); dialog.setContentText("Twitch username:"); dialog.showAndWait().ifPresent(name -> { final ImportFollowedService ifs = new ImportFollowedService(this.channelHandler, name, this.sb); ifs.start(); }); }); this.details = GlyphsDude.createIconButton(FontAwesomeIcons.INFO); this.details.setDisable(true); this.details.setOnAction(event -> { this.detailChannel.set(this.table.getSelectionModel().getSelectedItem()); if (!this.sp.getItems().contains(this.detailPane)) { this.sp.getItems().add(this.detailPane); this.doDetailSlide(true); } }); this.details.setTooltip(new Tooltip("Show channel information")); this.remove = GlyphsDude.createIconButton(FontAwesomeIcons.TRASH); this.remove.setDisable(true); this.remove.setOnAction(event -> { final Channel candidate = this.table.getSelectionModel().getSelectedItem(); final Alert alert = new Alert(AlertType.CONFIRMATION); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(stage); alert.setTitle("Delete channel"); alert.setHeaderText("Delete " + candidate.getName()); alert.setContentText("Do you really want to delete " + candidate.getName() + "?"); final Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { this.channelHandler.getChannels().remove(candidate); this.sb.setText("Removed channel " + candidate.getName()); } }); this.refresh = GlyphsDude.createIconButton(FontAwesomeIcons.REFRESH); this.refresh.setTooltip(new Tooltip("Refresh all channels")); this.refresh.setOnAction(event -> { this.refresh.setDisable(true); final ForcedChannelUpdateService service = new ForcedChannelUpdateService(this.channelHandler, this.sb, this.refresh); service.start(); }); this.settings = GlyphsDude.createIconButton(FontAwesomeIcons.COG); this.settings.setTooltip(new Tooltip("Settings")); this.settings.setOnAction(event -> { final SettingsDialog dialog = new SettingsDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); final Optional<StateContainer> result = dialog.showAndWait(); if (result.isPresent()) { this.persistenceHandler.saveState(result.get()); } }); this.onlineOnly = new ToggleButton("Live", GlyphsDude.createIcon(FontAwesomeIcons.FILTER)); this.onlineOnly.setSelected(this.currentState.isOnlineFilterActive()); this.onlineOnly.setOnAction(event -> { this.currentState.setOnlineFilterActive(this.onlineOnly.isSelected()); this.persistenceHandler.saveState(this.currentState); this.updateFilterPredicate(); }); // TODO re-enable if 8u60 is released this.onlineOnly.setDisable(true); this.filterText = new TextField(); this.filterText.textProperty().addListener((obs, oldV, newV) -> this.updateFilterPredicate()); this.filterText.setTooltip(new Tooltip("Filter channels by name, status and game")); // TODO re-enable if 8u60 is released this.filterText.setDisable(true); this.tb = new ToolBar(); this.tb.getItems().addAll(this.addName, this.add, this.imprt, new Separator(), this.refresh, this.settings, new Separator(), this.onlineOnly, this.filterText, new Separator(), this.details, this.remove); this.chatAndStreamButton = new HandlerControlButton(this.chatHandler, this.streamHandler, this.table, this.tb, this.sb); this.updateFilterPredicate(); }
From source file:org.cryptomator.ui.controllers.MainController.java
@FXML private void didClickRemoveSelectedEntry(ActionEvent e) { Alert confirmDialog = DialogBuilderUtil.buildConfirmationDialog( // localization.getString("main.directoryList.remove.confirmation.title"), // localization.getString("main.directoryList.remove.confirmation.header"), // localization.getString("main.directoryList.remove.confirmation.content"), // SystemUtils.IS_OS_MAC_OSX ? ButtonType.CANCEL : ButtonType.OK); Optional<ButtonType> choice = confirmDialog.showAndWait(); if (ButtonType.OK.equals(choice.get())) { vaults.remove(selectedVault.get()); if (vaults.isEmpty()) { activeController.set(welcomeController.get()); }/* w ww . j av a2 s.c om*/ } }
From source file:statos2_0.StatOS2_0.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); GridPane root = new GridPane(); Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); root.setAlignment(Pos.CENTER);//from ww w . j a v a 2 s . c om root.setHgap(10); root.setVgap(10); root.setPadding(new Insets(25, 25, 25, 25)); Text scenetitle = new Text(""); root.add(scenetitle, 0, 0, 2, 1); scenetitle.setId("welcome-text"); Label userName = new Label(":"); //userName.setId("label"); root.add(userName, 0, 1); TextField userTextField = new TextField(); root.add(userTextField, 1, 1); Label pw = new Label(":"); root.add(pw, 0, 2); PasswordField pwBox = new PasswordField(); root.add(pwBox, 1, 2); ComboBox store = new ComboBox(); store.setItems(GetByTag()); root.add(store, 1, 3); Button btn = new Button(""); //btn.setPrefSize(100, 20); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); root.add(hbBtn, 1, 4); Button btn2 = new Button(""); //btn2.setPrefSize(100, 20); HBox hbBtn2 = new HBox(10); hbBtn2.setAlignment(Pos.BOTTOM_RIGHT); hbBtn2.getChildren().add(btn2); root.add(hbBtn2, 1, 5); final Text actiontarget = new Text(); root.add(actiontarget, 1, 6); btn2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.exit(0); } }); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (userTextField.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (pwBox.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (store.getSelectionModel().getSelectedIndex() < 0) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { try { String[] resu = checkpas(userTextField.getText(), pwBox.getText()); if (resu[0].equals("-1")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !" + "\n - "); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } else { // ... user chose CANCEL or closed the dialog } } else { // idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } } catch (NoSuchAlgorithmException ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } } /** * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){ * actiontarget.setId("acttrue"); * actiontarget.setText(" !"); * MainA ma = new MainA(); * ma.m=1; * try { * ma.m=1; * ma.MT="m1"; * ma.start(primaryStage); * } catch (Exception ex) { * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); * } * }else{ * actiontarget.setId("actfalse"); * actiontarget.setText(" !"); * } **/ } }); //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); //sSize.getHeight(); Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight()); primaryStage.setScene(scene); scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm()); primaryStage.show(); }
From source file:org.cryptomator.ui.controllers.UnlockController.java
@FXML private void didClickSavePasswordCheckbox(ActionEvent event) { if (!savePassword.isSelected() && hasStoredPassword()) { Alert confirmDialog = DialogBuilderUtil.buildConfirmationDialog( // localization.getString("unlock.savePassword.delete.confirmation.title"), // localization.getString("unlock.savePassword.delete.confirmation.header"), // localization.getString("unlock.savePassword.delete.confirmation.content"), // SystemUtils.IS_OS_MAC_OSX ? ButtonType.CANCEL : ButtonType.OK); Optional<ButtonType> choice = confirmDialog.showAndWait(); if (ButtonType.OK.equals(choice.get())) { keychainAccess.get().deletePassphrase(vault.getId()); } else if (ButtonType.CANCEL.equals(choice.get())) { savePassword.setSelected(true); }//from ww w . j av a 2s . c o m } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void initialize() { try {/* www .j av a 2 s . c o m*/ miHelp.setAccelerator(KeyCombination.keyCombination("F1")); cbType.getItems().add(SigningArgumentsType.JAR); cbType.getItems().add(SigningArgumentsType.FOLDER); cbType.getSelectionModel().select(SigningArgumentsType.JAR); cbType.setConverter(new StringConverter<SigningArgumentsType>() { @Override public String toString(SigningArgumentsType type) { return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type))); } @Override public SigningArgumentsType fromString(String type) { return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type)); } }); activeConfiguration.activeProfileProperty().bindBidirectional(activeProfile.profileNameProperty()); tfSourceFile.textProperty().bindBidirectional(activeProfile.sourceFileFileNameProperty()); tfTargetFile.textProperty().bindBidirectional(activeProfile.targetFileFileNameProperty()); ckReplace.selectedProperty().bindBidirectional(activeProfile.replaceSignaturesProperty()); cbType.valueProperty().bindBidirectional(activeProfile.argsTypeProperty()); miSave.disableProperty().bind(needsSave.not()); tfSourceFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); tfTargetFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); ckReplace.selectedProperty().addListener(new WeakInvalidationListener(needsSaveListener)); cbType.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener)); lblSource.setText(SOURCE_LABEL_JAR); lblTarget.setText(TARGET_LABEL_JAR); cbType.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == SigningArgumentsType.FOLDER) { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_FOLDER)) { lblSource.setText(SOURCE_LABEL_FOLDER); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_FOLDER)) { lblTarget.setText(TARGET_LABEL_FOLDER); } } else { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_JAR)) { lblSource.setText(SOURCE_LABEL_JAR); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_JAR)) { lblTarget.setText(TARGET_LABEL_JAR); } } }); lvProfiles.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == null) { // coming from clearSelection or sort return; } if (needsSave.getValue()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Discard unsaved profile?"); alert.setHeaderText("Unsaved profile"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[SELECT] discard canceled"); } return; } } if (logger.isDebugEnabled()) { logger.debug("[SELECT] nv={}", new_v); } doLoadProfile(new_v); }); lvProfiles.setCellFactory(TextFieldListCell.forListView()); Task<Void> t = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage("Loading configuration"); configurationDS.loadConfiguration(); if (!configurationDS.isSecured()) { if (logger.isDebugEnabled()) { logger.debug("[CALL] config not secured; getting password"); } NewPasswordController npc = newPasswordControllerProvider.get(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc id={}", npc.hashCode()); } Platform.runLater(() -> { try { npc.showAndWait(); } catch (Exception exc) { logger.error("error showing npc", exc); } }); synchronized (npc) { try { npc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("new password operation interrupted", exc); } } if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc={}", npc.getHashedPassword()); } if (StringUtils.isNotEmpty(npc.getHashedPassword())) { activeConfiguration.setHashedPassword(npc.getHashedPassword()); activeConfiguration.setUnhashedPassword(npc.getUnhashedPassword()); activeConfiguration.setLastUpdatedDateTime(LocalDateTime.now()); configurationDS.saveConfiguration(); configurationDS.loadConfiguration(); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); } else { Platform.runLater(() -> { Alert noPassword = new Alert(Alert.AlertType.INFORMATION, "You'll need to provide a password to save your keystore credentials."); noPassword.showAndWait(); }); return null; } } else { PasswordController pc = passwordControllerProvider.get(); Platform.runLater(() -> { try { pc.showAndWait(); } catch (Exception exc) { logger.error("error showing pc", exc); } }); synchronized (pc) { try { pc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("password operation interrupted", exc); } } Platform.runLater(() -> { if (pc.getStage().isShowing()) { // ended in timeout timeout pc.getStage().hide(); } if (pc.wasCancelled() || pc.wasReset() || !pc.doesPasswordMatch()) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] was cancelled or the number of retries was exceeded"); } String msg = ""; if (pc.wasCancelled()) { msg = "You must provide a password to the datastore. Exitting..."; } else if (pc.wasReset()) { msg = "Data file removed. Exitting..."; } else { msg = "Exceeded maximum number of retries. Exitting..."; } Alert alert = new Alert(Alert.AlertType.WARNING, msg); alert.setOnCloseRequest((evt) -> { Platform.exit(); System.exit(1); }); alert.showAndWait(); } else { // // save password for later decryption ops // activeConfiguration.setUnhashedPassword(pc.getPassword()); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); // // init profileBrowser // if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles from source"); } long startTimeMillis = System.currentTimeMillis(); final List<String> profileNames = configurationDS.getProfiles().stream() .map(Profile::getProfileName).sorted((o1, o2) -> o1.compareToIgnoreCase(o2)) .collect(Collectors.toList()); final List<String> recentProfiles = configurationDS.getRecentProfileNames(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles into UI"); } lvProfiles.setItems(FXCollections.observableArrayList(profileNames)); if (CollectionUtils.isNotEmpty(recentProfiles)) { mRecentProfiles.getItems().clear(); mRecentProfiles.getItems().addAll( FXCollections.observableArrayList(recentProfiles.stream().map((s) -> { MenuItem mi = new MenuItem(s); mi.setOnAction(recentProfileLoadHandler); return mi; }).collect(Collectors.toList()))); } // // #31 preload the last active profile // if (StringUtils.isNotEmpty(activeConfiguration.getActiveProfile())) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] preloading last active profile={}", activeConfiguration.getActiveProfile()); } doLoadProfile(activeConfiguration.getActiveProfile()); } long endTimeMillis = System.currentTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles took {} ms", (endTimeMillis - startTimeMillis)); } } }); } return null; } @Override protected void succeeded() { super.succeeded(); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void cancelled() { super.cancelled(); logger.error("task cancelled", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void failed() { super.failed(); logger.error("task failed", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } }; lblStatus.textProperty().bind(t.messageProperty()); new Thread(t).start(); } catch (Exception exc) { logger.error("can't load configuration", exc); String msg = "Verify that the user has access to the directory '" + configFile + "' under " + System.getProperty("user.home") + "."; Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't load config file"); alert.showAndWait(); Platform.exit(); } }
From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java
@Override ContextMenu createContextMenu() {/* w ww .j a va 2s . c o m*/ final ContextMenu cm = new ContextMenu(); final MenuItem mi = new MenuItem("Delete edge"); mi.setGraphic(Icons.getIconGraphics("delete")); mi.setStyle("-fx-text-fill:red"); mi.setOnAction(event -> { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirm"); alert.setHeaderText("You are about to delete the edge."); alert.setContentText("Do you want to continue?"); alert.showAndWait().filter(response -> response == ButtonType.OK) .ifPresent(response -> this.removeNodeAndEdges()); }); cm.getItems().add(mi); return cm; }
From source file:Watcher.FXMLDocumentController.java
@FXML protected void clear(MouseEvent event) { if (event.isPrimaryButtonDown()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Warning"); alert.setHeaderText("Deleting statistics"); alert.setContentText("Are you sure you want to delete statistics? It's not reversable!"); alert.initOwner(JavaFXApplication4.getStage()); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { if (HSQL_Manager.clearStat(getSelectedItem())) { processor.renew(getSelectedItem()); }//from w w w. j a v a 2 s . co m } } }