Example usage for javafx.scene.control ButtonType OK

List of usage examples for javafx.scene.control ButtonType OK

Introduction

In this page you can find the example usage for javafx.scene.control ButtonType OK.

Prototype

ButtonType OK

To view the source code for javafx.scene.control ButtonType OK.

Click Source Link

Document

A pre-defined ButtonType that displays "OK" and has a ButtonData of ButtonData#OK_DONE .

Usage

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

private void profileEdit(Profile profile) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(mStage);/*from  w  w  w  . jav  a  2s .com*/
    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:net.rptools.tokentool.controller.ManageOverlays_Controller.java

@FXML
void restoreButton_onAction(ActionEvent event) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(I18N.getString("ManageOverlays.dialog.restore.overlays.title"));
    alert.setContentText(I18N.getString("ManageOverlays.dialog.restore.overlays.content_text"));

    Optional<ButtonType> result = alert.showAndWait();

    if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
        log.info("Restoring default images...");
        try {//from   w  w  w. j  a  v  a  2s.  c  om
            AppSetup.installDefaultOverlays();
        } catch (IOException e) {
            log.error("Error restoring default overlays!", e);
        }

        displayTreeView();
    }
}

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  w  w .java2s  .  c o 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();
    } 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);
    }
}

From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java

public void handleAddIsotopePattern(Event e) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(IsotopePatternPlotModule.class);
    ButtonType exitCode = parameters.showSetupDialog("Add isotope pattern");
    if (exitCode != ButtonType.OK)
        return;/* w w  w.  ja v  a  2s.  co  m*/
    final String formula = parameters.getParameter(IsotopePatternPlotParameters.formula).getValue();
    final Double mzTolerance = parameters.getParameter(IsotopePatternPlotParameters.mzTolerance).getValue();
    final Double minAbundance = parameters.getParameter(IsotopePatternPlotParameters.minAbundance).getValue();
    final Double normalizedIntensity = parameters.getParameter(IsotopePatternPlotParameters.normalizedIntensity)
            .getValue();
    final MsSpectrum pattern = IsotopePatternGeneratorAlgorithm.generateIsotopes(formula, minAbundance,
            normalizedIntensity.floatValue(), mzTolerance);
    addSpectrum(pattern, formula);
}

From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java

private Optional<String> askUserForTextField(String text) {
    TextField textfield = new TextField();

    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.getDialogPane().headerTextProperty().set(text);
    dialog.getDialogPane().contentProperty().set(textfield);
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    Optional<ButtonType> result = dialog.showAndWait();

    if (result.isPresent() && result.get().equals(ButtonType.OK))
        return Optional.of(textfield.getText());
    else//from   w  w  w  .  java  2  s . c o m
        return Optional.empty();
}

From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java

private Optional<String> askUserForTextArea(String label, String initialText) {
    TextArea textarea = new TextArea();
    if (initialText != null)
        textarea.setText(initialText);// w  ww.  j a  v  a 2 s . c  o  m

    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.getDialogPane().headerTextProperty().set(label);
    dialog.getDialogPane().contentProperty().set(textarea);
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    Optional<ButtonType> result = dialog.showAndWait();

    if (result.isPresent() && result.get().equals(ButtonType.OK))
        return Optional.of(textarea.getText());
    else
        return Optional.empty();
}

From source file:com.cdd.bao.editor.EditSchema.java

private boolean confirmClose() {
    pullDetail();//  w  w  w . ja va  2s. c  o m

    if (!stack.isDirty())
        return true;

    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Close Window");
    alert.setHeaderText("Abandon changes");
    alert.setContentText("Closing this window will cause modifications to be lost.");

    Optional<ButtonType> result = alert.showAndWait();
    return result.get() == ButtonType.OK;
}

From source file:acmi.l2.clientmod.l2smr.Controller.java

@FXML
private void createStaticMeshToUnr() {
    Platform.runLater(() -> {//  ww w . j a  v  a  2  s  . c  o m
        StaticMeshActorDialog dlg = new StaticMeshActorDialog();
        ButtonType response = dlg.showAndWait().orElse(null);
        if (response != ButtonType.OK)
            return;

        boolean rot = dlg.isRotating();
        boolean zrs = dlg.isZoneRenderState();

        longTask(progress -> {
            String usx = this.usxChooser.getSelectionModel().getSelectedItem();
            usx = usx.substring(0, usx.indexOf('.'));
            try (UnrealPackage up = new UnrealPackage(
                    new File(getMapsDir(), this.unrChooser.getSelectionModel().getSelectedItem()), false)) {
                addStaticMeshToUnr(up);
                int actorInd = StaticMeshActorUtil.addStaticMeshActor(up,
                        up.objectReferenceByName(
                                usx + "." + this.smChooser.getSelectionModel().getSelectedItem(), c -> true),
                        dlg.getActorClass(), rot, zrs, this.oldFormat.isSelected()) - 1;

                Platform.runLater(() -> {
                    int ind = this.unrChooser.getSelectionModel().getSelectedIndex();
                    this.unrChooser.getSelectionModel().clearSelection();
                    this.unrChooser.getSelectionModel().select(ind);

                    ind = 0;
                    for (int i = 0; i < actors.size(); i++)
                        if (actors.get(i).getInd() == actorInd)
                            ind = i;

                    table.getSelectionModel().select(ind);
                    table.scrollTo(ind);
                });
            }
        }, e -> onException("Creation failed", e));
    });
}

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

@FXML
private void deleteExplicitChange(ActionEvent evt) {
    List<Change> changesToDelete = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());
    List<Change> explicitChangesToDelete = changesToDelete.stream()
            .filter(ch -> !ch.getDataset().isChangeImplicit(ch)).collect(Collectors.toList());

    if (explicitChangesToDelete.isEmpty())
        return;/*from  www .j  a  v a 2s .  co  m*/

    // Explicit changes! Verify before deleting.
    Optional<ButtonType> opt = new Alert(AlertType.CONFIRMATION,
            "Are you sure you want to delete " + explicitChangesToDelete.size()
                    + " explicit changes starting with " + explicitChangesToDelete.get(0).toString()
                    + "? This cannot be undone!").showAndWait();
    if (!opt.isPresent() || !opt.get().equals(ButtonType.OK))
        return;

    // Okay, we're verified! Time to die.
    for (Change ch : explicitChangesToDelete) {
        ch.getDataset().deleteChange(ch);
    }
}

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

@FXML
public void saveProfile() {

    if (logger.isDebugEnabled()) {
        logger.debug("[SAVE PROFILE]");
    }/*from  w w w .j  av  a  2 s.  c o m*/

    if (activeConfiguration.activeProfileProperty().isEmpty().get()) {

        if (logger.isDebugEnabled()) {
            logger.debug("[SAVE PROFILE] activeProfileName is empty");
        }

        Dialog<String> dialog = new TextInputDialog();
        dialog.setTitle("Profile name");
        dialog.setHeaderText("Enter profile name");
        Optional<String> result = dialog.showAndWait();

        if (result.isPresent()) {
            String newProfileName = result.get();

            if (configurationDS.profileExists(newProfileName)) {
                Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Overwrite existing profile?");
                alert.setHeaderText("Profile exists");
                Optional<ButtonType> response = alert.showAndWait();
                if (!response.isPresent() || response.get() != ButtonType.OK) {
                    return;
                }
            }

            activeConfiguration.activeProfileProperty().set(newProfileName);

            try {
                recordRecentProfile(newProfileName); // #18
                configurationDS.saveProfile(); // saves active profile

                Stage s = (Stage) sp.getScene().getWindow();
                s.setTitle("ResignatorApp - " + newProfileName);

                needsSave.set(false);

                addToProfileBrowser(newProfileName);

            } catch (IOException exc) {
                logger.error("error saving profile '" + newProfileName + "'", exc);

                Alert alert = new Alert(Alert.AlertType.ERROR, exc.getMessage());
                alert.setHeaderText("Can't save profile");
                alert.showAndWait();
            }

        } else {
            String msg = "A profile name is required";
            Alert alert = new Alert(Alert.AlertType.ERROR, msg);
            alert.setHeaderText("Can't save profile");
            alert.showAndWait();
        }
    } else { // just save

        if (logger.isDebugEnabled()) {
            logger.debug("[SAVE PROFILE] there is an active profile");
        }

        try {
            recordRecentProfile(activeProfile.getProfileName()); // #18
            configurationDS.saveProfile(); // saves active profile
            needsSave.set(false);

        } catch (IOException exc) {
            logger.error("error saving profile '" + activeConfiguration.activeProfileProperty().get() + "'",
                    exc);

            Alert alert = new Alert(Alert.AlertType.ERROR, exc.getMessage());
            alert.setHeaderText("Can't save profile");
            alert.showAndWait();
        }

    }
}