Search in sources :

Example 11 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)

Example 12 with ButtonType

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

Example 13 with ButtonType

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;
}
Also used : UnsavedResponse(io.github.vocabhunter.gui.common.UnsavedResponse) ButtonType(javafx.scene.control.ButtonType) LinkedHashMap(java.util.LinkedHashMap)

Example 14 with ButtonType

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();
}
Also used : DialogPane(javafx.scene.control.DialogPane) GridPane(javafx.scene.layout.GridPane) StringWriter(java.io.StringWriter) TextArea(javafx.scene.control.TextArea) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) PrintWriter(java.io.PrintWriter)

Example 15 with ButtonType

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;
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Image(javafx.scene.image.Image) Dialog(javafx.scene.control.Dialog) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) PasswordField(javafx.scene.control.PasswordField) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair)

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