/**
   * @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());
  }
Esempio n. 2
0
  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());
  }
  @SuppressWarnings("JavadocMethod")
  public ProjectSettingsEditor(
      Parent root, ProjectSettings projectSettings, AppSettings appSettings) {
    super();

    VBox content =
        new VBox(
            new CustomPropertySheet(BeanPropertyUtils.getProperties(projectSettings)),
            new Separator(),
            new CustomPropertySheet(BeanPropertyUtils.getProperties(appSettings)));
    content.setSpacing(5.0);

    DialogPane pane = getDialogPane();
    pane.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);
    pane.setContent(content);
    pane.styleProperty().bind(root.styleProperty());
    pane.getStylesheets().addAll(root.getStylesheets());
    pane.setPrefSize(DPIUtility.SETTINGS_DIALOG_SIZE, DPIUtility.SETTINGS_DIALOG_SIZE);

    ImageView graphic =
        new ImageView(new Image(getClass().getResourceAsStream("icons/settings.png")));
    graphic.setFitWidth(DPIUtility.SMALL_ICON_SIZE);
    graphic.setFitHeight(DPIUtility.SMALL_ICON_SIZE);

    setTitle("Settings");
    setHeaderText("Settings");
    setGraphic(graphic);
    setResizable(true);
  }
 private void setupButtons(DialogPane dialogPane) {
   ButtonType confirmButtonType = new ButtonType("Confirm", ButtonBar.ButtonData.OK_DONE);
   dialogPane.getButtonTypes().addAll(confirmButtonType, ButtonType.CANCEL);
 }
Esempio n. 5
0
 private void addLinkToDialog(DialogPane dialogPane, CommandLinksButtonType link) {
   typeMap.put(link.getButtonType(), link);
   dialogPane.getButtonTypes().add(link.getButtonType());
 }