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

下面列出了怎么用javafx.scene.control.ButtonType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: OpenLabeler   文件: TrainingPane.java
public void onCreateTrainData(ActionEvent actionEvent) {
    Settings.setTFImageDir(dirTFImage.getText());
    Settings.setTFAnnotationDir(dirTFAnnotation.getText());
    Settings.setTFDataDir(dirTFData.getText());
    File dataDir = new File(Settings.getTFDataDir());
    if (dataDir.isDirectory() && dataDir.exists()) {
        var res = AppUtils.showConfirmation(bundle.getString("label.alert"), bundle.getString("msg.confirmCreateTrainData"));
        if (res.get() != ButtonType.OK) {
            return;
        }
    }
    btnCreateTrainData.setDisable(true);
    TFTrainer.createTrainData(labelMapPane.getItems());
    AppUtils.showInformation(bundle.getString("label.alert"), bundle.getString("msg.trainDataCreated"));
    btnCreateTrainData.setDisable(false);
}
 
源代码2 项目: constellation   文件: QueryListDialog.java
static String getQueryName(final Object owner, final String[] labels) {
    final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
    dialog.setTitle("Saved JDBC parameters");

    final ObservableList<String> q = FXCollections.observableArrayList(labels);
    final ListView<String> labelList = new ListView<>(q);
    labelList.setEditable(false);
    labelList.setOnMouseClicked(event -> {
        if (event.getClickCount() > 1) {
            dialog.setResult(ButtonType.OK);
        }
    });

    dialog.setResizable(false);
    dialog.setHeaderText("Select a parameter set to load.");
    dialog.getDialogPane().setContent(labelList);
    final Optional<ButtonType> option = dialog.showAndWait();
    if (option.isPresent() && option.get() == ButtonType.OK) {
        return labelList.getSelectionModel().getSelectedItem();
    }

    return null;
}
 
源代码3 项目: mcaselector   文件: DialogHelper.java
public static void importChunks(TileMap tileMap, Stage primaryStage) {
	File dir = createDirectoryChooser(FileHelper.getLastOpenedDirectory("chunk_import_export")).showDialog(primaryStage);
	DataProperty<ImportConfirmationDialog.ChunkImportConfirmationData> dataProperty = new DataProperty<>();
	if (dir != null) {
		Optional<ButtonType> result = new ImportConfirmationDialog(primaryStage, dataProperty::set).showAndWait();
		result.ifPresent(r -> {
			if (r == ButtonType.OK) {
				FileHelper.setLastOpenedDirectory("chunk_import_export", dir.getAbsolutePath());
				new CancellableProgressDialog(Translation.DIALOG_PROGRESS_TITLE_IMPORTING_CHUNKS, primaryStage)
						.showProgressBar(t -> ChunkImporter.importChunks(
								dir, t, false, dataProperty.get().overwrite(),
								dataProperty.get().selectionOnly() ? tileMap.getMarkedChunks() : null,
								dataProperty.get().getRanges(),
								dataProperty.get().getOffset()));
				CacheHelper.clearAllCache(tileMap);
			}
		});
	}
}
 
源代码4 项目: qiniu   文件: DialogUtils.java
public static Optional<ButtonType> showException(String header, Exception e) {
    // 获取一个警告对象
    Alert alert = getAlert(header, "错误信息追踪:", AlertType.ERROR);
    // 打印异常信息
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    e.printStackTrace(printWriter);
    String exception = stringWriter.toString();
    // 显示异常信息
    TextArea textArea = new TextArea(exception);
    textArea.setEditable(false);
    textArea.setWrapText(true);
    // 设置弹窗容器
    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);
    GridPane gridPane = new GridPane();
    gridPane.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(textArea, 0, 0);
    alert.getDialogPane().setExpandableContent(gridPane);
    return alert.showAndWait();
}
 
源代码5 项目: marathonv5   文件: FileResource.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 `" + path + "`?", "Confirm", AlertType.CONFIRMATION,
                ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
    }
    if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
        if (Files.exists(path)) {
            try {
                Files.delete(path);
                Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, this));
                getParent().getChildren().remove(this);
            } catch (IOException e) {
                String message = String.format("Unable to delete: %s: %s%n", path, e);
                FXUIUtils.showMessageDialog(null, message, "Unable to delete", AlertType.ERROR);
            }
        }
    }
    return option;
}
 
源代码6 项目: pikatimer   文件: FXMLTimingController.java
public void resetTimingLocations(ActionEvent fxevent){
    // prompt 
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Confirm Resetting all Timing Locations");
    alert.setHeaderText("This action cannot be undone.");
    alert.setContentText("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations.");
    //Label alertContent = new Label("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations.");
    //alertContent.setWrapText(true); 
    //alert.getDialogPane().setContent(alertContent);
    
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        timingDAO.createDefaultTimingLocations();
    } else {
        // ... user chose CANCEL or closed the dialog
    }
    
    timingLocAddButton.requestFocus();
    //timingLocAddButton.setDefaultButton(true);
}
 
源代码7 项目: phoebus   文件: DeleteLayoutsMenuItem.java
DeleteLayoutsDialog()
{
    setTitle(Messages.DeleteLayouts);
    setHeaderText(Messages.DeleteLayoutsInfo);

    list.getItems().setAll(memento_files);
    list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getDialogPane().setContent(list);
    getDialogPane().setMinSize(280, 500);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    final Button ok = (Button) getDialogPane().lookupButton(ButtonType.OK);
    ok.addEventFilter(ActionEvent.ACTION, event -> deleteSelected());

    setResultConverter(button -> true);
}
 
public static boolean infoBox(String infoMessage, String headerText, String title){
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setContentText(infoMessage);
    alert.setTitle(title);
    alert.setHeaderText(headerText);
    alert.getButtonTypes();
    
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        // ... user chose OK button
     return true;
    } else {
    // ... user chose CANCEL or closed the dialog
    return false;
    }
    
}
 
源代码9 项目: 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];
    }
}
 
源代码10 项目: phoebus   文件: PropertiesAction.java
public FilePropertiesDialog(final File file)
{
    this.file = file;
    setTitle(Messages.PropDlgTitle);
    setResizable(true);

    getDialogPane().setContent(createContent());
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    final Button ok = (Button) getDialogPane().lookupButton(ButtonType.OK);
    ok.addEventFilter(ActionEvent.ACTION, event ->
    {
        if (! updateFile())
            event.consume();
    });

    setResultConverter(button -> null);
}
 
源代码11 项目: MyBox   文件: TableManageController.java
@FXML
@Override
public void clearAction() {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(getBaseTitle());
    alert.setContentText(AppVariables.message("SureClear"));
    alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
    ButtonType buttonSure = new ButtonType(AppVariables.message("Sure"));
    ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
    alert.getButtonTypes().setAll(buttonSure, buttonCancel);
    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() != buttonSure) {
        return;
    }

    if (clearData()) {
        clearView();
        refreshAction();
    }
}
 
源代码12 项目: pcgen   文件: RadioChooserDialog.java
private void onOK(final ActionEvent ignored)
{
	Toggle selectedToggle = toggleGroup.getSelectedToggle();
	Logging.debugPrint("selected toggle is " + selectedToggle);
	if (selectedToggle != null)
	{
		Integer whichItemId = (Integer)selectedToggle.getUserData();
		InfoFacade selectedItem = chooser.getAvailableList().getElementAt(whichItemId);
		chooser.addSelected(selectedItem);
	}
	if (chooser.isRequireCompleteSelection() && (chooser.getRemainingSelections().get() > 0))
	{
		Dialog<ButtonType> alert = new Alert(Alert.AlertType.INFORMATION);
		alert.setTitle(chooser.getName());
		alert.setContentText(LanguageBundle.getFormattedString("in_chooserRequireComplete",
				chooser.getRemainingSelections().get()));
		alert.showAndWait();
		return;
	}
	chooser.commit();
	committed = true;
	this.dispose();
}
 
源代码13 项目: PreferencesFX   文件: PreferencesFxDialog.java
private void setupDialogClose() {
  dialog.setOnCloseRequest(e -> {
    LOGGER.trace("Closing because of dialog close request");
    ButtonType resultButton = (ButtonType) dialog.resultProperty().getValue();
    if (ButtonType.CANCEL.equals(resultButton)) {
      LOGGER.trace("Dialog - Cancel Button was pressed");
      model.discardChanges();
    } else {
      LOGGER.trace("Dialog - Close Button or 'x' was pressed");
      if (persistWindowState) {
        saveWindowState();
      }
      model.saveSettings();
    }
  });
}
 
源代码14 项目: PeerWasp   文件: SelectRootPathUtils.java
private static boolean askToCreateDirectory() {

		boolean yes = false;

		Alert dlg = DialogUtils.createAlert(AlertType.CONFIRMATION);
		dlg.setTitle("Create Directory");
		dlg.setHeaderText("Create the directory?");
		dlg.setContentText("The directory does not exist yet. Do you want to create it?");
		dlg.getButtonTypes().clear();
		dlg.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);

		dlg.showAndWait();
		yes = dlg.getResult() == ButtonType.YES;

		return yes;
	}
 
public void handleAddScan(Event e) {
  ParameterSet parameters =
      MZmineCore.getConfiguration().getModuleParameters(MsSpectrumPlotModule.class);
  ButtonType exitCode = parameters.showSetupDialog("Add scan");
  if (exitCode != ButtonType.OK)
    return;

  final RawDataFilesSelection fileSelection =
      parameters.getParameter(MsSpectrumPlotParameters.inputFiles).getValue();
  final Integer scanNumber =
      parameters.getParameter(MsSpectrumPlotParameters.scanNumber).getValue();
  final ScanSelection scanSelection =
      new ScanSelection(Range.singleton(scanNumber), null, null, null, null, null);
  final List<RawDataFile> dataFiles = fileSelection.getMatchingRawDataFiles();
  boolean spectrumAdded = false;
  for (RawDataFile dataFile : dataFiles) {
    for (MsScan scan : scanSelection.getMatchingScans(dataFile)) {
      String title = MsScanUtils.createSingleLineMsScanDescription(scan);
      addSpectrum(scan, title);
      spectrumAdded = true;
    }
  }
  if (!spectrumAdded) {
    MZmineGUI.displayMessage("Scan not found");
  }
}
 
public void removeTimingInput(ActionEvent fxevent){
    
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Clear Input...");
    alert.setHeaderText("Delete Input:");
    alert.setContentText("Do you want to remove the " +timingLocationInput.getLocationName() + " input?\nThis will clear all reads associated with this input.");

    ButtonType removeButtonType = new ButtonType("Remove",ButtonBar.ButtonData.YES);
    ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(cancelButtonType, removeButtonType );

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == removeButtonType) {
        boolean remove = ((VBox) baseGridPane.getParent()).getChildren().remove(baseGridPane);
        if (timingLocationInput != null) {
            timingLocationDAO.removeTimingLocationInput(timingLocationInput);
        }
    }
}
 
源代码17 项目: logbook-kai   文件: BattleLogScriptController.java
@FXML
void remove() {
    ButtonType result = Tools.Conrtols.alert(AlertType.CONFIRMATION,
            "スクリプトの削除", "このスクリプトを削除しますか?", this.getWindow())
            .orElse(null);
    if (!ButtonType.OK.equals(result)) {
        return;
    }

    BattleLogScript selected = this.list.getSelectionModel().getSelectedItem();
    if (selected != null) {
        this.list.getItems().remove(selected);
        BattleLogScriptCollection.get().getScripts().remove(selected);
    }
    if (this.current == selected) {
        this.setCurrent(null);
    }
}
 
源代码18 项目: pcgen   文件: DesktopBrowserLauncher.java
/**
 * View a URI in a browser.
 *
 * @param uri URI to display in browser.
 * @throws IOException if browser can not be launched
 */
private static void viewInBrowser(URI uri) throws IOException
{
	if (Desktop.isDesktopSupported() && DESKTOP.isSupported(Action.BROWSE))
	{
		DESKTOP.browse(uri);
	}
	else
	{
		Dialog<ButtonType> alert = GuiUtility.runOnJavaFXThreadNow(() ->  new Alert(Alert.AlertType.WARNING));
		Logging.debugPrint("unable to browse to " + uri);
		alert.setTitle(LanguageBundle.getString("in_err_browser_err"));
		alert.setContentText(LanguageBundle.getFormattedString("in_err_browser_uri", uri));
		GuiUtility.runOnJavaFXThreadNow(alert::showAndWait);
	}
}
 
源代码19 项目: WorkbenchFX   文件: DialogTestModule.java
private void initDialogParts() {
  // create the data to show in the CheckListView
  final ObservableList<String> libraries = FXCollections.observableArrayList();
  libraries.addAll("WorkbenchFX", "PreferencesFX", "CalendarFX", "FlexGanttFX", "FormsFX");

  // Create the CheckListView with the data
  checkListView = new CheckListView<>(libraries);

  // initialize map for dialog
  mapView = new GoogleMapView();
  mapView.addMapInializedListener(this);

  // initialize favorites dialog separately
  favoriteLibrariesDialog =
      WorkbenchDialog.builder("Select your favorite libraries", checkListView, Type.INPUT)
          .onResult(buttonType -> {
            if (ButtonType.CANCEL.equals(buttonType)) {
              System.err.println("Dialog was cancelled!");
            } else {
              System.err.println("Chosen favorite libraries: " +
                  checkListView.getCheckModel().getCheckedItems().stream().collect(
                      Collectors.joining(", ")));
            }
          }).build();
}
 
源代码20 项目: phoebus   文件: RemoveTagDialog.java
public RemoveTagDialog(final Node parent, final Collection<String> tags) {
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    setResizable(true);
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(this.getClass().getResource("SelectEntity.fxml"));
    try {
        getDialogPane().setContent(loader.load());
        SelectEntityController controller = loader.getController();
        controller.setAvaibleOptions(tags);
        setResultConverter(button -> {
            return button == ButtonType.OK
                    ? Tag.Builder.tag(controller.getSelectedOption()).build()
                    : null;
        });
    } catch (IOException e) {
        // TODO update the dialog
        logger.log(Level.WARNING, "Failed to remove tag", e);
    }
}
 
源代码21 项目: phoebus   文件: ScanEditor.java
@Override
public void execute(UndoableAction action)
{
    final ScanInfoModel infos = scan_info_model.get();
    if (infos != null)
    {
        // Warn that changes to the running scan are limited
        final Alert dlg = new Alert(AlertType.CONFIRMATION);
        dlg.setHeaderText("");
        dlg.setContentText(Messages.scan_active_prompt);
        dlg.setResizable(true);
        dlg.getDialogPane().setPrefSize(600, 300);
        DialogHelper.positionDialog(dlg, scan_tree, -100, -100);
        if (dlg.showAndWait().get() != ButtonType.OK)
            return;

        // Only property change is possible while running.
        // Adding/removing commands detaches from the running scan.
        if (! (action instanceof ChangeProperty))
            detachFromScan();
    }
    super.execute(action);
}
 
源代码22 项目: marathonv5   文件: DisplayWindow.java
private boolean closeEditor(IEditor e) {
    if (e == null) {
        return true;
    }
    if (e.isDirty()) {
        Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this,
                "File \"" + e.getName() + "\" Modified. Do you want to save the changes ",
                "File \"" + e.getName() + "\" Modified", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO,
                ButtonType.CANCEL);
        ButtonType shouldSaveFile = result.get();
        if (shouldSaveFile == ButtonType.CANCEL) {
            return false;
        }
        if (shouldSaveFile == ButtonType.YES) {
            File file = save(e);
            if (file == null) {
                return false;
            }
            EditorDockable dockable = (EditorDockable) e.getData("dockable");
            dockable.updateKey();
        }
    }
    return true;
}
 
源代码23 项目: AsciidocFX   文件: AlertHelper.java
public static void showDuplicateWarning(List<String> duplicatePaths, Path lib) {
    Alert alert = new WindowModalAlert(Alert.AlertType.WARNING);

    DialogPane dialogPane = alert.getDialogPane();

    ListView listView = new ListView();
    listView.getStyleClass().clear();
    ObservableList items = listView.getItems();
    items.addAll(duplicatePaths);
    listView.setEditable(false);

    dialogPane.setContent(listView);

    alert.setTitle("Duplicate JARs found");
    alert.setHeaderText(String.format("Duplicate JARs found, it may cause unexpected behaviours.\n\n" +
            "Please remove the older versions from these pair(s) manually. \n" +
            "JAR files are located at %s directory.", lib));
    alert.getButtonTypes().clear();
    alert.getButtonTypes().addAll(ButtonType.OK);
    alert.showAndWait();
}
 
源代码24 项目: MyBox   文件: BaseController.java
public boolean clearSettings() {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(getBaseTitle());
    alert.setContentText(AppVariables.message("SureClear"));
    alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
    ButtonType buttonSure = new ButtonType(AppVariables.message("Sure"));
    ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
    alert.getButtonTypes().setAll(buttonSure, buttonCancel);
    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() != buttonSure) {
        return false;
    }
    DerbyBase.clearData();
    cleanAppPath();
    AppVariables.initAppVaribles();
    return true;
}
 
源代码25 项目: phoebus   文件: DisplayEditorApplication.java
@Override
public DisplayEditorInstance create()
{
    if (!AuthorizationService.hasAuthorization("edit_display"))
    {
        // User does not have a permission to start editor
        final Alert alert = new Alert(Alert.AlertType.WARNING);
        DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100);
        alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow());
        alert.setResizable(true);
        alert.setTitle(DISPLAY_NAME);
        alert.setHeaderText(Messages.DisplayApplicationMissingRight);
        // Autohide in some seconds, also to handle the situation after
        // startup without edit_display rights but opening editor from memento
        PauseTransition wait = new PauseTransition(Duration.seconds(7));
        wait.setOnFinished((e) -> {
            Button btn = (Button)alert.getDialogPane().lookupButton(ButtonType.OK);
            btn.fire();
        });
        wait.play();
        
        alert.showAndWait();
        return null;
    }
    return new DisplayEditorInstance(this);
}
 
源代码26 项目: OEE-Designer   文件: DatabaseServerController.java
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		if (dataSource != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(dataSource);
			databaseServers.remove(dataSource);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
源代码27 项目: WorkbenchFX   文件: DialogControlTest.java
@Test
void getButton() {
  // when asking for a button type
  Optional<Button> button = dialogControl.getButton(BUTTON_TYPE_1);

  // returns its button in an Optional
  assertNotEquals(Optional.empty(), button);
  assertEquals(dialogControl.getButtons().get(0), button.get());

  // if the buttonType doesn't exist
  button = dialogControl.getButton(ButtonType.CANCEL);

  // return empty optional
  assertEquals(Optional.empty(), button);

  // if there are no buttonTypes
  buttonTypes.clear();
  button = dialogControl.getButton(BUTTON_TYPE_1);

  // return empty optional
  assertEquals(Optional.empty(), button);
}
 
源代码28 项目: old-mzmine3   文件: ManualZoomDialog.java
/**
 * Constructor
 */
public ManualZoomDialog(Window parent, XYPlot plot) {

  initOwner(parent);

  setTitle("Manual zoom");

  setGraphic(new ImageView("file:icons/axesicon.png"));

  getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

  xAxis = (NumberAxis) plot.getDomainAxis();
  yAxis = (NumberAxis) plot.getRangeAxis();

  try {
    URL layersDialogFXML = getClass().getResource(DIALOG_FXML);
    FXMLLoader loader = new FXMLLoader(layersDialogFXML);
    loader.setController(this);
    GridPane grid = loader.load();
    getDialogPane().setContent(grid);
  } catch (Exception e) {
    e.printStackTrace();
  }

  final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK);
  btOk.addEventFilter(ActionEvent.ACTION, event -> {
    commitChanges(event);
  });

}
 
源代码29 项目: 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;
        }
    }
}
 
源代码30 项目: G-Earth   文件: Authenticator.java
private static boolean askForPermission(NetworkExtension extension) {
    boolean[] allowConnection = {true};

    final String connectExtensionKey = "allow_extension_connection";

    if (ConfirmationDialog.showDialog(connectExtensionKey)) {
        boolean[] done = {false};
        Platform.runLater(() -> {
            Alert alert = ConfirmationDialog.createAlertWithOptOut(Alert.AlertType.WARNING, connectExtensionKey
                    ,"Confirmation Dialog", null,
                    "Extension \""+extension.getTitle()+"\" tries to connect but isn't known to G-Earth, accept this connection?", "Remember my choice",
                    ButtonType.YES, ButtonType.NO
            );

            if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) {
                allowConnection[0] = false;
            }
            done[0] = true;
            if (!ConfirmationDialog.showDialog(connectExtensionKey)) {
                rememberOption = allowConnection[0];
            }
        });

        while (!done[0]) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        return allowConnection[0];
    }

    return rememberOption;
}
 
 类所在包
 同包方法