Search in sources :

Example 6 with ButtonType

use of javafx.scene.control.ButtonType in project Gargoyle by callakrsos.

the class DialogUtil method showYesOrNoDialog.

// public static Optional<Pair<String, String>> showYesOrNoDialog(String title, String message) {
// return showYesOrNoDialog(SharedMemory.getPrimaryStage(), title, message, consumer, null);
// }
public static Optional<Pair<String, String>> showYesOrNoDialog(Stage stage, String title, String message, Consumer<? super Pair<String, String>> consumer, Consumer<Dialog<Pair<String, String>>> dialogHandler) {
    // Create the custom dialog.
    Dialog<Pair<String, String>> dialog = new Dialog<>();
    dialog.setTitle(title);
    dialog.setHeaderText(message);
    // Set the button types.
    ButtonType yesBtn = new ButtonType("Yes", ButtonData.YES);
    ButtonType noBtn = new ButtonType("No", ButtonData.NO);
    dialog.getDialogPane().getButtonTypes().addAll(yesBtn, noBtn);
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == yesBtn) {
            return new Pair<>("RESULT", "Y");
        } else if (dialogButton == noBtn) {
            return new Pair<>("RESULT", "N");
        }
        return null;
    });
    dialog.initOwner(stage);
    if (dialogHandler != null)
        dialogHandler.accept(dialog);
    Optional<Pair<String, String>> result = dialog.showAndWait();
    if (consumer != null)
        result.ifPresent(consumer);
    return result;
}
Also used : Dialog(javafx.scene.control.Dialog) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair)

Example 7 with ButtonType

use of javafx.scene.control.ButtonType in project jgnash by ccavanaugh.

the class Alert method setButtons.

private void setButtons(final ButtonType... buttons) {
    for (final ButtonType buttonType : buttons) {
        final Button button = new Button(buttonType.getText());
        ButtonBar.setButtonData(button, buttonType.getButtonData());
        button.setOnAction(event -> {
            Alert.this.buttonType = buttonType;
            ((Stage) parent.get().getWindow()).close();
        });
        buttonBar.getButtons().add(button);
    }
}
Also used : Button(javafx.scene.control.Button) Stage(javafx.stage.Stage) ButtonType(javafx.scene.control.ButtonType)

Example 8 with ButtonType

use of javafx.scene.control.ButtonType in project cryptomator by cryptomator.

the class MainController method didClickRemoveSelectedEntry.

@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());
        }
    }
}
Also used : Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType) FXML(javafx.fxml.FXML)

Example 9 with ButtonType

use of javafx.scene.control.ButtonType in project cryptomator by cryptomator.

the class UnlockController method didClickSavePasswordCheckbox.

// ****************************************
// Save password checkbox
// ****************************************
@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);
        }
    }
}
Also used : Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType) FXML(javafx.fxml.FXML)

Example 10 with ButtonType

use of javafx.scene.control.ButtonType in project jabref by JabRef.

the class FXDialogService method showConfirmationDialogAndWait.

@Override
public boolean showConfirmationDialogAndWait(String title, String content, String okButtonLabel) {
    FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
    ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
    alert.getButtonTypes().setAll(ButtonType.CANCEL, okButtonType);
    return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
}
Also used : ExceptionDialog(org.controlsfx.dialog.ExceptionDialog) ButtonBar(javafx.scene.control.ButtonBar) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration) ButtonType(javafx.scene.control.ButtonType) JabRefGUI(org.jabref.JabRefGUI) Collectors(java.util.stream.Collectors) File(java.io.File) FileChooser(javafx.stage.FileChooser) List(java.util.List) DialogPane(javafx.scene.control.DialogPane) AlertType(javafx.scene.control.Alert.AlertType) TextInputDialog(javafx.scene.control.TextInputDialog) DirectoryDialogConfiguration(org.jabref.gui.util.DirectoryDialogConfiguration) Optional(java.util.Optional) Localization(org.jabref.logic.l10n.Localization) Path(java.nio.file.Path) Collections(java.util.Collections) DirectoryChooser(javafx.stage.DirectoryChooser) ButtonType(javafx.scene.control.ButtonType)

Aggregations

ButtonType (javafx.scene.control.ButtonType)18 Alert (javafx.scene.control.Alert)9 Dialog (javafx.scene.control.Dialog)5 File (java.io.File)4 Label (javafx.scene.control.Label)4 GridPane (javafx.scene.layout.GridPane)4 Pair (javafx.util.Pair)4 TextField (javafx.scene.control.TextField)3 FileChooser (javafx.stage.FileChooser)3 Dimension (java.awt.Dimension)2 ArrayList (java.util.ArrayList)2 FXML (javafx.fxml.FXML)2 Insets (javafx.geometry.Insets)2 Node (javafx.scene.Node)2 DialogPane (javafx.scene.control.DialogPane)2 PasswordField (javafx.scene.control.PasswordField)2 DirectoryChooser (javafx.stage.DirectoryChooser)2 EntityAttribute (aimax.osm.data.entities.EntityAttribute)1 MapEntity (aimax.osm.data.entities.MapEntity)1 MapNode (aimax.osm.data.entities.MapNode)1