/** * @param title Title, message * @param correct_password Password to check */ public PasswordDialog(final String title, final String correct_password) { this.correct_password = correct_password; final DialogPane pane = getDialogPane(); pass_entry.setPromptText(Messages.Password_Prompt); pass_entry.setMaxWidth(Double.MAX_VALUE); getDialogPane().setContent(pass_entry); setTitle(Messages.Password); setHeaderText(title); pane.getStyleClass().add("text-input-dialog"); pane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); // Check password in dialog? if (correct_password != null && correct_password.length() > 0) { final Button okButton = (Button) pane.lookupButton(ButtonType.OK); okButton.addEventFilter( ActionEvent.ACTION, event -> { if (!checkPassword()) event.consume(); }); } setResultConverter( (button) -> { return button.getButtonData() == ButtonData.OK_DONE ? pass_entry.getText() : null; }); Platform.runLater(() -> pass_entry.requestFocus()); }
public CommandLinksDialog(List<CommandLinksButtonType> links) { this.grid.setHgap(gapSize); this.grid.setVgap(gapSize); this.grid.getStyleClass().add("container"); // $NON-NLS-1$ final DialogPane dialogPane = new DialogPane() { @Override protected Node createButtonBar() { return null; } @Override protected Node createButton(ButtonType buttonType) { return createCommandLinksButton(buttonType); } }; setDialogPane(dialogPane); setTitle(getString("Dialog.info.title")); // $NON-NLS-1$ dialogPane.getStyleClass().add("command-links-dialog"); // $NON-NLS-1$ dialogPane .getStylesheets() .add(getClass().getResource("dialogs.css").toExternalForm()); // $NON-NLS-1$ dialogPane .getStylesheets() .add(getClass().getResource("commandlink.css").toExternalForm()); // $NON-NLS-1$ // create a map from ButtonType -> CommandLinkButtonType, and put the // ButtonType values into the dialog pane typeMap = new HashMap<>(); for (CommandLinksButtonType link : links) { addLinkToDialog(dialogPane, link); } addLinkToDialog(dialogPane, CommandLinksButtonType.buildHiddenCancelLink()); updateGrid(); dialogPane .getButtonTypes() .addListener((ListChangeListener<? super ButtonType>) c -> updateGrid()); contentTextProperty().addListener(o -> updateContentText()); }