/** * Display an alert for the about button */ @FXML private void onActionAbout() { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("About..."); alert.setHeaderText(null); alert.setContentText("Author: Guduche\nVersion: 1.0.1"); alert.getButtonTypes().clear(); ButtonType boutonOk = new ButtonType("Ok"); alert.getButtonTypes().add(boutonOk); ButtonType boutonGithub = new ButtonType("Github project"); alert.getButtonTypes().add(boutonGithub); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == boutonGithub) { try { java.awt.Desktop.getDesktop().browse(new URI("https://github.com/Guduche/UTGenerator")); } catch (Exception e) { } } }
@Override public void initialize(URL location, ResourceBundle resources) { logoImg.setImage(UIUtils.getImage("logo.png")); Dialog diag = new Dialog(); diag.getDialogPane().setContent(borderPane); diag.getDialogPane().setBackground(Background.EMPTY); diag.setResizable(true); UIUtils.setIcon(diag); ButtonType closeButton = new ButtonType("Close", ButtonBar.ButtonData.OK_DONE); diag.getDialogPane().getButtonTypes().addAll(closeButton); diag.setTitle("About HueSense"); Optional<ButtonType> opt = diag.showAndWait(); if (opt.isPresent() && opt.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) { // nothing } }
private void loadAllEntities() { int i = 0; entities.clear(); for (Iterator<T> it = currentQueryList.fullIterator(); it.hasNext();) { T entity = it.next(); entities.add(new EntityListEntry<T>().setEntity(entity)); i++; if (i >= 500) { LOGGER.warn("Warning after {}. Total: {}.", i, entities.size()); Optional<ButtonType> result = new Alert(Alert.AlertType.WARNING, "Already loaded " + entities.size() + " Entities.\nContinue loading?", ButtonType.CANCEL, ButtonType.YES).showAndWait(); if (!result.isPresent() || result.get() != ButtonType.YES) { break; } i = 0; } } buttonNext.setDisable(!currentQueryList.hasNextLink()); buttonDelete.setDisable(true); }
private void removeAction(Event e) { Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to delete this organization ?\n" + "Every server and member association will be lost."); Optional<ButtonType> result = conf.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) { try { wsp.removeOrganization(orgas.selectionModelProperty().get().getSelectedItem().getOrganization()); forceOrganizationListRefresh(); App.getCurrentInstance().refreshWSPTabs(); } catch(Exception e1) { ErrorUtils.getAlertFromException(e1).show(); } } }
@FXML private void mnuUndo(ActionEvent event) { Stage CashCalculateStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(CashCalculateStage.getX() + 60); alert.setY(CashCalculateStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(CashCalculateStage.getX(), CashCalculateStage.getY()); CashCalculateStage.close(); } }
@FXML private void mnuUndo(ActionEvent event) { Stage HelpStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(HelpStage.getX() + 60); alert.setY(HelpStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(HelpStage.getX(), HelpStage.getY()); HelpStage.close(); } }
/** * A játék megnyerése esetén hívjuk a függvényt (ha kiürült minden kocsi) * Üzenetet küld, hogy teljesítettük a pályát, a következő pályára lép */ public void won() { if (winMedia != null) { winMedia.seek(Duration.ZERO); winMedia.play(); } Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Train Simulator 2017"); alert.setHeaderText(null); alert.setContentText("Gratulálunk, nyertél!"); ButtonType nextButton = new ButtonType("Következő pálya"); alert.getButtonTypes().setAll(nextButton); alert.showAndWait(); mapManager.nextMap(); startGame(); }
@FXML private void mnuUndo(ActionEvent event) { Stage DashboardStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(DashboardStage.getX() + 60); alert.setY(DashboardStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(DashboardStage.getX(), DashboardStage.getY()); DashboardStage.close(); } }
@FXML private void mnuUndo(ActionEvent event) { Stage AboutStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(AboutStage.getX() + 60); alert.setY(AboutStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(AboutStage.getX(), AboutStage.getY()); AboutStage.close(); } }
private void setup() { ProjectConfig config = ProjectConfig.getLast(); Dialog<ProjectConfig> dialog = new Dialog<>(); //dialog.initModality(Modality.APPLICATION_MODAL); dialog.setResizable(true); dialog.setTitle("UID Setup"); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK); UidSetupPane setupPane = new UidSetupPane(config, dialog.getOwner(), okButton); dialog.getDialogPane().setContent(setupPane); dialog.setResultConverter(button -> button == ButtonType.OK ? config : null); dialog.showAndWait().ifPresent(newConfig -> { setupPane.updateConfig(); if (!newConfig.isValid()) return; newConfig.saveAsLast(); }); }
@FXML private void onClickPageClose(ActionEvent event) { if (this.rootTagElement == null) { return; } final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Saving?"); alert.setContentText("Do you want to save your latest changes?"); alert.getButtonTypes().clear(); alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); final ButtonType result = alert.showAndWait().orElse(ButtonType.CANCEL); if (result == ButtonType.YES) { save(); } if (result != ButtonType.CANCEL) { this.tags_view.setRoot(null); this.file_save.setDisable(true); this.rootTagElement = null; this.openFile = null; } }
public void changeLocaleAndReload(String locale){ saveCurrentProject(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("This will take effect after reboot"); alert.setContentText("Are you ok with this?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ // ... user chose OK try { Properties props = new Properties(); props.setProperty("locale", locale); File f = new File(getClass().getResource("../bundles/Current.properties").getFile()); OutputStream out = new FileOutputStream( f ); props.store(out, "This is an optional header comment string"); start(primaryStage); } catch (Exception e ) { e.printStackTrace(); } } else { // ... user chose CANCEL or closed the dialog } }
@Override public void setMainASMFile() { ASMFile activeFile = getActiveFile(); if (activeFile == null) { Dialogues.showActionFailedDialogue("No file is selected!"); return; } Project activeProject = activeFile.getProject(); String message = "The file \"" + activeFile.getName() + "\" will be used as the main file for the project \"" + activeProject.getName() + "\""; Optional<ButtonType> result = Dialogues.showConfirmationDialogue(message); if (result.get() == ButtonType.OK) { int index = activeProject.indexOf(activeFile); Collections.swap(activeProject, 0, index); } }
public boolean canAppend(File file) { EditorDockable dockable = findEditorDockable(file); if (dockable == null) { return true; } if (!dockable.getEditor().isDirty()) { return true; } Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this, "File " + file.getName() + " being edited. Do you want to save the file?", "Save Module", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO); ButtonType option = result.get(); if (option == ButtonType.YES) { save(dockable.getEditor()); return true; } return false; }
@SuppressWarnings("unchecked") public static Optional<ButtonType> showConfirmDialog(Window parent, String message, String title, AlertType type, ButtonType... buttonTypes) { if (Platform.isFxApplicationThread()) { return _showConfirmDialog(parent, message, title, type, buttonTypes); } else { Object r[] = { null }; Object lock = new Object(); synchronized (lock) { Platform.runLater(() -> { r[0] = _showConfirmDialog(parent, message, title, type, buttonTypes); synchronized (lock) { lock.notifyAll(); } }); } synchronized (lock) { try { lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } return (Optional<ButtonType>) r[0]; } }
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) { if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) { option = FXUIUtils.showConfirmDialog(null, "Do you want to delete the entry `" + entry.getName() + "`?", "Confirm", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL); } if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) { GroupResource parent = (GroupResource) getParent(); parent.deleteEntry(this); try { Group.updateFile(parent.getSuite()); Event.fireEvent(parent, new ResourceModificationEvent(ResourceModificationEvent.UPDATE, parent)); } catch (IOException e) { e.printStackTrace(); return option; } } return option; }
public void show() { paneController.load(); ResourceBundle i18n = toolBox.getI18nBundle(); Dialog<ButtonType> dialog = new Dialog<>(); dialog.setTitle(i18n.getString("prefsdialog.title")); dialog.setHeaderText(i18n.getString("prefsdialog.header")); GlyphsFactory gf = MaterialIconFactory.get(); Text settingsIcon = gf.createIcon(MaterialIcon.SETTINGS, "30px"); dialog.setGraphic(settingsIcon); dialog.getDialogPane() .getButtonTypes() .addAll(ButtonType.OK, ButtonType.CANCEL); dialog.getDialogPane() .setContent(paneController.getRoot()); dialog.getDialogPane() .getStylesheets() .addAll(toolBox.getStylesheets()); Optional<ButtonType> buttonType = dialog.showAndWait(); buttonType.ifPresent(bt -> { if (bt == ButtonType.OK) { paneController.save(); } }); }
@FXML private void loadPlugin() { FileChooser chooser = new FileChooser(); chooser.setTitle("Choose a plugin"); chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Plugin", "*.jar")); List<File> files = chooser.showOpenMultipleDialog(root.getScene().getWindow()); if (files == null) { return; } files.forEach(f -> { try { // TODO save this in user preferences PluginLoader.getDefault().loadPluginJar(f.toURI()); } catch (IOException | IllegalArgumentException e) { log.log(Level.WARNING, "Could not load jar", e); // TODO improve the dialog; use something like what GRIP has Alert alert = new Alert(Alert.AlertType.ERROR, null, ButtonType.OK); alert.setTitle("Could not load plugins"); alert.setHeaderText("Plugins in " + f.getName() + " could not be loaded"); alert.setContentText("Error message:\n\n " + e.getMessage()); alert.showAndWait(); } }); }
@FXML public void newFile() { Alert closeConfirmation = new Alert( Alert.AlertType.CONFIRMATION, "Create a new station?", ButtonType.YES, ButtonType.NO ); closeConfirmation.setHeaderText("New station"); closeConfirmation.initModality(Modality.APPLICATION_MODAL); closeConfirmation.initOwner(root.getScene().getWindow()); Optional<ButtonType> closeResponse = closeConfirmation.showAndWait(); if (ButtonType.YES.equals(closeResponse.get())) { station = new Station(); updateEditors(); updateTitle(); } }
private void shortcutDelete(int index, ObservableGanttTask obs) { if(index == -1 || obs == null) { index = getSelectionModel().getSelectedIndex(); obs = getSelectionModel().getSelectedItem(); } if(obs == null || index == 0) return; if(obs.getTask().size() > 0) { ButtonType type = FXDialog.binaryChoiceAlert("This will delete also all sub-tasks. Proceed?").showAndWait().get(); if(type == ButtonType.NO) return; } removeTask(index); }
public void saveOnExit() { if (!taNoteText.getText().equals(this.note.getText())) { if (!JGMRConfig.getInstance().isDontAskMeToSave()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Save notes?"); alert.setHeaderText("Would you like to save your notes?"); ButtonType save = new ButtonType("Save"); ButtonType dontaskmeagain = new ButtonType("Don't ask me again"); ButtonType dontsave = new ButtonType("Don't save", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(save, dontaskmeagain, dontsave); Optional<ButtonType> result = alert.showAndWait(); if(result.get() == save){ save(); }else if(result.get() == dontaskmeagain){ JGMRConfig.getInstance().setDontAskMeToSave(true); save(); } } else { save(); } } }
/** * Creates the menu for editing the properties of a widget. * * @param tile the tile to pull properties from * @return the edit property menu */ private void showPropertySheet(Tile<?> tile) { ExtendedPropertySheet propertySheet = new ExtendedPropertySheet(); propertySheet.getItems().add(new ExtendedPropertySheet.PropertyItem<>(tile.getContent().titleProperty())); Dialog<ButtonType> dialog = new Dialog<>(); if (tile.getContent() instanceof Widget) { ((Widget) tile.getContent()).getProperties().stream() .map(ExtendedPropertySheet.PropertyItem::new) .forEachOrdered(propertySheet.getItems()::add); } dialog.setTitle("Edit widget properties"); dialog.getDialogPane().getStylesheets().setAll(AppPreferences.getInstance().getTheme().getStyleSheets()); dialog.getDialogPane().setContent(new BorderPane(propertySheet)); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE); dialog.showAndWait(); }
public static Boolean showWarningMessage(String headerText, String contentText, String okButtonLabel, Pane pane) { ButtonType okButton = new ButtonType(okButtonLabel); ButtonType cancelButton = new ButtonType("Cancel"); List<ButtonType> buttonList = new LinkedList<>(); buttonList.add(okButton); buttonList.add(cancelButton); Optional optional = showMessage("Warning", headerText, contentText, Alert.AlertType.WARNING, null, buttonList, pane); if(optional != null) { if(optional.get().equals(okButton)) { return true; } else { return false; } } return null; }
public static <T extends Entity<T>> Optional<List<T>> entitySearchDialog(Query<T> query, boolean multiSelect) { try { FXMLLoader loader = new FXMLLoader(EntityGuiController.class.getResource("/fxml/Collection.fxml")); AnchorPane content = (AnchorPane) loader.load(); final ControllerCollection<T> controller = loader.<ControllerCollection<T>>getController(); controller.setQuery(query, false, false, false, multiSelect); Dialog<List<T>> dialog = new Dialog<>(); dialog.setHeight(800); if (multiSelect) { dialog.setTitle("Choose one or more " + EntityType.singleForClass(query.getEntityType().getType()).getName()); } else { dialog.setTitle("Choose a " + EntityType.singleForClass(query.getEntityType().getType()).getName()); } dialog.setResizable(true); dialog.getDialogPane().setContent(content); ButtonType buttonTypeOk = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); dialog.getDialogPane().getButtonTypes().add(buttonTypeCancel); dialog.setResultConverter((ButtonType button) -> { if (button == buttonTypeOk) { if (multiSelect) { return controller.getSelectedEntities(); } List<T> list = new ArrayList<>(); list.add(controller.getSelectedEntity()); return list; } return null; }); return dialog.showAndWait(); } catch (IOException ex) { LoggerFactory.getLogger(EntityGuiController.class).error("Failed to load Tab.", ex); return Optional.empty(); } }
public int alertConfirm(Stage stage) { int r = 0; Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.setTitle("확인 알림"); alert.setHeaderText(null); alert.setContentText(this.msg); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { r = 1; } return r; }
@FXML private void actionAdd(ActionEvent event) { if (childSetter == null) { new Alert(Alert.AlertType.ERROR, "No childSetter defined.", ButtonType.CLOSE).showAndWait(); return; } Class<T> entityClass = query.getEntityClass(); Query<T> allQuery = new Query<>(query.getService(), entityClass); Optional<List<T>> result = EntityGuiController.entitySearchDialog(allQuery, true); if (result.isPresent() && !result.get().isEmpty()) { List<T> newChildren = result.get(); childSetter.setChildren(newChildren); } }
private void removeServerAction(Event e) { Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to remove this server ?"); Optional<ButtonType> result = conf.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) { Server s = content.removeSelectedServer(); if (s != null) { servers.remove(s); ServerListLoader.writeServerList(servers); } else new Alert(AlertType.ERROR, "No selected server"); } }
@Override protected void handleCloseRequest(WindowEvent event) { if(!gantt.isSaved()) { // TODO add cancel button ButtonType bt = FXDialog.binaryChoiceAlert("There are unsaved changes in this project. Save and close?").showAndWait().get(); if(bt == ButtonType.YES) { saveGantt(); } else { event.consume(); return; } } storageManager.rememberLastViewed(currentFile); }
@FXML private void sectorbtnDelete(ActionEvent event) { try { Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Delete Sector"); alert.setHeaderText("Are you sure?"); alert.setContentText("You are going to delete Sector \""+ sectorcmboDelete.getValue() + "\" "); alert.setX(SettingsStage.getX() + 210); alert.setY(SettingsStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ sector.deleteSector(sectorcmboDelete.getValue()); advancedSector.deleteSectorFromAdvancedList(sectorcmboDelete.getValue()); Alert confirmationMsg = new Alert(AlertType.INFORMATION); confirmationMsg.setTitle("Message"); confirmationMsg.setHeaderText(null); confirmationMsg.setContentText(sectorcmboDelete.getValue()+ " Deleted Successfully"); confirmationMsg.setX(SettingsStage.getX() + 190); confirmationMsg.setY(SettingsStage.getY() + 190); confirmationMsg.showAndWait(); } tabSectorInitialize(); } catch (Exception e) {} }
public boolean requestConfirmation(String title, String headerText, String text) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(title); alert.setHeaderText(headerText); alert.setContentText(text); return alert.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK; }
private void newProject() { ProjectConfig config = ProjectConfig.getLast(); Dialog<ProjectConfig> dialog = new Dialog<>(); //dialog.initModality(Modality.APPLICATION_MODAL); dialog.setResizable(true); dialog.setTitle("Project configuration"); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK); dialog.getDialogPane().setContent(new NewProjectPane(config, dialog.getOwner(), okButton)); dialog.setResultConverter(button -> button == ButtonType.OK ? config : null); dialog.showAndWait().ifPresent(newConfig -> { if (!newConfig.isValid()) return; newConfig.saveAsLast(); gui.getMatcher().reset(); gui.onProjectChange(); gui.runProgressTask("Initializing files...", progressReceiver -> gui.getMatcher().init(newConfig, progressReceiver), () -> gui.onProjectChange(), Throwable::printStackTrace); }); }
private void loadProject() { Path file = Gui.requestFile("Select matches file", gui.getScene().getWindow(), getMatchesLoadExtensionFilters(), true); if (file == null) return; List<Path> paths = new ArrayList<>(); Dialog<List<Path>> dialog = new Dialog<>(); //dialog.initModality(Modality.APPLICATION_MODAL); dialog.setResizable(true); dialog.setTitle("Project paths"); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK); dialog.getDialogPane().setContent(new LoadProjectPane(paths, dialog.getOwner(), okButton)); dialog.setResultConverter(button -> button == ButtonType.OK ? paths : null); dialog.showAndWait().ifPresent(newConfig -> { if (paths.isEmpty()) return; gui.getMatcher().reset(); gui.onProjectChange(); gui.runProgressTask("Initializing files...", progressReceiver -> gui.getMatcher().readMatches(file, paths, progressReceiver), () -> gui.onProjectChange(), Throwable::printStackTrace); }); }
@Override public AlertDialog build() { initOwner(ownerStage); setTitle(title); setHeaderText(header); setContentText(content); ButtonType yes = new ButtonType(dictionary.DIALOG_BUTTON_YES_LABEL, ButtonBar.ButtonData.YES), no = new ButtonType(dictionary.DIALOG_BUTTON_NO_LABEL, ButtonBar.ButtonData.NO), cancel = new ButtonType(dictionary.DIALOG_BUTTON_CANCEL_LABEL, ButtonBar.ButtonData.CANCEL_CLOSE); getButtonTypes().setAll(yes, no, cancel); return this; }
@FXML public void btnExcluirOnAction(ActionEvent evt) { SoftwareEntity tmpSoftware = getSoftwareSelected(); if (tmpSoftware != null) { if (Alertas.exibirAlerta(Alert.AlertType.CONFIRMATION, "Excluir", "Confirmar exclusão?", "Deseja mesmo excluir o software " + tmpSoftware.getDescricao() + "?", Alertas.SIM_NAO_BOTOES).get() == ButtonType.YES) { SoftwareException delete = negocio.delete(software); if (delete != null) { Alertas.exibirAlerta(Alert.AlertType.ERROR, "Erro", "Erro ao excluir o software", delete.getLocalizedMessage()); } else { listaSoftwares.remove(tmpSoftware); } } } }
private Callback<ButtonType, M> createResultConverter() { return new Callback<ButtonType, M>() { @Override public M call(ButtonType aDialogButton) { if (ButtonType.OK == aDialogButton) { return MODEL; } else { return null; } } }; }
public static Optional<ButtonType> _showConfirmDialog(Window parent, String message, String title, AlertType type, ButtonType... buttonTypes) { Alert alert = new Alert(type, message, buttonTypes); alert.initOwner(parent); alert.setTitle(title); alert.initModality(Modality.APPLICATION_MODAL); return alert.showAndWait(); }
private void deleteSelectedFavourites() { final Alert alert = new Alert(AlertType.CONFIRMATION, Client.lang.getString("sureYouWantToDeleteFavourites"), ButtonType.YES, ButtonType.NO); Client.insertAlertOwner(alert); alert.setTitle(Client.lang.getString("deleteFavourites")); final Optional<ButtonType> result = alert.showAndWait(); result.ifPresent(buttonType -> { if (buttonType == ButtonType.YES) { final List<SampServer> serverList = getSelectionModel().getSelectedItems(); serverList.forEach(FavouritesController::removeServerFromFavourites); servers.removeAll(serverList); } }); }
private void delete(ObservableList<TreeItem<Resource>> selectedItems) { Optional<ButtonType> option = Optional.empty(); ArrayList<TreeItem<Resource>> items = new ArrayList<>(selectedItems); for (TreeItem<Resource> treeItem : items) { option = treeItem.getValue().delete(option); if (option.isPresent() && option.get() == ButtonType.CANCEL) { break; } } }
protected ButtonType showDialog() { BlurbInfo blurbInfo; if (url == null) blurbInfo = new BlurbInfo(html, title, cancel); else blurbInfo = new BlurbInfo(url, title, cancel); BlurbStage blurbStage = new BlurbStage(blurbInfo); blurbStage.getStage().showAndWait(); return blurbStage.getSelection(); }
public ButtonType showMessage() { if (Platform.isFxApplicationThread()) { return showDialog(); } else { Object[] ret = new Object[1]; Platform.runLater(new Runnable() { @Override public void run() { ret[0] = showDialog(); } }); return (ButtonType) ret[0]; } }