Java 类javafx.scene.control.ButtonType 实例源码

项目:UTGenerator    文件:FXMLDocumentController.java   
/**
 * Display an alert for the about button
 */
@FXML
private void onActionAbout() {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("About...");
    alert.setHeaderText(null);
    alert.setContentText("Author: Guduche\nVersion: 1.0.1");
    alert.getButtonTypes().clear();
    ButtonType boutonOk = new ButtonType("Ok");
    alert.getButtonTypes().add(boutonOk);
    ButtonType boutonGithub = new ButtonType("Github project");
    alert.getButtonTypes().add(boutonGithub);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == boutonGithub) {
        try {
            java.awt.Desktop.getDesktop().browse(new URI("https://github.com/Guduche/UTGenerator"));
        } catch (Exception e) {
        }
    }
}
项目:HueSense    文件:AboutPresenter.java   
@Override
public void initialize(URL location, ResourceBundle resources) {

    logoImg.setImage(UIUtils.getImage("logo.png"));

    Dialog diag = new Dialog();
    diag.getDialogPane().setContent(borderPane);
    diag.getDialogPane().setBackground(Background.EMPTY);
    diag.setResizable(true);

    UIUtils.setIcon(diag);

    ButtonType closeButton = new ButtonType("Close", ButtonBar.ButtonData.OK_DONE);

    diag.getDialogPane().getButtonTypes().addAll(closeButton);
    diag.setTitle("About HueSense");

    Optional<ButtonType> opt = diag.showAndWait();
    if (opt.isPresent() && opt.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) {
        // nothing
    }

}
项目:SensorThingsManager    文件:ControllerCollection.java   
private void loadAllEntities() {
    int i = 0;
    entities.clear();
    for (Iterator<T> it = currentQueryList.fullIterator(); it.hasNext();) {
        T entity = it.next();
        entities.add(new EntityListEntry<T>().setEntity(entity));
        i++;
        if (i >= 500) {
            LOGGER.warn("Warning after {}. Total: {}.", i, entities.size());
            Optional<ButtonType> result = new Alert(Alert.AlertType.WARNING, "Already loaded " + entities.size() + " Entities.\nContinue loading?", ButtonType.CANCEL, ButtonType.YES).showAndWait();
            if (!result.isPresent() || result.get() != ButtonType.YES) {
                break;
            }
            i = 0;
        }
    }
    buttonNext.setDisable(!currentQueryList.hasNextLink());
    buttonDelete.setDisable(true);
}
项目:titanium    文件:OrganizationManagerStage.java   
private void removeAction(Event e) {
    Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to delete this organization ?\n"
            + "Every server and member association will be lost.");

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

    if (result.isPresent() && result.get().equals(ButtonType.OK)) {
        try {
            wsp.removeOrganization(orgas.selectionModelProperty().get().getSelectedItem().getOrganization());
            forceOrganizationListRefresh();
            App.getCurrentInstance().refreshWSPTabs();
        } catch(Exception e1) {
            ErrorUtils.getAlertFromException(e1).show();
        }
    }
}
项目:Money-Manager    文件:CashCalculateController.java   
@FXML
private void mnuUndo(ActionEvent event) {
    Stage CashCalculateStage = (Stage) btnSignOut.getScene().getWindow();
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Action Failed");
    alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window");
    alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window");
    alert.setX(CashCalculateStage.getX() + 60);
    alert.setY(CashCalculateStage.getY() + 170);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open
        (new GoToOperation()).goToMakeATransaction(CashCalculateStage.getX(), CashCalculateStage.getY());
        CashCalculateStage.close();
    }
}
项目:Money-Manager    文件:HelpController.java   
@FXML
private void mnuUndo(ActionEvent event) {
    Stage HelpStage = (Stage) btnSignOut.getScene().getWindow();
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Action Failed");
    alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window");
    alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window");
    alert.setX(HelpStage.getX() + 60);
    alert.setY(HelpStage.getY() + 170);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open
        (new GoToOperation()).goToMakeATransaction(HelpStage.getX(), HelpStage.getY());
        HelpStage.close();
    }
}
项目:szoftlab    文件:Game.java   
/**
 * A játék megnyerése esetén hívjuk a függvényt (ha kiürült minden kocsi)
 * Üzenetet küld, hogy teljesítettük a pályát, a következő pályára lép
 */
public void won() {
    if (winMedia != null) {
        winMedia.seek(Duration.ZERO);
        winMedia.play();
    }
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Train Simulator 2017");
    alert.setHeaderText(null);
    alert.setContentText("Gratulálunk, nyertél!");
    ButtonType nextButton = new ButtonType("Következő pálya");
    alert.getButtonTypes().setAll(nextButton);
    alert.showAndWait();
    mapManager.nextMap();
    startGame();
}
项目:Money-Manager    文件:DashboardController.java   
@FXML
private void mnuUndo(ActionEvent event) {
    Stage DashboardStage = (Stage) btnSignOut.getScene().getWindow();
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Action Failed");
    alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window");
    alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window");
    alert.setX(DashboardStage.getX() + 60);
    alert.setY(DashboardStage.getY() + 170);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open
        (new GoToOperation()).goToMakeATransaction(DashboardStage.getX(), DashboardStage.getY());
        DashboardStage.close();
    }
}
项目:Money-Manager    文件:AboutController.java   
@FXML
private void mnuUndo(ActionEvent event) {
    Stage AboutStage = (Stage) btnSignOut.getScene().getWindow();
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Action Failed");
    alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window");
    alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window");
    alert.setX(AboutStage.getX() + 60);
    alert.setY(AboutStage.getY() + 170);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open
        (new GoToOperation()).goToMakeATransaction(AboutStage.getX(), AboutStage.getY());
        AboutStage.close();
    }
}
项目:Matcher    文件:UidMenu.java   
private void setup() {
    ProjectConfig config = ProjectConfig.getLast();

    Dialog<ProjectConfig> dialog = new Dialog<>();
    //dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setResizable(true);
    dialog.setTitle("UID Setup");
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

    UidSetupPane setupPane = new UidSetupPane(config, dialog.getOwner(), okButton);
    dialog.getDialogPane().setContent(setupPane);
    dialog.setResultConverter(button -> button == ButtonType.OK ? config : null);

    dialog.showAndWait().ifPresent(newConfig -> {
        setupPane.updateConfig();

        if (!newConfig.isValid()) return;

        newConfig.saveAsLast();
    });
}
项目:LanternNBT    文件:NbtEditor.java   
@FXML
private void onClickPageClose(ActionEvent event) {
    if (this.rootTagElement == null) {
        return;
    }
    final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Saving?");
    alert.setContentText("Do you want to save your latest changes?");
    alert.getButtonTypes().clear();
    alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);

    final ButtonType result = alert.showAndWait().orElse(ButtonType.CANCEL);
    if (result == ButtonType.YES) {
        save();
    }
    if (result != ButtonType.CANCEL) {
        this.tags_view.setRoot(null);
        this.file_save.setDisable(true);
        this.rootTagElement = null;
        this.openFile = null;
    }
}
项目:uPMT    文件:Main.java   
public void changeLocaleAndReload(String locale){
    saveCurrentProject();
       Alert alert = new Alert(AlertType.CONFIRMATION);
       alert.setTitle("Confirmation Dialog");
       alert.setHeaderText("This will take effect after reboot");
       alert.setContentText("Are you ok with this?");

       Optional<ButtonType> result = alert.showAndWait();
       if (result.get() == ButtonType.OK){
           // ... user chose OK
        try {
            Properties props = new Properties();
            props.setProperty("locale", locale);
            File f = new File(getClass().getResource("../bundles/Current.properties").getFile());
            OutputStream out = new FileOutputStream( f );
            props.store(out, "This is an optional header comment string");

            start(primaryStage);
        }
        catch (Exception e ) {
            e.printStackTrace();
        }
       } else {
           // ... user chose CANCEL or closed the dialog
       }
}
项目:WebPLP    文件:Main.java   
@Override
public void setMainASMFile()
{
    ASMFile activeFile = getActiveFile();
    if (activeFile == null)
    {
        Dialogues.showActionFailedDialogue("No file is selected!");
        return;
    }

    Project activeProject = activeFile.getProject();
    String message = "The file \"" + activeFile.getName()
            + "\" will be used as the main file for the project \""
            + activeProject.getName() + "\"";
    Optional<ButtonType> result = Dialogues.showConfirmationDialogue(message);

    if (result.get() == ButtonType.OK)
    {
        int index = activeProject.indexOf(activeFile);
        Collections.swap(activeProject, 0, index);
    }
}
项目:marathonv5    文件:DisplayWindow.java   
public boolean canAppend(File file) {
    EditorDockable dockable = findEditorDockable(file);
    if (dockable == null) {
        return true;
    }
    if (!dockable.getEditor().isDirty()) {
        return true;
    }
    Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this,
            "File " + file.getName() + " being edited. Do you want to save the file?", "Save Module", AlertType.CONFIRMATION,
            ButtonType.YES, ButtonType.NO);
    ButtonType option = result.get();
    if (option == ButtonType.YES) {
        save(dockable.getEditor());
        return true;
    }
    return false;
}
项目:marathonv5    文件:FXUIUtils.java   
@SuppressWarnings("unchecked") public static Optional<ButtonType> showConfirmDialog(Window parent, String message, String title,
        AlertType type, ButtonType... buttonTypes) {
    if (Platform.isFxApplicationThread()) {
        return _showConfirmDialog(parent, message, title, type, buttonTypes);
    } else {
        Object r[] = { null };
        Object lock = new Object();
        synchronized (lock) {
            Platform.runLater(() -> {
                r[0] = _showConfirmDialog(parent, message, title, type, buttonTypes);
                synchronized (lock) {
                    lock.notifyAll();
                }
            });
        }
        synchronized (lock) {
            try {
                lock.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return (Optional<ButtonType>) r[0];
    }
}
项目:marathonv5    文件:GroupEntryResource.java   
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) {
    if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) {
        option = FXUIUtils.showConfirmDialog(null, "Do you want to delete the entry `" + entry.getName() + "`?", "Confirm",
                AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
    }
    if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
        GroupResource parent = (GroupResource) getParent();
        parent.deleteEntry(this);
        try {
            Group.updateFile(parent.getSuite());
            Event.fireEvent(parent, new ResourceModificationEvent(ResourceModificationEvent.UPDATE, parent));
        } catch (IOException e) {
            e.printStackTrace();
            return option;
        }
    }
    return option;
}
项目:vars-annotation    文件:PreferencesDialogController.java   
public void show() {
    paneController.load();
    ResourceBundle i18n = toolBox.getI18nBundle();
    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.setTitle(i18n.getString("prefsdialog.title"));
    dialog.setHeaderText(i18n.getString("prefsdialog.header"));
    GlyphsFactory gf = MaterialIconFactory.get();
    Text settingsIcon = gf.createIcon(MaterialIcon.SETTINGS, "30px");
    dialog.setGraphic(settingsIcon);
    dialog.getDialogPane()
            .getButtonTypes()
            .addAll(ButtonType.OK, ButtonType.CANCEL);
    dialog.getDialogPane()
            .setContent(paneController.getRoot());
    dialog.getDialogPane()
            .getStylesheets()
            .addAll(toolBox.getStylesheets());
    Optional<ButtonType> buttonType = dialog.showAndWait();
    buttonType.ifPresent(bt -> {
        if (bt == ButtonType.OK) {
            paneController.save();
        }
    });
}
项目:shuffleboard    文件:PluginPaneController.java   
@FXML
private void loadPlugin() {
  FileChooser chooser = new FileChooser();
  chooser.setTitle("Choose a plugin");
  chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Plugin", "*.jar"));
  List<File> files = chooser.showOpenMultipleDialog(root.getScene().getWindow());
  if (files == null) {
    return;
  }
  files.forEach(f -> {
    try {
      // TODO save this in user preferences
      PluginLoader.getDefault().loadPluginJar(f.toURI());
    } catch (IOException | IllegalArgumentException e) {
      log.log(Level.WARNING, "Could not load jar", e);
      // TODO improve the dialog; use something like what GRIP has
      Alert alert = new Alert(Alert.AlertType.ERROR, null, ButtonType.OK);
      alert.setTitle("Could not load plugins");
      alert.setHeaderText("Plugins in " + f.getName() + " could not be loaded");
      alert.setContentText("Error message:\n\n    " + e.getMessage());
      alert.showAndWait();
    }
  });
}
项目:CSLMusicModStationCreator    文件:MainWindow.java   
@FXML
public void newFile() {

    Alert closeConfirmation = new Alert(
            Alert.AlertType.CONFIRMATION,
            "Create a new station?",
            ButtonType.YES,
            ButtonType.NO
    );
    closeConfirmation.setHeaderText("New station");
    closeConfirmation.initModality(Modality.APPLICATION_MODAL);
    closeConfirmation.initOwner(root.getScene().getWindow());

    Optional<ButtonType> closeResponse = closeConfirmation.showAndWait();
    if (ButtonType.YES.equals(closeResponse.get())) {
        station = new Station();
        updateEditors();
        updateTitle();
    }
}
项目:qgu    文件:TaskTableView.java   
private void shortcutDelete(int index, ObservableGanttTask obs) {
    if(index == -1 || obs == null) {
        index = getSelectionModel().getSelectedIndex();
        obs = getSelectionModel().getSelectedItem();
    }

    if(obs == null || index == 0)
        return;

    if(obs.getTask().size() > 0) {
        ButtonType type = FXDialog.binaryChoiceAlert("This will delete also all sub-tasks. Proceed?").showAndWait().get();
        if(type == ButtonType.NO)
            return;
    }

    removeTask(index);
}
项目:javaGMR    文件:TexteditorController.java   
public void saveOnExit() {
    if (!taNoteText.getText().equals(this.note.getText())) {
        if (!JGMRConfig.getInstance().isDontAskMeToSave()) {
            Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle("Save notes?");
            alert.setHeaderText("Would you like to save your notes?");
            ButtonType save = new ButtonType("Save");
            ButtonType dontaskmeagain = new ButtonType("Don't ask me again");
            ButtonType dontsave = new ButtonType("Don't save", ButtonData.CANCEL_CLOSE);
            alert.getButtonTypes().setAll(save, dontaskmeagain, dontsave);
            Optional<ButtonType> result = alert.showAndWait();
            if(result.get() == save){
                save();
            }else if(result.get() == dontaskmeagain){
                JGMRConfig.getInstance().setDontAskMeToSave(true);
                save();
            }

        } else {
            save();
        }
    }
}
项目:shuffleboard    文件:WidgetPaneController.java   
/**
 * Creates the menu for editing the properties of a widget.
 *
 * @param tile the tile to pull properties from
 * @return     the edit property menu
 */
private void showPropertySheet(Tile<?> tile) {
  ExtendedPropertySheet propertySheet = new ExtendedPropertySheet();
  propertySheet.getItems().add(new ExtendedPropertySheet.PropertyItem<>(tile.getContent().titleProperty()));
  Dialog<ButtonType> dialog = new Dialog<>();
  if (tile.getContent() instanceof Widget) {
    ((Widget) tile.getContent()).getProperties().stream()
        .map(ExtendedPropertySheet.PropertyItem::new)
        .forEachOrdered(propertySheet.getItems()::add);
  }

  dialog.setTitle("Edit widget properties");
  dialog.getDialogPane().getStylesheets().setAll(AppPreferences.getInstance().getTheme().getStyleSheets());
  dialog.getDialogPane().setContent(new BorderPane(propertySheet));
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);

  dialog.showAndWait();
}
项目:Planchester    文件:AlertHelper.java   
public static Boolean showWarningMessage(String headerText, String contentText, String okButtonLabel, Pane pane) {
    ButtonType okButton = new ButtonType(okButtonLabel);
    ButtonType cancelButton = new ButtonType("Cancel");
    List<ButtonType> buttonList = new LinkedList<>();
    buttonList.add(okButton);
    buttonList.add(cancelButton);

    Optional optional = showMessage("Warning", headerText, contentText, Alert.AlertType.WARNING, null, buttonList, pane);

    if(optional != null) {
        if(optional.get().equals(okButton)) {
            return true;
        } else {
            return false;
        }
    }

    return null;
}
项目:SensorThingsManager    文件:EntityGuiController.java   
public static <T extends Entity<T>> Optional<List<T>> entitySearchDialog(Query<T> query, boolean multiSelect) {
    try {
        FXMLLoader loader = new FXMLLoader(EntityGuiController.class.getResource("/fxml/Collection.fxml"));
        AnchorPane content = (AnchorPane) loader.load();
        final ControllerCollection<T> controller = loader.<ControllerCollection<T>>getController();
        controller.setQuery(query, false, false, false, multiSelect);

        Dialog<List<T>> dialog = new Dialog<>();
        dialog.setHeight(800);
        if (multiSelect) {
            dialog.setTitle("Choose one or more " + EntityType.singleForClass(query.getEntityType().getType()).getName());
        } else {
            dialog.setTitle("Choose a " + EntityType.singleForClass(query.getEntityType().getType()).getName());
        }
        dialog.setResizable(true);
        dialog.getDialogPane().setContent(content);
        ButtonType buttonTypeOk = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
        ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
        dialog.getDialogPane().getButtonTypes().add(buttonTypeCancel);
        dialog.setResultConverter((ButtonType button) -> {
            if (button == buttonTypeOk) {
                if (multiSelect) {
                    return controller.getSelectedEntities();
                }
                List<T> list = new ArrayList<>();
                list.add(controller.getSelectedEntity());
                return list;
            }
            return null;
        });
        return dialog.showAndWait();

    } catch (IOException ex) {
        LoggerFactory.getLogger(EntityGuiController.class).error("Failed to load Tab.", ex);
        return Optional.empty();
    }
}
项目:WebtoonDownloadManager    文件:AlertSupport.java   
public int alertConfirm(Stage stage) {
    int r = 0;
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(stage);
    alert.setTitle("확인 알림");
    alert.setHeaderText(null);
    alert.setContentText(this.msg);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        r = 1;
    }

    return r;
}
项目:SensorThingsManager    文件:ControllerCollection.java   
@FXML
private void actionAdd(ActionEvent event) {
    if (childSetter == null) {
        new Alert(Alert.AlertType.ERROR, "No childSetter defined.", ButtonType.CLOSE).showAndWait();
        return;
    }
    Class<T> entityClass = query.getEntityClass();
    Query<T> allQuery = new Query<>(query.getService(), entityClass);
    Optional<List<T>> result = EntityGuiController.entitySearchDialog(allQuery, true);
    if (result.isPresent() && !result.get().isEmpty()) {
        List<T> newChildren = result.get();
        childSetter.setChildren(newChildren);
    }
}
项目:titanium    文件:MainPane.java   
private void removeServerAction(Event e) {
    Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to remove this server ?");

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

    if (result.isPresent() && result.get().equals(ButtonType.OK)) {
        Server s = content.removeSelectedServer();
        if (s != null) {
            servers.remove(s);
            ServerListLoader.writeServerList(servers);
        } else
            new Alert(AlertType.ERROR, "No selected server");

    }
}
项目:qgu    文件:QGUViewController.java   
@Override
protected void handleCloseRequest(WindowEvent event) {
    if(!gantt.isSaved()) { // TODO add cancel button
        ButtonType bt = FXDialog.binaryChoiceAlert("There are unsaved changes in this project. Save and close?").showAndWait().get();
        if(bt == ButtonType.YES) {
            saveGantt();
        } else {
            event.consume();
            return;
        }
    }   

    storageManager.rememberLastViewed(currentFile);
}
项目:Money-Manager    文件:SettingsController.java   
@FXML
private void sectorbtnDelete(ActionEvent event) {
    try {
        Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();

        Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("Delete Sector");
        alert.setHeaderText("Are you sure?");
        alert.setContentText("You are going to delete Sector \""+ sectorcmboDelete.getValue() + "\" ");
        alert.setX(SettingsStage.getX() + 210);
        alert.setY(SettingsStage.getY() + 170);
        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == ButtonType.OK){

            sector.deleteSector(sectorcmboDelete.getValue());
            advancedSector.deleteSectorFromAdvancedList(sectorcmboDelete.getValue());

            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Message");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText(sectorcmboDelete.getValue()+ " Deleted Successfully");
            confirmationMsg.setX(SettingsStage.getX() + 190);
            confirmationMsg.setY(SettingsStage.getY() + 190);
            confirmationMsg.showAndWait();
        }

        tabSectorInitialize();
    } catch (Exception e) {}
}
项目:Matcher    文件:Gui.java   
public boolean requestConfirmation(String title, String headerText, String text) {
    Alert alert = new Alert(AlertType.CONFIRMATION);

    alert.setTitle(title);
    alert.setHeaderText(headerText);
    alert.setContentText(text);

    return alert.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK;
}
项目:Matcher    文件:FileMenu.java   
private void newProject() {
    ProjectConfig config = ProjectConfig.getLast();

    Dialog<ProjectConfig> dialog = new Dialog<>();
    //dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setResizable(true);
    dialog.setTitle("Project configuration");
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

    dialog.getDialogPane().setContent(new NewProjectPane(config, dialog.getOwner(), okButton));
    dialog.setResultConverter(button -> button == ButtonType.OK ? config : null);

    dialog.showAndWait().ifPresent(newConfig -> {
        if (!newConfig.isValid()) return;

        newConfig.saveAsLast();

        gui.getMatcher().reset();
        gui.onProjectChange();

        gui.runProgressTask("Initializing files...",
                progressReceiver -> gui.getMatcher().init(newConfig, progressReceiver),
                () -> gui.onProjectChange(),
                Throwable::printStackTrace);
    });
}
项目:Matcher    文件:FileMenu.java   
private void loadProject() {
    Path file = Gui.requestFile("Select matches file", gui.getScene().getWindow(), getMatchesLoadExtensionFilters(), true);
    if (file == null) return;

    List<Path> paths = new ArrayList<>();

    Dialog<List<Path>> dialog = new Dialog<>();
    //dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setResizable(true);
    dialog.setTitle("Project paths");
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

    dialog.getDialogPane().setContent(new LoadProjectPane(paths, dialog.getOwner(), okButton));
    dialog.setResultConverter(button -> button == ButtonType.OK ? paths : null);

    dialog.showAndWait().ifPresent(newConfig -> {
        if (paths.isEmpty()) return;

        gui.getMatcher().reset();
        gui.onProjectChange();

        gui.runProgressTask("Initializing files...",
                progressReceiver -> gui.getMatcher().readMatches(file, paths, progressReceiver),
                () -> gui.onProjectChange(),
                Throwable::printStackTrace);
    });
}
项目:textmd    文件:YesNoAlertDialog.java   
@Override
public AlertDialog build() {
    initOwner(ownerStage);
    setTitle(title);
    setHeaderText(header);
    setContentText(content);
    ButtonType yes = new ButtonType(dictionary.DIALOG_BUTTON_YES_LABEL, ButtonBar.ButtonData.YES),
            no = new ButtonType(dictionary.DIALOG_BUTTON_NO_LABEL, ButtonBar.ButtonData.NO),
            cancel = new ButtonType(dictionary.DIALOG_BUTTON_CANCEL_LABEL, ButtonBar.ButtonData.CANCEL_CLOSE);
    getButtonTypes().setAll(yes, no, cancel);
    return this;
}
项目:AlphaLab    文件:ManutencaoSoftware.java   
@FXML
public void btnExcluirOnAction(ActionEvent evt) {
    SoftwareEntity tmpSoftware = getSoftwareSelected();
    if (tmpSoftware != null) {
        if (Alertas.exibirAlerta(Alert.AlertType.CONFIRMATION, "Excluir", "Confirmar exclusão?", "Deseja mesmo excluir o software " + tmpSoftware.getDescricao() + "?", Alertas.SIM_NAO_BOTOES).get() == ButtonType.YES) {
            SoftwareException delete = negocio.delete(software);
            if (delete != null) {
                Alertas.exibirAlerta(Alert.AlertType.ERROR, "Erro", "Erro ao excluir o software", delete.getLocalizedMessage());
            } else {
                listaSoftwares.remove(tmpSoftware);
            }
        }
    }

}
项目:fx-dialogs    文件:FxDialog.java   
private Callback<ButtonType, M> createResultConverter() {
    return new Callback<ButtonType, M>() {
        @Override
        public M call(ButtonType aDialogButton) {
            if (ButtonType.OK == aDialogButton) {
                return MODEL;
            }
            else {
                return null;
            }
        }
    };
}
项目:marathonv5    文件:FXUIUtils.java   
public static Optional<ButtonType> _showConfirmDialog(Window parent, String message, String title, AlertType type,
        ButtonType... buttonTypes) {
    Alert alert = new Alert(type, message, buttonTypes);
    alert.initOwner(parent);
    alert.setTitle(title);
    alert.initModality(Modality.APPLICATION_MODAL);
    return alert.showAndWait();
}
项目:ServerBrowser    文件:SampServerTable.java   
private void deleteSelectedFavourites() {
    final Alert alert = new Alert(AlertType.CONFIRMATION, Client.lang.getString("sureYouWantToDeleteFavourites"), ButtonType.YES, ButtonType.NO);
    Client.insertAlertOwner(alert);
    alert.setTitle(Client.lang.getString("deleteFavourites"));
    final Optional<ButtonType> result = alert.showAndWait();

    result.ifPresent(buttonType -> {
        if (buttonType == ButtonType.YES) {
            final List<SampServer> serverList = getSelectionModel().getSelectedItems();
            serverList.forEach(FavouritesController::removeServerFromFavourites);
            servers.removeAll(serverList);
        }
    });
}
项目:marathonv5    文件:ResourceView.java   
private void delete(ObservableList<TreeItem<Resource>> selectedItems) {
    Optional<ButtonType> option = Optional.empty();
    ArrayList<TreeItem<Resource>> items = new ArrayList<>(selectedItems);
    for (TreeItem<Resource> treeItem : items) {
        option = treeItem.getValue().delete(option);
        if (option.isPresent() && option.get() == ButtonType.CANCEL) {
            break;
        }
    }
}
项目:marathonv5    文件:Blurb.java   
protected ButtonType showDialog() {
    BlurbInfo blurbInfo;
    if (url == null)
        blurbInfo = new BlurbInfo(html, title, cancel);
    else
        blurbInfo = new BlurbInfo(url, title, cancel);
    BlurbStage blurbStage = new BlurbStage(blurbInfo);
    blurbStage.getStage().showAndWait();
    return blurbStage.getSelection();
}
项目:marathonv5    文件:Blurb.java   
public ButtonType showMessage() {
    if (Platform.isFxApplicationThread()) {
        return showDialog();
    } else {
        Object[] ret = new Object[1];
        Platform.runLater(new Runnable() {
            @Override public void run() {
                ret[0] = showDialog();
            }
        });
        return (ButtonType) ret[0];
    }
}