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;
}
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);
}
}
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());
}
}
}
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);
}
}
}
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();
}
Aggregations