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:cz.lbenda.rcp.DialogHelper.java

/** Ask user if file can be overwrite if file exist */
@SuppressWarnings("unused")
public boolean canBeOverwriteDialog(File file) {
    if (file == null) {
        return false;
    }/*from   w  w  w.ja v a2  s  . c  o  m*/
    if (!file.exists()) {
        return true;
    }
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(msgCanOverwriteTitle);
    alert.setContentText(String.format(msgCanOverwriteContent, file.getName()));
    Optional<ButtonType> result = alert.showAndWait();
    return (result.isPresent()) && (result.get() == ButtonType.OK);
}

From source file:com.properned.application.LocaleListCell.java

private MenuItem getDeleteMenu(Locale locale) {
    MenuItem deleteMenu = new MenuItem(MessageReader.getInstance().getMessage("action.deleteMessageKey"));
    deleteMenu.setOnAction(new EventHandler<ActionEvent>() {
        @Override// w  ww  . ja  va  2  s.c o  m
        public void handle(ActionEvent event) {
            logger.info("Clic on delete button for locale '" + locale.toString() + "'");

            String fileName = properties.getMapPropertiesFileByLocale().get(locale).getAbsolutePath();

            Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle(MessageReader.getInstance().getMessage("manageLocale.confirmDelete.title"));
            alert.setHeaderText(MessageReader.getInstance().getMessage("manageLocale.confirmDelete.header"));
            alert.setContentText(
                    MessageReader.getInstance().getMessage("manageLocale.confirmDelete.content", fileName));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.isPresent() && result.get() == ButtonType.OK) {
                logger.info("User say OK to the confirm");
                properties.deleteLocale(locale);

                // Reload list
                controller.initializeList();
            }

        }
    });

    if (properties.getMapPropertiesByLocale().keySet().size() <= 1) {
        // We can delete only if there is more than the current locale
        deleteMenu.setDisable(true);
    }

    return deleteMenu;
}

From source file:uk.ac.bris.cs.scotlandyard.ui.controller.BaseGame.java

BaseGame(ResourceManager manager, Stage stage) {
    this.resourceManager = manager;
    this.stage = stage;
    Controller.bind(this);

    // initialise all controllers
    travelLog = new TravelLog(resourceManager, config);
    ticketsCounter = new TicketsCounter(resourceManager, config);
    notifications = new Notifications(resourceManager, config);
    status = new Status(resourceManager, config);
    board = new Board(resourceManager, notifications, config);

    Rectangle clip = new Rectangle();
    clip.widthProperty().bind(gamePane.widthProperty());
    clip.heightProperty().bind(gamePane.heightProperty());
    gamePane.setClip(clip);/*from  ww w.  ja  va2 s  .  co  m*/

    // system menu
    menu.setUseSystemMenuBar(true);

    // add all views
    mapPane.getChildren().add(board.root());
    roundsPane.getChildren().add(travelLog.root());
    playersPane.getChildren().add(ticketsCounter.root());
    notificationPane.getChildren().add(notifications.root());
    statusPane.getChildren().add(status.root());

    close.setOnAction(e -> stage.close());
    debug.setOnAction(evt -> {
        try {
            Debug.showDebugger(stage);
        } catch (Exception e) {
            Utils.handleFatalException(e);
        }
    });
    about.setOnAction(e -> {
        Alert alert = new Alert(AlertType.INFORMATION,
                "ScotlandYard is part of the CW-MODEL coursework prepared for University of Bristol course COMS100001",
                ButtonType.OK);
        ImageView logo = new ImageView(resourceManager.getImage(ImageResource.UOB_LOGO));
        logo.setPreserveRatio(true);
        logo.setSmooth(true);
        logo.setFitHeight(100);
        alert.setGraphic(logo);
        alert.setTitle("About ScotlandYard");
        alert.setHeaderText("ScotlandYard v0.1");
        alert.show();
    });

    findNode.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("Find node");
        s.setScene(new Scene(new FindNode(config, s, resourceManager).root()));
        s.show();
    });
    manual.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("Manual");
        s.setScene(new Scene(new Manual(s).root()));
        s.show();
    });

    license.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("License");
        s.setScene(new Scene(new License(s).root()));
        s.show();
    });

    // bind all menu values
    resetViewport.setOnAction(e -> {
        board.resetViewport();
    });

    setAndBind(travelLog.root().visibleProperty(), travelLogToggle.selectedProperty());
    setAndBind(ticketsCounter.root().visibleProperty(), ticketToggle.selectedProperty());
    setAndBind(config.scrollPanProperty(), scrollToggle.selectedProperty());
    setAndBind(config.historyProperty(), historyToggle.selectedProperty());
    setAndBind(config.focusPlayerProperty(), focusToggle.selectedProperty());

    if (SystemUtils.IS_OS_WINDOWS)
        config.scrollPanProperty().setValue(false);

}

From source file:cz.lbenda.rcp.DialogHelper.java

/** Ask user if file can be overwrite if file exist
 * @param file file which is rewrite//from  w w w . j  a v a  2s  .  c om
 * @param defaultExtension if file haven't extension then default is add
 * @return file if user want rewrite it, or no file with this name exist */
public File canBeOverwriteDialog(File file, String defaultExtension) {
    if (file == null) {
        return null;
    }
    if ("".equals(FilenameUtils.getExtension(file.getName()))) {
        file = new File(file.getAbsoluteFile() + "." + defaultExtension);
    }
    if (!file.exists()) {
        return file;
    }
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(msgCanOverwriteTitle);
    alert.setContentText(String.format(msgCanOverwriteContent, file.getName()));
    Optional<ButtonType> result = alert.showAndWait();
    return (result.isPresent()) && (result.get() == ButtonType.OK) ? file : null;
}

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

@FXML
public void cancel(ActionEvent evt) {

    if (dirtyFlag) {

        Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Form has been modified");
        alert.setHeaderText("Discard edits?");

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

        if (response.isPresent() && response.get() == ButtonType.OK) {

            Configuration savedConf = configurationDS.getConfiguration();

            if (logger.isDebugEnabled()) {
                logger.debug("[CANCEL] reverting configuration ac jdkhome={} to sc jjdkhome={}",
                        activeConfiguration.getJDKHome(), savedConf.getJDKHome().get());
            }/*from  ww w. j ava  2 s .  c  o  m*/

            activeConfiguration.setJDKHome(savedConf.getJDKHome().get());

            dirtyFlag = false;

        } else {
            return; // dirtyFlag continues to be true
        }
    }

    Scene scene = ((Button) evt.getSource()).getScene();
    if (scene != null) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}

From source file:jlotoprint.MainViewController.java

public static void showExceptionAlert(String message, String details) {
    Alert alert = new Alert(Alert.AlertType.ERROR, message, ButtonType.OK);
    alert.initModality(Modality.APPLICATION_MODAL);
    alert.initOwner(JLotoPrint.stage.getScene().getWindow());
    TextArea textArea = new TextArea(details);
    textArea.setEditable(false);//w w w. j  a v a2 s . c  o  m
    textArea.setWrapText(true);

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 0, 10));
    grid.add(textArea, 0, 0);

    //set content
    alert.getDialogPane().setExpandableContent(grid);
    alert.showAndWait();
}

From source file:de.micromata.mgc.javafx.launcher.gui.AbstractMainWindow.java

@Override
public void initializeWithModel() {
    Thread currentThread = Thread.currentThread();
    currentThread.setUncaughtExceptionHandler(model.getUncaughtExceptionHandler());
    addCss();/*from  w w w .j  a  v  a 2  s  .c o  m*/
    LauncherLocalSettingsConfigModel config = MgcLauncher.getLauncherConfig();
    if (config.isEnableLF5() == false) {
        launchMenu.setVisible(false);
    }
    if (SystemService.get().getOsType() != OsType.Windows) {
        hideWindowMenu.setVisible(false);
    }
    stage.setOnCloseRequest(event -> {
        if (SystemService.get().getOsType() != OsType.Windows) {
            event.consume();

            Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle(model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.title"));
            alert.setHeaderText(
                    model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.header"));
            alert.setContentText(
                    model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.message"));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get() == ButtonType.OK) {
                closeApplication(null);
            }
        }
    });

    startServerButton.setOnAction(e -> {
        startServer();
    });
    stopServerButton.setOnAction(e -> {
        stopServer();
    });
    stopServerButton.setDisable(true);
    boolean runnin = MgcLauncher.get().getApplication().isRunning();
    startServerButton.setDisable(runnin);
    stopServerButton.setDisable(runnin == false);
    openBrowser.setDisable(runnin == false);
    addStartServerEventHandler();
    addStopServerEventHandler();

    openBrowser.setOnAction(e -> {
        launchBrowser();
    });
    loggingPane.widthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth,
                Number newSceneWidth) {
            loggingController.adjustWidth(newSceneWidth.doubleValue());
        }
    });
    loggingPane.heightProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth,
                Number newSceneWidth) {
            loggingController.adjustHeight(newSceneWidth.doubleValue());
        }
    });
    loggingController.adjustHeight(loggingPane.getHeight());
    loggingController.adjustWidth(loggingPane.getWidth());
    MgcEventRegistries.getEventInstanceRegistry()
            .registerListener(new MgcApplicationStartStopToEventListener());
    String helpUrl = getModel().getApplicationInfo().getHelpUrl();
    if (StringUtils.isBlank(helpUrl) == true) {
        helpButton.setVisible(false);
    } else {
        helpButton.setOnAction(event -> {
            SystemService.get().openUrlInBrowser(helpUrl);
        });
    }
    FXEvents.get().addEventHandler(this, stopServerButton, MgcLauncherEvent.APP_STARTED, event -> {

        if (config.isStartBrowserOnStartup() == true) {
            launchBrowser();
        }
    });
}

From source file:org.apache.cayenne.modeler.layout.MainWindowLayout.java

public MainWindowLayout() throws IOException {
    super(new Stage(), "/layouts/MainWindowLayout.fxml");

    setMinimumWindowSize(900, 700);//from  w  w  w  . ja  v a  2s. co m

    getStage().setOnCloseRequest(event -> {
        LOGGER.debug("Window is closing!");
        // ideas for checking if window should save before closing or cancel, etc:
        // event.consume();  <- Prevents window from closing
        // http://stackoverflow.com/questions/31540500/alert-box-for-when-user-attempts-to-close-application-using-setoncloserequest-in
        // http://stackoverflow.com/questions/23160573/javafx-stage-setoncloserequest-without-function

        if (cayenneProject.isDirty()) {
            final Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle("Close Window");
            alert.setHeaderText("Unsaved Changes");
            alert.setContentText("Are you sure you want to close this window and lose your changes?");

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

            if (result.get() == ButtonType.OK) {
                // ... user chose OK
            } else {
                // ... user chose CANCEL or closed the dialog
                event.consume();
            }
        }
    });
}

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

@FXML
public void resetDataFile(ActionEvent evt) {

    if (logger.isDebugEnabled()) {
        logger.debug("[RESET DATA FILE]");
    }//from   www.  j a  v  a 2s. c o m

    ((Hyperlink) evt.getSource()).getScene().getWindow().hide();

    ButtonType myCancel = new ButtonType("Just Exit", ButtonBar.ButtonData.CANCEL_CLOSE);

    Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Delete all data and exit the app?", ButtonType.OK,
            myCancel);

    alert.setHeaderText("Delete all data");
    //alert.setOnCloseRequest((w_evt) -> Platform.exit());

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

    if (!response.isPresent() || response.get() != ButtonType.OK) {
        if (logger.isDebugEnabled()) {
            logger.debug("[RESET DATA FILE] reset cancelled");
        }

        exitCode = ExitCodeType.CANCELLED;
        passwordMatches.setValue(false);

        synchronized (this) {
            this.notify();
        }

    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("[RESET DATA FILE] reset");
        }

        configurationDataSource.deleteDataFile();

        exitCode = ExitCodeType.RESET;
        passwordMatches.setValue(false);

        synchronized (this) {
            this.notify();
        }
    }
}

From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java

@Override
ContextMenu createContextMenu() {/*from  w w w  .j ava  2s . c o  m*/
    final ContextMenu cm = new ContextMenu();

    MenuItem mi = new MenuItem("Create edge from here");
    mi.setGraphic(Icons.getIconGraphics("bullet_go"));
    mi.setOnAction(event -> {
        final AutomatonEdgeBuilder newEdge = new AutomatonEdgeBuilder(this.getGraph());
        this.getGraph().startDrawingConnector(this, newEdge);
    });
    cm.getItems().add(mi);

    mi = new MenuItem("Delete state");
    mi.setGraphic(Icons.getIconGraphics("delete"));
    mi.setStyle("-fx-text-fill:#FF3030");
    mi.setOnAction(event -> {
        final Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("Confirm");
        alert.setHeaderText("You are about to delete the state.");
        alert.setContentText("Do you want to continue?");
        alert.showAndWait().filter(response -> response == ButtonType.OK)
                .ifPresent(response -> this.removeNodeAndEdges());
    });
    cm.getItems().add(mi);

    return cm;
}