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

项目:dss-demonstrations    文件:SelectCertificateTask.java   
@Override
public DSSPrivateKeyEntry call() throws Exception {
    Map<String, DSSPrivateKeyEntry> map = new HashMap<String, DSSPrivateKeyEntry>();
    for (DSSPrivateKeyEntry dssPrivateKeyEntry : keys) {
        CertificateToken certificate = dssPrivateKeyEntry.getCertificate();
        String text = DSSASN1Utils.getHumanReadableName(certificate) + " (" + certificate.getSerialNumber() + ")";
        map.put(text, dssPrivateKeyEntry);
    }
    Set<String> keySet = map.keySet();
    ChoiceDialog<String> dialog = new ChoiceDialog<String>(keySet.iterator().next(), keySet);
    dialog.setHeaderText("Select your certificate");
    Optional<String> result = dialog.showAndWait();

    try {
        return map.get(result.get());
    } catch (NoSuchElementException e) {
        return null;
    }
}
项目:vars-annotation    文件:OldReferenceNumberBC.java   
protected void apply() {
    Media media = toolBox.getData().getMedia();
    List<Annotation> selected = new ArrayList<>(toolBox.getData().getSelectedAnnotations());

    decorator.findReferenceNumberAssociations(media, associationKey)
            .thenAccept(as -> {
                List<String> refNums = associationToIdentityRefs(as);
                Platform.runLater(() -> {
                    ChoiceDialog<String> dlg = getDialog();
                    dlg.getItems().clear();
                    if (!refNums.isEmpty()) {
                        dlg.getItems().addAll(refNums);
                        dlg.setSelectedItem(refNums.iterator().next());
                        Optional<String> integer = dlg.showAndWait();
                        integer.ifPresent(i -> {
                            Association a = new Association(associationKey, Association.VALUE_SELF, i);
                            toolBox.getEventBus()
                                    .send(new CreateAssociationsCmd(a, selected));
                        });
                    }
                });

            });
}
项目:photometric-data-retriever    文件:PhotometricDataOverviewController.java   
@FXML
private void handleSaveAllMenuItem() {
    String entryFormat = ".csv";
    String[] choices = {"CSV file .csv", "Ascii table .txt"};
    ChoiceDialog<String> dialog = FXMLUtils.showOptionDialog(stage, Arrays.asList(choices), "Choose output format", "Choose output format",
            resources.getString("output.format"));
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        entryFormat = result.get();

        String coords = stellarObject.getRightAscension() + " " + stellarObject.getDeclination();
        File zip = FXMLUtils.showSaveFileChooser(resources.getString("choose.output.file"),
                lastSavePath,
                "pdr-export-" + entryFormat.split(" ")[0] + "-" + coords,
                stage,
                new FileChooser.ExtensionFilter("Zip file (*.zip)", "*.zip"));
        if (zip != null) {
            updateLastSavePath(zip.getParent());
            toZip(zip, coords + entryFormat);
        }
    }
}
项目:programmierpraktikum-abschlussprojekt-team-2    文件:RootLayoutController.java   
@FXML
private void changeLanguage(ActionEvent event) {
    List<String> choices = new ArrayList<>();
    choices.add("English");
    choices.add("Deutsch");

    ChoiceDialog<String> dialog = new ChoiceDialog<>("English", choices);
    dialog.setTitle(resources.getString("languagedialog.title"));
    dialog.setHeaderText(resources.getString("languagedialog.headerText"));
    dialog.setContentText(resources.getString("languagedialog.contentText"));

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

    Locale locale = result.isPresent() && result.get().equals("English") ? new Locale("en", "EN")
            : result.isPresent() && result.get().equals("Deutsch") ? new Locale("de", "DE") : resources.getLocale();

    if (!resources.getLocale().toString().equals(locale.toString().substring(0, 2))) {

        this.resources = ResourceBundle.getBundle("bundles.tddt", locale);
        bus.post(new LanguageChangeEvent(resources));
        phaseManager.resetPhase();
    }

}
项目:knitcap    文件:DeviceDialog.java   
void show(Config config) {
    try {
        List<PcapNetworkInterface> devices = Pcaps.findAllDevs();
        List<String> names = devices.stream().map(PcapNetworkInterface::getName).collect(Collectors.toList());
        ChoiceDialog<String> dialog = new ChoiceDialog<>(names.get(0), names);
        dialog.initModality(Modality.WINDOW_MODAL);
        dialog.setResizable(false);
        dialog.setHeaderText("Choose a network interface:");
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            config.setDevice(dialog.getSelectedItem());
            MainWindow app = new MainWindow("Knitcap");
            app.start(config);
        }
    } catch (PcapNativeException e) {
        e.printStackTrace();
    }
}
项目:keymix    文件:Controller.java   
@FXML protected void removeFiles(ActionEvent event) {
    ChoiceDialog<File> dialog = new ChoiceDialog<>(new File(DEFAULT_OPTION), importedSounds);
    dialog.setTitle("Delete Sample");
    dialog.setHeaderText("Choose what sample you would like to delete");
    dialog.setContentText("Sample:");

    Optional<File> result = dialog.showAndWait();
    result.ifPresent(file -> {
        if (!file.toString().equals(DEFAULT_OPTION)) {
            importedSounds.remove(file);
            message.setText(file.getName() + " was removed.");
        }
    });

    event.consume();
}
项目:programmierpraktikum-abschlussprojekt-halt-doch-einfach-mal-dein-maul    文件:WarningUnit.java   
public String askForBabySteps() {
    List<String> Optionen = new ArrayList<>();
    Optionen.add("Keine BabySteps aktivieren");
    Optionen.add("1:00 Minuten");
    Optionen.add("2:00 Minuten");
    Optionen.add("2:30 Minuten");
    Optionen.add("3:00 Minuten");
    Optionen.add("4:00 Minuten");
    ChoiceDialog<String> dialog = new ChoiceDialog<>("Keine BabySteps aktivieren", Optionen);
    dialog.setTitle("BabySteps");
    dialog.setHeaderText("M" + "\u00F6" + "chtest du BabySteps aktivieren ?\n" +
            "Bei BabySteps wird die Zeit zum Code Schreiben limitiert.");
    dialog.setContentText("Bitte w" + "\u00E4" + "hle deine gew" + "\u00FC" + "nschte Zeit:");
    Optional<String> Auswahl = dialog.showAndWait();
    if (Auswahl.isPresent()) {
        return Auswahl.get();
    }
    return "";
}
项目:Turnierserver    文件:Dialog.java   
/**
 * Öffnet einen Dialog, in dem der Spieler auswählen kann,
 * zu welcher KI die hochzuladende Version hinzugefügt werden soll.
 * 
 * @return
 */
public static AiBase selectOwnVersion() {

    if (MainApp.ownOnlineAis == null)
        return null;

    ObservableList<AiBase> list = FXCollections.observableArrayList();
    list.addAll(MainApp.ownOnlineAis);
    list.add(new AiFake());

    ChoiceDialog<AiBase> dialog = new ChoiceDialog<>();
    dialog.getItems().addAll(list);
    dialog.setSelectedItem(list.get(0));
    dialog.setTitle("Version hochladen");
    dialog.setHeaderText("Wähle bitte eine KI aus, zu dem die Version hochgeladen werden soll.");
    dialog.setContentText("KI:");

    Optional<AiBase> result = dialog.showAndWait();
    if (result.isPresent()) {
        return result.get();
    }
    return null;
}
项目:nanobot    文件:MainController.java   
@FXML
public void handleScriptsButtonAction() {
    final ChoiceDialog<String> dialog = new ChoiceDialog<>(null, model.getScripts());
    dialog.initOwner(application.getPrimaryStage());
    dialog.setTitle("Scripts");
    dialog.setHeaderText("Select script to run");
    dialog.setContentText("Script:");
    dialog.setSelectedItem(model.getLastRunnedScript());
    final Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        try {
            model.runScript(result.get());
        } catch (final IllegalAccessException e) {
            logger.warning(e.getMessage());
        }
    }
}
项目:org.csstudio.display.builder    文件:JFXRepresentation.java   
@Override
public String showSelectionDialog(final Widget widget, final String title, final List<String> options)
{
    final Node node = JFXBaseRepresentation.getJFXNode(widget);
    final CompletableFuture<String> done = new CompletableFuture<>();
    execute( ()->
    {
        final ChoiceDialog<String> dialog = new ChoiceDialog<>(null, options);
        DialogHelper.positionDialog(dialog, node, -100, -50);

        dialog.setHeaderText(title);
        final Optional<String> result = dialog.showAndWait();
        done.complete(result.orElse(null));
    });
    try
    {
        return done.get();
    }
    catch (Exception ex)
    {
        logger.log(Level.WARNING, "Selection dialog ('" + title + ", ..') failed", ex);
    }
    return null;
}
项目:iText-GUI    文件:Controller.java   
private void pickStylerToConfigure(final List<Parameterizable> stylers) {
   if (stylers.size() == 1) {
      selectInCombo(stylers.get(0));
      return;
   } else if (stylers.isEmpty()) {
      selectInCombo(null);
      return;
   }
   List<ParameterizableWrapper> pw = new ArrayList<>(stylers.size());
   stylers.stream().forEach((p) -> {
      pw.add(new ParameterizableWrapper(p));
   });
   Dialog<ParameterizableWrapper> dialog = new ChoiceDialog<>(pw.get(0), pw);
   ButtonType bt = new ButtonType("choose", ButtonBar.ButtonData.OK_DONE);
   dialog.getDialogPane().getButtonTypes().clear();
   dialog.getDialogPane().getButtonTypes().add(bt);
   dialog.setTitle("Please choose");
   dialog.setHeaderText(null);
   dialog.setResizable(true);
   dialog.setContentText("choose the styler or condition you want to configure");
   Optional<ParameterizableWrapper> choice = dialog.showAndWait();
   if (choice.isPresent()) {
      selectInCombo(choice.get().p);
   }
}
项目:nonogram    文件:MainView.java   
@FXML
public void newGame(){
    ChoiceDialog<Integer> dialog = new ChoiceDialog<>(viewModel.sizeProperty().get(), viewModel.getSizeOptions());
    dialog.setTitle("New Game");
    dialog.setHeaderText("Start a new Game");
    dialog.setContentText("Choose the size:");

    Optional<Integer> result = dialog.showAndWait();
    result.ifPresent(size->{
        viewModel.sizeProperty().set(size);

        final ViewTuple<PuzzleView, PuzzleViewModel> viewTuple = FluentViewLoader.fxmlView(PuzzleView.class).load();

        final Parent view = viewTuple.getView();

        center.setMinSize(0,0);
        center.setPrefSize(0,0);

        if(view instanceof Region){
            center.setContent((Region) view);
        }
    });
}
项目:reta    文件:MessageDialog.java   
/**
 * @param parent
 *            dialog parent, if null default parent is used
 * @param message
 *            Question message to show
 * @param choices
 *            possible choices where {@link Pair} value is the choice label displayed
 * @return selected choice or null if canceled
 * @param <T>
 *            choice type
 */
public static <T> T showOptionsMessage(final Window parent, final String message,
        final Collection<Pair<T, String>> choices)
{
    final List<ChoiceWrapper<T>> choiceWrapper = choices.stream()
            .map((c) -> new ChoiceWrapper<T>(c.getKey(), c.getValue()))
            .collect(Collectors.toList());

    final ChoiceDialog<ChoiceWrapper<T>> dialog = new ChoiceDialog<ChoiceWrapper<T>>(choiceWrapper.get(0),
            choiceWrapper);
    initDialog(parent, dialog);
    dialog.setContentText(message);
    dialog.showAndWait();

    final ChoiceWrapper<T> result = dialog.getResult();

    return (result != null ? result.getValue() : null);
}
项目:Zong    文件:FilenameDialogFilter.java   
@Override public List<String> filter(List<String> values) {
    List<String> ret = new LinkedList<>();
    //when there is only one file, select it. when there is no file, also don't
    //show a dialog.
    if (values.size() < 2) {
        ret.addAll(values);
    }
    else {
        ChoiceDialog<String> dialog = new ChoiceDialog<>(values.get(0), values); //TODO: use Zong! dialog factory
        dialog.setContentText(Lang.getLabel(Voc.SelectDocument));
        Optional<String> selectedFile = dialog.showAndWait();
        //open file
        selectedFile.ifPresent(ret::add);
    }
    return ret;
}
项目:javaGMR    文件:JgmrGuiController.java   
private void initializeChoiceDialog() {
    newSaveFileDialog = new ChoiceDialog<>(null, playerGames);
    newSaveFileDialog.setTitle("Save file");
    newSaveFileDialog.setHeaderText("I see you played your turn");
    ((Stage) newSaveFileDialog.getDialogPane().getScene().getWindow()).setAlwaysOnTop(true);
    newSaveFileDialog.setContentText("Choose the game you would to submit to GMR");
}
项目:drd    文件:HeroCreatorController3.java   
public void handleAddItem(ActionEvent actionEvent) {
    ChoiceDialog<ChoiceEntry> dialog = new ChoiceDialog<>(null, item_registry);
    dialog.setTitle("Přidat item");
    dialog.setHeaderText("Výběr itemu");
    dialog.setContentText("Vyberte...");
    // Trocha čarování k získání reference na combobox abych ho mohl upravit
    final ComboBox<ChoiceEntry> comboBox = (ComboBox) (((GridPane) dialog.getDialogPane()
        .getContent())
        .getChildren().get(1));
    comboBox.setPrefWidth(100);
    comboBox.setButtonCell(new ChoiceEntryCell());
    comboBox.setCellFactory(param -> new ChoiceEntryCell());
    comboBox.setMinWidth(200);
    comboBox.setMinHeight(40);
    Optional<ChoiceEntry> result = dialog.showAndWait();
    result.ifPresent(choiceEntry -> {
        try {
            final Optional<ItemEntry> entry = items.stream()
                .filter(itemEntry -> itemEntry.getId().equals(choiceEntry.id.get()))
                .findFirst();
            if (!entry.isPresent()) {
                items.add(new ItemEntry(choiceEntry));
            }
        } catch (ItemException e) {
            e.printStackTrace();
        }
    });
}
项目:vars-annotation    文件:OldReferenceNumberBC.java   
private ChoiceDialog<String> getDialog() {
    if (dialog == null) {
        ResourceBundle i18n = toolBox.getI18nBundle();
        MaterialIconFactory iconFactory = MaterialIconFactory.get();
        Text icon = iconFactory.createIcon(MaterialIcon.EXPOSURE_NEG_1, "30px");
        dialog = new ChoiceDialog<>();
        dialog.setTitle(i18n.getString("buttons.oldnumber.dialog.title"));
        dialog.setHeaderText(i18n.getString("buttons.oldnumber.dialog.header"));
        dialog.setContentText(i18n.getString("buttons.oldnumber.dialog.content"));
        dialog.setGraphic(icon);
        dialog.getDialogPane().getStylesheets().addAll(toolBox.getStylesheets());
    }
    return dialog;
}
项目:AlertFX    文件:ChoiceBox.java   
/**
 * Shows the alert
 * @return String - Whatever the user selects
 */
public String show(){
    alert = new ChoiceDialog<>(null, choices);
    alert.initStyle(style);
    Optional<String> result = alert.showAndWait();
    return result.orElse(null);
}
项目:photometric-data-retriever    文件:FXMLUtils.java   
public static ChoiceDialog<String> showOptionDialog(Window owner, List<String> choices,
                                                    String title,
                                                    String header,
                                                    String content) {
    ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
    dialog.setTitle(title);
    dialog.setHeaderText(header);
    dialog.setContentText(content);
    return dialog;
}
项目:megan-ce    文件:GroupSamplesByCommand.java   
public void actionPerformed(ActionEvent event) {
    final Document doc = ((Director) getDir()).getDocument();
    final java.util.List<String> attributes = doc.getSampleAttributeTable().getUnhiddenAttributes();

    if (attributes.size() > 0) {
        final JFrame frame = getViewer().getFrame();
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                String defaultChoice = ProgramProperties.get("SetByAttribute", "");

                if (!attributes.contains(defaultChoice))
                    defaultChoice = attributes.get(0);

                ChoiceDialog<String> dialog = new ChoiceDialog<>(defaultChoice, attributes);

                dialog.setTitle("MEGAN6 " + getViewer().getClassName() + " choice");
                dialog.setHeaderText("Select attribute to group by");
                dialog.setContentText("Choose attribute:");

                if (frame != null) {
                    dialog.setX(frame.getX() + (frame.getWidth() - 200) / 2);
                    dialog.setY(frame.getY() + (frame.getHeight() - 200) / 2);
                }

                final Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    final String choice = result.get();
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            execute("groupBy attribute='" + choice + "';show window=groups;");
                        }
                    });
                }
            }
        });
    }
}
项目:megan-ce    文件:ColorSamplesByCommand.java   
public void actionPerformed(ActionEvent event) {
    final Document doc = ((Director) getDir()).getDocument();
    final java.util.List<String> attributes = doc.getSampleAttributeTable().getUnhiddenAttributes();

    if (attributes.size() > 0) {
        final JFrame frame = getViewer().getFrame();
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                String defaultChoice = ProgramProperties.get("SetByAttribute", "");

                if (!attributes.contains(defaultChoice))
                    defaultChoice = attributes.get(0);

                final ChoiceDialog<String> dialog = new ChoiceDialog<>(defaultChoice, attributes);
                dialog.setTitle("MEGAN6 " + getViewer().getClassName() + " choice");
                dialog.setHeaderText("Select attribute to color by");
                dialog.setContentText("Choose attribute:");

                if (frame != null) {
                    dialog.setX(frame.getX() + (frame.getWidth() - 200) / 2);
                    dialog.setY(frame.getY() + (frame.getHeight() - 200) / 2);
                }

                final Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    final String choice = result.get();
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            execute("colorBy attribute='" + choice + "';");
                        }
                    });
                }
            }
        });
    }
}
项目:megan-ce    文件:ShapeSamplesByCommand.java   
public void actionPerformed(ActionEvent event) {
    final Document doc = ((Director) getDir()).getDocument();
    final java.util.List<String> attributes = doc.getSampleAttributeTable().getUnhiddenAttributes();

    if (attributes.size() > 0) {
        final JFrame frame = getViewer().getFrame();
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                String defaultChoice = ProgramProperties.get("SetByAttribute", "");

                if (!attributes.contains(defaultChoice))
                    defaultChoice = attributes.get(0);

                ChoiceDialog<String> dialog = new ChoiceDialog<>(defaultChoice, attributes);
                dialog.setTitle("MEGAN6 " + getViewer().getClassName() + " choice");
                dialog.setHeaderText("Select attribute to shape by");
                dialog.setContentText("Choose attribute:");

                if (frame != null) {
                    dialog.setX(frame.getX() + (frame.getWidth() - 200) / 2);
                    dialog.setY(frame.getY() + (frame.getHeight() - 200) / 2);
                }

                final Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    final String choice = result.get();
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            execute("shapeBy attribute='" + choice + "';");
                        }
                    });
                }
            }
        });
    }
}
项目:megan-ce    文件:LabelSamplesByCommand.java   
public void actionPerformed(ActionEvent event) {
    final Document doc = ((Director) getDir()).getDocument();
    final java.util.List<String> attributes = doc.getSampleAttributeTable().getUnhiddenAttributes();

    if (attributes.size() > 0) {
        final JFrame frame = getViewer().getFrame();
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                String defaultChoice = ProgramProperties.get("SetByAttribute", "");

                if (!attributes.contains(defaultChoice))
                    defaultChoice = attributes.get(0);

                ChoiceDialog<String> dialog = new ChoiceDialog<>(defaultChoice, attributes);
                dialog.setTitle("MEGAN6 " + getViewer().getClassName() + " choice");
                dialog.setHeaderText("Select attribute to label by");
                dialog.setContentText("Choose attribute:");

                if (frame != null) {
                    dialog.setX(frame.getX() + (frame.getWidth() - 200) / 2);
                    dialog.setY(frame.getY() + (frame.getHeight() - 200) / 2);
                }

                final Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    final String choice = result.get();
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            execute("labelBy attribute='" + choice + "';");
                        }
                    });
                }
            }
        });
    }
}
项目:megan-ce    文件:PasteByAttributeCommand.java   
public void actionPerformed(ActionEvent event) {
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            SamplesViewer samplesViewer = (SamplesViewer) getViewer();
            final java.util.List<String> list = getDoc().getSampleAttributeTable().getUnhiddenAttributes();
            if (list.size() > 0) {
                String choice = ProgramProperties.get("PasteByAttribute", list.get(0));
                if (!list.contains(choice))
                    choice = list.get(0);

                final ChoiceDialog<String> dialog = new ChoiceDialog<>(choice, list);
                dialog.setTitle("Paste By Attribute");
                dialog.setHeaderText("Select an attribute to guide paste");
                Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    final String selected = result.get();
                    try {
                        ProgramProperties.put("PasteByAttribute", selected);
                        samplesViewer.getSamplesTable().pasteClipboardByAttribute(selected);
                        samplesViewer.getSamplesTable().getDataGrid().save(samplesViewer.getSampleAttributeTable(), null);
                        samplesViewer.getCommandManager().updateEnableStateFXItems();
                        if (!samplesViewer.getDocument().isDirty() && samplesViewer.getSamplesTable().getDataGrid().isChanged(samplesViewer.getSampleAttributeTable())) {
                            samplesViewer.getDocument().setDirty(true);
                            samplesViewer.setWindowTitle();
                        }
                    } catch (IOException e) {
                        Basic.caught(e);
                    }
                }
            }
        }
    });
}
项目:megan-ce    文件:SetSampleShapeCommand.java   
/**
 * action to be performed
 *
 * @param ev
 */
public void actionPerformed(ActionEvent ev) {
    final SamplesViewer viewer = (SamplesViewer) getViewer();

    final Collection<String> selected = viewer.getSamplesTable().getSelectedSamples();

    if (selected.size() > 0) {
        String sample = selected.iterator().next();
        String shapeLabel = viewer.getSampleAttributeTable().getSampleShape(sample);
        NodeShape nodeShape = NodeShape.valueOfIgnoreCase(shapeLabel);
        if (nodeShape == null)
            nodeShape = NodeShape.Oval;
        final NodeShape nodeShape1 = nodeShape;

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                final ChoiceDialog<NodeShape> dialog = new ChoiceDialog<>(nodeShape1, NodeShape.values());
                dialog.setTitle("MEGAN choice");
                dialog.setHeaderText("Choose shape to represent sample(s)");
                dialog.setContentText("Shape:");

                final Optional<NodeShape> result = dialog.showAndWait();
                if (result.isPresent()) {
                    execute("set nodeShape=" + result.get() + " sample='" + Basic.toString(selected, "' '") + "';");
                }
            }
        };
        if (Platform.isFxApplicationThread())
            runnable.run();
        else
            Platform.runLater(runnable);
    }
}
项目:StorageSystem    文件:Alerter.java   
/**
 * returns the selected Choice of the choices array
 * @param title
 * @param header
 * @param content
 * @return
 */
public static Optional<String> getChoiceDialog(String title, String header, String content) {

    log.info("GetAlert called with: " + title + " - " + header + " - " + content);

    ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
    dialog.setTitle(title);
    dialog.setHeaderText(header);
    dialog.setContentText(content);

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

    return result;
}
项目:knitcap    文件:WindowSizeDialog.java   
public void show(Config config) {
    List<String> screenSizeList = new ArrayList<>();
    screenSizeList.add("1280x720");
    screenSizeList.add("1920x1080");
    ChoiceDialog<String> dialog = new ChoiceDialog<>(screenSizeList.get(0), screenSizeList);
    dialog.initModality(Modality.WINDOW_MODAL);
    dialog.setResizable(false);
    dialog.setHeaderText("Choose a window size:");
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        config.setScreenSize(dialog.getSelectedItem());
        DeviceDialog deviceDialog = new DeviceDialog();
        deviceDialog.show(config);
    }
}
项目:keymix    文件:Controller.java   
@FXML protected void clickLetter(ActionEvent event) {
    String id = ((Node)event.getTarget()).idProperty().getValue();

    ChoiceDialog<File> dialog = new ChoiceDialog<>(new File(DEFAULT_OPTION), importedSounds);
    dialog.setTitle("Choose Sample");
    dialog.setHeaderText("Choose what sample you would like to map to letter " + id);
    dialog.setContentText("Sample:");

    Optional<File> result = dialog.showAndWait();
    result.ifPresent(file -> this.mapKey(file, id));

    event.consume();
}
项目:qupath    文件:DisplayHelpers.java   
public static <T> T showChoiceDialog(final String title, final String message, final T[] choices, final T defaultChoice) {
    if (Platform.isFxApplicationThread()) {
        ChoiceDialog<T> dialog = new ChoiceDialog<>(defaultChoice, choices);
        dialog.setTitle(title);
        dialog.getDialogPane().setHeaderText(null);
        if (message != null)
            dialog.getDialogPane().setContentText(message);
        Optional<T> result = dialog.showAndWait();
        if (result.isPresent())
            return result.get();
        return null;
    } else
        return (T)JOptionPane.showInputDialog(getPossibleParent(), message, title, JOptionPane.PLAIN_MESSAGE, null, choices, defaultChoice);
}
项目:TranslationHelper    文件:JFXLocaleChooserController.java   
private void showLocaleDialog(Consumer<String> callback) {
    final String[] localeChoices = localeOptionCache.toArray(new String[localeOptionCache.size()]);
    Arrays.sort(localeChoices);
    ChoiceDialog<String> dialog = new ChoiceDialog<>(localeChoices[0], localeChoices);
    dialog.initOwner(owner);
    dialog.setHeaderText("Choose a Language");
    dialog.setContentText("");
    dialog.show();
    dialog.setOnCloseRequest(evt -> {
        dialog.close();
        dialog.getOwner().requestFocus();
        callback.accept(dialog.getSelectedItem());
    });
}
项目:mars-sim    文件:MarsNode.java   
public Button createGreenhouseDialog(Farming farm) {
    String name = farm.getBuilding().getNickName();
    Button b = new Button(name);
    b.setMaxWidth(Double.MAX_VALUE);

     List<String> choices = new ArrayList<>();
     choices.add("Lettuce");
     choices.add("Green Peas");
     choices.add("Carrot");

     ChoiceDialog<String> dialog = new ChoiceDialog<>("List of Crops", choices);
     dialog.setTitle(name);
     dialog.setHeaderText("Plant a Crop");
     dialog.setContentText("Choose Your Crop:");
     dialog.initOwner(stage); // post the same icon from stage
     dialog.initStyle(StageStyle.UTILITY);
     //dialog.initModality(Modality.NONE);

    b.setPadding(new Insets(20));
    b.setId("settlement-node");
    b.getStylesheets().add("/fxui/css/settlementnode.css");
    b.setOnAction(e->{
        // The Java 8 way to get the response value (with lambda expression).
        Optional<String> selected = dialog.showAndWait();
        selected.ifPresent(crop -> System.out.println("Crop added to the queue: " + crop));
    });

   //ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
   //ButtonType buttonTypeOk = new ButtonType("OK", ButtonData.OK_DONE);
   //dialog.getButtonTypes().setAll(buttonTypeCancel, buttonTypeOk);

    return b;
}
项目:nanobot    文件:MainController.java   
private String select(final String str, final String[] options) {
    final String[] toReturn = new String[1];
    platformRunNow(() -> {
        final ChoiceDialog<String> dialog = new ChoiceDialog<>(null, options);
        dialog.initOwner(application.getPrimaryStage());
        dialog.setHeaderText(str);
        final Optional<String> result = dialog.showAndWait();
        toReturn[0] = result.isPresent() ? result.get() : null;
    });
    return toReturn[0];
}
项目:SimpleTaskList    文件:NewEditDialogController.java   
/**
 * Handle a click on the "select context" button: open a selection dialog
 * and add the selected context to the list.
 */
@FXML
private void handleSelectContext() {
    if (!contexts.isEmpty()) {
        final ChoiceDialog<String> choice = new ChoiceDialog<String>(contexts.get(0), contexts);
        AbstractDialogController.prepareDialog(choice, "dialog.context.select.title",
                "dialog.context.select.header", "dialog.context.select.content",
                getCurrentWindowData());
        final Optional<String> text = choice.showAndWait();
        if (text.isPresent() && !listviewContext.getItems().contains(text.get())) {
            listviewContext.getItems().add(text.get());
        }
    }
}
项目:SimpleTaskList    文件:NewEditDialogController.java   
/**
 * Handle a click on the "select project" button: open a selection dialog
 * and add the selected project to the list.
 */
@FXML
private void handleSelectProject() {
    if (!projects.isEmpty()) {
        final ChoiceDialog<String> choice = new ChoiceDialog<String>(projects.get(0), projects);
        AbstractDialogController.prepareDialog(choice, "dialog.project.select.title",
                "dialog.project.select.header", "dialog.project.select.content",
                getCurrentWindowData());
        final Optional<String> text = choice.showAndWait();
        if (text.isPresent() && !listviewProject.getItems().contains(text.get())) {
            listviewProject.getItems().add(text.get());
        }
    }
}
项目:CloudTrailViewer    文件:DialogUtils.java   
public static Optional<String> showChoiceDialog(String title, String message, List<String> choices) {

        ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
        dialog.setTitle(title);
        dialog.setHeaderText(message);

        return dialog.showAndWait();
    }
项目:mars-sim    文件:MultiplayerMode.java   
public ChoiceDialog<String> getChoiceDialog() {
    return dialog;
}
项目:vidada-desktop    文件:ApplicationFX.java   
private void configLocalServerDatabase(){

        final VidadaServerSettings settings = VidadaServerSettings.instance();

        if(!settings.autoConfigDatabase()){

            logger.info("Vidada instance / Database must be selected by user.");

            ThreadUtil.runUIThreadWait(() -> {

                ChoiceDialog<VidadaDatabaseConfig> dialog = new StyledChoiceDialog<>(settings.getAvaiableDatabases().get(0), settings.getAvaiableDatabases());
                dialog.setTitle("Vidada-Server Database Chooser");
                dialog.setHeaderText("Choose the media database which you want to open.");

                dialog.showAndWait().ifPresent(config -> settings.setCurrentDBConfig(config));
            });


        }else{
            logger.info("Instance / Database automatically configured.");
        }
    }
项目:keyboard-light-composer    文件:DialogUtil.java   
public static <T> T select(Window owner, String title, String headerText, String contentText,
        Collection<T> choices) {

    Dialog<T> dialog = new ChoiceDialog<T>(null, choices);

    setupDialog(owner, title, headerText, contentText, dialog);

    return dialog.showAndWait().orElse(null);

}
项目:vidada-desktop    文件:ApplicationFX.java   
private VidadaInstanceConfig configInstance(){

        List<VidadaInstanceConfig> allVidadaInstanceConfigs = new ArrayList<>(VidadaClientSettings.instance().getVidadaInstances());

        logger.info("Configuring Vidada Instance form found " + allVidadaInstanceConfigs.size() + " configurations.");


        if(allVidadaInstanceConfigs.size() > 1) {
            logger.info("Multiple instance configurations are available, user has to choose...");

            // Multiple instances to choose from
            ChoiceDialog<VidadaInstanceConfig> dialog = new StyledChoiceDialog<>(allVidadaInstanceConfigs.get(0), allVidadaInstanceConfigs);
            dialog.setTitle("Vidada Instance Chooser");
            dialog.setHeaderText("Choose to which Vidada Instance you want to connect.");

            dialog.showAndWait().ifPresent(config -> VidadaClientSettings.instance().setCurrentInstnace(config));

        }else if(allVidadaInstanceConfigs.size() == 1){
            logger.info("Automatically configure the only available instance.");
            VidadaClientSettings.instance().setCurrentInstnace(allVidadaInstanceConfigs.get(0));
        }else if(allVidadaInstanceConfigs.size() == 0){
            logger.warn("No instance configuration found. Check your client settings!");
        }

        logger.debug("Vidada instance configured.");

        return VidadaClientSettings.instance().getCurrentInstance();
    }