List of usage examples for javafx.scene.control ButtonType OK
ButtonType OK
To view the source code for javafx.scene.control ButtonType OK.
Click Source Link
From source file:spdxedit.license.LicenseEditControl.java
@FXML void initialize() { assert rdoNone != null : "fx:id=\"rdoNone\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; assert rdoNoAssert != null : "fx:id=\"rdoNoAssert\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; assert rdoStandard != null : "fx:id=\"rdoStandard\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; assert chcListedLicense != null : "fx:id=\"chcListedLicense\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; assert chcExtractedLicenses != null : "fx:id=\"chcExtractedLicenses\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; assert rdoExtracted != null : "fx:id=\"rdoExtracted\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; assert btnNewFromFile != null : "fx:id=\"btnNewFromFile\" was not injected: check your FXML file 'LicenseEditControl.fxml'."; //Make radio buttons mutually exclusive ToggleGroup licenseTypeGroup = new ToggleGroup(); rdoExtracted.setToggleGroup(licenseTypeGroup); rdoStandard.setToggleGroup(licenseTypeGroup); rdoNone.setToggleGroup(licenseTypeGroup); rdoNoAssert.setToggleGroup(licenseTypeGroup); //Choice boxes should disable when their respective radio buttons are untoggled. rdoStandard.selectedProperty()/*from ww w . j ava2 s .c om*/ .addListener((observable, oldValue, newValue) -> chcListedLicense.setDisable(!newValue)); rdoExtracted.selectedProperty() .addListener((observable, oldValue, newValue) -> chcExtractedLicenses.setDisable(!newValue)); chcListedLicense.getItems() .addAll(Arrays.stream(ListedLicenses.getListedLicenses().getSpdxListedLicenseIds()).sorted() .collect(Collectors.toList())); chcExtractedLicenses.setConverter(new StringConverter<ExtractedLicenseInfo>() { @Override public String toString(ExtractedLicenseInfo object) { return object.getName(); } @Override public ExtractedLicenseInfo fromString(String string) { return Arrays.stream(documentContainer.getExtractedLicenseInfos()) .filter(license -> StringUtils.equals(license.getName(), string)).findAny().get(); } }); btnNewFromFile.setVisible(showExtractLicenseButton); //Apply the initial value if (this.initialValue instanceof SpdxListedLicense) { chcListedLicense.setValue(((SpdxListedLicense) initialValue).getLicenseId()); chcListedLicense.setDisable(false); rdoStandard.selectedProperty().setValue(true); } else if (initialValue instanceof ExtractedLicenseInfo) { refreshExtractedLicenses(); chcExtractedLicenses.setValue((ExtractedLicenseInfo) initialValue); chcExtractedLicenses.setDisable(false); rdoExtracted.selectedProperty().setValue(true); } else if (initialValue instanceof SpdxNoAssertionLicense) { rdoNoAssert.selectedProperty().setValue(true); } else if (initialValue instanceof SpdxNoneLicense) { rdoNone.selectedProperty().setValue(true); } else { new Alert(Alert.AlertType.ERROR, "Unsupported license type: " + initialValue.getClass().getSimpleName() + ".", ButtonType.OK); } //Listen for change events licenseTypeGroup.selectedToggleProperty().addListener((observable1, oldValue1, newValue1) -> { hanldLicenseChangeEvent(); }); chcExtractedLicenses.valueProperty().addListener((observable, oldValue, newValue) -> { hanldLicenseChangeEvent(); }); chcListedLicense.valueProperty().addListener((observable, oldValue, newValue) -> { hanldLicenseChangeEvent(); }); }
From source file:de.micromata.mgc.application.webserver.config.JettyConfigTabController.java
private void createSslValidate(ValContext ctx) { File storePath = new File("."); if (StringUtils.isNotBlank(sslKeystorePath.getText()) == true) { String sp = sslKeystorePath.getText(); if (sp.contains("/") == false && sp.contains("\\") == false) { if (StringUtils.isBlank(sp) == true) { storePath = new File("."); } else { storePath = new File(new File("."), sp); }/*from ww w . j a v a 2 s .co m*/ } else { storePath = new File(sslKeystorePath.getText()); } } if (storePath.getParentFile() == null || storePath.getParentFile().exists() == false) { ctx.directError("sslKeystorePath", "The parent path doesn't exists: " + (storePath.getParentFile() == null ? "null" : storePath.getParentFile().getAbsolutePath())); return; } if (storePath.exists() && storePath.isDirectory() == true) { ctx.directError("sslKeystorePath", "Please give an path to file: " + storePath.getAbsolutePath()); return; } if (storePath.exists() == true) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Overwrite keystore"); // alert.setHeaderText("Overwrite the existant keystore file?"); alert.setContentText("Overwrite the existant keystore file?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() != ButtonType.OK) { return; } } if (StringUtils.length(sslKeystorePassword.getText()) < 6) { ctx.directError("sslKeystorePassword", "Please give a password for Keystore password with at least 6 characters"); return; } if (StringUtils.isBlank(sslCertAlias.getText()) == true) { ctx.directError("sslCertAlias", "Please give a Alias for the key"); return; } KeyTool.generateKey(ctx, storePath, sslKeystorePassword.getText(), sslCertAlias.getText()); Alert alert = new Alert(AlertType.WARNING); alert.setTitle("Certificate created"); alert.setHeaderText( "Certificate created. You are using a self signed certificate, which should not be used in production."); alert.setContentText( "If you open the browser, will will receive a warning, that the certificate is not secure.\n" + "You have to accept the certificate to continue."); Optional<ButtonType> result = alert.showAndWait(); }
From source file:org.sleuthkit.autopsy.timeline.actions.SaveSnapshotAsReport.java
/** * Constructor/*from ww w . j a v a 2 s. c o m*/ * * @param controller The controller for this timeline action * @param nodeSupplier The Supplier of the node to snapshot. */ @NbBundle.Messages({ "Timeline.ModuleName=Timeline", "SaveSnapShotAsReport.action.dialogs.title=Timeline", "SaveSnapShotAsReport.action.name.text=Snapshot Report", "SaveSnapShotAsReport.action.longText=Save a screen capture of the current view of the timeline as a report.", "# {0} - report file path", "SaveSnapShotAsReport.ReportSavedAt=Report saved at [{0}]", "SaveSnapShotAsReport.Success=Success", "SaveSnapShotAsReport.FailedToAddReport=Failed to add snaphot to case as a report.", "# {0} - report path", "SaveSnapShotAsReport.ErrorWritingReport=Error writing report to disk at {0}.", "# {0} - generated default report name", "SaveSnapShotAsReport.reportName.prompt=leave empty for default report name: {0}.", "SaveSnapShotAsReport.reportName.header=Enter a report name for the Timeline Snapshot Report.", "SaveSnapShotAsReport.duplicateReportNameError.text=A report with that name already exists." }) public SaveSnapshotAsReport(TimeLineController controller, Supplier<Node> nodeSupplier) { super(Bundle.SaveSnapShotAsReport_action_name_text()); setLongText(Bundle.SaveSnapShotAsReport_action_longText()); setGraphic(new ImageView(SNAP_SHOT)); this.controller = controller; this.currentCase = controller.getAutopsyCase(); setEventHandler(actionEvent -> { //capture generation date and use to make default report name Date generationDate = new Date(); final String defaultReportName = FileUtil.escapeFileName(currentCase.getName() + " " + new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss").format(generationDate)); //NON_NLS BufferedImage snapshot = SwingFXUtils.fromFXImage(nodeSupplier.get().snapshot(null, null), null); //prompt user to pick report name TextInputDialog textInputDialog = new TextInputDialog(); PromptDialogManager.setDialogIcons(textInputDialog); textInputDialog.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title()); textInputDialog.getEditor() .setPromptText(Bundle.SaveSnapShotAsReport_reportName_prompt(defaultReportName)); textInputDialog.setHeaderText(Bundle.SaveSnapShotAsReport_reportName_header()); //keep prompt even if text field has focus, until user starts typing. textInputDialog.getEditor() .setStyle("-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);");//NON_NLS /* * Create a ValidationSupport to validate that a report with the * entered name doesn't exist on disk already. Disable ok button if * report name is not validated. */ ValidationSupport validationSupport = new ValidationSupport(); validationSupport.registerValidator(textInputDialog.getEditor(), false, new Validator<String>() { @Override public ValidationResult apply(Control textField, String enteredReportName) { String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName); boolean exists = Files.exists(Paths.get(currentCase.getReportDirectory(), reportName)); return ValidationResult.fromErrorIf(textField, Bundle.SaveSnapShotAsReport_duplicateReportNameError_text(), exists); } }); textInputDialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty() .bind(validationSupport.invalidProperty()); //show dialog and handle result textInputDialog.showAndWait().ifPresent(enteredReportName -> { //reportName defaults to case name + timestamp if left blank String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName); Path reportFolderPath = Paths.get(currentCase.getReportDirectory(), reportName, "Timeline Snapshot"); //NON_NLS Path reportMainFilePath; try { //generate and write report reportMainFilePath = new SnapShotReportWriter(currentCase, reportFolderPath, reportName, controller.getEventsModel().getZoomParamaters(), generationDate, snapshot) .writeReport(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Error writing report to disk at " + reportFolderPath, ex); //NON_NLS new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_ErrorWritingReport(reportFolderPath)).show(); return; } try { //add main file as report to case Case.getCurrentCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(), reportName); } catch (TskCoreException ex) { LOGGER.log(Level.WARNING, "Failed to add " + reportMainFilePath.toString() + " to case as a report", ex); //NON_NLS new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_FailedToAddReport()).show(); return; } //notify user of report location final Alert alert = new Alert(Alert.AlertType.INFORMATION, null, OPEN, OK); alert.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title()); alert.setHeaderText(Bundle.SaveSnapShotAsReport_Success()); //make action to open report, and hyperlinklable to invoke action final OpenReportAction openReportAction = new OpenReportAction(reportMainFilePath); HyperlinkLabel hyperlinkLabel = new HyperlinkLabel( Bundle.SaveSnapShotAsReport_ReportSavedAt(reportMainFilePath.toString())); hyperlinkLabel.setOnAction(openReportAction); alert.getDialogPane().setContent(hyperlinkLabel); alert.showAndWait().filter(OPEN::equals).ifPresent(buttonType -> openReportAction.handle(null)); }); }); }
From source file:com.exalttech.trex.util.Util.java
/** * Generate and return alert message window * * @param type/* w w w . ja va 2 s.c o m*/ * @return */ public static Alert getAlert(Alert.AlertType type) { Alert alert = new Alert(type, "", ButtonType.OK); alert.setHeaderText(null); alert.setX(TrexApp.getPrimaryStage().getX() + ALERT_X_POSITION); alert.setY(TrexApp.getPrimaryStage().getY() + ALERT_Y_POSITION); return alert; }
From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java
public static DbConfig openDialog(final DbConfig sc) { Dialog<DbConfig> dialog = DialogHelper.createDialog(); dialog.setResizable(false);/*from w ww . j a v a2 s. c o m*/ final Tuple2<Parent, DbConfigFrmController> tuple = createNewInstance(); if (sc != null) { tuple.get2().loadDataFromSessionConfiguration(sc); } dialog.setTitle(msgDialogTitle); dialog.setHeaderText(msgDialogHeader); dialog.getDialogPane().setContent(tuple.get1()); ButtonType buttonTypeOk = ButtonType.OK; ButtonType buttonTypeCancel = ButtonType.CANCEL; dialog.getDialogPane().getButtonTypes().add(buttonTypeCancel); dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); dialog.getDialogPane().setPadding(new Insets(0, 0, 0, 0)); dialog.setResultConverter(b -> { if (b == buttonTypeOk) { DbConfig sc1 = sc; if (sc1 == null) { sc1 = new DbConfig(); tuple.get2().storeDataToSessionConfiguration(sc1); DbConfigFactory.getConfigurations().add(sc1); } else { tuple.get2().storeDataToSessionConfiguration(sc1); if (DbConfigFactory.getConfigurations().contains(sc1)) { // The copied session isn't in list yet int idx = DbConfigFactory.getConfigurations().indexOf(sc1); DbConfigFactory.getConfigurations().remove(sc1); DbConfigFactory.getConfigurations().add(idx, sc1); } else { DbConfigFactory.getConfigurations().add(sc1); } } DbConfigFactory.saveConfiguration(); return sc1; } return null; }); Optional<DbConfig> result = dialog.showAndWait(); if (result.isPresent()) { return result.get(); } return null; }
From source file:utilitybasedfx.MainGUIController.java
@FXML public void eventImportSource(ActionEvent event) { File selectedDir = Utils.dirChooser("Please choose the project source root folder"); File sourceDir = new File(Prefs.getSourcePath()); boolean shouldContinue = true; if (selectedDir != null) { if (sourceDir.isDirectory()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("This project already exists!"); alert.setHeaderText("This project already has a src folder meaning it already has files imported"); alert.setContentText(/* w ww . jav a 2 s . c om*/ "Are you sure you want to import the new source?\nPressing OK will delete the files previous imported to this project and replace them with the new files."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sourceDir.delete(); } else { shouldContinue = false; } } if (shouldContinue) { shouldRefreshFileTree = true; enableWorking(new Task<String>() { @Override protected String call() throws InterruptedException { updateMessage("Copying Files..."); try { FileUtils.copyDirectory(selectedDir, sourceDir); } catch (IOException e) { Utils.stackErrorDialog(e); } updateMessage(""); return ""; //[FIXME] find a way to do this inline function without a class as return type } }); } } }
From source file:spdxedit.license.LicenseEditControl.java
public AnyLicenseInfo getValue() { AnyLicenseInfo result = null;/*from www. j a v a 2 s . com*/ if (rdoNoAssert.isSelected()) { result = new SpdxNoAssertionLicense(); } else if (rdoNone.isSelected()) { result = new SpdxNoneLicense(); } else if (rdoStandard.isSelected()) { try { result = ListedLicenses.getListedLicenses().getListedLicenseById(chcListedLicense.getValue()); } catch (InvalidSPDXAnalysisException e) { throw new RuntimeException(e); } } else if (rdoExtracted.isSelected()) { result = chcExtractedLicenses.getValue(); } if (result == null) { new Alert(Alert.AlertType.ERROR, "Unable to extract selected license", ButtonType.OK); } return result; }
From source file:org.cryptomator.ui.InitializeController.java
private boolean shouldEncryptExistingFiles() { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(localization.getString("initialize.alert.directoryIsNotEmpty.title")); alert.setHeaderText(null);/* www . j a v a 2s . c om*/ alert.setContentText(localization.getString("initialize.alert.directoryIsNotEmpty.content")); final Optional<ButtonType> result = alert.showAndWait(); return ButtonType.OK.equals(result.get()); }
From source file:se.trixon.filebydate.ui.MainApp.java
private void displayOptions() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.initOwner(mStage);/* w w w .j av a 2 s . c om*/ alert.setTitle(Dict.OPTIONS.toString()); alert.setGraphic(null); alert.setHeaderText(null); Label label = new Label(Dict.CALENDAR_LANGUAGE.toString()); LocaleComboBox localeComboBox = new LocaleComboBox(); CheckBox checkBox = new CheckBox(Dict.DYNAMIC_WORD_WRAP.toString()); GridPane gridPane = new GridPane(); //gridPane.setGridLinesVisible(true); gridPane.addColumn(0, label, localeComboBox, checkBox); GridPane.setMargin(checkBox, new Insets(16, 0, 0, 0)); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(gridPane); localeComboBox.setLocale(mOptions.getLocale()); checkBox.setSelected(mOptions.isWordWrap()); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { mOptions.setLocale(localeComboBox.getLocale()); mOptions.setWordWrap(checkBox.isSelected()); } }
From source file:se.trixon.mapollage.ui.MainApp.java
private void displayOptions() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.initOwner(mStage);/*w ww . java2 s .c om*/ alert.setTitle(Dict.OPTIONS.toString()); alert.setGraphic(null); alert.setHeaderText(null); final DialogPane dialogPane = alert.getDialogPane(); OptionsPanel optionsPanel = new OptionsPanel(); dialogPane.setContent(optionsPanel); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { optionsPanel.save(); } }