List of usage examples for javafx.scene.image ImageView visibleProperty
public final BooleanProperty visibleProperty()
From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java
/** * Setup an 'INFORMATION' info marker on the component. Automatically displays anytime that the initialControl is disabled. * Put the initial control in the provided stack pane *//*from w ww. jav a 2 s.c om*/ public static Node setupDisabledInfoMarker(Control initialControl, StackPane stackPane, ObservableStringValue reasonWhyControlDisabled) { ImageView information = Images.INFORMATION.createImageView(); information.visibleProperty().bind(initialControl.disabledProperty()); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(reasonWhyControlDisabled); Tooltip.install(information, tooltip); tooltip.setAutoHide(true); information.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { tooltip.show(information, event.getScreenX(), event.getScreenY()); } }); stackPane.setMaxWidth(Double.MAX_VALUE); stackPane.getChildren().add(initialControl); StackPane.setAlignment(initialControl, Pos.CENTER_LEFT); stackPane.getChildren().add(information); if (initialControl instanceof Button) { StackPane.setAlignment(information, Pos.CENTER); } else if (initialControl instanceof CheckBox) { StackPane.setAlignment(information, Pos.CENTER_LEFT); StackPane.setMargin(information, new Insets(0, 0, 0, 1)); } else { StackPane.setAlignment(information, Pos.CENTER_RIGHT); double insetFromRight = (initialControl instanceof ComboBox ? 30.0 : 5.0); StackPane.setMargin(information, new Insets(0.0, insetFromRight, 0.0, 0.0)); } return stackPane; }
From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java
/** * Setup an 'EXCLAMATION' error marker on the component. Automatically displays anytime that the reasonWhyControlInvalid value * is false. Hides when the isControlCurrentlyValid is true. * @param stackPane - optional - created if necessary *//*from www . j av a2 s . c o m*/ public static StackPane setupErrorMarker(Node initialNode, StackPane stackPane, ValidBooleanBinding isNodeCurrentlyValid) { ImageView exclamation = Images.EXCLAMATION.createImageView(); if (stackPane == null) { stackPane = new StackPane(); } exclamation.visibleProperty().bind(isNodeCurrentlyValid.not()); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(isNodeCurrentlyValid.getReasonWhyInvalid()); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { tooltip.show(exclamation, event.getScreenX(), event.getScreenY()); } }); stackPane.setMaxWidth(Double.MAX_VALUE); stackPane.getChildren().add(initialNode); StackPane.setAlignment(initialNode, Pos.CENTER_LEFT); stackPane.getChildren().add(exclamation); StackPane.setAlignment(exclamation, Pos.CENTER_RIGHT); double insetFromRight; if (initialNode instanceof ComboBox) { insetFromRight = 30.0; } else if (initialNode instanceof ChoiceBox) { insetFromRight = 25.0; } else { insetFromRight = 5.0; } StackPane.setMargin(exclamation, new Insets(0.0, insetFromRight, 0.0, 0.0)); return stackPane; }
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java
private void buildDataFields(boolean assemblageValid, DynamicSememeDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }/*from ww w . ja va2 s . c o m*/ currentDataFieldWarnings_.clear(); for (SememeGUIDataTypeNodeDetails 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 (DynamicSememeColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<DynamicSememeDataType> 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() == DynamicSememeDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<DynamicSememeDataType>() { @Override public String toString(DynamicSememeDataType object) { return object.getDisplayName(); } @Override public DynamicSememeDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (DynamicSememeDataType type : DynamicSememeDataType.values()) { if (type == DynamicSememeDataType.POLYMORPHIC || type == DynamicSememeDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? DynamicSememeDataType.STRING : (currentValues[row] == null ? DynamicSememeDataType.STRING : currentValues[row].getDynamicSememeDataType()))); } SememeGUIDataTypeNodeDetails nd = SememeGUIDataTypeFXNodeBuilder.buildNodeForType( ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, ci.getValidator(), ci.getValidatorData()); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == DynamicSememeDataType.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); } }
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); }/*from w w w . java 2 s. c om*/ 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); } }