Example usage for javafx.scene.control Alert getButtonTypes

List of usage examples for javafx.scene.control Alert getButtonTypes

Introduction

In this page you can find the example usage for javafx.scene.control Alert getButtonTypes.

Prototype


public final ObservableList<ButtonType> getButtonTypes() 

Source Link

Document

Returns an ObservableList of all ButtonType instances that are currently set inside this Alert instance.

Usage

From source file:io.github.medinam.jcheesum.util.VersionChecker.java

public static void showDownloadLatestAlert() {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);

    ResourceBundle resources = ResourceBundle.getBundle("i18n/Bundle", Locale.getDefault());

    alert.setTitle(resources.getString("newVersion"));
    alert.setHeaderText(resources.getString("newVersionLooksLike"));
    alert.setContentText(resources.getString("youHave") + App.class.getPackage().getImplementationVersion()
            + " " + resources.getString("latestVersionIs") + getLatestStable() + "\n\n"
            + resources.getString("wannaDownload"));

    ButtonType yesBtn = new ButtonType(resources.getString("yes"));
    ButtonType noBtn = new ButtonType(resources.getString("no"), ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(yesBtn, noBtn);

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

    if (o.get() == yesBtn) {
        General.openLink(getLatestStableDownloadURL());
    } else if (o.get() == noBtn) {
        alert.close();/*from w ww .  j  a  v  a2 s  . c o  m*/
    }
}

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

/**
 * Confirm deletion message window/*from w  ww.j  a v a  2 s  .c o m*/
 *
 * @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.rcs.shoe.shop.fx.controller.ui.Controller.java

protected void showInformationPopup(String title, String headerText, String contentText) {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle(title);/*w w w  . ja v a 2  s.  c om*/
    alert.setHeaderText(headerText);
    alert.setContentText(contentText);

    ButtonType okButton = new ButtonType("Nastavi", ButtonBar.ButtonData.OK_DONE);

    alert.getButtonTypes().setAll(okButton);

    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.getIcons().add(uIConfig.getIcon());

    alert.showAndWait();
}

From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java

protected boolean showConfirmPopup(String title, String header, String contentText) {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(title);//from ww  w  .  j  a v  a2 s.  com
    alert.setHeaderText(header);
    alert.setContentText(contentText);

    ButtonType okButton = new ButtonType("Da", ButtonBar.ButtonData.OK_DONE);
    ButtonType cancelButton = new ButtonType("Ne", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(okButton, cancelButton);

    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.getIcons().add(uIConfig.getIcon());

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) {
        return true;
    }
    return false;
}

From source file:com.rcs.shoe.shop.fx.controller.ui.NewProductController.java

private void showProductCodePopup() {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("ifra proizvoda!");
    alert.setHeaderText("ifra ne moe biti prazna!");
    alert.setContentText("");

    ButtonType okButton = new ButtonType("Nastavi", ButtonData.OK_DONE);

    alert.getButtonTypes().setAll(okButton);

    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.getIcons().add(uIConfig.getIcon());

    alert.showAndWait();//  w w  w .ja v  a 2s  .  c om
}

From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java

private boolean acceptDelete(File file) {
    String YES = bundle.getString("yes");
    String NO = bundle.getString("no");
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(bundle.getString("w1DeleteISO"));
    alert.setHeaderText(bundle.getString("w1DeleteConfirmation").replace("%1", file.getName()));
    alert.setContentText(bundle.getString("deleteInfo"));
    ButtonType buttonYes = new ButtonType(YES, ButtonBar.ButtonData.YES);
    ButtonType buttonNo = new ButtonType(NO, ButtonBar.ButtonData.NO);
    alert.getButtonTypes().setAll(buttonNo, buttonYes);
    return alert.showAndWait().get().equals(buttonYes);
}

From source file:com.rcs.shoe.shop.fx.controller.ui.NewProductController.java

private void openProductFoundDialog() {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Ovaj reni broj je zauzet!");
    alert.setHeaderText("Redni broj: " + produstNumber.textProperty().getValue() + " je zauzet!");
    alert.setContentText("Da li elite da izmenite stanje za ovaj proizvod?");

    ButtonType okButton = new ButtonType("Da", ButtonData.OK_DONE);
    ButtonType cancelButton = new ButtonType("Ne", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(okButton, cancelButton);

    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.getIcons().add(uIConfig.getIcon());

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get().getButtonData() == ButtonData.OK_DONE) {
        openEditForm();//from w ww . j  av  a 2 s  .c o  m
    }
}

From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignController.java

public void addConfigFile(File file, boolean ask) {
    if (file != null) {
        // Check valid config
        if (!readConfig(file.getPath())) {
            getContext().send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.ERROR,
                    DPFManagerProperties.getBundle().getString("errorReadingConfFile")));
            file = null;//  www  .j  a v  a  2 s.  co m
        }
    }

    if (file != null && ask) {
        DPFManagerProperties.setDefaultDirConfig(file.getParent());
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(getBundle().getString("copyTitle"));
        alert.setHeaderText(getBundle().getString("copyHeader"));
        alert.setContentText(getBundle().getString("copyContent"));
        ButtonType buttonTypeYes = new ButtonType(getBundle().getString("yes"));
        ButtonType buttonTypeNo = new ButtonType(getBundle().getString("no"));
        alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == buttonTypeYes) {
            // Copy the file
            boolean needAdd = true;
            boolean error = false;
            File configFile = new File(DPFManagerProperties.getConfigDir() + "/" + file.getName());
            if (configFile.exists()) {
                configFile.delete();
                needAdd = false;
            }
            try {
                FileUtils.copyFile(file, configFile);
            } catch (IOException e) {
                error = true;
            }
            if (error) {
                // Add source file
                String description = readDescription(file);
                getView().addConfigFile(file.getAbsolutePath(), description, false);
                getContext().send(BasicConfig.MODULE_MESSAGE,
                        new AlertMessage(AlertMessage.Type.WARNING, getBundle().getString("errorCopyConfig")));
            } else if (needAdd) {
                String description = readDescription(configFile);
                getView().addConfigFile(configFile.getName(), description, false);
            }
        } else {
            String description = readDescription(file);
            getView().addConfigFile(file.getAbsolutePath(), description, false);
        }
    } else if (file != null && !ask) {
        getView().addConfigFile(file.getAbsolutePath(), readDescription(file), false);
    }
}

From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java

public void addIsoFile(File file, boolean ask) {
    if (file == null) {
        return;//ww w. j  av  a  2 s  .com
    }

    // Check valid config
    ImplementationCheckerObjectType rules = ImplementationCheckerLoader.getRules(file.getPath());
    if (rules == null) {
        context.send(BasicConfig.MODULE_MESSAGE, new AlertMessage(AlertMessage.Type.ERROR,
                DPFManagerProperties.getBundle().getString("w1errorReadingIso").replace("%1", file.getPath())));
        return;
    }

    if (ask) {
        DPFManagerProperties.setDefaultDirConfig(file.getParent());
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(bundle.getString("w1copyTitle"));
        alert.setHeaderText(bundle.getString("w1copyHeader"));
        alert.setContentText(bundle.getString("w1copyContent"));
        ButtonType buttonTypeYes = new ButtonType(bundle.getString("yes"));
        ButtonType buttonTypeNo = new ButtonType(bundle.getString("no"));
        alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == buttonTypeYes) {
            // Copy the file
            boolean needAdd = true, error = false;
            File configFile = new File(DPFManagerProperties.getIsosDir() + "/" + file.getName());
            if (configFile.exists()) {
                configFile.delete();
                needAdd = false;
            }
            try {
                FileUtils.copyFile(file, configFile);
            } catch (IOException e) {
                error = true;
            }
            if (error) {
                // Add source file
                addExternalCheckBox(file.getAbsolutePath(), true);
                context.send(BasicConfig.MODULE_MESSAGE,
                        new AlertMessage(AlertMessage.Type.WARNING, bundle.getString("w1errorCopyConfig")));
            } else if (needAdd) {
                addConfigCheckBox(configFile, true);
            }
        } else {
            addExternalCheckBox(file.getAbsolutePath(), true);
        }
    } else {
        addExternalCheckBox(file.getAbsolutePath(), true);
    }
}

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

private boolean handleCloseTab() {
    final Editor currentEditor = this.getCurrentEditor();
    if (!currentEditor.hasUnsavedChanges()) {
        return true;
    }/*from  w  ww. j a  v a2  s .  c om*/

    final Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("Confirm close");
    alert.setHeaderText("If the " + currentEditor.getTypeName() + " \"" + currentEditor.getTitleShort().get()
            + "\" is not saved, all changes are lost.");
    alert.setContentText("Do you want to save the " + currentEditor.getTypeName() + "?");

    final ButtonType yes = new ButtonType("Yes");
    final ButtonType no = new ButtonType("No");
    final ButtonType cancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(yes, no, cancel);

    final Optional<ButtonType> choice = alert.showAndWait();
    if (choice.get() == yes) {
        // Continue with saving
        if (!this.handleSaveDocument()) {
            return false;
        }
    } else if (choice.get() == no) {
        // Dispose document
    } else {
        // User closed dialog or chose cancel
        return false;
    }

    return true;
}