javafx.scene.control.Alert.AlertType#CONFIRMATION源码实例Demo

下面列出了javafx.scene.control.Alert.AlertType#CONFIRMATION 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CircuitSim   文件: CircuitSim.java
boolean confirmAndDeleteCircuit(CircuitManager circuitManager, boolean removeTab) {
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.initOwner(stage);
	alert.initModality(Modality.WINDOW_MODAL);
	alert.setTitle("Delete \"" + circuitManager.getName() + "\"?");
	alert.setHeaderText("Delete \"" + circuitManager.getName() + "\"?");
	alert.setContentText("Are you sure you want to delete this circuit?");
	
	Optional<ButtonType> result = alert.showAndWait();
	if(!result.isPresent() || result.get() != ButtonType.OK) {
		return false;
	} else {
		deleteCircuit(circuitManager, removeTab, true);
		return true;
	}
}
 
源代码2 项目: 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);
}
 
源代码3 项目: JetUML   文件: EditorFrame.java
/**
 * If a user confirms that they want to close their modified graph, this method
 * will remove it from the current list of tabs.
 * 
 * @param pDiagramTab The current Tab that one wishes to close.
 */
public void close(DiagramTab pDiagramTab) 
{
	if(pDiagramTab.hasUnsavedChanges()) 
	{
		Alert alert = new Alert(AlertType.CONFIRMATION, RESOURCES.getString("dialog.close.ok"), ButtonType.YES, ButtonType.NO);
		alert.initOwner(aMainStage);
		alert.setTitle(RESOURCES.getString("dialog.close.title"));
		alert.setHeaderText(RESOURCES.getString("dialog.close.title"));
		alert.showAndWait();

		if (alert.getResult() == ButtonType.YES) 
		{
			removeGraphFrameFromTabbedPane(pDiagramTab);
		}
	}
	else
	{
		removeGraphFrameFromTabbedPane(pDiagramTab);
	}
}
 
源代码4 项目: Open-Lowcode   文件: ClientDisplay.java
/**
 * displays a modal popup and waits for answer
 * 
 * @param message    what to display as main message
 * @param yesmessage what to display on button for yes
 * @param nomessage  what to display on button for no
 * @return true if answer is yes, false if answer of the popup is false
 */
public boolean displayModalPopup(String message, String yesmessage, String nomessage) {
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.setTitle("Unsaved data warning");
	alert.setContentText("There is unsaved data. Do you want to continue and lose data ?");

	Optional<ButtonType> result = alert.showAndWait();
	if (result.get() == ButtonType.OK)
		return true;
	return false;
}
 
源代码5 项目: BetonQuest-Editor   文件: BetonQuestEditor.java
/**
 * Shows a confirmation pop-up window with specified translated message.
 * Returns result - true if the user confirms the action, false if he wants
 * to cancel it.
 *
 * @param message ID of message
 * @return true if confirmed, false otherwise
 */
public static boolean confirm(String message) {
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.setHeaderText(BetonQuestEditor.getInstance().getLanguage().getString(message));
	alert.getDialogPane().getStylesheets().add(instance.getClass().getResource("resource/style.css").toExternalForm());
	Optional<ButtonType> action = alert.showAndWait();
	if (action.isPresent() && action.get() == ButtonType.OK) {
		return true;
	}
	return false;
}
 
源代码6 项目: oim-fx   文件: UserHeadEditViewImpl.java
private void initEvent() {

		alert = new Alert(AlertType.CONFIRMATION, "");
		alert.initModality(Modality.APPLICATION_MODAL);
		alert.initOwner(frame);
		alert.getDialogPane().setContentText("确定选择");
		alert.getDialogPane().setHeaderText(null);

		frame.setWidth(430);
		frame.setHeight(580);
		frame.setResizable(false);
		frame.setTitlePaneStyle(2);
		frame.setTitle("选择头像");

		frame.setCenter(p);
		frame.show();


		p.setPrefWrapLength(400);
		p.showWaiting(true, WaitingPane.show_waiting);
		appContext.add(new ExecuteTask() {

			@Override
			public void execute() {
				init(p);
			}
		});
	}
 
源代码7 项目: Path-of-Leveling   文件: MainApp_Controller.java
public boolean custom_editor_exit_with_validate(){
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Save changes");
    alert.setHeaderText("Any changes you made will be saved upon exit.");
    alert.setContentText("Are you ok with this?");

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        return validateToLauncher();
    }else{
        parent.returnToLauncher();
        return true;
    }
}
 
源代码8 项目: GitFx   文件: GitFxDialog.java
public void gitConfirmationDialog(String title, String header, String content) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(content);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        setResponse(GitFxDialogResponse.OK);
    } else {
        setResponse(GitFxDialogResponse.CANCEL);
    }
}
 
源代码9 项目: kafka-message-tool   文件: UserGuiInteractor.java
@Override
public boolean getYesNoDecision(String title,
                                String header,
                                String content) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.initOwner(owner);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.getDialogPane().setContent(getTextNodeContent(content));

    decorateWithCss(alert);

    Optional<ButtonType> result = alert.showAndWait();
    return result.get() == ButtonType.OK;
}
 
源代码10 项目: 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();
				return saveFile == null;
			} else {
				return result.get() == ButtonType.CANCEL;
			}
		}
	}
	
	return false;
}
 
源代码11 项目: java-ml-projects   文件: AppUtils.java
public static boolean askIfOk(String msg) {
	Alert dialog = new Alert(AlertType.CONFIRMATION);
	dialog.setTitle("Confirmation");
	dialog.setResizable(true);
	dialog.setContentText(msg);
	dialog.setHeaderText(null);
	dialog.showAndWait();
	return dialog.getResult() == ButtonType.OK;
}
 
源代码12 项目: gluon-samples   文件: CommentListCell.java
/**
 * Create a Dialog for getting deletion confirmation
 * @param item Item to be deleted
 */
private void showDialog(Comment item) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitleText("Confirm deletion");
    alert.setContentText("This comment will be deleted permanently.\nDo you want to continue?");
    
    Button yes = new Button("Yes, delete permanently");
    yes.setOnAction(e -> {
        alert.setResult(ButtonType.YES); 
        alert.hide();
    });
    yes.setDefaultButton(true);
    
    Button no = new Button("No");
    no.setCancelButton(true);
    no.setOnAction(e -> {
        alert.setResult(ButtonType.NO); 
        alert.hide();
    });
    alert.getButtons().setAll(yes, no);
    
    Optional result = alert.showAndWait();
    if (result.isPresent() && result.get().equals(ButtonType.YES)) {
        /*
        With confirmation, delete the item from the ListView. This will be
        propagated to the Cloud, and from there to the rest of the clients
        */
        listViewProperty().get().getItems().remove(item);
    }
}
 
private void deleteSnapshots(ObservableList<Node> selectedItems) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(Messages.promptDeleteSelectedTitle);
    alert.setHeaderText(Messages.promptDeleteSelectedHeader);
    alert.setContentText(Messages.promptDeleteSelectedContent);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.isPresent() && result.get().equals(ButtonType.OK)) {
        selectedItems.stream().forEach(item -> deleteListItem(item));
    }
}
 
源代码14 项目: JetUML   文件: EditorFrame.java
/**
 * Exits the program if no graphs have been modified or if the user agrees to
 * abandon modified graphs.
 */
public void exit() 
{
	final int modcount = getNumberOfUsavedDiagrams();
	if (modcount > 0) 
	{
		Alert alert = new Alert(AlertType.CONFIRMATION, 
				MessageFormat.format(RESOURCES.getString("dialog.exit.ok"), new Object[] { Integer.valueOf(modcount) }),
				ButtonType.YES, 
				ButtonType.NO);
		alert.initOwner(aMainStage);
		alert.setTitle(RESOURCES.getString("dialog.exit.title"));
		alert.setHeaderText(RESOURCES.getString("dialog.exit.title"));
		alert.showAndWait();

		if (alert.getResult() == ButtonType.YES) 
		{
			Preferences.userNodeForPackage(UMLEditor.class).put("recent", aRecentFiles.serialize());
			System.exit(0);
		}
	}
	else 
	{
		Preferences.userNodeForPackage(UMLEditor.class).put("recent", aRecentFiles.serialize());
		System.exit(0);
	}
}
 
源代码15 项目: pikatimer   文件: FXMLParticipantController.java
public void clearParticipants(ActionEvent fxevent){
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Confirm Participant Removal");
    alert.setHeaderText("This will remove all Participants from the event.");
    alert.setContentText("This action cannot be undone. Are you sure you want to do this?");

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        participantDAO.clearAll();
        resetForm(); 
    } else {
        // ... user chose CANCEL or closed the dialog
    }
    
}
 
源代码16 项目: phoebus   文件: PhoebusApplication.java
/** Close the main stage
 *
 *  <p>If there are more stages open, warn user that they will be closed.
 *
 *  <p>When called from the onCloseRequested handler of the primary stage, we must
 *  _not_ send another close request to it because that would create an infinite
 *  loop.
 *
 *  @param main_stage_already_closing
 *            Primary stage when called from its onCloseRequested handler, else <code>null</code>
 *  @return <code>true</code> on success, <code>false</code> when some panel doesn't want to close
 */
private boolean closeMainStage(final Stage main_stage_already_closing)
{
    final List<Stage> stages = DockStage.getDockStages();

    if (stages.size() > 1)
    {
        final Alert dialog = new Alert(AlertType.CONFIRMATION);
        dialog.setTitle(Messages.ExitTitle);
        dialog.setHeaderText(Messages.ExitHdr);
        dialog.setContentText(Messages.ExitContent);
        DialogHelper.positionDialog(dialog, stages.get(0).getScene().getRoot(), -200, -200);
        if (dialog.showAndWait().orElse(ButtonType.CANCEL) != ButtonType.OK)
            return false;
    }

    // If called from the main stage that's already about to close,
    // skip that one when closing all stages
    if (main_stage_already_closing != null)
        stages.remove(main_stage_already_closing);

    // Save current state, _before_ tabs are closed and thus
    // there's nothing left to save
    final File memfile = XMLMementoTree.getDefaultFile();
    MementoHelper.saveState(memfile, last_opened_file, default_application, isMenuVisible(), isToolbarVisible());

    if (!closeStages(stages))
        return false;

    // Once all other stages are closed,
    // potentially check the main stage.
    if (main_stage_already_closing != null && !DockStage.isStageOkToClose(main_stage_already_closing))
        return false;
    return true;
}
 
源代码17 项目: phoebus   文件: AlertWithToggleDemo.java
@Override
public void start(final Stage stage)
{
    AlertWithToggle dialog = new AlertWithToggle(AlertType.CONFIRMATION, "Test",
            "This is a test\nAnother line");
    System.out.println("Selected: " + dialog.showAndWait());
    System.out.println("Hide from now on: " + dialog.isHideSelected());

    dialog = new AlertWithToggle(AlertType.WARNING,
            "Just using\nheader text",
            "");
    System.out.println("Selected: " + dialog.showAndWait());
    System.out.println("Hide from now on: " + dialog.isHideSelected());

}
 
源代码18 项目: pikatimer   文件: FXMLTimingController.java
public void clearAllTimes(ActionEvent fxevent){
    //TODO: Prompt and then remove all times associated with that timing location 
    // _or_ all timing locations
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Clear Timing Data...");
    alert.setHeaderText("Clear Timing Data:");
    alert.setContentText("Do you want to clear the times for all locations or just the " + selectedTimingLocation.getLocationName()+ " location?");

    ButtonType allButtonType = new ButtonType("All Times");
    
    ButtonType currentButtonType = new ButtonType(selectedTimingLocation.getLocationName() + " Times",ButtonData.YES);
    ButtonType cancelButtonType = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(cancelButtonType, allButtonType,  currentButtonType );

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == allButtonType){
        // ... user chose All
        timingDAO.clearAllTimes();
        // itterate over all of the timing locations
        timingLocationList.stream().forEach(tl -> {tl.getInputs().stream().forEach(tli -> {tli.clearLocalReads();});});
    } else if (result.get() == currentButtonType) {
        // ... user chose "Two"
        selectedTimingLocation.getInputs().stream().forEach(tli -> {tli.clearReads();});
    } else {
        // ... user chose CANCEL or closed the dialog
    }
 
}
 
源代码19 项目: mzmine3   文件: DialogLoggerUtil.java
public static boolean showDialogYesNo(String title, String message) {
  Alert alert = new Alert(AlertType.CONFIRMATION, message, ButtonType.YES, ButtonType.NO);
  alert.setTitle(title);
  Optional<ButtonType> result = alert.showAndWait();
  return (result.isPresent() && result.get() == ButtonType.YES);
}
 
源代码20 项目: chart-fx   文件: AbstractChartMeasurement.java
public AbstractChartMeasurement(final ParameterMeasurements plugin, final String measurementName, final AxisMode axisMode, final int requiredNumberOfIndicators,
        final int requiredNumberOfDataSets) {
    if (plugin == null) {
        throw new IllegalArgumentException("plugin is null");
    }
    this.plugin = plugin;
    this.measurementName = measurementName;
    this.axisMode = axisMode;
    this.requiredNumberOfIndicators = requiredNumberOfIndicators;
    this.requiredNumberOfDataSets = requiredNumberOfDataSets;

    plugin.getChartMeasurements().add(this);

    alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Measurement Config Dialog");
    alert.setHeaderText("Please, select data set and/or other parameters:");
    alert.initModality(Modality.APPLICATION_MODAL);

    final DecorationPane decorationPane = new DecorationPane();
    decorationPane.getChildren().add(gridPane);
    alert.getDialogPane().setContent(decorationPane);
    alert.getButtonTypes().setAll(buttonOK, buttonDefault, buttonRemove);
    alert.setOnCloseRequest(evt -> alert.close());
    // add data set selector if necessary (ie. more than one data set available)
    dataSetSelector = new DataSetSelector(plugin, requiredNumberOfDataSets);
    if (dataSetSelector.getNumberDataSets() >= 1) {
        lastLayoutRow = shiftGridPaneRowOffset(dataSetSelector.getChildren(), lastLayoutRow);
        gridPane.getChildren().addAll(dataSetSelector.getChildren());
    }

    valueIndicatorSelector = new ValueIndicatorSelector(plugin, axisMode, requiredNumberOfIndicators); // NOPMD
    lastLayoutRow = shiftGridPaneRowOffset(valueIndicatorSelector.getChildren(), lastLayoutRow);
    gridPane.getChildren().addAll(valueIndicatorSelector.getChildren());
    valueField.setMouseTransparent(true);
    GridPane.setVgrow(dataViewWindow, Priority.NEVER);
    dataViewWindow.setOnMouseClicked(mouseHandler);

    getValueIndicatorsUser().addListener(valueIndicatorsUserChangeListener);

    dataViewWindow.nameProperty().bindBidirectional(title);
    setTitle(AbstractChartMeasurement.this.getClass().getSimpleName()); // NOPMD

    dataSet.addListener(dataSetChangeListener);
    dataSetChangeListener.changed(dataSet, null, null);

    getMeasurementPlugin().getDataView().getVisibleChildren().add(dataViewWindow);
}