Example usage for javafx.scene.control ButtonType NO

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

Introduction

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

Prototype

ButtonType NO

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

Click Source Link

Document

A pre-defined ButtonType that displays "No" and has a ButtonData of ButtonData#NO .

Usage

From source file:de._692b8c32.cdlauncher.MainController.java

public MainController(Application application, Preferences preferences) {
    this.application = application;
    this.preferences = preferences;

    if (preferences.get("basedir", null) == null) {
        while (new OptionsController(application, preferences).selectDirectory() == null) {
            new Alert(Alert.AlertType.ERROR,
                    "The launcher needs a directory to store temporary files. Press cancel if you want to close the application.",
                    ButtonType.CANCEL, ButtonType.PREVIOUS).showAndWait().ifPresent(button -> {
                        if (button == ButtonType.CANCEL) {
                            throw new RuntimeException("User requested abort.");
                        }//from   w  ww .  j  a va 2  s .  com
                    });
        }

        new Alert(Alert.AlertType.INFORMATION,
                "Do you want to use a prebuilt version of OpenRA? This is recommended unless you are an OpenRA developer.",
                ButtonType.NO, ButtonType.YES).showAndWait().ifPresent(button -> {
                    if (button == ButtonType.YES) {
                        preferences.putBoolean("buildFromSources", false);
                    }
                    if (button == ButtonType.NO) {
                        preferences.putBoolean("buildFromSources", true);
                    }
                });

        if (System.getProperty("os.name").toLowerCase().contains("win")) {
            preferences.put("commandMono", "");
            preferences.put("commandMake", "");
        }
    }
}

From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java

@FXML
private void onAbrirActionEvent(ActionEvent event) {
    File csvFile = null;// w w  w  . jav a 2  s . c o  m
    try {
        if (!saved) {
            Alert a = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
            a.setHeaderText("Deseja descartar as alteraes??");
            a.initOwner(root.getScene().getWindow());
            Optional<ButtonType> result = a.showAndWait();
            if (result.get() != ButtonType.YES) {
                return;
            }
        }
        csvFile = openFileChooser();
        if (csvFile == null || !csvFile.exists()) {
            throw new FileNotFoundException("O arquivo selecionado no existe!");
        }
        ObservableList<CSVRow> rows = readFile(csvFile);
        if (rows == null || rows.isEmpty()) {
            throw new FilerException("O arquivo selecionado est vazio!");
        }
        updateTable(rows);
        this.file = csvFile;
        setSaved();
    } catch (Exception ex) {
        ex.printStackTrace();
        Alert d = new Alert(Alert.AlertType.ERROR);
        d.setHeaderText(
                "Ooops, no foi possvel abrir o arquivo " + (csvFile != null ? csvFile.getName() : "."));
        d.setContentText(ex.getMessage());
        d.setTitle("Erro");
        d.initOwner(root.getScene().getWindow());
        d.show();
    }
}

From source file:com.exalttech.trex.util.Util.java

/**
 * Confirm deletion message window/*from   w ww  .java 2  s .com*/
 *
 * @param deleteMsg
 * @return
 */
public static boolean isConfirmed(String deleteMsg) {
    Alert confirmMsgBox = Util.getAlert(Alert.AlertType.CONFIRMATION);
    confirmMsgBox.getButtonTypes().clear();
    confirmMsgBox.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);
    confirmMsgBox.setContentText(deleteMsg);
    Optional<ButtonType> result = confirmMsgBox.showAndWait();
    return result.get() == ButtonType.YES;
}

From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java

@FXML
private void onSairActionEvent(ActionEvent event) {
    if (saved) {/* ww  w. j a  v  a2  s . c o  m*/
        sair();
    } else {
        Alert a = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
        a.setHeaderText("Deseja sair sem salvar?");
        a.initOwner(root.getScene().getWindow());
        Optional<ButtonType> result = a.showAndWait();
        if (result.get() == ButtonType.YES) {
            sair();
        }
    }
}

From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java

private void saveAsScript(final BaseMqttMessage message) {
    boolean valid = false;

    while (!valid) {
        final Optional<String> response = DialogFactory.createInputDialog(pane.getScene().getWindow(),
                "Enter a name for your message-based script", "Script name (without .js)");

        logger.info("Script name response = " + response);
        if (response.isPresent()) {
            final String scriptName = response.get();

            final String configuredDirectory = connection.getProperties().getConfiguredProperties()
                    .getPublicationScripts();
            final String directory = InteractiveMqttScriptManager
                    .getScriptDirectoryForConnection(configuredDirectory);
            final File scriptFile = new File(directory + scriptName + MqttScriptManager.SCRIPT_EXTENSION);

            final Script script = scriptManager.getScriptObjectFromName(Script.getScriptIdFromFile(scriptFile));

            if (script != null) {
                Optional<ButtonType> duplicateNameResponse = DialogFactory.createQuestionDialog(
                        "Script name already exists",
                        "Script with name \"" + scriptName + "\" already exists in your script folder ("
                                + directory + "). Do you want to override it?");
                if (duplicateNameResponse.get() == ButtonType.NO) {
                    continue;
                } else if (duplicateNameResponse.get() == ButtonType.CANCEL) {
                    break;
                }//from   w  w  w  . jav a  2s  .  c  o m
            }

            createScriptFromMessage(scriptFile, configuredDirectory, message);
            break;
        } else {
            break;
        }
    }
}