javafx.stage.Modality Java Examples

The following examples show how to use javafx.stage.Modality. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenWithDialog.java    From pdfsam with GNU Affero General Public License v3.0 7 votes vote down vote up
@Inject
public OpenWithDialog(StylesConfig styles, List<Module> modules) {
    initModality(Modality.WINDOW_MODAL);
    initStyle(StageStyle.UTILITY);
    setResizable(false);
    setTitle(DefaultI18nContext.getInstance().i18n("Open with"));

    this.modules = modules.stream().sorted(comparing(m -> m.descriptor().getName())).collect(toList());

    messageTitle.getStyleClass().add("-pdfsam-open-with-dialog-title");

    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().addAll("-pdfsam-open-with-dialog", "-pdfsam-open-with-container");
    containerPane.setTop(messageTitle);
    BorderPane.setAlignment(messageTitle, Pos.TOP_CENTER);

    filesList.setPrefHeight(150);
    containerPane.setCenter(filesList);

    buttons.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setBottom(buttons);
    BorderPane.setAlignment(buttons, Pos.CENTER);

    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    eventStudio().addAnnotatedListeners(this);
}
 
Example #2
Source File: GUIUtil.java    From bisq with GNU Affero General Public License v3.0 7 votes vote down vote up
public static void showSelectableTextModal(String title, String text) {
    TextArea textArea = new BisqTextArea();
    textArea.setText(text);
    textArea.setEditable(false);
    textArea.setWrapText(true);
    textArea.setPrefSize(800, 600);

    Scene scene = new Scene(textArea);
    Stage stage = new Stage();
    if (null != title) {
        stage.setTitle(title);
    }
    stage.setScene(scene);
    stage.initModality(Modality.NONE);
    stage.initStyle(StageStyle.UTILITY);
    stage.show();
}
 
Example #3
Source File: GuiUtils.java    From thunder with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void runAlert (BiConsumer<Stage, AlertWindowController> setup) {
    try {
        // JavaFX2 doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
        // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
        // an odd sort of way.
        Stage dialogStage = new Stage();
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
        Pane pane = loader.load();
        AlertWindowController controller = loader.getController();
        setup.accept(dialogStage, controller);
        dialogStage.setScene(new Scene(pane));
        dialogStage.showAndWait();
    } catch (IOException e) {
        // We crashed whilst trying to show the alert dialog (this should never happen). Give up!
        throw new RuntimeException(e);
    }
}
 
Example #4
Source File: BytesEditerController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
protected void setSecondArea(String hexFormat) {
    if (isSettingValues || displayArea == null
            || !contentSplitPane.getItems().contains(displayArea)) {
        return;
    }
    isSettingValues = true;
    LoadingController loadingController = openHandlingStage(Modality.WINDOW_MODAL);
    if (!hexFormat.isEmpty()) {
        String[] lines = hexFormat.split("\n");
        StringBuilder text = new StringBuilder();
        String lineText;
        for (String line : lines) {
            lineText = new String(ByteTools.hexFormatToBytes(line), sourceInformation.getCharset());
            lineText = lineText.replaceAll("\n", " ").replaceAll("\r", " ") + "\n";
            text.append(lineText);
        }
        displayArea.setText(text.toString());
    } else {
        displayArea.clear();
    }
    if (loadingController != null) {
        loadingController.closeStage();
    }
    isSettingValues = false;
}
 
Example #5
Source File: FXUIUtils.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static void _showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) {
    Alert alert = new Alert(type);
    alert.initOwner(parent);
    alert.setTitle(title);
    alert.setHeaderText(title);
    alert.setContentText(message);
    alert.initModality(Modality.APPLICATION_MODAL);
    alert.setResizable(true);
    if (monospace) {
        Text text = new Text(message);
        alert.getDialogPane().setStyle("-fx-padding: 0 10px 0 10px;");
        text.setStyle(" -fx-font-family: monospace;");
        alert.getDialogPane().contentProperty().set(text);
    }
    alert.showAndWait();
}
 
Example #6
Source File: GuiUtils.java    From thundernetwork with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void runAlert(BiConsumer<Stage, AlertWindowController> setup) {
    try {
        // JavaFX2 doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
        // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
        // an odd sort of way.
        Stage dialogStage = new Stage();
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
        Pane pane = loader.load();
        AlertWindowController controller = loader.getController();
        setup.accept(dialogStage, controller);
        dialogStage.setScene(new Scene(pane));
        dialogStage.showAndWait();
    } catch (IOException e) {
        // We crashed whilst trying to show the alert dialog (this should never happen). Give up!
        throw new RuntimeException(e);
    }
}
 
Example #7
Source File: CurlyApp.java    From curly with Apache License 2.0 6 votes vote down vote up
public static void openActivityMonitor(BatchRunner runner) {
    try {
        FXMLLoader loader = new FXMLLoader(CurlyApp.class.getResource("/fxml/RunnerReport.fxml"));
        loader.setResources(ApplicationState.getInstance().getResourceBundle());
        loader.load();
        RunnerActivityController runnerActivityController = loader.getController();

        Stage popup = new Stage();
        popup.setScene(new Scene(loader.getRoot()));
        popup.initModality(Modality.APPLICATION_MODAL);
        popup.initOwner(applicationWindow);

        runnerActivityController.attachRunner(runner);

        popup.showAndWait();
    } catch (IOException ex) {
        Logger.getLogger(CurlyApp.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #8
Source File: FxmlUtil.java    From milkman with MIT License 6 votes vote down vote up
public static JFXAlert createDialog(JFXDialogLayout content) {
	JFXAlert dialog = new JFXAlert(primaryStage);
	dialog.setContent(content);
	dialog.setOverlayClose(false);
	dialog.initModality(Modality.APPLICATION_MODAL);
	return dialog;
}
 
Example #9
Source File: ConvertImageTask.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
public Arma3ToolsDirNotSetPopup() {
	super(ArmaDialogCreator.getPrimaryStage(), new VBox(5), null);
	ResourceBundle bundle = Lang.ApplicationBundle();

	setTitle(bundle.getString("Popups.generic_popup_title"));

	myStage.initModality(Modality.APPLICATION_MODAL);
	myStage.setResizable(false);

	Button btnLocate = new Button(bundle.getString("ValueEditors.ImageValueEditor.set_a3_tools_btn"));
	btnLocate.setOnAction(new EventHandler<>() {
		@Override
		public void handle(ActionEvent event) {
			new ChangeDirectoriesDialog().showAndWait();
			close();
		}
	});

	myRootElement.setPadding(new Insets(10));
	myRootElement.getChildren().add(new Label(bundle.getString("ValueEditors.ImageValueEditor.a3_tools_dir_not_set")));
	myRootElement.getChildren().add(btnLocate);

	myRootElement.getChildren().addAll(new Separator(Orientation.HORIZONTAL), getBoundResponseFooter(true, true, false));
}
 
Example #10
Source File: ProgressDialog.java    From mcaselector with MIT License 6 votes vote down vote up
public ProgressDialog(Translation title, Stage primaryStage) {
	initStyle(StageStyle.TRANSPARENT);
	setResizable(false);
	initModality(Modality.APPLICATION_MODAL);
	initOwner(primaryStage);

	this.title.textProperty().bind(title.getProperty());
	this.title.getStyleClass().add("progress-title");

	label.getStyleClass().add("progress-info");

	box.getStyleClass().add("progress-dialog");
	box.getChildren().addAll(this.title, progressBar, label);

	progressBar.prefWidthProperty().bind(box.widthProperty());
	this.title.prefWidthProperty().bind(box.widthProperty());
	label.prefWidthProperty().bind(box.widthProperty());

	Scene scene = new Scene(box);
	scene.setFill(Color.TRANSPARENT);

	scene.getStylesheets().addAll(primaryStage.getScene().getStylesheets());

	setScene(scene);
}
 
Example #11
Source File: FxmlStage.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static BaseController openScene(Stage stage, String newFxml,
        StageStyle stageStyle) {
    try {
        Stage newStage = new Stage();  // new stage should be opened instead of keeping old stage, to clean resources
        newStage.initModality(Modality.NONE);
        newStage.initStyle(StageStyle.DECORATED);
        newStage.initOwner(null);
        BaseController controller = initScene(newStage, newFxml, stageStyle);

        if (stage != null) {
            closeStage(stage);
        }
        return controller;
    } catch (Exception e) {
        logger.error(e.toString());
        return null;
    }
}
 
Example #12
Source File: PreferencesFxDialog.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * Opens {@link PreferencesFx} in a dialog window.
 *
 * @param modal if true, will not allow the user to interact with any other window than
 *              the {@link PreferencesFxDialog}, as long as it is open.
 */
public void show(boolean modal) {
  if (!modalityInitialized) {
    // only set modality once to avoid exception:
    // java.lang.IllegalStateException: Cannot set modality once stage has been set visible
    Modality modality = modal ? Modality.APPLICATION_MODAL : Modality.NONE;
    dialog.initModality(modality);
    modalityInitialized = true;
  }

  if (modal) {
    dialog.showAndWait();
  } else {
    dialog.show();
  }
}
 
Example #13
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private AvailabilityEditorController getAvailabilityController() throws Exception {
	if (availabilityEditorController == null) {
		FXMLLoader loader = FXMLLoaderFactory.availabilityEditorLoader();
		AnchorPane page = (AnchorPane) loader.getRoot();

		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("availability.editor"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		Scene scene = new Scene(page);
		dialogStage.setScene(scene);

		// get the controller
		availabilityEditorController = loader.getController();
		availabilityEditorController.setDialogStage(dialogStage);
	}
	return availabilityEditorController;
}
 
Example #14
Source File: UserCategoryMenuViewImpl.java    From oim-fx with MIT License 6 votes vote down vote up
private void initMenu() {

		information.initModality(Modality.APPLICATION_MODAL);
		information.initOwner(menu);
		information.getDialogPane().setHeaderText(null);

		textInput.setTitle("输入分组");
		textInput.setContentText("名称:");
		textInput.getEditor().setText("");

		addCategoryMenuItem.setText("新建分组");
		findUserMenuItem.setText("查找用户");
		updateCategoryNameMenuItem.setText("重命名分组");

		menu.getItems().add(addCategoryMenuItem);
		menu.getItems().add(findUserMenuItem);
		menu.getItems().add(updateCategoryNameMenuItem);
	}
 
Example #15
Source File: GroupCategoryMenuViewImpl.java    From oim-fx with MIT License 6 votes vote down vote up
private void initMenu() {

		//BaseFrame frame=new BaseFrame();
		
		information.initModality(Modality.APPLICATION_MODAL);
		information.initOwner(menu);
		information.getDialogPane().setHeaderText(null);
		//information.initOwner(frame);
		
		//textInput.initOwner(frame);
		textInput.setTitle("输入分组");
		textInput.setContentText("名称:");
		textInput.getEditor().setText("");

		addCategoryMenuItem.setText("新建分组");
		findGroupMenuItem.setText("查找群");
		updateCategoryNameMenuItem.setText("重命名分组");
		addMenuItem.setText("创建一个群");
		
		menu.getItems().add(addCategoryMenuItem);
		menu.getItems().add(findGroupMenuItem);
		menu.getItems().add(updateCategoryNameMenuItem);
		menu.getItems().add(addMenuItem);
	}
 
Example #16
Source File: GeographyCodeController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public void importChinaTowns() {
    synchronized (this) {
        if (task != null) {
            return;
        }
        task = new SingletonTask<Void>() {

            @Override
            protected boolean handle() {
                File file = FxmlControl.getInternalFile("/data/db/Geography_Code_china_towns_internal.csv",
                        "data", "Geography_Code_china_towns_internal.csv", false);
                GeographyCode.importInternalCSV(loading, file, true);
                return true;
            }

            @Override
            protected void whenSucceeded() {
                refreshAction();
            }
        };
        loading = openHandlingStage(task, Modality.WINDOW_MODAL);
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
    }
}
 
Example #17
Source File: TransactionDetailsDialog.java    From cate with MIT License 6 votes vote down vote up
/**
 * Construct and return a transaction details dialog window.
 */
public static Stage build(final ResourceBundle resources, final WalletTransaction transaction)
    throws IOException {
    final Stage stage = new Stage();
    final FXMLLoader loader = new FXMLLoader(TransactionDetailsDialog.class.getResource("/txDetailsDialog.fxml"), resources);
    final Scene scene = new Scene(loader.load());

    scene.getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    stage.setScene(scene);

    final TransactionDetailsDialog controller = loader.getController();

    controller.setTransaction(transaction);
    controller.stage = stage;

    stage.setTitle(resources.getString("txDetails.title"));
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setResizable(false);
    stage.getIcons().add(new Image("/org/libdohj/cate/cate.png"));

    return stage;
}
 
Example #18
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
HttpSource showHttpServerEditor() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.httpServerLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("http.servers.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	HttpServerController httpServerController = loader.getController();
	httpServerController.setDialogStage(dialogStage);
	httpServerController.initializeServer();

	// Show the dialog and wait until the user closes it
	httpServerController.getDialogStage().showAndWait();

	return httpServerController.getSource();
}
 
Example #19
Source File: RregulloPunen.java    From Automekanik with GNU General Public License v3.0 5 votes vote down vote up
public RregulloPunen(int id, ShikoPunetPunetoret spp, boolean kryer){
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setResizable(false);
    stage.setTitle("Rregullo");
    HBox btn = new HBox(5);
    btn.getChildren().addAll(btnOk, btnAnulo);
    btn.setAlignment(Pos.CENTER_RIGHT);
    GridPane grid = new GridPane();
    grid.add(cbKryer, 0, 0);
    grid.add(btn, 0, 1);
    grid.setVgap(10);
    grid.setAlignment(Pos.CENTER);

    cbKryer.setSelected(kryer);

    btnOk.setOnAction(e -> {
        azhurno(id);
        new Thread(new Runnable() {
            @Override
            public void run() {
                spp.mbushNgaStatusi(spp.lblEmri.getText());
            }
        }).start();
    });
    btnAnulo.setOnAction(e -> stage.close());

    Scene scene = new Scene(grid, 230, 100);
    scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
 
Example #20
Source File: AboutDialog.java    From classpy with MIT License 5 votes vote down vote up
public static void showDialog() {
    Stage stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    
    BorderPane aboutPane = createAboutPane(stage);
    Scene scene = new Scene(aboutPane, 300, 180);
    
    stage.setScene(scene);
    stage.setTitle("About");
    stage.show();
}
 
Example #21
Source File: GameDialog.java    From FXTutorials with MIT License 5 votes vote down vote up
public GameDialog() {
    Button btnSubmit = new Button("Submit");
    btnSubmit.setOnAction(event -> {
        fieldAnswer.setEditable(false);
        textActualAnswer.setVisible(true);
        correct = textActualAnswer.getText().equals(fieldAnswer.getText().trim());
    });

    VBox vbox = new VBox(10, textQuestion, fieldAnswer, textActualAnswer, btnSubmit);
    vbox.setAlignment(Pos.CENTER);
    Scene scene = new Scene(vbox);

    setScene(scene);
    initModality(Modality.APPLICATION_MODAL);
}
 
Example #22
Source File: CreateKeyMenu.java    From MythRedisClient with Apache License 2.0 5 votes vote down vote up
/**
 * 显示输入窗体.
 * @param treeView 树
 * @param item 数据库
 * @return 是否点击确认
 */
private boolean showPanel(TreeView treeView, TreeItem<Label> item) {
    // 创建 FXMLLoader 对象
    loader = new FXMLLoader();
    // 加载文件
    loader.setLocation(Main.class.getResource("/views/AddKeyLayout.fxml"));
    AnchorPane pane = null;
    try {
        pane = loader.load();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // 创建对话框
    Stage dialogStage = new Stage();
    dialogStage.setTitle("添加值");
    dialogStage.initModality(Modality.WINDOW_MODAL);
    Scene scene = new Scene(pane);
    dialogStage.setScene(scene);

    controller = loader.getController();
    controller.setDialogStage(dialogStage);
    controller.setItem(item);
    controller.setTreeView(treeView);

    // 显示对话框, 并等待, 直到用户关闭
    dialogStage.showAndWait();

    return controller.isOkChecked();
}
 
Example #23
Source File: LocationEditBaseController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void loadCountries() {
        if (countrySelector == null) {
            return;
        }
        countrySelector.getItems().clear();
        synchronized (this) {

            BaseTask addressesTask = new BaseTask<Void>() {

                private List<String> countries;

                @Override
                protected boolean handle() {
//                    countries = GeographyCode.countries();
                    return true;
                }

                @Override
                protected void whenSucceeded() {
                    isSettingValues = true;
                    String sc = countrySelector.getValue();
                    countrySelector.getItems().addAll(countries);
                    isSettingValues = false;
                    if (sc != null) {
                        countrySelector.setValue(sc);
                    }
                }
            };
            openHandlingStage(addressesTask, Modality.WINDOW_MODAL);
            Thread thread = new Thread(addressesTask);
            thread.setDaemon(true);
            thread.start();
        }
    }
 
Example #24
Source File: LocationEditController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void loadDataSets(String dataset) {
    synchronized (this) {
        if (task != null) {
            return;
        }
        task = new SingletonTask<Void>() {

            private List<String> datasets;

            @Override
            protected boolean handle() {
                datasets = TableLocation.datasets();
                return true;
            }

            @Override
            protected void whenSucceeded() {
                isSettingValues = true;
                datasetSelector.getItems().addAll(datasets);
                isSettingValues = false;
                if (dataset != null && datasets.contains(dataset)) {
                    datasetSelector.getSelectionModel().select(dataset);
                }
            }

        };
        openHandlingStage(task, Modality.WINDOW_MODAL);
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
    }
}
 
Example #25
Source File: RGB2RGBConversionMatrixController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
public void calculateAllAction(ActionEvent event) {
    synchronized (this) {
        if (task != null) {
            return;
        }
        task = new SingletonTask<Void>() {

            private String allTexts;

            @Override
            protected boolean handle() {
                allData = FXCollections.observableArrayList();
                allData.addAll(RGB2RGBConversionMatrix.all(scale));
                allTexts = RGB2RGBConversionMatrix.allTexts(scale);
                return allTexts != null;
            }

            @Override
            protected void whenSucceeded() {
                matrixTableView.setItems(allData);
                textsArea.setText(allTexts);
                textsArea.home();
            }

        };
        openHandlingStage(task, Modality.WINDOW_MODAL);
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
    }
}
 
Example #26
Source File: TranslationChoiceDialog.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create the translation choice dialog.
 */
public TranslationChoiceDialog() {
    initModality(Modality.APPLICATION_MODAL);
    setTitle(LabelGrabber.INSTANCE.getLabel("translation.choice.title"));
    Utils.addIconsToStage(this);
    BorderPane root = new BorderPane();
    content = new VBox(5);
    BorderPane.setMargin(content, new Insets(10));
    root.setCenter(content);

    Label selectTranslationLabel = new Label(LabelGrabber.INSTANCE.getLabel("select.translation.label"));
    selectTranslationLabel.setWrapText(true);
    content.getChildren().add(selectTranslationLabel);

    Button okButton = new Button(LabelGrabber.INSTANCE.getLabel("close.button"));
    okButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            hide();
        }
    });
    okButton.setDefaultButton(true);
    StackPane.setMargin(okButton, new Insets(5));
    StackPane buttonPane = new StackPane();
    buttonPane.setAlignment(Pos.CENTER);
    buttonPane.getChildren().add(okButton);
    root.setBottom(buttonPane);

    Scene scene = new Scene(root);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    setScene(scene);
}
 
Example #27
Source File: DialogWindow.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
public void show(boolean isLockParent) {
    DialogKeyPressHandler controller = (DialogKeyPressHandler) getController();
    if (controller != null) {
        controller.setupStage(dialogStage);
    }

    if (dialogStage.isShowing()) {
        dialogStage.requestFocus();
    }

    if (!hasBeenVisible) {
        Modality modality = isLockParent? Modality.APPLICATION_MODAL : Modality.NONE;
        dialogStage.initModality(modality);

        if (!isLockParent) {
            dialogStage.initOwner(null);
        }
    }

    if (isLockParent) {
        dialogStage.showAndWait();
    } else {
        dialogStage.show();
    }

    hasBeenVisible = true;
}
 
Example #28
Source File: CircuitSim.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example #29
Source File: DesignerApplication.java    From OEE-Designer with MIT License 5 votes vote down vote up
String showScriptEditor(EventResolver eventResolver) throws Exception {
	// Load the fxml file and create a new stage for the pop-up dialog.
	if (scriptController == null) {
		FXMLLoader loader = FXMLLoaderFactory.eventResolverLoader();
		AnchorPane page = (AnchorPane) loader.getRoot();

		// Create the dialog Stage.
		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("script.editor.title"));
		dialogStage.initModality(Modality.NONE);

		Scene scene = new Scene(page);
		dialogStage.setScene(scene);

		// get the controller
		scriptController = loader.getController();
		scriptController.setDialogStage(dialogStage);
		scriptController.initialize(this, eventResolver);
	}

	// display current script
	scriptController.showFunctionScript(eventResolver);

	// Show the dialog and wait until the user closes it
	if (!scriptController.getDialogStage().isShowing()) {
		scriptController.getDialogStage().showAndWait();
	}

	return scriptController.getResolver().getScript();
}
 
Example #30
Source File: ImageManufactureTransformController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
public void verticalAction() {
    synchronized (this) {
        if (task != null) {
            return;
        }
        task = new SingletonTask<Void>() {

            private Image newImage;

            @Override
            protected boolean handle() {
                newImage = FxmlImageManufacture.verticalImage(imageView.getImage());
                if (task == null || isCancelled()) {
                    return false;
                }
                return newImage != null;
            }

            @Override
            protected void whenSucceeded() {
                parent.updateImage(ImageOperation.Transform, "vertical", null, newImage, cost);
            }

        };
        parent.openHandlingStage(task, Modality.WINDOW_MODAL);
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
    }
}