Java 类javafx.scene.control.ButtonBar.ButtonData 实例源码

项目:Virtual-Game-Shelf    文件:GameShelf.java   
public static void displayDeleteGameAlert() {
    int index = -1;

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setHeaderText(null);
    alert.setContentText("Are you sure you want to delete the selected games?");

    ButtonType deleteGame = new ButtonType("Delete Game(s)");
    ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(deleteGame, buttonTypeCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == deleteGame){
        for (String g : selectedGamesString) {
            index = getGameIndex(g);
            gameList.getGameList().remove(index);
        }

        refreshGameList();
        deleteButton.setDisable(true);
    }
    else {
        // ... user chose CANCEL or closed the dialog
    }
}
项目:EistReturns    文件:Utils.java   
void displayFirstRunAlert(){
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/cloud.png").toExternalForm()));
    alert.setTitle("Hall of Fame cloud service");
    alert.setHeaderText("Create or login to a Hall of Fame account");
    alert.setContentText("Online account lets you sync the game state\nbetween devices and compare results\nto other players.\n\n");
    alert.initOwner(mGameStage);

    ButtonType buttonTypeOK = new ButtonType("Create/Login", ButtonData.OK_DONE);
    ButtonType buttonTypeDontAsk = new ButtonType("Don't ask again", ButtonData.NO);
    ButtonType buttonTypeLater = new ButtonType("Ask later", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(buttonTypeOK, buttonTypeDontAsk, buttonTypeLater);

    Optional<ButtonType> result = alert.showAndWait();
    if(result.isPresent()) {
        if (result.get() == buttonTypeOK) {
            prefs.putBoolean("hofAsked", true);
            displayHallOfFame();
        } else if (result.get() == buttonTypeDontAsk) {
            prefs.putBoolean("hofAsked", true);
        }
    }

}
项目: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();
        }
    }
}
项目:uPMT    文件:InterviewTreeView.java   
public void deleteInterview(DescriptionEntretien interview){
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Supression Entretien");
    alert.setHeaderText("Vous allez supprimer "+interview.getNom());

    ButtonType buttonTypeOne = new ButtonType("Valider");
    ButtonType buttonTypeCancel = new ButtonType("Annuler", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonTypeOne){
        main.getCurrentProject().getEntretiens().remove(interview);
        this.getTreeItem().getParent().getChildren().remove(this.getTreeItem());
    }
}
项目:OneClient    文件:FileSelection.java   
public FileSelection(File parent) {
    DialogPane dialogPane = this.getDialogPane();
    dialogPane.setMaxWidth(1.7976931348623157E308D);
    this.directoryView = new CheckTreeView<>();
    this.directoryView.setMaxWidth(1.7976931348623157E308D);
    CheckBoxTreeItem<File> root = createTree(new CheckBoxTreeItem<>(parent));
    root.setExpanded(true);
    directoryView.setRoot(root);
    GridPane.setHgrow(this.directoryView, Priority.ALWAYS);
    GridPane.setFillWidth(this.directoryView, true);
    this.grid = new GridPane();
    this.grid.setHgap(10.0D);
    this.grid.setMaxWidth(1.7976931348623157E308D);
    this.grid.setAlignment(Pos.CENTER_LEFT);
    dialogPane.contentTextProperty().addListener((o) -> this.updateGrid());
    this.setTitle(ControlResources.getString("Dialog.confirm.title"));
    dialogPane.setHeaderText(ControlResources.getString("Dialog.confirm.header"));
    dialogPane.getStyleClass().add("text-input-dialog");
    dialogPane.getButtonTypes().addAll(new ButtonType[] { ButtonType.APPLY, ButtonType.CANCEL });
    this.updateGrid();
    this.setResultConverter((dialogButton) -> {
        ButtonBar.ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
        return data == ButtonData.APPLY ? this.getValues() : null;
    });
}
项目:zest-writer    文件:MenuController.java   
private void displayIndex(Map<String, Double> resultIndex, String title, String header) {
    BaseDialog dialog = new BaseDialog(title, header);
    dialog.getDialogPane().setPrefSize(800, 600);
    dialog.getDialogPane().getButtonTypes().addAll(new ButtonType(Configuration.getBundle().getString("ui.actions.stats.close"), ButtonBar.ButtonData.CANCEL_CLOSE));

    // draw
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<String,Number> lineChart = new LineChart<>(xAxis, yAxis);
    lineChart.setTitle(title);
    lineChart.setLegendVisible(false);

    xAxis.setLabel(Configuration.getBundle().getString("ui.actions.stats.xaxis"));
    yAxis.setLabel(Configuration.getBundle().getString("ui.actions.readable.yaxis"));

    XYChart.Series<String, Number> series = new XYChart.Series();
    for(Map.Entry<String, Double> st:resultIndex.entrySet()) {
        series.getData().add(new XYChart.Data(st.getKey(), st.getValue()));
    }
    lineChart.getData().addAll(series);
    dialog.getDialogPane().setContent(lineChart);
    dialog.setResizable(true);
    dialog.showAndWait();
}
项目:MineIDE-UI    文件:PopupForgeInstallation.java   
public static void showPopup()
{
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("Information");
    alert.setHeaderText(
            Translation.LANG.getTranslation("alert.forge.reinstall.header") + Gui.mineIdeInfo.getForgeVersion());
    alert.setContentText(Translation.LANG.getTranslation("alert.forge.reinstall.content.line1") + "\n"
            + Translation.LANG.getTranslation("alert.forge.reinstall.content.line2"));

    ButtonType buttonForceUpdate = new ButtonType(Translation.LANG.getTranslation("button.forceUpdate"));
    ButtonType buttonCancel = new ButtonType(Translation.LANG.getTranslation("button.cancel"),
            ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(buttonForceUpdate, buttonCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonForceUpdate)
        ForgeWorkspace.getInstance().forceUpdate();
    else
    {
    }
}
项目:certmgr    文件:PasswordDialog.java   
@Nullable
private char[] queryPasswordHelper(Supplier<PasswordResult> query, boolean requery) {
    PasswordResult passwordResult;

    if (this.cancelAll) {
        passwordResult = PasswordResult.CANCEL;
    } else if (!requery && this.rememberedPassword != null) {
        passwordResult = new PasswordResult(ButtonType.YES, this.rememberedPassword, true);
    } else {
        passwordResult = PlatformHelper.runLater(query);
    }

    ButtonData dialogResultData = passwordResult.dialogResult().getButtonData();

    if (dialogResultData == ButtonData.YES) {
        this.cancelAll = false;
        this.rememberedPassword = (passwordResult.rememberPassword() ? passwordResult.password() : null);
    } else if (dialogResultData == ButtonData.NO) {
        this.cancelAll = false;
        this.rememberedPassword = null;
    } else {
        this.cancelAll = true;
        this.rememberedPassword = null;
    }
    return passwordResult.password();
}
项目:certmgr    文件:StoreController.java   
@SuppressWarnings("unused")
@FXML
void onCmdDeleteEntry(ActionEvent evt) {
    UserCertStoreEntry entry = getSelectedStoreEntry();

    if (entry != null) {
        Optional<ButtonType> confirmation = Alerts
                .message(AlertType.CONFIRMATION, StoreI18N.formatSTR_MESSAGE_CONFIRM_DELETE(entry)).showAndWait();

        if (confirmation.isPresent() && confirmation.get().getButtonData() == ButtonData.OK_DONE) {
            try {
                this.storeProperty.get().deleteEntry(entry.id());
                if (entry.equals(getSelectedStoreEntry())) {
                    this.ctlStoreEntryView.getSelectionModel().clearSelection();
                }
            } catch (IOException e) {
                Alerts.unexpected(e).showAndWait();
            }
        }
        updateStoreEntryView();
    }
}
项目:downloadclient    文件:Controller.java   
/**
 * Handler to close the application.
 *
 * @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) {
        Stage stage = (Stage) buttonClose.getScene().getWindow();
        stage.fireEvent(new WindowEvent(
                stage,
                WindowEvent.WINDOW_CLOSE_REQUEST
        ));
    }
}
项目:JavaFX-Skeleton-DEPRECATED    文件:LoginDialog.java   
private Node setupButtons(Map<TextFieldDescription, TextField> fields) {
        ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
        getDialog().getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

        // Enable/Disable login button depending on whether a username was entered.
        Node loginButton = getDialog().getDialogPane().lookupButton(loginButtonType);
//      loginButton.setDisable(true);

        // Convert the result to a username-password-pair when the login button is clicked.
        getDialog().setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return DialogResult.newInstance(fields);
            }
            return null;
        });

        return loginButton;
    }
项目:maptranslator    文件:NBTVersionChooser.java   
public NBTVersionChooser() {
    setTitle(translate("nbt_version_chooser.title"));
    setHeaderText(translate("nbt_version_chooser.header"));
    boxInputVersion = new ComboBox<>(FXCollections.observableArrayList(NBTVersion.values()));
    boxOutputVersion = new ComboBox<>(FXCollections.observableArrayList(NBTVersion.values()));
    GridPane grid = new GridPane();
    grid.add(new Label(translate("nbt_version_chooser.input_version")), 1, 1);
    grid.add(boxInputVersion, 2, 1);
    grid.add(new Label(translate("nbt_version_chooser.output_version")), 1, 2);
    grid.add(boxOutputVersion, 2, 2);
    getDialogPane().setContent(grid);
    getDialogPane().getButtonTypes().add(ButtonType.OK);
    getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
    setResultConverter(button -> {
        if (button.getButtonData() == ButtonData.OK_DONE) {
            return new NBTVersionConfig(boxInputVersion.getValue(), boxOutputVersion.getValue());
        } else {
            return null;
        }
    });

    boxInputVersion.setValue(NBTVersion.defaultConfig.getInputVersion());
    boxOutputVersion.setValue(NBTVersion.defaultConfig.getOutputVersion());
}
项目:dnainator    文件:HotkeyHelpDialog.java   
private void setupDialog(Menu... menus) {
    this.setTitle("Hotkeys");
    this.getDialogPane().getStylesheets().add(getClass().getResource(STYLE).toString());
    this.initOwner(parent.getScene().getWindow());
    this.initModality(Modality.NONE);
    this.getDialogPane().setPrefWidth(WIDTH);
    setupContentGrid();
    this.setHeaderText("Hotkeys");
    setupContent(menus);

    getDialogPane().setContent(content);

    ButtonType close = new ButtonType("Close", ButtonData.CANCEL_CLOSE);
    this.getDialogPane().getButtonTypes().add(close);
    this.showingProperty().addListener((obj, oldV, newV) -> {
        MenuItem hotkey = menus[menus.length - 1].getItems().get(0);
        hotkey.setDisable(!hotkey.isDisable());
    });
}
项目:dnainator    文件:AboutDialog.java   
private void setupDialog() {
    this.setTitle("About DNAinator");
    this.setResizable(true);
    this.getDialogPane().getStylesheets().add(getClass().getResource(STYLE).toString());
    this.initOwner(parent.getScene().getWindow());

    ImageView img = new ImageView();
    img.setImage(new Image(getClass().getResourceAsStream(LOGO)));
    this.setGraphic(img);
    readProperties();

    this.setHeaderText("DNAinator\nDNA network visualization tool");
    this.setContentText(contentText());

    ButtonType close = new ButtonType("Close", ButtonData.CANCEL_CLOSE);
    this.getDialogPane().getButtonTypes().add(close);
}
项目:FlagMaker-2    文件:MainWindowController.java   
private boolean CheckUnsaved()
{
    if (!_isUnsaved) return false;

    Alert alert = new Alert(AlertType.CONFIRMATION);
    ButtonType buttonYes = new ButtonType(LocalizationHandler.Get("Yes"));
    ButtonType buttonNo = new ButtonType(LocalizationHandler.Get("No"));
    ButtonType buttonCancel = new ButtonType(LocalizationHandler.Get("Cancel"), ButtonData.CANCEL_CLOSE);
    alert.setTitle(CommonExtensions.TitleAndVersionString(getClass()));
    alert.setHeaderText(LocalizationHandler.Get("NotSaved"));
    alert.setContentText(String.format(LocalizationHandler.Get("SaveChangesPrompt"), txtName.getText()));
    alert.getButtonTypes().setAll(buttonYes, buttonNo, buttonCancel);

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

    ButtonType b = result.get();
    if (b == buttonYes)
    {
        Save();
    }

    return b == buttonCancel;
}
项目:mongofx    文件:UIBuilder.java   
public Optional<String> editDocument(String formattedJson, int cursorPosition) {
  Dialog<String> dialog = new Dialog<>();
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
  dialog.setTitle("MongoFX - edit document");
  dialog.setResizable(true);
  dialog.getDialogPane().getStylesheets().add(getClass().getResource("/ui/editor.css").toExternalForm());

  CodeArea codeArea = setupEditorArea(formattedJson, dialog, cursorPosition);

  dialog.setResultConverter(bt -> {
    if (ButtonData.OK_DONE == bt.getButtonData()) {
      return codeArea.getText();
    }
    return null;
  });
  return dialog.showAndWait();
}
项目:StreamSis    文件:SettingsController.java   
/**
 * Initializes "OK" and "Cancel" buttons.
 */
private void initializeBottomButtons() {
    Button okButton = new Button("OK");
    ButtonBar.setButtonData(okButton, ButtonData.OK_DONE);
    Button cancelButton = new Button("Cancel");
    ButtonBar.setButtonData(cancelButton, ButtonData.CANCEL_CLOSE);
    buttonBar.getButtons().addAll(okButton, cancelButton);
    okButton.addEventFilter(ActionEvent.ACTION, (event) -> {
        applySettings();
        ((Stage) okButton.getScene().getWindow()).close();
    });
    cancelButton.addEventFilter(ActionEvent.ACTION, (event) -> {
        ((Stage) okButton.getScene().getWindow()).close();
    });
    validationSupport.validationResultProperty().addListener((o, oldVal, newVal) -> {
        if (newVal.getErrors().isEmpty()) {
            // If no errors, enable okButton.
            okButton.setDisable(false);
        } else {
            // If errors, disable okButton.
            okButton.setDisable(true);
        }
    });
}
项目:HubTurbo    文件:MenuControl.java   
/**
 * Deletes the board named {@boardName}
 *
 * @param boardName name of the board to delete
 */
public final void deleteBoard(String boardName) {
    Alert dlg = new Alert(AlertType.CONFIRMATION, "");
    dlg.initModality(Modality.APPLICATION_MODAL);
    dlg.setTitle("Confirmation");
    dlg.getDialogPane().setHeaderText("Delete board '" + boardName + "'?");
    dlg.getDialogPane().setContentText("Are you sure you want to delete this board?");
    Optional<ButtonType> response = dlg.showAndWait();

    if (response.isPresent() && response.get().getButtonData() == ButtonData.OK_DONE) {
        prefs.removeBoard(boardName);
        if (prefs.getLastOpenBoard().isPresent() &&
                prefs.getLastOpenBoard().get().equals(boardName)) {

            prefs.clearLastOpenBoard();
            prefs.clearLastOpenBoardPanelInfos();
        }
        ui.triggerEvent(new BoardSavedEvent());
        logger.info(boardName + " was deleted");
        ui.updateTitle();
    } else {
        logger.info(boardName + " was not deleted");
    }
}
项目:Matrixonator-Java    文件:MatrixAlerts.java   
/**
 * Performs checks when User asks for a Matrix to be removed
 * 
 * @param name of matrix to be deleted
 */
public static boolean handleDeleteRequest(String name) {
  // Need to check if there is a file of given name there. If not we just return false, so no
  // delete occurs
  if (MatrixIO.isMatrixSaved(name + ".matrix")) {
    Alert alert = new Alert(AlertType.WARNING);
    alert.setTitle("Warning : Delete");
    alert.setHeaderText("Delete " + name);
    alert
        .setContentText(name
            + " is saved on your system. Do you wish to remove this? (This operation can't be undone)");

    ButtonType yesButton = new ButtonType("Yes", ButtonData.YES);
    ButtonType noButton = new ButtonType("No", ButtonData.NO);
    alert.getButtonTypes().setAll(yesButton, noButton);

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

    // Only return true if the user wants the stuff to be removed
    if (result.get().getButtonData() == ButtonData.YES) {
      return true;
    }
    return false;
  }
  return true;
}
项目:Matrixonator-Java    文件:MatrixAlerts.java   
/**
 * Asks user if they wish to update Matrixonator, if it can find an update
 * 
 * @param version - new version of program
 * @return true if user wishes to continue, false otherwise
 */
public static boolean showUpdates(String version) {
  Alert alert = new Alert(AlertType.INFORMATION);
  alert.setTitle("Matrixonator - Update");
  alert.setHeaderText("Update available");
  alert.setContentText("Matrixonator Version " + version
      + " is ready to download. Do you wish to download?");

  ButtonType yesButton = new ButtonType("Yes", ButtonData.YES);
  ButtonType noButton = new ButtonType("No", ButtonData.NO);
  alert.getButtonTypes().setAll(yesButton, noButton);

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

  if (result.get().getButtonData() == ButtonData.YES) {
    return true;
  } else {
    return false;
  }
}
项目:skadi    文件:SettingsDialog.java   
public SettingsDialog(final StateContainer state, final PersistenceHandler persistenceHandler) {
    this.persistenceHandler = persistenceHandler;
    this.state = state;

    setTitle("Skadi settings");
    setHeaderText(null);
    setGraphic(null);

    final ButtonType saveButtonType = new ButtonType("Save", ButtonData.OK_DONE);
    getDialogPane().getButtonTypes().addAll(saveButtonType, ButtonType.CANCEL);

    getDialogPane().setContent(getContentPane());

    setResultConverter(btn -> {
        if (btn == saveButtonType) {
            state.setExecutableStreamlink(tfStreamlink.getText());
            state.setExecutableChrome(tfChrome.getText());

            state.setDisplayNotifications(cbShowNotifications.isSelected());
            state.setMinimizeToTray(cbMinimizeToTray.isSelected());
            state.setUseDarkTheme(cbDarkTheme.isSelected());
            return state;
        }
        return null;
    });
}
项目:ChessPairs    文件:TournamentViewer.java   
public boolean saveOpportunity() {
    if (!saved) {
        final Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("Save Tournament");
        alert.setHeaderText("Do you want to save the changes you made to the tournament?");
        alert.setContentText("Your changes will be lost if you don't save them.");
        final ButtonType dont = new ButtonType("Don't Save", ButtonData.NO);
        final ButtonType save = new ButtonType("Save", ButtonData.YES);
        final ButtonType cancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
        alert.getButtonTypes().setAll(dont, save, cancel);
        switch (alert.showAndWait().get().getButtonData()) {
            case NO:
                return false;
            case YES:
                save(false);
                return true;
            case CANCEL_CLOSE:
                return true;
        }
    }
    return false;
}
项目:Virtual-Game-Shelf    文件:GameShelf.java   
public static void displayEditGameAlert() {
    int index = getGameIndex(selectedGamesString.get(0));
    ArrayList<Game> tempGameList = (ArrayList<Game>) gameList.getGameList().clone();

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("" + tempGameList.get(index).getName());
    alert.setHeaderText(null);
    alert.setContentText("Would you like to edit the game " + tempGameList.get(index).getName() + "?");

    ButtonType editGame = new ButtonType("Edit Game");
    ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(editGame, buttonTypeCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == editGame) {
        NewGameWindow newGameWindow = new NewGameWindow(tempGameList.get(index) );
        Game newGame = newGameWindow.showAndAddGame();
        if (newGame != null) {
            // Add title to game list
            gameList.getGameList().remove(index);
            gameList.addGame(newGame);
            refreshGameList();
            editButton.setDisable(true);
            deleteButton.setDisable(true);
        }
    }
    else {
        // ... user chose CANCEL or closed the dialog
    }
}
项目:titanium    文件:MapSelectorDialog.java   
public MapSelectorDialog(String title) {
    super();
    // Create the custom dialog.
    this.setTitle(title);

    // Set the button types.
    ButtonType addButtonType = new ButtonType("Select map", ButtonData.OK_DONE);
    this.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);

    // Create the username and password labels and fields.
    VBox inputPane = new VBox();

    ComboBox<String> maps = new ComboBox<>();

    maps.getItems().addAll(MapListLoader.loadMapList());

    inputPane.getChildren().addAll(new Label("Select a map"), maps);


    this.getDialogPane().setContent(inputPane);

    this.setResultConverter(dialogButton -> {
        try {
            if (dialogButton == addButtonType) {
                return maps.getSelectionModel().getSelectedItem();
            }
        } catch (NumberFormatException e) {
            return null;
        }
        return null;
    });

}
项目:rsam-gui    文件:Dialogue.java   
public static void openDirectory(String headerText, File dir) {

        if (OSUtils.getOs().isLinux()) {
            return;
        }

        OptionMessage alert = new OptionMessage(headerText);

        ButtonType choiceOne = new ButtonType("Yes.");
        ButtonType close = new ButtonType("No", ButtonData.CANCEL_CLOSE);

        alert.getButtonTypes().setAll(choiceOne, close);

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

        if (result.isPresent()) {

            ButtonType type = result.get();

            if (type == choiceOne) {
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop().open(dir);
                    }
                } catch (Exception ex) {
                    Dialogue.showException("Error while trying to view image on desktop.", ex).showAndWait();
                }
            }

        }
    }
项目:qiniu    文件:Dialogs.java   
public Dialog<String[]> getDialog(ButtonType ok) {
    Dialog<String[]> dialog = new Dialog<String[]>();
    dialog.setTitle(Values.MAIN_TITLE);
    dialog.setHeaderText(null);

    dialog.initModality(Modality.APPLICATION_MODAL);

    // 自定义确认和取消按钮
    ButtonType cancel = new ButtonType(Values.CANCEL, ButtonData.CANCEL_CLOSE);
    dialog.getDialogPane().getButtonTypes().addAll(ok, cancel);
    return dialog;
}
项目:javaGMR    文件:GameController.java   
/**
 * Downloads the save file from the GMR site.
 *
 * @param selectedItem This parameter is used to download the save file from
 * the site
 */
public void downloadSaveFile(Game selectedItem) throws MalformedURLException, IOException {
    String requestUrl = "http://multiplayerrobot.com/api/Diplomacy/GetLatestSaveFileBytes";
    URL url = new URL(requestUrl + "?authkey=" + JGMRConfig.getInstance().getAuthCode() + "&gameId=" + selectedItem.getGameid());
    HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
    long completeFileSize = httpConnection.getContentLength();
    httpConnection.setReadTimeout(15000);

    File targetFile = new File(JGMRConfig.getInstance().getPath() + "/(jGMR) Play this one.Civ5Save");
    if (!new File(JGMRConfig.getInstance().getPath() + "/.jgmrlock.lock").exists()) {
        File lock = new File(JGMRConfig.getInstance().getPath() + "/.jgmrlock.lock");
        lock.createNewFile();

        java.io.BufferedInputStream is = new java.io.BufferedInputStream(httpConnection.getInputStream());

        try (OutputStream outStream = new FileOutputStream(targetFile)) {
            byte[] buffer = new byte[8 * 1024];
            int bytesRead;
            double downLoadFileSize = 0;
            while ((bytesRead = is.read(buffer)) != -1) {
                downLoadFileSize = downLoadFileSize + bytesRead;
                outStream.write(buffer, 0, bytesRead);
                sendDownloadProgress(((double) downLoadFileSize / (double) completeFileSize));
            }
            JGMRConfig.getInstance().readDirectory();
        }
        lock.delete();
    } else {
        Dialog dg = new Dialog();
        dg.setContentText("An upload or download is already in progress, please wait for the previous operation to finish.");
        dg.setTitle("Download or Upload already in progress.");
        dg.getDialogPane().getButtonTypes().add(new ButtonType("Login", ButtonData.OK_DONE));
        Platform.runLater(() -> {
            dg.showAndWait();
        });

    }

}
项目:CyberTigerScoreboard    文件:PasswordDialog.java   
public PasswordDialog(String whatFor) {
  setTitle(whatFor+" Password");
  setHeaderText("Please enter your "+whatFor+" password: ");

  ButtonType passwordButtonType = new ButtonType("Login", ButtonData.OK_DONE);
  getDialogPane().getButtonTypes().addAll(passwordButtonType, ButtonType.CANCEL);

  passwordField = new PasswordField();
  passwordField.setPromptText(whatFor+" password");

  HBox hBox = new HBox();
  hBox.getChildren().add(passwordField);
  hBox.setPadding(new Insets(20));

  HBox.setHgrow(passwordField, Priority.ALWAYS);

  getDialogPane().setContent(hBox);

  Platform.runLater(() -> passwordField.requestFocus());

  setResultConverter(dialogButton -> {
    if (dialogButton == passwordButtonType) {
      return passwordField.getText();
    }
    return "";
  });
}
项目:Incubator    文件:DialogProvider.java   
public static final DailySectionModel showDailySectionChooserDialog() {
       LoggerFacade.INSTANCE.debug(DialogProvider.class, "Show DailySection chooser dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO add size to the dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO use properties"); // NOI18N

       final Dialog<DailySectionModel> dialog = new Dialog<>();
       dialog.setTitle("Daily Section Chooser"); // NOI18N
       dialog.setHeaderText("Select the Daily Section to which the Project should be added!"); // NOI18N
       dialog.setResizable(false);

       final DailySectionChooserDialogView view = new DailySectionChooserDialogView();
       dialog.getDialogPane().setContent(view.getView());

       final ButtonType buttonTypeOk = new ButtonType("Okay", ButtonData.OK_DONE); // NOI18N
       final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); // NOI18N
dialog.getDialogPane().getButtonTypes().addAll(buttonTypeOk, buttonTypeCancel);

dialog.setResultConverter((ButtonType buttonType) -> {
           if (
                   buttonType != null
                   && buttonType.equals(buttonTypeOk)
           ) {
               return view.getRealPresenter().getDailySection();
           }

           return null;
       });

       final Optional<DailySectionModel> result = dialog.showAndWait();
       if (!result.isPresent()) {
           return null;
       }

       return result.get();
   }
项目:Incubator    文件:DialogProvider.java   
public static final void showDeleteProjectDialog(long idToDelete, String projectTitle) {
       LoggerFacade.INSTANCE.debug(DialogProvider.class, "Show delete Project dialog"); // NOI18N

       final Dialog<Boolean> dialog = new Dialog<>();
       dialog.setTitle("Delete " + projectTitle); // NOI18N
       dialog.setHeaderText("Do you really want to delete this project?"); // NOI18N
       dialog.setResizable(false);

       final ButtonType buttonTypeOk = new ButtonType("Okay", ButtonData.OK_DONE); // NOI18N
       final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); // NOI18N
dialog.getDialogPane().getButtonTypes().addAll(buttonTypeOk, buttonTypeCancel);

       dialog.setResultConverter((ButtonType buttonType) -> {
           final boolean shouldProjectDelete = buttonType != null && buttonType.equals(buttonTypeOk);
           return shouldProjectDelete;
       });

       final Optional<Boolean> result = dialog.showAndWait();
       if (
               !result.isPresent()
               || !result.get()
       ) {
           return;
       }

       // Delete the project
       SqlFacade.INSTANCE.getProjectSqlProvider().delete(idToDelete);

       // Cleanup
       ActionFacade.INSTANCE.handle(INavigationOverviewConfiguration.ON_ACTION__UPDATE_PROJECTS);
   }
项目:Incubator    文件:DialogProvider.java   
public static final DailySectionModel showNewDailySectionDialog() {
       LoggerFacade.INSTANCE.debug(DialogProvider.class, "Show new DailySection dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO add size to the dialog"); // NOI18N
       LoggerFacade.INSTANCE.trace(DialogProvider.class, "TODO use properties"); // NOI18N

       final Dialog<DailySectionModel> dialog = new Dialog<>();
       dialog.setTitle("New Daily Section"); // NOI18N
       dialog.setHeaderText("Creates a new Daily Section."); // NOI18N
       dialog.setResizable(false);

       final DailySectionDialogView view = new DailySectionDialogView();
       dialog.getDialogPane().setContent(view.getView());

       final ButtonType buttonTypeOk = new ButtonType("Create", ButtonData.OK_DONE); // NOI18N
       final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); // NOI18N
dialog.getDialogPane().getButtonTypes().addAll(buttonTypeOk, buttonTypeCancel);

dialog.setResultConverter((ButtonType buttonType) -> {
           if (
                   buttonType != null
                   && buttonType.equals(buttonTypeOk)
           ) {
               return view.getRealPresenter().getDailySection();
           }

           return null;
       });

       final Optional<DailySectionModel> result = dialog.showAndWait();
       if (!result.isPresent()) {
           return null;
       }

       return result.get();
   }
项目:Gargoyle    文件:DialogUtil.java   
public static Optional<Pair<String, String>> showYesOrNoDialog(Stage stage, String title, String message,
        Consumer<? super Pair<String, String>> consumer, Consumer<Dialog<Pair<String, String>>> dialogHandler) {

    // Create the custom dialog.
    Dialog<Pair<String, String>> dialog = new Dialog<>();
    dialog.setTitle(title);
    dialog.setHeaderText(message);

    // Set the button types.
    ButtonType yesBtn = new ButtonType("Yes", ButtonData.YES);
    ButtonType noBtn = new ButtonType("No", ButtonData.NO);

    dialog.getDialogPane().getButtonTypes().addAll(yesBtn, noBtn);

    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == yesBtn) {
            return new Pair<>("RESULT", "Y");
        } else if (dialogButton == noBtn) {
            return new Pair<>("RESULT", "N");
        }
        return null;
    });

    dialog.initOwner(stage);
    if (dialogHandler != null)
        dialogHandler.accept(dialog);

    Optional<Pair<String, String>> result = dialog.showAndWait();

    if (consumer != null)
        result.ifPresent(consumer);

    return result;

}
项目:CircuitSim    文件:CircuitSim.java   
private boolean checkUnsavedChanges() {
    clearSelection();

    if(editHistory.editStackSize() != savedEditStackSize) {
        Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.initOwner(stage);
        alert.initModality(Modality.WINDOW_MODAL);
        alert.setTitle("Unsaved changes");
        alert.setHeaderText("Unsaved changes");
        alert.setContentText("There are unsaved changes, do you want to save them?");

        ButtonType discard = new ButtonType("Discard", ButtonData.NO);
        alert.getButtonTypes().add(discard);

        Optional<ButtonType> result = alert.showAndWait();
        if(result.isPresent()) {
            if(result.get() == ButtonType.OK) {
                saveCircuitsInternal();

                if(saveFile == null) {
                    return true;
                }
            } else if(result.get() == ButtonType.CANCEL) {
                return true;
            }
        }
    }

    return false;
}
项目:trex-stateless-gui    文件:PacketHex.java   
/**
 * Show dialog
 *
 * @param selectedText
 * @return
 */
private String showDialog(String selectedText) {
    Dialog dialog = new Dialog();
    dialog.setTitle("Edit Hex");
    dialog.setResizable(false);
    TextField text1 = new TextField();
    text1.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(2));
    text1.setText(selectedText);
    StackPane dialogPane = new StackPane();
    dialogPane.setPrefSize(150, 50);
    dialogPane.getChildren().add(text1);
    dialog.getDialogPane().setContent(dialogPane);
    ButtonType buttonTypeOk = new ButtonType("Save", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
    dialog.setResultConverter(new Callback<ButtonType, String>() {
        @Override
        public String call(ButtonType b) {

            if (b == buttonTypeOk) {
                switch (text1.getText().length()) {
                    case 0:
                        return null;
                    case 1:
                        return "0".concat(text1.getText());
                    default:
                        return text1.getText();
                }
            }
            return null;
        }
    });

    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        return result.get();
    }
    return null;
}
项目:certmgr    文件:PasswordDialog.java   
PasswordResult getPasswordInputResult(ButtonType button) {
    PasswordResult passwordResult = PasswordResult.CANCEL;
    ButtonData dialogResultData = button.getButtonData();

    if (dialogResultData == ButtonData.YES) {
        passwordResult = new PasswordResult(button, this.controller.getPasswordInput().toCharArray(),
                this.controller.getRememberPasswordOption());
    } else if (dialogResultData == ButtonData.NO) {
        passwordResult = new PasswordResult(button, null, this.controller.getRememberPasswordOption());
    }
    return passwordResult;
}
项目:byproxy    文件:KeyStoreSettingDialog.java   
public KeyStoreSettingDialog() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/key_store_setting.fxml"));
    loader.setRoot(this);
    loader.setController(this);
    loader.load();

    setResultConverter((dialogButton) -> {
        ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
        return data == ButtonData.OK_DONE ? getModel() : null;
    });

    keyStoreSetting.addListener((o, old, n) -> setModel(n));

}
项目:byproxy    文件:MainSettingDialog.java   
public MainSettingDialog() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/main_setting.fxml"));
    loader.setRoot(this);
    loader.setController(this);
    loader.load();

    setResultConverter((dialogButton) -> {
        ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
        return data == ButtonData.OK_DONE ? getModel() : null;
    });

    mainSetting.addListener((o, old, n) -> setModel(n));

}
项目:byproxy    文件:ProxySettingDialog.java   
public ProxySettingDialog() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/proxy_setting.fxml"));
    loader.setRoot(this);
    loader.setController(this);
    loader.load();

    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    setResultConverter((dialogButton) -> {
        ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
        return data == ButtonData.OK_DONE ? getModel() : null;
    });

    proxySetting.addListener((o, old, n) -> setModel(n));

}
项目:drbookings    文件:DrBookingsApplication.java   
@Override
public void handle(final WindowEvent event) {

    final Alert alert = new Alert(AlertType.CONFIRMATION);
    final ButtonType buttonTypeOne = new ButtonType("Yes", ButtonData.OK_DONE);
    final ButtonType buttonTypeTwo = new ButtonType("No", ButtonData.NO);
    final ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(buttonTypeCancel, buttonTypeTwo, buttonTypeOne);
    alert.setTitle("Save changes?");
    alert.setHeaderText("Save changes?");

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

    if (result.get() == buttonTypeOne) {
        try {
            final FileChooser fileChooser = new FileChooser();
            final File file = SettingsManager.getInstance().getDataFile();
            fileChooser.setInitialDirectory(file.getParentFile());
            fileChooser.getExtensionFilters().addAll(
                    new FileChooser.ExtensionFilter("Dr.Booking Booking Data", Arrays.asList("*.xml")),
                    new FileChooser.ExtensionFilter("All Files", "*"));
            fileChooser.setTitle("Select File");
            fileChooser.setInitialFileName(file.getName());
            final File file2 = fileChooser.showSaveDialog(((Stage) event.getSource()));
            if (file2 != null) {
                SettingsManager.getInstance().setDataFile(file2);
                mainController.save(file);
            }
        } catch (final Exception e) {
            logger.error(e.getLocalizedMessage(), e);
        }
        exit();
    } else if (result.get() == buttonTypeTwo) {
        exit();
    } else {
        // cancel shutdown
        event.consume();
    }
}
项目:Tuntuni    文件:VideoCallController.java   
public void acceptCallDialog(final Client client) {
    // set current client
    Core.instance().main().showUser(client);
    Core.instance().main().selectVideoCall();

    // create the custom dialog.
    Dialog<Boolean> dialog = new Dialog<>();
    dialog.setTitle("Incoming Call!");
    dialog.setHeaderText(userName.getText());
    dialog.setContentText(userName.getText() + " is calling...\n"
            + "Do you want to accept this call?");

    // set the icon 
    dialog.setGraphic(new ImageView(userPhoto.getImage()));

    // set the button types.
    ButtonType acceptButton = new ButtonType("Accept", ButtonData.OK_DONE);
    ButtonType declineButton = new ButtonType("Decline", ButtonData.CANCEL_CLOSE);
    dialog.getDialogPane().getButtonTypes().addAll(acceptButton, declineButton);

    // define result converter 
    dialog.setResultConverter(dialogButton -> {
        return dialogButton == acceptButton;
    });

    // return the result
    Optional<Boolean> result = dialog.showAndWait();
    if (result.isPresent() && result.get()) {
        Core.instance().dialer().acceptResponse(client, null);
    } else {
        Core.instance().dialer().acceptResponse(client, new Exception("Call was rejected"));
    }
}