private ObservableList<Node> getChildren(Node node) { if (node instanceof ButtonBar) { return ((ButtonBar) node).getButtons(); } if (node instanceof ToolBar) { return ((ToolBar) node).getItems(); } if (node instanceof Pane) { return ((Pane) node).getChildren(); } if (node instanceof TabPane) { ObservableList<Node> contents = FXCollections.observableArrayList(); ObservableList<Tab> tabs = ((TabPane) node).getTabs(); for (Tab tab : tabs) { contents.add(tab.getContent()); } return contents; } return FXCollections.observableArrayList(); }
public void deleteRankings() { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Are you sure about this?"); alert.setHeaderText("This operation cannot be undone."); alert.setContentText("You are about to purge team standings in TOA's databases for event " + Config.EVENT_ID + ". Rankings will become unavailable until you re-upload."); ButtonType okayButton = new ButtonType("Purge Rankings"); ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(okayButton, cancelButton); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == okayButton) { TOAEndpoint rankingEndpoint = new TOAEndpoint("DELETE", "upload/event/rankings"); rankingEndpoint.setCredentials(Config.EVENT_API_KEY, Config.EVENT_ID); TOARequestBody requestBody = new TOARequestBody(); requestBody.setEventKey(Config.EVENT_ID); rankingEndpoint.setBody(requestBody); rankingEndpoint.execute(((response, success) -> { if (success) { TOALogger.log(Level.INFO, "Deleted rankings."); } })); } }
@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 } }
@Inject public SelectMediaDialog(AnnotationService annotationService, MediaService mediaService, ResourceBundle uiBundle) { this.annotationService = annotationService; this.mediaService = mediaService; this.uiBundle = uiBundle; VideoBrowserPaneController controller = new VideoBrowserPaneController(annotationService, mediaService, uiBundle); getDialogPane().setContent(controller.getRoot()); ButtonType ok = new ButtonType(uiBundle.getString("global.ok"), ButtonBar.ButtonData.OK_DONE); ButtonType cancel = new ButtonType(uiBundle.getString("global.cancel"), ButtonBar.ButtonData.CANCEL_CLOSE); getDialogPane().getButtonTypes().addAll(ok, cancel); setResultConverter(buttonType -> { if (buttonType == ok) { return controller.getSelectedMedia().orElse(null); } else { return null; } }); }
/** * Initializes the whole view. */ public FilesView() { chatLogTextArea = new TextArea(); chatLogTextArea.setEditable(false); clearLogsButton = new Button(Client.lang.getString("clear")); loadLogsButton = new Button(Client.lang.getString("reload")); final ButtonBar buttonBar = new ButtonBar(); buttonBar.getButtons().addAll(loadLogsButton, clearLogsButton); final VBox chatLogsTabContent = new VBox(5.0, chatLogTextArea, buttonBar); VBox.setVgrow(chatLogTextArea, Priority.ALWAYS); chatLogsTab = new Tab(Client.lang.getString("chatlogs"), chatLogsTabContent); rootPane = new TabPane(chatLogsTab); rootPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); }
public TemplateBox(String name) { setTitle(name); initModality(Modality.NONE); String style = LocalFont.getDefaultFontCSS(); getDialogPane().setStyle( style ); Stage stage = (Stage) getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(checkForceOnTop()); stage.getIcons().add(new Image(App.ICON_URL.toString())); getDialogPane().getButtonTypes().add(new ButtonType(Main.getString("close"), ButtonBar.ButtonData.CANCEL_CLOSE)); openedDialogs.add(this); final TemplateBox thisBox = this; setOnCloseRequest(new EventHandler<DialogEvent>() { @Override public void handle(DialogEvent event) { openedDialogs.remove(thisBox); for(EventHandler<DialogEvent> handler : handlers){ handler.handle(event); } } }); applyStyle(); }
public void showAlert(String title, String header, String content, Alert.AlertType type) { Stage primaryStage = mPrimaryStage; Platform.runLater(() -> { Alert alert = new Alert(type); alert.getDialogPane().getStylesheets() .add("com/budiyev/population/resource/style/alert.css"); alert.setX(primaryStage.getX() + WINDOW_OFFSET); alert.setY(primaryStage.getY() + WINDOW_OFFSET); alert.initStyle(StageStyle.UTILITY); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(content); alert.getButtonTypes().clear(); alert.getButtonTypes().add(new ButtonType(getResources().getString("alert_close"), ButtonBar.ButtonData.OK_DONE)); alert.showAndWait(); }); }
/** * Function name: showRemovePathTileDialog * Usage: This method would remove the chosen pathTile from the grid and its relevant data from the back-end database * @param pathTile pathTile to be removed */ private void showRemovePathTileDialog(PathTile pathTile) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); String headerMessage = "Remove this folder?"; alert.setTitle(headerMessage); alert.setHeaderText(headerMessage); alert.setContentText("If you remove the \"" + pathTile.getFolderNameStr() + "\" folder from Music, it won't" + "appear in Music anymore, but won't be deleted."); alert.initOwner(settingsWindow); ButtonType buttonTypeConfirm = new ButtonType("Remove Folder", ButtonBar.ButtonData.APPLY); ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeConfirm, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeConfirm){ removePathTile(pathTile, false); } }
/** * Shows a dialog, which prompts the user to choose how he wants to save the exercise. * @return 0 == New catalog, 1 == Append a catalog, -1 == cancel or error. */ private int howToSaveDialog(){ Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("What is your plan, master?"); alert.setHeaderText("Dobby is a free elf, and Dobby has come to save your exercise!"); ((Stage)alert.getDialogPane().getScene().getWindow()).getIcons().add(new Image("file:pictures/icon.png")); alert.setContentText("Do you want me to save the exercise to an existing catalog, or do you want to create a new one?"); ButtonType newCatalog = new ButtonType("Create a new catalog"); ButtonType appendCatalog = new ButtonType("Append an existing catalog"); ButtonType cancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(newCatalog, appendCatalog, cancel); Optional<ButtonType> result = alert.showAndWait(); if(result.isPresent()) { if (result.get() == newCatalog) { return 0; } else if (result.get() == appendCatalog) { return 1; } } return -1; }
/** * This method is called when there is a need of confirmation somewhere in * the interface. */ public boolean confirmMessage(String message) { ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE); ButtonType cancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); Alert alert = new Alert(AlertType.WARNING, null, ok, cancel); alert.setTitle("Warning"); alert.setHeaderText("Look, an Information Dialog"); alert.setContentText(message); alert.showAndWait(); if (alert.getResult() != null) { if (alert.getResult().getText().equalsIgnoreCase("ok")) { return true; } } return false; }
public boolean confirmMessage(String message) { ButtonType ok = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE); ButtonType cancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); Alert alert = new Alert(AlertType.WARNING, null, ok, cancel); alert.setTitle("Warning"); alert.setHeaderText("Look, an Information Dialog"); alert.setContentText(message); alert.showAndWait(); if (alert.getResult() != null) { if (alert.getResult().getText().equalsIgnoreCase("ok")) { return true; } } return false; }
/** * Shows a blocking Yes/No/Cancel dialog and returns a <code>ButtonType</code> whose <code>ButtonData</code> is one * of the corresponding enum values ({@link ButtonBar.ButtonData#YES}, {@link ButtonBar.ButtonData#NO}, * {@link ButtonBar.ButtonData#CANCEL_CLOSE}). * * @param content * the content <code>String</code> for the <code>Alert</code> * @param owner * the owner <code>Window</code> for the dialog, may be null in which case the dialog will be non-modal * @return the optional <code>ButtonType</code> returned from {@link Alert#showAndWait()} */ private Optional<ButtonType> showYesNoDialog(String content, Window owner) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); ButtonType yesType = new ButtonType("Yes", ButtonBar.ButtonData.YES); ButtonType noType = new ButtonType("No", ButtonBar.ButtonData.NO); ButtonType cancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.setHeaderText(null); alert.setContentText(content); alert.getButtonTypes().setAll(yesType, noType, cancel); if (owner != null) { alert.initOwner(owner); alert.initModality(Modality.WINDOW_MODAL); } return alert.showAndWait(); }
/** * @param checkForEnvVariable * if true, the method will consult RODA-in env. variable to see if * its running in a special mode (e.g. testing), in order to avoid * checking for version update */ private static boolean checkForUpdates(boolean checkForEnvVariable) { Optional<String> updateMessage = Controller.checkForUpdates(checkForEnvVariable); if (updateMessage.isPresent()) { Alert dlg = new Alert(Alert.AlertType.CONFIRMATION); dlg.initStyle(StageStyle.UNDECORATED); dlg.setHeaderText(I18n.t(Constants.I18N_MAIN_NEW_VERSION_HEADER)); dlg.setTitle(""); dlg.setContentText(updateMessage.get()); dlg.initModality(Modality.APPLICATION_MODAL); dlg.initOwner(stage); dlg.getDialogPane().setMinWidth(300); dlg.showAndWait(); if (dlg.getResult().getButtonData() == ButtonBar.ButtonData.OK_DONE) { OpenPathInExplorer.open(Constants.RODAIN_GITHUB_LATEST_VERSION_LINK); } return true; } else { return false; } }
private void removeMetadataAction() { if (metadataCombo.getSelectionModel().getSelectedIndex() == -1) return; String remContent = I18n.t(Constants.I18N_INSPECTIONPANE_REMOVE_METADATA_CONTENT); Alert dlg = new Alert(Alert.AlertType.CONFIRMATION); dlg.initStyle(StageStyle.UNDECORATED); dlg.setHeaderText(I18n.t(Constants.I18N_INSPECTIONPANE_REMOVE_METADATA_HEADER)); dlg.setTitle(I18n.t(Constants.I18N_INSPECTIONPANE_REMOVE_METADATA_TITLE)); dlg.setContentText(remContent); dlg.initModality(Modality.APPLICATION_MODAL); dlg.initOwner(stage); dlg.showAndWait(); if (dlg.getResult().getButtonData() == ButtonBar.ButtonData.OK_DONE) { DescriptiveMetadata toRemove = (DescriptiveMetadata) metadataCombo.getSelectionModel().getSelectedItem().getKey(); currentDescOb.getMetadata().remove(toRemove); metadataCombo.getItems().remove(metadataCombo.getSelectionModel().getSelectedItem()); metadataCombo.getSelectionModel().selectFirst(); } }
private boolean confirmUpdate() { if (rootNode.getChildren().isEmpty()) { return true; } String content = I18n.t(Constants.I18N_SCHEMAPANE_CONFIRM_NEW_SCHEME_CONTENT); Alert dlg = new Alert(Alert.AlertType.CONFIRMATION); dlg.initStyle(StageStyle.UNDECORATED); dlg.setHeaderText(I18n.t(Constants.I18N_SCHEMAPANE_CONFIRM_NEW_SCHEME_HEADER)); dlg.setTitle(I18n.t(Constants.I18N_SCHEMAPANE_CONFIRM_NEW_SCHEME_TITLE)); dlg.setContentText(content); dlg.initModality(Modality.APPLICATION_MODAL); dlg.initOwner(primaryStage); dlg.showAndWait(); if (dlg.getResult().getButtonData() == ButtonBar.ButtonData.OK_DONE) { rootNode.remove(); createRootNode(); treeView.setRoot(rootNode); return true; } else return false; }
/** * Shows the dialog in which the user has to choose between saving the * changes, not saving the changes and canceling the action. * * @since 2.0.0 * @return A number which indicates whether to save or not. -1="cancel" * 0="don't save" 1="save" */ public static int showUnsavedChangesDialog() { int ret = -1; final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Unsaved Changes"); alert.setHeaderText("Your changes will be lost if you don't save them."); alert.setContentText("Do you want to save your changes?"); final ButtonType btnYes = new ButtonType("Yes", ButtonBar.ButtonData.YES); final ButtonType btnNo = new ButtonType("No", ButtonBar.ButtonData.NO); final ButtonType btnCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(btnYes, btnNo, btnCancel); final Optional<ButtonType> result = alert.showAndWait(); if (result.get() == btnYes) { ret = 1; } else if (result.get() == btnNo) { ret = 0; } return ret; }
/** * Initializes "OK" and "Cancel" buttons. */ private void initializeBottomButtons() { Button okButton = new Button("OK"); ButtonBar.setButtonData(okButton, ButtonData.OK_DONE); Button cancelButton = new Button("Cancel"); ButtonBar.setButtonData(cancelButton, ButtonData.CANCEL_CLOSE); buttonBar.getButtons().addAll(okButton, cancelButton); okButton.addEventFilter(ActionEvent.ACTION, (event) -> { applySettings(); ((Stage) okButton.getScene().getWindow()).close(); }); cancelButton.addEventFilter(ActionEvent.ACTION, (event) -> { ((Stage) okButton.getScene().getWindow()).close(); }); validationSupport.validationResultProperty().addListener((o, oldVal, newVal) -> { if (newVal.getErrors().isEmpty()) { // If no errors, enable okButton. okButton.setDisable(false); } else { // If errors, disable okButton. okButton.setDisable(true); } }); }
private void pickStylerToConfigure(final List<Parameterizable> stylers) { if (stylers.size() == 1) { selectInCombo(stylers.get(0)); return; } else if (stylers.isEmpty()) { selectInCombo(null); return; } List<ParameterizableWrapper> pw = new ArrayList<>(stylers.size()); stylers.stream().forEach((p) -> { pw.add(new ParameterizableWrapper(p)); }); Dialog<ParameterizableWrapper> dialog = new ChoiceDialog<>(pw.get(0), pw); ButtonType bt = new ButtonType("choose", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().clear(); dialog.getDialogPane().getButtonTypes().add(bt); dialog.setTitle("Please choose"); dialog.setHeaderText(null); dialog.setResizable(true); dialog.setContentText("choose the styler or condition you want to configure"); Optional<ParameterizableWrapper> choice = dialog.showAndWait(); if (choice.isPresent()) { selectInCombo(choice.get().p); } }
ActionButtonCell() { _bb = new ButtonBar(); _removeButton = new Button("Remove"); _removeButton.setOnAction(event -> { remove(); }); _suspendButton = new Button("Suspend"); _suspendButton.setOnAction(event -> { suspend(); }); _resumeButton = new Button("Resume"); _resumeButton.setOnAction(event -> { resume(); }); _abortButton = new Button("Abort"); _abortButton.setOnAction(event -> { abort(); }); }
/** * Creates a new dialog to display code generation settings. * * @param root the root pane of the code generation settings scene. This <i>must</i> have the * controller as the property "controller" */ public CodeGenerationSettingsDialog(@Nonnull Pane root) { super(); Object controllerObj = root.getProperties().get("controller"); checkNotNull(controllerObj, "The root pane must have a 'controller' property"); checkArgument(controllerObj instanceof CodeGenerationOptionsController, "Unexpected controller class: " + controllerObj.getClass().getName()); CodeGenerationOptionsController controller = (CodeGenerationOptionsController) controllerObj; setTitle("Code Generation Settings"); setHeaderText(null); setGraphic(null); getDialogPane().setContent(root); getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); getDialogPane().styleProperty().bind(root.styleProperty()); getDialogPane().getStylesheets().setAll(root.getStylesheets()); root.requestFocus(); setResultConverter(bt -> { if (ButtonBar.ButtonData.OK_DONE.equals(bt.getButtonData())) { return controller.getOptions(); } else { return null; } }); }
private void showUpdateDialog(SoftwareUpdateDetails updateDetails) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Update Available"); alert.setHeaderText(String.format("A new version of %s is available", Archivo.APPLICATION_NAME)); alert.setContentText(String.format("%s %s was released on %s.\n\nNotable changes include %s.\n\n" + "Would you like to install the update now?\n\n", Archivo.APPLICATION_NAME, updateDetails.getVersion(), updateDetails.getReleaseDate().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)), updateDetails.getSummary())); ButtonType deferButtonType = new ButtonType("No, I'll Update Later", ButtonBar.ButtonData.NO); ButtonType updateButtonType = new ButtonType("Yes, Let's Update Now", ButtonBar.ButtonData.YES); alert.getButtonTypes().setAll(deferButtonType, updateButtonType); ((Button) alert.getDialogPane().lookupButton(deferButtonType)).setDefaultButton(false); ((Button) alert.getDialogPane().lookupButton(updateButtonType)).setDefaultButton(true); Optional<ButtonType> result = alert.showAndWait(); if ((result.isPresent() && result.get() == updateButtonType)) { try { Desktop.getDesktop().browse(updateDetails.getLocation().toURI()); } catch (URISyntaxException | IOException e) { Archivo.logger.error("Error opening a web browser to download '{}': ", updateDetails.getLocation(), e); } } }
/** * If there are active tasks, prompt the user before exiting. * Returns true if the user wants to cancel all tasks and exit. */ private boolean confirmTaskCancellation() { if (archiveQueueManager.hasTasks()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Cancel Task Confirmation"); alert.setHeaderText("Really cancel all tasks and exit?"); alert.setContentText("You are currently archiving recordings from your TiVo. Are you sure you want to " + "close Archivo and cancel these tasks?"); ButtonType cancelButtonType = new ButtonType("Cancel tasks and exit", ButtonBar.ButtonData.NO); ButtonType keepButtonType = new ButtonType("Keep archiving", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(cancelButtonType, keepButtonType); ((Button) alert.getDialogPane().lookupButton(cancelButtonType)).setDefaultButton(false); ((Button) alert.getDialogPane().lookupButton(keepButtonType)).setDefaultButton(true); Optional<ButtonType> result = alert.showAndWait(); if (!result.isPresent()) { logger.error("No result from alert dialog"); return false; } else { return (result.get() == cancelButtonType); } } return true; }
private boolean confirmDelete(Recording recording, Tivo tivo) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Remove Recording Confirmation"); alert.setHeaderText("Really remove this recording?"); alert.setContentText(String.format("Are you sure you want to delete %s from %s?", recording.getFullTitle(), tivo.getName())); ButtonType deleteButtonType = new ButtonType("Delete", ButtonBar.ButtonData.NO); ButtonType keepButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(deleteButtonType, keepButtonType); ((Button) alert.getDialogPane().lookupButton(deleteButtonType)).setDefaultButton(false); ((Button) alert.getDialogPane().lookupButton(keepButtonType)).setDefaultButton(true); Optional<ButtonType> result = alert.showAndWait(); if (!result.isPresent()) { logger.error("No result from alert dialog"); return false; } else { return (result.get() == deleteButtonType); } }
private void createButtons() { ButtonType submitButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE); getDialogPane().getButtonTypes().addAll(submitButtonType, ButtonType.CANCEL); submitButton = (Button) getDialogPane().lookupButton(submitButtonType); submitButton.addEventFilter(ActionEvent.ACTION, event -> { if (isBoardNameDuplicate(nameField.getText()) && !shouldOverwriteDuplicateBoard()) { event.consume(); } }); submitButton.setId(IdGenerator.getBoardNameSaveButtonId()); setResultConverter(submit -> { if (submit == submitButtonType) { return nameField.getText(); } return null; }); }
public static boolean showYesNoWarningDialog(String title, String header, String message, String yesButtonLabel, String noButtonLabel) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(message); ButtonType yesButton = new ButtonType(yesButtonLabel, ButtonBar.ButtonData.YES); ButtonType noButton = new ButtonType(noButtonLabel, ButtonBar.ButtonData.NO); alert.getButtonTypes().setAll(yesButton, noButton); Optional<ButtonType> result = alert.showAndWait(); return result.get().equals(yesButton); }
public static boolean showYesNoConfirmationDialog(String title, String header, String message, String yesButtonLabel, String noButtonLabel) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(message); ButtonType yesButton = new ButtonType(yesButtonLabel, ButtonBar.ButtonData.YES); ButtonType noButton = new ButtonType(noButtonLabel, ButtonBar.ButtonData.NO); alert.getButtonTypes().setAll(yesButton, noButton); Optional<ButtonType> result = alert.showAndWait(); return result.get().equals(yesButton); }
@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 protected void uploadGame() { if (!new File(JGMRConfig.getInstance().getPath() + "/.jgmrlock.lock").exists()) { FileChooser directoryChooser = new FileChooser(); if (JGMRConfig.getInstance().getPath() != null) { directoryChooser.setInitialDirectory(new File(JGMRConfig.getInstance().getPath())); } Stage stage = new Stage(); File fileResult = directoryChooser.showOpenDialog(stage); if (fileResult != null) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Upload to " + game.getName()); alert.setHeaderText("Upload to " + game.getName()); alert.setContentText("Are you sure you wish to upload " + fileResult.getName() + " to the game " + game.getName()); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { uploadGame(fileResult); } } } else { Dialog dg = new Dialog(); dg.setContentText("An upload or download is already in progress, please wait for the previous operation to finish."); dg.setTitle("Download or Upload already in progress."); dg.getDialogPane().getButtonTypes().add(new ButtonType("Ok", ButtonBar.ButtonData.OK_DONE)); Platform.runLater(() -> { dg.showAndWait(); }); } }
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 void execute(TOAExecuteAdapter toaExecuteAdapter) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Are you sure about this?"); alert.setHeaderText("This operation cannot be undone."); String matchesText; if (this.controller.btnSyncMatches.selectedProperty().get()) { matchesText = "Match results WILL AUTOMATICALLY BE UPLOADED ON COMPLETED MATCH."; } else { matchesText = "Match results, however, MUST be uploaded separately in the matches tab."; } alert.setContentText("You are about to start AutoSync. This will automatically stage changes from the scoring system and make them ready to be uploaded. " + "Rankings WILL AUTOMATICALLY BE UPLOADED ON COMPLETED MATCH. " + matchesText + " Continue?"); ButtonType okayButton = new ButtonType("Sure?"); ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(okayButton, cancelButton); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == okayButton) { this.service = Executors.newSingleThreadScheduledExecutor(); this.controller.btnSyncStart.setDisable(true); this.totalSyncs = 0; controller.btnSyncStop.setDisable(false); controller.btnSyncMatches.setDisable(true); service.scheduleAtFixedRate(this, 0, 5, TimeUnit.SECONDS); executeAdapter = toaExecuteAdapter; } }
public void deleteEventTeams() { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Are you sure about this?"); alert.setHeaderText("This operation cannot be undone."); alert.setContentText("You are about to purge TOA's EventParticipant data for EventID " + Config.EVENT_ID + ". We don't recommend doing this unless our databases are wrong and you have teams present/not present at your event."); ButtonType okayButton = new ButtonType("Purge Anyway"); ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(okayButton, cancelButton); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == okayButton) { // Begin the purging of the data table... controller.sendInfo("Purging data from event " + Config.EVENT_ID + "..."); TOAEndpoint deleteEndpoint = new TOAEndpoint("DELETE", "upload/event/teams"); deleteEndpoint.setCredentials(Config.EVENT_API_KEY, Config.EVENT_ID); TOARequestBody requestBody = new TOARequestBody(); requestBody.setEventKey(Config.EVENT_ID); deleteEndpoint.setBody(requestBody); deleteEndpoint.execute((response, success) -> { if (success) { controller.sendInfo("Successfully purged data from TOA. " + response); } else { controller.sendError("Connection to TOA unsuccessful. " + response); } }); } }
private void showDialog() { Optional<ButtonType> opt = diag.showAndWait(); if (opt.isPresent()) { if (opt.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) { onExport(null); } } }
@Inject public OpenRealTimeDialog(ResourceBundle i18n) { controller = MediaParamsPaneController.newInstance(); setTitle(i18n.getString("realtime.dialog.title")); setHeaderText(i18n.getString("realtime.dialog.header")); setContentText(i18n.getString("realtime.dialog.content")); getDialogPane().setContent(controller.getRoot()); ButtonType ok = new ButtonType(i18n.getString("global.ok"), ButtonBar.ButtonData.OK_DONE); ButtonType cancel = new ButtonType(i18n.getString("global.cancel"), ButtonBar.ButtonData.CANCEL_CLOSE); getDialogPane().getButtonTypes().addAll(ok, cancel); setResultConverter(buttonType -> { MediaParams mediaParams = null; if (buttonType == ok) { String cameraId = controller.getCameraIdComboBox() .getSelectionModel() .getSelectedItem(); String sn = controller.getSequenceNumberTextField().getText(); if (cameraId != null && sn != null) { mediaParams = new MediaParams(cameraId, Long.parseLong(sn)); } } return mediaParams; }); }
public CommentPopOver() { super(); textArea = new TextArea(); saveButton = GlyphsDude.createIconButton(FontAwesomeIcon.SAVE); buttonBar = new ButtonBar(); buttonBar.getButtons().addAll(saveButton); VBox content = new VBox(textArea, buttonBar); content.setPadding(new Insets(5)); this.setTitle("Edit Comment"); this.setContentNode(content); textArea.editableProperty().bind(editable); }
public void initContent() { buttonTypeShowFolder = new ButtonType(BUNDLE.getString("downloadScreen.showFolder")); buttonTypeOK = new ButtonType(BUNDLE.getString("misc.ok"), ButtonBar.ButtonData.CANCEL_CLOSE); setTitle(BUNDLE.getString("download.statistics.header")); setHeaderText(null); getDialogPane().setContent(createContent()); setButtons(); }
public static void showExceptionAlert(String title, String header, String content, Throwable exc, Screens app) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(content); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exc.printStackTrace(pw); String exceptionText = sw.toString(); Label label = new Label("The exception stacktrace was:"); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); ButtonType e = new ButtonType("Report error", ButtonBar.ButtonData.OTHER); alert.getDialogPane().getButtonTypes().add(e); Optional<ButtonType> buttonType = alert.showAndWait(); buttonType.ifPresent(buttonType1 -> { app.showReportErrorWindow(app.getPrimaryStage()); }); }
public RevertChangesDialog(Val<Git> git, Status firstStatus) { super(git); setTitle("Revert modified files"); setResizable(true); ButtonType revertButtonType = new ButtonType("Revert...", ButtonBar.ButtonData.YES); setDialogPane(new RevertChangesDialogPane(git, new SelectableFileViewer(firstStatus), revertButtonType)); setResultConverter(buttonType -> { if (buttonType.equals(revertButtonType)) { return revertChanges(); } else { return null; } }); }
public CommitDialog(Val<Git> git, Status firstStatus) { super(git); setTitle("Commit changes"); setResizable(true); ButtonType commitButton = new ButtonType("Commit...", ButtonBar.ButtonData.YES); setDialogPane(new CommitDialogPane(git, new SelectableFileViewer(firstStatus), commitButton)); setResultConverter(buttonType -> { if (buttonType.equals(commitButton)) { return addAndCommitSelectedFiles(); } else { return null; } }); }