Example usage for javafx.scene.control DialogPane lookupButton

List of usage examples for javafx.scene.control DialogPane lookupButton

Introduction

In this page you can find the example usage for javafx.scene.control DialogPane lookupButton.

Prototype

public final Node lookupButton(ButtonType buttonType) 

Source Link

Document

This method provides a way in which developers may retrieve the actual Node for a given ButtonType (assuming it is part of the #getButtonTypes() button types list).

Usage

From source file:se.trixon.filebydate.ui.MainApp.java

private void profileEdit(Profile profile) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(mStage);/*w w  w .  ja  v a2s .co  m*/
    String title = Dict.EDIT.toString();
    boolean addNew = false;
    boolean clone = profile != null && profile.getName() == null;

    if (profile == null) {
        title = Dict.ADD.toString();
        addNew = true;
        profile = new Profile();
        profile.setSourceDir(FileUtils.getUserDirectory());
        profile.setDestDir(FileUtils.getUserDirectory());
        profile.setFilePattern("{*.jpg,*.JPG}");
        profile.setDatePattern("yyyy/MM/yyyy-MM-dd");
        profile.setOperation(0);
        profile.setFollowLinks(true);
        profile.setRecursive(true);
        profile.setReplaceExisting(false);
        profile.setCaseBase(NameCase.UNCHANGED);
        profile.setCaseExt(NameCase.UNCHANGED);
    } else if (clone) {
        title = Dict.CLONE.toString();
        profile.setLastRun(0);
    }

    alert.setTitle(title);
    alert.setGraphic(null);
    alert.setHeaderText(null);

    ProfilePanel profilePanel = new ProfilePanel(profile);

    final DialogPane dialogPane = alert.getDialogPane();
    dialogPane.setContent(profilePanel);
    profilePanel.setOkButton((Button) dialogPane.lookupButton(ButtonType.OK));

    Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage);
    if (result.get() == ButtonType.OK) {
        profilePanel.save();
        if (addNew || clone) {
            mProfiles.add(profile);
        }

        profilesSave();
        populateProfiles(profile);
    }
}

From source file:se.trixon.mapollage.ui.MainApp.java

private void profileEdit(Profile profile) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(mStage);/*from   w ww.ja v  a 2 s . c  om*/
    String title = Dict.EDIT.toString();
    boolean addNew = false;
    boolean clone = profile != null && profile.getName() == null;

    if (profile == null) {
        title = Dict.ADD.toString();
        addNew = true;
        profile = new Profile();
    } else if (clone) {
        title = Dict.CLONE.toString();
        profile.setLastRun(0);
    }

    alert.setTitle(title);
    alert.setGraphic(null);
    alert.setHeaderText(null);
    alert.setResizable(true);

    ProfilePanel profilePanel = new ProfilePanel(profile);

    final DialogPane dialogPane = alert.getDialogPane();
    dialogPane.setContent(profilePanel);
    profilePanel.setOkButton((Button) dialogPane.lookupButton(ButtonType.OK));

    Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage);
    if (result.get() == ButtonType.OK) {
        profilePanel.save();
        if (addNew || clone) {
            mProfiles.add(profile);
        }

        profilesSave();
        populateProfiles(profile);
    }
}