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:com.properned.application.SystemController.java

public ButtonType askForSave() {
    logger.info("Save alert open");
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(MessageReader.getInstance().getMessage("popup.confirmation.warning"));
    alert.setHeaderText(MessageReader.getInstance().getMessage("popup.confirmation.close.title"));
    alert.setContentText(MessageReader.getInstance().getMessage("popup.confirmation.close.body"));

    ButtonType buttonTypeYes = new ButtonType(MessageReader.getInstance().getMessage("yes"));
    ButtonType buttonTypeNo = new ButtonType(MessageReader.getInstance().getMessage("no"));
    ButtonType buttonTypeCancel = new ButtonType("cancel", ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo, buttonTypeCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonTypeYes) {
        logger.info("the user want to save current files");
        this.save();
    } else if (result.get() == buttonTypeNo) {
        // Nothing to do here
        logger.info("the user doesn't want to save current files");
    } else {//from  w  ww. j  av  a2  s.c  o  m
        logger.info("Properned close cancelled");
    }
    return result.get();

}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 *///  w w w .  j ava2  s.c  o  m
private void annulerE2C() {

    ButtonType reponse = null;
    ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui"));
    ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non"));
    if ((lvListeFichier.getItems().size() != 0) && (!bTraitementEffectue)) {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
        alert.setHeaderText(null);
        alert.setContentText(rbLocalisation.getString("transformation.traiteImagesQuitte"));
        alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon);
        Optional<ButtonType> actReponse = alert.showAndWait();
        reponse = actReponse.get();

    }
    if ((reponse == buttonTypeOui) || (reponse == null)) {
        bTraitementEffectue = false;
        stTransformations.hide();
    }
}

From source file:investiagenofx2.view.InvestiaGenOFXController.java

@FXML
void handleBtnAccounts(ActionEvent event) {
    ArrayList<Account> accountsToGen = new ArrayList<>();
    if ("Tous les comptes".equals(cbo_accounts.getSelectionModel().getSelectedItem())) {
        accountsToGen = accounts;//from   www .  ja  v a2s  .c  om
    } else {
        accountsToGen.add(accounts.get(cbo_accounts.getSelectionModel().getSelectedIndex()));
    }
    getTransactionsFromWeb();
    String fileName = "";
    try {
        fileName = genOFXFile(accountsToGen);
    } catch (MyOwnException ex) {
        Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex);
    }
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Confirmation ");
    alert.setHeaderText(null);
    alert.setX(InvestiaGenOFX.getPrimaryStage().getX() + 100);
    alert.setY(InvestiaGenOFX.getPrimaryStage().getY() + 100);
    alert.setContentText("Fichier OFX gnr \rLance le fichier OFX?");
    ButtonType buttonTypeYes = new ButtonType("Oui");
    ButtonType buttonTypeNo = new ButtonType("Non");
    alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonTypeYes) {
        try {
            Utilities.launchFile(fileName);
        } catch (IOException ex) {
            Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex);
        }
        new File(fileName).deleteOnExit();
    }
    showAcountsInvestments(accountsToGen);
}

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

private void profileRemove(Profile profile) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(mStage);//from  w ww .  j a  v a2 s .  c o  m
    alert.setTitle(Dict.Dialog.TITLE_PROFILE_REMOVE.toString() + "?");
    String message = String.format(Dict.Dialog.MESSAGE_PROFILE_REMOVE.toString(), profile.getName());
    alert.setHeaderText(message);

    ButtonType removeButtonType = new ButtonType(Dict.REMOVE.toString(), ButtonData.OK_DONE);
    ButtonType cancelButtonType = new ButtonType(Dict.CANCEL.toString(), ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(removeButtonType, cancelButtonType);

    Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage);
    if (result.get() == removeButtonType) {
        mProfiles.remove(profile);
        profilesSave();
        populateProfiles(null);
        mLogAction.setDisabled(mItems.isEmpty() || mLastRunProfile == null);
    }
}

From source file:ubicrypt.UbiCrypt.java

@Override
public void start(final Stage stage) throws Exception {
    setUserAgentStylesheet(STYLESHEET_MODENA);
    stage.setTitle("UbiCrypt");
    anchor().setStage(stage);/*from   w ww.  j  ava 2  s  .  c  o m*/
    try {
        final PGPKeyPair kp = encryptionKey();
        encrypt(Collections.singletonList(kp.getPublicKey()),
                new ByteArrayInputStream(StringUtils.repeat("ciao", 1).getBytes()));
    } catch (Exception e) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("Strong Encryption Required");
        alert.setHeaderText("Install JCE Unlimited Strength Jurisdiction policy files");
        alert.setContentText(
                "You can install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files, which are required to use strong encryption.\n"
                        + "Download the files and instructions for Java 8.\n"
                        + "Locate the jre\\lib\\security directory for the Java instance that the UbiCrypt is using.\n"
                        + "For example, this location might be: C:\\Program Files\\Java\\jre8\\lib\\security.\n"
                        + "Replace these two files with the .jar files included in the JCE Unlimited Strength Jurisdiction Policy Files download.\n"
                        + "Stop and restart the UbiCrypt.\n\n\n\n\n\n");
        ButtonType icePage = new ButtonType("Go to JCE download Page");
        alert.getButtonTypes().addAll(icePage);
        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == icePage) {
            getHostServices().showDocument(
                    "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html");
        }
        Platform.exit();
    }
    final File secFile = securityFile().toFile();
    stage.setScene(anchor().show(secFile.exists() ? "login" : "createKey", getHostServices()));
    stage.show();
    final UbiCrypt ubiCrypt = this;
    anchor().getPasswordStream().subscribeOn(Schedulers.io()).subscribe(pwd -> {
        final SpringApplication app = new SpringApplication(UbiConf.class, PathConf.class, UIConf.class);
        app.setRegisterShutdownHook(false);
        app.addInitializers(new FixPassPhraseInitializer(pwd));
        app.setLogStartupInfo(true);
        ctx = app.run();
        ctx.getAutowireCapableBeanFactory().autowireBean(ubiCrypt);
        ctx.getBeanFactory().registerSingleton("stage", stage);
        ctx.getBeanFactory().registerSingleton("hostService", getHostServices());
        ctx.getBeanFactory().registerSingleton("osUtil", new OSUtil(getHostServices()));
        ControllerFactory cfactory = new ControllerFactory(ctx);
        StackNavigator navigator = new StackNavigator(null, "main", cfactory);
        stage.setScene(new Scene(navigator.open()));
    });

    stage.setOnCloseRequest(windowEvent -> shutdown.run());
    Runtime.getRuntime().addShutdownHook(new Thread(shutdown));
}

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

private void profileRun(Profile profile) {
    String title = String.format(Dict.Dialog.TITLE_PROFILE_RUN.toString(), profile.getName());
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(mStage);/*from   www  . ja v  a2 s.c om*/

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

    PreviewPanel previewPanel = new PreviewPanel();
    previewPanel.load(profile);
    final DialogPane dialogPane = alert.getDialogPane();
    dialogPane.setContent(previewPanel);

    ButtonType runButtonType = new ButtonType(Dict.RUN.toString());
    ButtonType dryRunButtonType = new ButtonType(Dict.DRY_RUN.toString(), ButtonData.OK_DONE);
    ButtonType cancelButtonType = new ButtonType(Dict.CANCEL.toString(), ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(runButtonType, dryRunButtonType, cancelButtonType);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() != cancelButtonType) {
        boolean dryRun = result.get() == dryRunButtonType;
        profile.setDryRun(dryRun);
        mProgressPanel.clear();
        mRoot.setCenter(mProgressPanel);
        mIndicator.setProfile(profile);

        if (profile.isValid()) {
            mLastRunProfile = profile;
            mOperationThread = new Thread(() -> {
                Operation operation = new Operation(mOperationListener, profile);
                operation.start();
            });
            mOperationThread.setName("Operation");
            mOperationThread.start();
        } else {
            mProgressPanel.out(profile.toDebugString());
            mProgressPanel.out(profile.getValidationError());
            mProgressPanel.out(Dict.ABORTING.toString());
        }
    }
}

From source file:statos2_0.MainA.java

public void finishnal(String ttitg, String ress, int selt) {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("");
    alert.setHeaderText("");
    alert.setContentText("  ");
    ButtonType buttonCheck = new ButtonType(" ");
    ButtonType buttonTOK = new ButtonType("");
    ButtonType buttonCancel2 = new ButtonType("", ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(buttonCheck, buttonTOK, buttonCancel2);
    Optional<ButtonType> result3 = alert.showAndWait();
    if (result3.get() == buttonCheck) {
        printerstart(ttitg, ress);//from  ww  w . ja v  a  2 s . c  o m
        finishnal(ttitg, ress, selt);
    } else if (result3.get() == buttonTOK) {
        //jsares
        for (int i = 0; i < jsares.size(); i++) {
            if (jsares.get(i).has("seltype")) {

            } else {
                jsares.get(i).put("seltype", selt);
                jsares.get(i).put("idcheck", checkcheck());
                jsares.get(i).put("dolgid", 0);
            }
        }

        sendJson(jsares);
        if (selt == 1) {
            double titgr = Double.parseDouble(titg.getText());
            addkas(titgr, 0, titgr, 0);
        } else if (selt == 2) {
            double titgr = Double.parseDouble(titg.getText());
            addkas(0, titgr, 0, titgr);
        }
        jsares.clear();
        int chknum = checkcheck();
        chknum++;
        chup(chknum);
        itog = 0;
        res.setText("");
        titg.setText("");
        sp3.setVisible(false);
        lb3.setVisible(false);
        t3.setVisible(false);
        bt3.setVisible(false);
        sp1.setVisible(false);
        lb1.setVisible(false);
        t1.setVisible(false);
        lbb1.setVisible(false);
        spb1.setVisible(false);
        bt1.setVisible(false);
        cbx4.setVisible(false);
        sp2.setVisible(false);
        lb2.setVisible(false);
        t2.setVisible(false);
        bt2.setVisible(false);
        cbx1.getSelectionModel().clearSelection();
        cbx2.getSelectionModel().clearSelection();
        cbx3.getSelectionModel().clearSelection();
        cbx4.getSelectionModel().clearSelection();
        sp1.getValueFactory().setValue(0.0);
        sp2.getValueFactory().setValue(0);
        sp3.getValueFactory().setValue(0);
        spb1.getValueFactory().setValue(0);
        //

    } else if (result3.get() == buttonCancel2) {

    }
}

From source file:ui.main.MainViewController.java

@FXML
public void handleFriendRequestButtonAction(ActionEvent event) {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Confirmation");
    alert.setHeaderText("Accept Friend Request!");
    alert.setContentText("Are you sure to add the this user as a friend?");

    ButtonType buttonTpeYes = new ButtonType("Yes");
    ButtonType buttonTypeNo = new ButtonType("Not Now");
    ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(buttonTpeYes, buttonTypeNo, buttonTypeCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonTpeYes) {
        contactsManager.acceptFriend(currentChat.getParticipant());
        friendRequest.setVisible(false);
    } else if (result.get() == buttonTypeNo) {
        // ... no thing to do
    } else {/*  ww w .ja va2 s .  c  o  m*/
        // ... user chose CANCEL or closed the dialog
    }

}

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Handler to close the application./*from   w  ww .ja v a 2 s .co  m*/
 *
 * @param event The event.
 */
@FXML
protected void handleCloseApp(ActionEvent event) {
    Alert closeDialog = new Alert(Alert.AlertType.CONFIRMATION);
    closeDialog.setTitle(I18n.getMsg("gui.confirm-exit"));
    closeDialog.setContentText(I18n.getMsg("gui.want-to-quit"));
    ButtonType confirm = new ButtonType(I18n.getMsg("gui.exit"));
    ButtonType cancel = new ButtonType(I18n.getMsg("gui.cancel"), ButtonData.CANCEL_CLOSE);
    closeDialog.getButtonTypes().setAll(confirm, cancel);
    Optional<ButtonType> res = closeDialog.showAndWait();
    if (res.isPresent() && res.get() == confirm) {
        logToAppLog(I18n.format("dlc.stop"));
        Stage stage = (Stage) buttonClose.getScene().getWindow();
        stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST));
    }
}

From source file:ui.main.MainViewController.java

private void clearHistory() {
    //clears the chat history
    if (currentChat == null) {
        return;/*from  w  w w  .j a  v a 2 s  . c o  m*/
    } else {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("Confirmation");
        alert.setHeaderText("Confirm to Clear History");
        alert.setContentText("Are you sure to clear the current history?");

        ButtonType buttonTpeYes = new ButtonType("Yes");
        ButtonType buttonTypeNo = new ButtonType("No");
        ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

        alert.getButtonTypes().setAll(buttonTpeYes, buttonTypeNo, buttonTypeCancel);

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == buttonTpeYes) {
            DBSingleChat.clearHistory(currentChat.getParticipant());
            chatList.getChildren().clear();
        } else if (result.get() == buttonTypeNo) {
            // ... no thing to do
        } else {
            // ... user chose CANCEL or closed the dialog
        }
    }
}