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();
}
use of javafx.scene.control.ButtonType in project jabref by JabRef.
the class KeyBindingsDialogViewModel method resetToDefault.
public void resetToDefault() {
String title = Localization.lang("Resetting all key bindings");
String content = Localization.lang("All key bindings will be reset to their defaults.");
ButtonType resetButtonType = new ButtonType("Reset", ButtonBar.ButtonData.OK_DONE);
dialogService.showCustomButtonDialogAndWait(Alert.AlertType.INFORMATION, title, content, resetButtonType, ButtonType.CANCEL).ifPresent(response -> {
if (response == resetButtonType) {
keyBindingRepository.resetToDefault();
populateTable();
}
});
}
use of javafx.scene.control.ButtonType in project VocabHunter by VocabHunter.
the class UnsavedChangesDialogue method unsavedResponseMap.
private Map<ButtonType, UnsavedResponse> unsavedResponseMap() {
Map<ButtonType, UnsavedResponse> map = new LinkedHashMap<>();
map.put(new ButtonType("Save"), UnsavedResponse.SAVE);
map.put(new ButtonType("Discard"), UnsavedResponse.DISCARD);
map.put(new ButtonType("Cancel"), UnsavedResponse.CANCEL);
return map;
}
use of javafx.scene.control.ButtonType in project aic-praise by aic-sri-international.
the class FXUtil method exception.
public static void exception(Throwable th) {
Dialog<ButtonType> dialog = new Dialog<ButtonType>();
dialog.setTitle("Program exception");
final DialogPane dialogPane = dialog.getDialogPane();
dialogPane.setContentText("Details of the problem:");
dialogPane.getButtonTypes().addAll(ButtonType.OK);
dialogPane.setContentText(th.getMessage());
dialog.initModality(Modality.APPLICATION_MODAL);
Label label = new Label("Exception stacktrace:");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
th.printStackTrace(pw);
pw.close();
TextArea textArea = new TextArea(sw.toString());
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 root = new GridPane();
root.setVisible(false);
root.setMaxWidth(Double.MAX_VALUE);
root.add(label, 0, 0);
root.add(textArea, 0, 1);
dialogPane.setExpandableContent(root);
dialog.showAndWait();
}
use of javafx.scene.control.ButtonType in project Gargoyle by callakrsos.
the class DialogUtil method showLoginDialog.
/**
* login Dialog 로그인 처리 다이얼로그
*
* @param consumer
* @return
*/
public static <T> Optional<Pair<String, String>> showLoginDialog(Consumer<? super Pair<String, String>> consumer) {
// Create the custom dialog.
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Login Dialog");
dialog.setHeaderText("Look, a Custom Login Dialog");
dialog.setGraphic(new ImageView(new Image("file:resources/images/login.png")));
// Set the button types.
ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
ButtonType localButtonType = new ButtonType("Local", ButtonData.APPLY);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, localButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Username");
PasswordField password = new PasswordField();
password.setPromptText("Password");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
grid.add(new Label("Password:"), 0, 1);
grid.add(password, 1, 1);
// Enable/Disable login button depending on whether a username was
// entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
username.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(() -> username.requestFocus());
// Convert the result to a username-password-pair when the login button
// is clicked.
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(username.getText(), password.getText());
} else if (dialogButton == localButtonType) {
return new Pair<>(MEMO_LOCAL_USER, "");
}
return null;
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(consumer);
return result;
}
Aggregations