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:ninja.javafx.smartcsv.fx.SmartCSVController.java

@FXML
public void preferences(ActionEvent actionEvent) {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setGraphic(null);/*from ww  w  .j a v  a2  s.  co m*/
    alert.setTitle(resourceBundle.getString("dialog.preferences.title"));
    alert.setHeaderText(resourceBundle.getString("dialog.preferences.header.text"));
    alert.getDialogPane().setContent(preferencesController.getView());

    Node okButton = alert.getDialogPane().lookupButton(ButtonType.OK);
    okButton.disableProperty().bind(preferencesController.validProperty().not());

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

    if (result.get() == ButtonType.OK) {
        CsvPreference csvPreference = preferencesController.getCsvPreference();
        setCsvPreference(csvPreference);
        saveCsvPreferences(csvPreference);
    } else {
        preferencesController.setCsvPreference(csvPreferenceFile.getContent());
    }
}

From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java

private boolean confirmDelete(LinkedList<File> overlayFiles) {
    String confirmationText = I18N.getString("ManageOverlays.dialog.delete.confirmation");

    if (overlayFiles.isEmpty())
        return false;
    else if (overlayFiles.size() == 1) {
        confirmationText += overlayFiles.get(0).getName() + "?";
    } else {//from w w  w. j  a v  a 2  s  .c o  m
        confirmationText += I18N.getString("ManageOverlays.dialog.delete.confirmation.these")
                + overlayFiles.size() + I18N.getString("ManageOverlays.dialog.delete.confirmation.overlays");
    }

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(I18N.getString("ManageOverlays.dialog.delete.title"));
    alert.setContentText(confirmationText);

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

    if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
        return true;
    }

    return false;
}

From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java

private void handleError(final String message, final Throwable exception) {
    logger.error(exception.getMessage(), exception);
    final Alert alert = new Alert(Alert.AlertType.ERROR, exception.getMessage(), ButtonType.OK);
    alert.setTitle(message);// www  .j  a  va  2s.  co  m
    alert.setHeaderText(rb.getString("error-header"));
    alert.show();
}

From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java

private void gpxExportFinished() {
    final Alert info = new Alert(Alert.AlertType.INFORMATION, "", ButtonType.OK);
    info.setTitle(rb.getString("gpx-export-finished"));
    info.setHeaderText(rb.getString("gpx-export-finished"));
    info.show();/* w  w w.  ja v  a2 s .  co  m*/
}

From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java

private boolean confirmDelete(File dir) {
    String confirmationText = I18N.getString("ManageOverlays.dialog.delete.dir.confirmation");
    long dirSize = FileUtils.listFiles(dir, ImageUtil.SUPPORTED_FILE_FILTER, TrueFileFilter.INSTANCE).size();

    if (dirSize == 0) {
        confirmationText += dir.getName()
                + I18N.getString("ManageOverlays.dialog.delete.dir.confirmation.directory");
    } else {/*from  w  w  w . j a v a 2  s .com*/
        confirmationText += dir.getName()
                + I18N.getString("ManageOverlays.dialog.delete.dir.directory_containing") + dirSize
                + I18N.getString("ManageOverlays.dialog.delete.dir.overlays");
    }

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(I18N.getString("ManageOverlays.dialog.delete.dir.title"));
    alert.setContentText(confirmationText);

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

    if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
        return true;
    }

    return false;
}

From source file:de.pixida.logtest.designer.MainWindow.java

private boolean handleSaveDocumentAs() {
    final FileChooser fileChooser = this.createFileDialog(this.getCurrentEditor().getType(), "Save");
    final File selectedFile = fileChooser.showSaveDialog(this.primaryStage);
    if (selectedFile == null) {
        return false;
    } else {/*w  w w .j a  v a  2  s . c o m*/
        this.applyFolderOfSelectedFileInOpenOrSaveAsFileDialog(selectedFile);

        boolean overwriteIfPresent = true;
        final Tab openedDocument = this.findTabThatIsAssignedToFile(selectedFile);
        if (openedDocument != null) {
            final Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle("Confirm overwrite");
            alert.setHeaderText("The file is already opened.");
            alert.setContentText("Do you want to overwrite the file?");
            final Optional<ButtonType> choice = alert.showAndWait();
            if (choice.get() != ButtonType.OK) {
                overwriteIfPresent = false;
            }
        }
        if (overwriteIfPresent) {
            this.getCurrentEditor().assignDocumentToFile(selectedFile);
            return this.saveDocument();
        } else {
            return false;
        }
    }
}

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

public void handleAddScan(Event e) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MsSpectrumPlotModule.class);
    ButtonType exitCode = parameters.showSetupDialog("Add scan");
    if (exitCode != ButtonType.OK)
        return;//  w  w w.j  a  v a 2  s.c om

    final RawDataFilesSelection fileSelection = parameters.getParameter(MsSpectrumPlotParameters.inputFiles)
            .getValue();
    final Integer scanNumber = parameters.getParameter(MsSpectrumPlotParameters.scanNumber).getValue();
    final ScanSelection scanSelection = new ScanSelection(Range.singleton(scanNumber), null, null, null, null,
            null);
    final List<RawDataFile> dataFiles = fileSelection.getMatchingRawDataFiles();
    boolean spectrumAdded = false;
    for (RawDataFile dataFile : dataFiles) {
        for (MsScan scan : scanSelection.getMatchingScans(dataFile)) {
            String title = MsScanUtils.createSingleLineMsScanDescription(scan);
            addSpectrum(scan, title);
            spectrumAdded = true;
        }
    }
    if (!spectrumAdded) {
        MZmineGUI.displayMessage("Scan not found");
    }
}

From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java

public boolean canExit() {
    boolean canExit = true;
    if (currentCsvFile.getContent() != null && currentCsvFile.isFileChanged()) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(resourceBundle.getString("dialog.exit.title"));
        alert.setHeaderText(resourceBundle.getString("dialog.exit.header.text"));
        alert.setContentText(resourceBundle.getString("dialog.exit.text"));

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() != ButtonType.OK) {
            canExit = false;//from   w  ww  .ja  v  a 2 s  . com
        }
    }

    return canExit;
}

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

public void handleAddSpectrumFromText(Event e) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(SpectrumParserPlotModule.class);
    ButtonType exitCode = parameters.showSetupDialog("Parse spectrum");
    if (exitCode != ButtonType.OK)
        return;/*from   ww w .j a v  a  2s.  c  o m*/

    final String spectrumText = parameters.getParameter(SpectrumParserPlotParameters.spectrumText).getValue();
    final MsSpectrumType spectrumType = parameters.getParameter(SpectrumParserPlotParameters.spectrumType)
            .getValue();

    Preconditions.checkNotNull(spectrumText);
    Preconditions.checkNotNull(spectrumType);

    final MsSpectrum spectrum = TxtImportAlgorithm.parseMsSpectrum(spectrumText);
    spectrum.setSpectrumType(spectrumType);

    String spectrumName = "Manual spectrum";

    addSpectrum(spectrum, spectrumName);
}

From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java

public void showValidationEditor(String column) {
    validationEditorController.setSelectedColumn(column);
    validationEditorController.updateForm();

    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setGraphic(null);/* w w  w  . j a v  a  2s  .  c  om*/
    alert.setTitle(resourceBundle.getString("dialog.validation.rules.title"));
    alert.setHeaderText(format(resourceBundle.getString("dialog.validation.rules.header"), column));
    alert.getDialogPane().setContent(validationEditorController.getView());
    Optional<ButtonType> result = alert.showAndWait();

    if (result.get() == ButtonType.OK) {
        runLater(() -> {
            validationEditorController.updateConfiguration();
            currentCsvFile.setFileChanged(true);
            currentCsvFile.getContent().revalidate(column);
        });
    }
}