List of usage examples for javafx.beans.property SimpleObjectProperty SimpleObjectProperty
public SimpleObjectProperty(T initialValue)
From source file:eu.over9000.skadi.ui.dialogs.PerformUpdateDialog.java
public PerformUpdateDialog(RemoteVersionResult newVersion) { this.chosen = new SimpleObjectProperty<>( Paths.get(SystemUtils.USER_HOME, newVersion.getVersion() + ".jar").toFile()); this.setHeaderText("Updating to " + newVersion.getVersion()); this.setTitle("Skadi Updater"); this.getDialogPane().getStyleClass().add("alert"); this.getDialogPane().getStyleClass().add("information"); final ButtonType restartButtonType = new ButtonType("Start New Version", ButtonBar.ButtonData.OK_DONE); this.getDialogPane().getButtonTypes().addAll(restartButtonType, ButtonType.CANCEL); Node btn = this.getDialogPane().lookupButton(restartButtonType); btn.setDisable(true);/* www . j av a 2s . co m*/ Label lbPath = new Label("Save as"); TextField tfPath = new TextField(); tfPath.textProperty() .bind(Bindings.createStringBinding(() -> this.chosen.get().getAbsolutePath(), this.chosen)); tfPath.setPrefColumnCount(40); tfPath.setEditable(false); Button btChangePath = GlyphsDude.createIconButton(FontAwesomeIcons.FOLDER_OPEN, "Browse..."); btChangePath.setOnAction(event -> { FileChooser fc = new FileChooser(); fc.setTitle("Save downloaded jar.."); fc.setInitialFileName(this.chosen.getValue().getName()); fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("Jar File", ".jar")); fc.setInitialDirectory(this.chosen.getValue().getParentFile()); File selected = fc.showSaveDialog(this.getOwner()); if (selected != null) { this.chosen.set(selected); } }); ProgressBar pbDownload = new ProgressBar(0); pbDownload.setDisable(true); pbDownload.setMaxWidth(Double.MAX_VALUE); Label lbDownload = new Label("Download"); Label lbDownloadValue = new Label(); Button btDownload = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD, "Start"); btDownload.setMaxWidth(Double.MAX_VALUE); btDownload.setOnAction(event -> { btChangePath.setDisable(true); btDownload.setDisable(true); this.downloadService = new DownloadService(newVersion.getDownloadURL(), this.chosen.getValue()); lbDownloadValue.textProperty().bind(this.downloadService.messageProperty()); pbDownload.progressProperty().bind(this.downloadService.progressProperty()); this.downloadService.setOnSucceeded(dlEvent -> { btn.setDisable(false); }); this.downloadService.setOnFailed(dlFailed -> { LOGGER.error("new version download failed", dlFailed.getSource().getException()); lbDownloadValue.textProperty().unbind(); lbDownloadValue.setText("Download failed, check log file for details."); }); this.downloadService.start(); }); final GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.add(lbPath, 0, 0); grid.add(tfPath, 1, 0); grid.add(btChangePath, 2, 0); grid.add(new Separator(), 0, 1, 3, 1); grid.add(lbDownload, 0, 2); grid.add(pbDownload, 1, 2); grid.add(btDownload, 2, 2); grid.add(lbDownloadValue, 1, 3); this.getDialogPane().setContent(grid); this.setResultConverter(btnType -> { if (btnType == restartButtonType) { return this.chosen.getValue(); } if (btnType == ButtonType.CANCEL) { if (this.downloadService.isRunning()) { this.downloadService.cancel(); } } return null; }); }
From source file:br.com.OCTur.view.ClassificacaoController.java
/** * Initializes the controller class.//w w w .j a v a 2 s.co m */ @Override public void initialize(URL url, ResourceBundle rb) { snGrafico = new SwingNode(); spContainer.setContent(snGrafico); tcCidade.setCellValueFactory( (TableColumn.CellDataFeatures<EntidadeGrafico<Cidade>, Cidade> param) -> new SimpleObjectProperty<>( param.getValue().getEntidade())); tcClassificacao.setCellValueFactory(( TableColumn.CellDataFeatures<EntidadeGrafico<Cidade>, Integer> param) -> new SimpleObjectProperty<>( cidades.indexOf(param.getValue()) + 1)); tcPais.setCellValueFactory( (TableColumn.CellDataFeatures<EntidadeGrafico<Cidade>, Pais> param) -> new SimpleObjectProperty<>( param.getValue().getEntidade().getEstado().getPais())); tcNota.setCellValueFactory(new PropertyValueFactory<>("value")); tcNota.setCellFactory(( TableColumn<EntidadeGrafico<Cidade>, Double> param) -> new TableCell<EntidadeGrafico<Cidade>, Double>() { @Override protected void updateItem(Double item, boolean empty) { if (empty) { setText(""); } else { setText(NumberFormatter.duasCasas(item)); } } }); tvCidade.setItems(cidades); }
From source file:gndata.app.ui.metadata.manage.AddRDFInstanceCtrl.java
public AddRDFInstanceCtrl(ProjectState projState, MetadataNavState navigationState, Resource extRes) { projectState = projState;// w w w . j av a 2s . com navState = navigationState; oh = projectState.getMetadata().ontmanager; preSelNewClass = extRes; currInsets = new SimpleObjectProperty<>(new Insets(5)); labelText = new SimpleStringProperty(); newClassesList = FXCollections.observableArrayList(); newClasses = new SimpleObjectProperty<>(); selectedNewClass = new SimpleObjectProperty<>(); newPredicatesList = FXCollections.observableArrayList(); newPredicates = new SimpleObjectProperty<>(); additionalPredicatesList = FXCollections.observableArrayList(); additionalPredicates = new SimpleObjectProperty<>(); selectedPredicate = new SimpleObjectProperty<>(); addPredValue = new SimpleStringProperty(); addPredType = new SimpleObjectProperty<>(); addPredPromptText = new SimpleStringProperty(); // Update the contents of the DataProperty table, if a new class has been selected selectedNewClass.addListener((observable, oldValue, newValue) -> { if (selectedNewClass.get().getValue() != null) { newPredicatesList.clear(); oh.listDatatypeProperties(selectedNewClass.get().getValue()).stream().forEach(c -> { //TODO take care of the case of multiple datatypes Set<RDFDatatype> dts = oh.getRange(c.asDatatypeProperty()); RDFDatatype dt = dts.iterator().next(); newPredicatesList.add(new DataPropertyTableItem(c.asProperty(), dt)); }); } }); // Listen on the selected new predicate and set the corresponding RDF DataType accordingly selectedPredicate.addListener((observable, oldValue, newValue) -> { addPredPromptText.set(""); if (observable != null && newValue != null) { //TODO take care of the case of multiple datatypes Set<RDFDatatype> dts = oh.getRange(observable.getValue()); RDFDatatype dt = dts.iterator().next(); addPredType.set(dt); addPredPromptText .set("Enter " + (dt == null ? "String" : dt.getJavaClass().getSimpleName()) + " value"); } }); // Handle list of additional DataType properties newPredicatesList.addListener((ListChangeListener<DataPropertyTableItem>) change -> { // Reset list of additional DataType properties additionalPredicatesList.clear(); // Get all available datatype properties for selected class oh.listDatatypeProperties(selectedNewClass.get().getValue()).stream() .forEach(c -> additionalPredicatesList.add(c.asDatatypeProperty())); // TODO implement check for DataType Properties which can be added // TODO multiple times // Remove all datatype properties which already exist in the table newPredicatesList.stream().forEach(c -> { if (additionalPredicatesList.contains(c.getProperty())) { additionalPredicatesList.remove(c.getProperty()); } }); }); }
From source file:com.loop81.fxcomparer.FXComparerController.java
/** * Initiate the table by setting the correct width of the columns and adding a custom value-factory for the * size column. /*from w w w . j a va 2 s .c o m*/ */ private void initiateTable() { columnName.prefWidthProperty().bind(compareTable.widthProperty().divide(5).multiply(3)); columnName.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ComparisonEntry, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ComparisonEntry, String> cell) { return new SimpleStringProperty(cell.getValue().getOriginalEntry().getEntryName()); } }); columnState.prefWidthProperty().bind(compareTable.widthProperty().divide(5)); columnState.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ComparisonEntry, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ComparisonEntry, String> cell) { return new SimpleObjectProperty<>(MessageBundle.getString( "result.state." + cell.getValue().getChangeState().toString().toLowerCase())); } }); columnChange.prefWidthProperty().bind(compareTable.widthProperty().divide(5)); columnChange.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ComparisonEntry, ChangeWrapper>, ObservableValue<ChangeWrapper>>() { @Override public ObservableValue<ChangeWrapper> call( CellDataFeatures<ComparisonEntry, ChangeWrapper> cell) { long sizeChange = cell.getValue().getSizeChange(); if (sizeChange == 0) { return new SimpleObjectProperty<ChangeWrapper>(new ChangeWrapper()); } else if (sizeChange == Long.MIN_VALUE) { return new SimpleObjectProperty<ChangeWrapper>( new ChangeWrapper(MessageBundle.getString("general.not_avalible"), 0)); } else { return new SimpleObjectProperty<ChangeWrapper>( new ChangeWrapper(convertdifferenceToReadableString(sizeChange), sizeChange)); } } }); columnChange.setComparator(new Comparator<ChangeWrapper>() { @Override public int compare(ChangeWrapper wrapper1, ChangeWrapper wrapper2) { return wrapper1.compareTo(wrapper2); } }); }
From source file:org.virtualAsylum.spriggan.data.Addon.java
public State doInstall() { log("Installing %s (%s)", getDisplayName(), getID()); State result = State.IDLE; State error = State.ERROR; setState(State.INSTALLING);//w w w.jav a2 s . c o m setStateProgress(-1); boolean didError = false; try { //<editor-fold desc="Dependencies"> Collection<String> dependencyIDs = getDependencies(); ArrayList<Addon> dependencies = new ArrayList(); if (dependencyIDs.size() > 0) { setState(State.INSTALLING_DEPENDENCIES); for (String dependencyIDString : dependencyIDs) { Addon dependency = Database.find_ID(dependencyIDString); if (dependency == null) { throw new Exception(String.format("Dependency %s was missing for %s(%s)", dependencyIDString, getDisplayName(), getID())); } if (!dependency.getInstalled()) { dependencies.add(dependency); } } if (dependencies.size() > 0) { SimpleObjectProperty<Boolean> popupResult = new SimpleObjectProperty(null); runLater(() -> { DependencyPopup popup = new DependencyPopup(this, dependencies, popupResult); Stage stage = popup.popup(StageStyle.UTILITY, Modality.WINDOW_MODAL, MainInterface.current.getWindow(), getDisplayName()); stage.setOnCloseRequest(e -> popupResult.set(false)); stage.show(); }); while (popupResult.get() == null) { sleep(500); } if (!popupResult.get()) { error = State.IDLE; throw new Exception(String.format("Did not install dependencies for %s (%s)", getDisplayName(), getID())); } double perDep = 1.0 / dependencies.size(); setStateProgress(0.0); for (Addon dependency : dependencies) { boolean downloaded = Database.getCurrent().getRepository().contains(dependency); State depResult = State.IDLE; if (!downloaded) { depResult = dependency.doDownloadAndInstall(); } else if (!dependency.getInstalled()) { depResult = dependency.doInstall(); } if (depResult != State.IDLE) { throw new Exception( String.format("Dependency %s (%s) failed to download and/or install", dependency.getDisplayName(), dependency.getID())); } incrementStateProgress(perDep); } setState(State.INSTALLING); } } //</editor-fold> error = State.ERROR; final File repositoryDirectory = getRepositoryDirectory(this); final File installDirectory = getInstallDirectory(this); ArrayList<File> files = getRepositoryFiles(); double perFile = 1.0 / files.size(); setStateProgress(0.0); for (File inputFile : files) { File outputFile = new File(installDirectory, repositoryDirectory.toPath().relativize(inputFile.toPath()).toString()); outputFile.getParentFile().mkdirs(); Files.copy(inputFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING); incrementStateProgress(perFile); } } catch (Exception ex) { if (error == State.ERROR) { handleException(ex); } result = error; didError = true; } if (!didError) { setInstalled(true); } log("Installing %s (%s): %s", getDisplayName(), getID(), result); setStateProgress(0); setState(result); return result; }
From source file:com.panemu.tiwulfx.table.BaseColumn.java
/** * * @param propertyName java bean property name to be used for get/set method * using introspection/* w w w. j a v a 2 s .c o m*/ * @param prefWidth preferred collumn width * @param columnHeader column header text. Default equals propertyName. This * text is localized */ public BaseColumn(String propertyName, double prefWidth, String columnHeader) { super(columnHeader); setPrefWidth(prefWidth); this.propertyName = propertyName; // setCellValueFactory(new PropertyValueFactory<S, T>(propertyName)); tableCriteria.addListener(new InvalidationListener() { @Override public void invalidated(Observable observable) { if (tableCriteria.get() != null) { BaseColumn.this.setGraphic(filterImage); } else { BaseColumn.this.setGraphic(null); } } }); setCellValueFactory(new Callback<CellDataFeatures<R, C>, ObservableValue<C>>() { private SimpleObjectProperty<C> propertyValue; @Override public ObservableValue<C> call(CellDataFeatures<R, C> param) { /** * This code is adapted from {@link PropertyValueFactory#getCellDataReflectively(T) */ try { Object cellValue; if (getPropertyName().contains(".")) { cellValue = PropertyUtils.getNestedProperty(param.getValue(), getPropertyName()); } else { cellValue = PropertyUtils.getSimpleProperty(param.getValue(), getPropertyName()); } propertyValue = new SimpleObjectProperty<>((C) cellValue); return propertyValue; } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { throw new RuntimeException(ex); } catch (Exception ex) { /** * Ideally it catches * org.apache.commons.beanutils.NestedNullException. However * we need to import apachec bean utils library in FXML file * to be able to display it in Scene Builder. So, I decided * to catch Exception to avoid the import. */ return new SimpleObjectProperty<>(null); } } }); }
From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java
@FXML public void initialize() { logger.info("Init!"); NUMBER_FORMAT.setMaximumFractionDigits(2); webEngine = webView.getEngine();//from w w w . ja v a2 s. com webEngine.load(getClass().getResource("/html/googleMap.html").toExternalForm()); // Activity Headers activityDaysHeaderService.setOnSucceeded(event -> { activitiesTable.setItems(FXCollections.observableArrayList(activityDaysHeaderService.getValue())); activitiesTable.getSortOrder().add(tcDate); tcDate.setSortable(true); }); activityDaysHeaderService.setOnFailed( event -> logger.error("Failed to obtain ActivityList!", activityDaysHeaderService.getException())); final ProgressDialog activityHeadersProgressDialog = new ProgressDialog(activityDaysHeaderService); activityHeadersProgressDialog.initModality(Modality.APPLICATION_MODAL); // Activity Details activityDetailsGroupService.setOnSucceeded( event -> this.currentActivityDetailsGroup.setValue(activityDetailsGroupService.getValue())); activityDetailsGroupService.setOnFailed(event -> logger.error("Failed to obtain ActivityDetails!", activityDaysHeaderService.getException())); final ProgressDialog activityDetailsProgressDialog = new ProgressDialog(activityDetailsGroupService); activityDetailsProgressDialog.initModality(Modality.APPLICATION_MODAL); // Gpx Export gpxExportService.setOnSucceeded(event -> gpxExportFinished()); gpxExportService .setOnFailed(event -> handleError("Failed to generate GPX File", gpxExportService.getException())); tcxExportService.setOnSucceeded(event -> gpxExportFinished()); tcxExportService .setOnFailed(event -> handleError("Failed to generate TCX File", tcxExportService.getException())); // ActivityTable tcDate.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate())); tcDate.setCellFactory(param -> new LocalDateCellFactory()); tcDate.setSortType(TableColumn.SortType.DESCENDING); tcDistance.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDistance() / 1000)); tcDistance.setCellFactory(param -> new NumberCellFactory(1, "km")); tcDuration.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDrivingTime())); tcDuration.setCellFactory(param -> new DurationCellFactory()); activitiesTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); activitiesTable.getSelectionModel().getSelectedItems() .addListener((ListChangeListener<ActivityHeaderGroup>) c -> { while (c.next()) { if (c.wasRemoved()) { for (ActivityHeaderGroup activityHeaderGroup : c.getRemoved()) { lstSegments.getItems().removeAll(activityHeaderGroup.getActivityHeaders()); } } if (c.wasAdded()) { for (ActivityHeaderGroup activityHeaderGroup : c.getAddedSubList()) { if (activityHeaderGroup != null) { // WTF? Why can this be null!? lstSegments.getItems().addAll(activityHeaderGroup.getActivityHeaders()); } } } } lstSegments.getItems().sort((o1, o2) -> o1.getStartTime().isAfter(o2.getStartTime()) ? 1 : 0); }); activitiesTable.setOnMouseClicked(event -> { if (event.getClickCount() == 2) { lstSegments.getCheckModel().checkAll(); openSelectedSections(); } }); // Segment List lstSegments .setCellFactory(listView -> new CheckBoxListCell<>(item -> lstSegments.getItemBooleanProperty(item), new StringConverter<ActivityHeader>() { @Override public ActivityHeader fromString(String arg0) { return null; } @Override public String toString(ActivityHeader activityHeader) { final String startTime = activityHeader.getStartTime().format(DATE_TIME_FORMATTER); final String endTime = activityHeader.getEndTime().format(TIME_FORMATTER); final double distance = activityHeader.getDistance() / 1000; return startTime + " - " + endTime + " (" + NUMBER_FORMAT.format(distance) + " km)"; } })); // -- Chart chartRangeSlider.setLowValue(0); chartRangeSlider.setHighValue(chartRangeSlider.getMax()); xAxis.setAutoRanging(false); xAxis.lowerBoundProperty().bind(chartRangeSlider.lowValueProperty()); xAxis.upperBoundProperty().bind(chartRangeSlider.highValueProperty()); xAxis.tickUnitProperty().bind( chartRangeSlider.highValueProperty().subtract(chartRangeSlider.lowValueProperty()).divide(20)); xAxis.setTickLabelFormatter(new StringConverter<Number>() { @Override public String toString(Number object) { final Duration duration = Duration.of(object.intValue(), ChronoUnit.SECONDS); return String.valueOf(DurationFormatter.formatHhMmSs(duration)); } @Override public Number fromString(String string) { return null; } }); chart.getChart().setOnScroll(event -> { final double scrollAmount = event.getDeltaY(); chartRangeSlider.setLowValue(chartRangeSlider.getLowValue() + scrollAmount); chartRangeSlider.setHighValue(chartRangeSlider.getHighValue() - scrollAmount); }); xAxis.setOnMouseMoved(event -> { if (getCurrentActivityDetailsGroup() == null) { return; } final Number valueForDisplay = xAxis.getValueForDisplay(event.getX()); final List<Coordinate> trackpoints = getCurrentActivityDetailsGroup().getJoinedTrackpoints(); final int index = valueForDisplay.intValue(); if (index >= 0 && index < trackpoints.size()) { final Coordinate coordinate = trackpoints.get(index); if (coordinate.isValid()) { final LatLng latLng = new LatLng(coordinate); try { webEngine.executeScript( "updateMarkerPosition(" + objectMapper.writeValueAsString(latLng) + ");"); } catch (JsonProcessingException e) { e.printStackTrace(); //TODO clean up ugly code!!!!-------------- } } } }); // -- Current ActivityDetails this.currentActivityDetailsGroup.addListener((observable, oldValue, newValue) -> { if (newValue != null) { activityGroupChanged(newValue); } }); }
From source file:com.ggvaidya.scinames.model.Project.java
public Project(String projectName, File projectFile) { this.projectName = new SimpleStringProperty(projectName); this.projectFile = new SimpleObjectProperty<>(projectFile); }
From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java
synchronized private void initVertex(INode vertex) { if (vertex.getAddress().isMulticast()) { return;/* w w w. j ava2s . c o m*/ } final IRenderer renderer = vertex.getComponent(ViewComponent.class).getRenderer(); final Shape nodeShape = renderer.getShape(); //nodeShape.addEventFilter( MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler()); //nodeShape.addEventFilter( MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler()); //nodeShape.setCache(false); //nodeShape.setCacheHint(CacheHint.); final NodeStatisticsComponent nsc = vertex.getComponent(NodeStatisticsComponent.class); final DoubleBinding nodeSize = MyBindings .divideIntToDouble(nsc.getCommunicationCountProperty(), port.getMaxThroughputProperty()).add(1); nodeShape.scaleXProperty().bind(nodeSize); nodeShape.scaleYProperty().bind(nodeSize); nodeShape.setLayoutX(layout.transform(vertex).getX()); nodeShape.setLayoutY(layout.transform(vertex).getY()); /////////// // LABEL // /////////// Label nodeLabel = new Label(); // cast the shapes to circles (because right now i know they are circles) //TODO make this for arbitrary shapes final Circle nodeCircle = (Circle) nodeShape; /* final DoubleProperty labelX = new SimpleDoubleProperty(); final DoubleProperty labelY = new SimpleDoubleProperty();*/ //labelX.bind(nodeShape.layoutXProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty()))); //labelY.bind(nodeShape.layoutYProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty()))); //nodeLabel.layoutXProperty().bindBidirectionalWithOffset(labelX); //nodeLabel.layoutYProperty().bindBidirectionalWithOffset(labelY); //nodeLabel.layoutXProperty().bind(nodeShape.layoutXProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty()))); nodeLabel.textFillProperty().bind(new SimpleObjectProperty<>(Color.WHITE)); //MyBindings.bindBidirectionalWithOffset(nodeLabel.layoutXProperty(), nodeShape.layoutXProperty(), nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())); //MyBindings.bindBidirectionalWithOffset(nodeLabel.layoutYProperty(), nodeShape.layoutYProperty(), nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty())); nodeLabel.layoutXProperty().bind(nodeShape.layoutXProperty().add(nodeShape.translateXProperty()) .add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty()))); nodeLabel.layoutYProperty().bind(nodeShape.layoutYProperty().add(nodeShape.translateYProperty()) .add(nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty()))); NodeInfoComponent nic = vertex.getComponent(NodeInfoComponent.class); if (nic != null) { nodeLabel.textProperty().bind(nic.toStringBinding()); } nodeLabel.scaleXProperty().bind(Bindings.divide(1, canvas.scaleXProperty())); nodeLabel.scaleYProperty().bind(Bindings.divide(1, canvas.scaleYProperty())); nodeLabel.addEventFilter(MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler(vertex)); nodeLabel.addEventFilter(MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler(vertex)); nodeLabel.addEventFilter(MouseEvent.MOUSE_RELEASED, nodeGestures.getOnMouseReleasedEventHandler(vertex)); nodeShape.addEventFilter(MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler(vertex)); nodeShape.addEventFilter(MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler(vertex)); nodeShape.addEventFilter(MouseEvent.MOUSE_RELEASED, nodeGestures.getOnMouseReleasedEventHandler(vertex)); nodeShape.addEventFilter(MouseEvent.MOUSE_CLICKED, nodeGestures.getOnMouseClickedEventHandler(vertex)); canvas.getChildren().addAll(nodeLabel, nodeShape); }
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java
private void buildDataFields(boolean assemblageValid, RefexDynamicDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }/* ww w .j a v a2 s.co m*/ currentDataFieldWarnings_.clear(); for (RefexDataTypeNodeDetails nd : currentDataFields_) { nd.cleanupListener(); } currentDataFields_.clear(); GridPane gp = new GridPane(); gp.setHgap(10.0); gp.setVgap(10.0); gp.setStyle("-fx-padding: 5;"); int row = 0; boolean extraInfoColumnIsRequired = false; for (RefexDynamicColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<RefexDynamicDataType> polymorphicType = null; Label l = new Label(ci.getColumnName()); l.getStyleClass().add("boldLabel"); l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l)); Tooltip.install(l, new Tooltip(ci.getColumnDescription())); int col = 0; gp.add(l, col++, row); if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<RefexDynamicDataType>() { @Override public String toString(RefexDynamicDataType object) { return object.getDisplayName(); } @Override public RefexDynamicDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (RefexDynamicDataType type : RefexDynamicDataType.values()) { if (type == RefexDynamicDataType.POLYMORPHIC || type == RefexDynamicDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? RefexDynamicDataType.STRING : (currentValues[row] == null ? RefexDynamicDataType.STRING : currentValues[row].getRefexDataType()))); } RefexDataTypeNodeDetails nd = RefexDataTypeFXNodeBuilder.buildNodeForType(ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, new SimpleObjectProperty<>(ci.getValidator()), new SimpleObjectProperty<>(ci.getValidatorData())); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) { nd.addUpdateParentListListener(currentDataFieldWarnings_); } currentDataFields_.add(nd); gp.add(nd.getNodeForDisplay(), col++, row); Label colType = new Label(ci.getColumnDataType().getDisplayName()); colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType)); gp.add((polymorphicType == null ? colType : polymorphicType), col++, row); if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) { extraInfoColumnIsRequired = true; StackPane stackPane = new StackPane(); stackPane.setMaxWidth(Double.MAX_VALUE); if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) { ImageView information = Images.INFORMATION.createImageView(); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(defaultValueTooltip); Tooltip.install(information, tooltip); tooltip.setAutoHide(true); information.setOnMouseClicked( event -> tooltip.show(information, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(information); } if (ci.isColumnRequired()) { ImageView exclamation = Images.EXCLAMATION.createImageView(); final BooleanProperty showExclamation = new SimpleBooleanProperty( StringUtils.isNotBlank(valueIsRequired.get())); valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue, newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue))); exclamation.visibleProperty().bind(showExclamation); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(valueIsRequired); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked( event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(exclamation); } gp.add(stackPane, col++, row); } row++; } ColumnConstraints cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); if (extraInfoColumnIsRequired) { cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); } if (row == 0) { sp_.setContent(new Label("This assemblage does not allow data fields")); } else { sp_.setContent(gp); } allValid_.invalidate(); } else { sp_.setContent(null); } }