List of usage examples for javafx.scene.control DialogPane setContent
public final void setContent(Node content)
From source file:org.sleuthkit.autopsy.timeline.ShowInTimelineDialog.java
/** * Common Private Constructor// w w w .j av a2 s . co m * * @param controller The controller for this Dialog. * @param eventIDS A List of eventIDs to present to the user to choose * from. */ @NbBundle.Messages({ "ShowInTimelineDialog.amountValidator.message=The entered amount must only contain digits." }) private ShowInTimelineDialog(TimeLineController controller, List<Long> eventIDS) { this.controller = controller; //load dialog content fxml final String name = "nbres:/" + StringUtils.replace(ShowInTimelineDialog.class.getPackage().getName(), ".", "/") + "/ShowInTimelineDialog.fxml"; // NON-NLS try { FXMLLoader fxmlLoader = new FXMLLoader(new URL(name)); fxmlLoader.setRoot(contentRoot); fxmlLoader.setController(this); fxmlLoader.load(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Unable to load FXML, node initialization may not be complete.", ex); //NON-NLS } //assert that fxml loading happened correctly assert eventTable != null : "fx:id=\"eventTable\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert typeColumn != null : "fx:id=\"typeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert dateTimeColumn != null : "fx:id=\"dateTimeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert amountSpinner != null : "fx:id=\"amountsSpinner\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert unitComboBox != null : "fx:id=\"unitChoiceBox\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; //validat that spinner has a integer in the text field. validationSupport.registerValidator(amountSpinner.getEditor(), false, Validator.createPredicateValidator( NumberUtils::isDigits, Bundle.ShowInTimelineDialog_amountValidator_message())); //configure dialog properties PromptDialogManager.setDialogIcons(this); initModality(Modality.APPLICATION_MODAL); //add scenegraph loaded from fxml to this dialog. DialogPane dialogPane = getDialogPane(); dialogPane.setContent(contentRoot); //add buttons to dialog dialogPane.getButtonTypes().setAll(SHOW, ButtonType.CANCEL); ///configure dialog controls amountSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1000)); amountSpinner.getValueFactory().setConverter(new IntegerStringConverter() { /** * Convert the String to an Integer using Integer.valueOf, but if * that throws a NumberFormatException, reset the spinner to the * last valid value. * * @param string The String to convert * * @return The Integer value of string. */ @Override public Integer fromString(String string) { try { return super.fromString(string); } catch (NumberFormatException ex) { return amountSpinner.getValue(); } } }); unitComboBox.setButtonCell(new ChronoFieldListCell()); unitComboBox.setCellFactory(comboBox -> new ChronoFieldListCell()); unitComboBox.getItems().setAll(SCROLL_BY_UNITS); unitComboBox.getSelectionModel().select(ChronoField.MINUTE_OF_HOUR); typeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getEventType())); typeColumn.setCellFactory(param -> new TypeTableCell<>()); dateTimeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getStartMillis())); dateTimeColumn.setCellFactory(param -> new DateTimeTableCell<>()); //add events to table eventTable.getItems().setAll( eventIDS.stream().map(controller.getEventsModel()::getEventById).collect(Collectors.toSet())); eventTable.setPrefHeight(Math.min(200, 24 * eventTable.getItems().size() + 28)); }
From source file:se.trixon.filebydate.ui.MainApp.java
private void displayOptions() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.initOwner(mStage);/* ww w. jav a 2 s . c o m*/ 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.filebydate.ui.MainApp.java
private void profileEdit(Profile profile) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(mStage);//from w ww.java 2 s . c om String title = Dict.EDIT.toString(); boolean addNew = false; boolean clone = profile != null && profile.getName() == null; if (profile == null) { title = Dict.ADD.toString(); addNew = true; profile = new Profile(); profile.setSourceDir(FileUtils.getUserDirectory()); profile.setDestDir(FileUtils.getUserDirectory()); profile.setFilePattern("{*.jpg,*.JPG}"); profile.setDatePattern("yyyy/MM/yyyy-MM-dd"); profile.setOperation(0); profile.setFollowLinks(true); profile.setRecursive(true); profile.setReplaceExisting(false); profile.setCaseBase(NameCase.UNCHANGED); profile.setCaseExt(NameCase.UNCHANGED); } else if (clone) { title = Dict.CLONE.toString(); profile.setLastRun(0); } alert.setTitle(title); alert.setGraphic(null); alert.setHeaderText(null); ProfilePanel profilePanel = new ProfilePanel(profile); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(profilePanel); profilePanel.setOkButton((Button) dialogPane.lookupButton(ButtonType.OK)); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { profilePanel.save(); if (addNew || clone) { mProfiles.add(profile); } profilesSave(); populateProfiles(profile); } }
From source file:se.trixon.filebydate.ui.MainApp.java
private void profileRun(Profile profile) { String title = String.format(Dict.Dialog.TITLE_PROFILE_RUN.toString(), profile.getName()); Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(mStage);/* w ww . java 2 s . c o m*/ alert.setTitle(title); alert.setGraphic(null); alert.setHeaderText(null); PreviewPanel previewPanel = new PreviewPanel(); previewPanel.load(profile); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(previewPanel); ButtonType runButtonType = new ButtonType(Dict.RUN.toString()); ButtonType dryRunButtonType = new ButtonType(Dict.DRY_RUN.toString(), ButtonData.OK_DONE); ButtonType cancelButtonType = new ButtonType(Dict.CANCEL.toString(), ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(runButtonType, dryRunButtonType, cancelButtonType); Optional<ButtonType> result = alert.showAndWait(); if (result.get() != cancelButtonType) { boolean dryRun = result.get() == dryRunButtonType; profile.setDryRun(dryRun); mProgressPanel.clear(); mRoot.setCenter(mProgressPanel); mIndicator.setProfile(profile); if (profile.isValid()) { mLastRunProfile = profile; mOperationThread = new Thread(() -> { Operation operation = new Operation(mOperationListener, profile); operation.start(); }); mOperationThread.setName("Operation"); mOperationThread.start(); } else { mProgressPanel.out(profile.toDebugString()); mProgressPanel.out(profile.getValidationError()); mProgressPanel.out(Dict.ABORTING.toString()); } } }
From source file:se.trixon.mapollage.ui.MainApp.java
private void displayOptions() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.initOwner(mStage);/*from w ww. jav a 2 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(); } }
From source file:se.trixon.mapollage.ui.MainApp.java
private void profileEdit(Profile profile) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(mStage);/*w w w. j a v a 2s.c o m*/ String title = Dict.EDIT.toString(); boolean addNew = false; boolean clone = profile != null && profile.getName() == null; if (profile == null) { title = Dict.ADD.toString(); addNew = true; profile = new Profile(); } else if (clone) { title = Dict.CLONE.toString(); profile.setLastRun(0); } alert.setTitle(title); alert.setGraphic(null); alert.setHeaderText(null); alert.setResizable(true); ProfilePanel profilePanel = new ProfilePanel(profile); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(profilePanel); profilePanel.setOkButton((Button) dialogPane.lookupButton(ButtonType.OK)); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { profilePanel.save(); if (addNew || clone) { mProfiles.add(profile); } profilesSave(); populateProfiles(profile); } }