Example usage for javafx.scene.layout Priority NEVER

List of usage examples for javafx.scene.layout Priority NEVER

Introduction

In this page you can find the example usage for javafx.scene.layout Priority NEVER.

Prototype

Priority NEVER

To view the source code for javafx.scene.layout Priority NEVER.

Click Source Link

Document

Layout area will never grow (or shrink) when there is an increase (or decrease) in space available in the region.

Usage

From source file:de.perdoctus.ebikeconnect.gui.dialogs.LoginDialog.java

@PostConstruct
public void init() {
    final ImageView graphic = new ImageView(
            new Image(getClass().getResource("/app-icon.png").toExternalForm()));
    graphic.setPreserveRatio(true);//from  w w  w.ja va  2s .  c  o m
    graphic.setFitHeight(64);
    setGraphic(graphic);
    setResizable(true);
    setWidth(400);
    setResizable(false);

    setTitle(rb.getString("dialogTitle"));
    setHeaderText(rb.getString("dialogMessage"));

    final ButtonType loginButtonType = new ButtonType(rb.getString("loginButton"),
            ButtonBar.ButtonData.OK_DONE);
    getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

    // Create the username and password labels and fields.
    final GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 10, 10, 10));
    grid.setPrefWidth(getWidth());
    grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.LEFT, true));
    grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.ALWAYS, HPos.LEFT, true));

    final String rbUsername = rb.getString(CFG_USERNAME);
    final TextField txtUsername = new TextField();
    txtUsername.setPromptText(rbUsername);
    txtUsername.setText(config.getString(CFG_USERNAME, ""));

    final Label lblUsername = new Label(rbUsername);
    lblUsername.setLabelFor(txtUsername);
    grid.add(lblUsername, 0, 0);
    grid.add(txtUsername, 1, 0);

    final String rbPassword = rb.getString(CFG_PASSWORD);
    final PasswordField txtPassword = new PasswordField();
    txtPassword.setPromptText(rbPassword);
    if (config.getBoolean(CFG_SAVE_PASSWORD, false)) {
        txtPassword.setText(config.getString(CFG_PASSWORD, ""));
    }

    final Label lblPassword = new Label(rbPassword);
    lblPassword.setLabelFor(txtPassword);
    grid.add(lblPassword, 0, 1);
    grid.add(txtPassword, 1, 1);

    final CheckBox cbSavePassword = new CheckBox(rb.getString("save-password"));
    cbSavePassword.setSelected(config.getBoolean(CFG_SAVE_PASSWORD, false));
    grid.add(cbSavePassword, 1, 2);

    getDialogPane().setContent(grid);

    // Enable/Disable login button depending on whether a username was entered.
    final Node loginButton = getDialogPane().lookupButton(loginButtonType);
    loginButton.disableProperty()
            .bind(txtUsername.textProperty().isEmpty().or(txtPassword.textProperty().isEmpty()));

    setResultConverter(buttonType -> {
        if (buttonType == loginButtonType) {
            config.setProperty(CFG_USERNAME, txtUsername.getText());
            config.setProperty(CFG_SAVE_PASSWORD, cbSavePassword.isSelected());
            if (cbSavePassword.isSelected()) {
                config.setProperty(CFG_PASSWORD, txtPassword.getText());
                config.setProperty(CFG_PASSWORD, txtPassword.getText());
            } else {
                config.clearProperty(CFG_PASSWORD);
            }
            return new Credentials(txtUsername.getText(), txtPassword.getText());
        } else {
            return null;
        }
    });

    if (txtUsername.getText().isEmpty()) {
        txtUsername.requestFocus();
    } else {
        txtPassword.requestFocus();
        txtPassword.selectAll();
    }
}

From source file:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginTextFieldProperty.java

public PreferencesPluginTextFieldProperty(Label label, boolean emptyStringAllowed) {
    super(label, new TextField(), new SimpleStringProperty(), null, // validator handled below
            new StringConverter<String>() {
                @Override// www  .  ja va2 s .com
                public String convertToString(String value) {
                    return value != null ? value.toString() : null;
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    property.getProperty().bind(property.getControl().textProperty());
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    property.getControl().textProperty().set(property.readFromPersistedPreferences());
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    GridPane.setHgrow(property.getLabel(), Priority.NEVER);
                    GridPane.setFillWidth(property.getControl(), true);
                    GridPane.setHgrow(property.getControl(), Priority.ALWAYS);
                }
            });
    validator = new ValidBooleanBinding() {
        {
            bind(getProperty());
            setComputeOnInvalidate(true);
        }

        @Override
        protected boolean computeValue() {
            if (!emptyStringAllowed && StringUtils.isBlank(getProperty().getValue())) {
                this.setInvalidReason("unspecified value for " + name);
                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }

            this.clearInvalidReason();

            return true;
        }
    };
}

From source file:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginComboBoxProperty.java

/**
 * @param name/*w ww  . j  a va 2  s.co m*/
 * @param stringConverter
 * 
 * Constructor for ComboBox that displays a String
 * that must be derived/converted from its underlying value
 * 
 * Allows a preexisting Label to be used
 */
protected PreferencesPluginComboBoxProperty(Label label, StringConverter<T> stringConverter) {
    super(label, new ComboBox<T>(), new SimpleObjectProperty<T>(), null, // validator handled below
            stringConverter, new PropertyAction<T, ComboBox<T>>() {
                @Override
                public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) {
                    property.getProperty()
                            .bind(property.getControl().getSelectionModel().selectedItemProperty());
                }
            }, new PropertyAction<T, ComboBox<T>>() {
                @Override
                public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) {
                    property.getControl().getSelectionModel().select(property.readFromPersistedPreferences());
                }
            }, new PropertyAction<T, ComboBox<T>>() {
                @Override
                public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) {
                    GridPane.setHgrow(property.getLabel(), Priority.NEVER);
                    GridPane.setFillWidth(property.getControl(), true);
                    GridPane.setHgrow(property.getControl(), Priority.ALWAYS);
                }
            });
    validator = new ValidBooleanBinding() {
        {
            bind(getProperty());
            setComputeOnInvalidate(true);
        }

        @Override
        protected boolean computeValue() {
            if (getProperty().getValue() == null) {
                this.setInvalidReason("null/unset/unselected " + name);

                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }
            if (StringUtils.isEmpty(getStringConverter().convertToString(getProperty().getValue()))) {
                this.setInvalidReason("Invalid " + name);

                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }

            this.clearInvalidReason();
            return true;
        }
    };

    control.setCellFactory(new Callback<ListView<T>, ListCell<T>>() {
        @Override
        public ListCell<T> call(ListView<T> param) {
            final ListCell<T> cell = new ListCell<T>() {
                @Override
                protected void updateItem(T c, boolean emptyRow) {
                    super.updateItem(c, emptyRow);

                    if (c == null) {
                        setText(null);
                    } else {
                        String diplay = getStringConverter().convertToString(c);
                        setText(diplay);
                    }
                }
            };

            return cell;
        }
    });
    control.setButtonCell(new ListCell<T>() {
        @Override
        protected void updateItem(T c, boolean emptyRow) {
            super.updateItem(c, emptyRow);
            if (emptyRow) {
                setText("");
            } else {
                String diplay = getStringConverter().convertToString(c);
                setText(diplay);
            }
        }
    });
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

private void createDialogItems() {
    Validate.notNull(this.logReader); // Will be used to initialize input field values

    // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables.
    final GridPane gp = new GridPane();
    gp.setAlignment(Pos.BASELINE_LEFT);/*from  w  w  w  .  jav a2 s .co m*/
    gp.setHgap(10d);
    gp.setVgap(15d);
    gp.setPadding(new Insets(5d));
    final ColumnConstraints column1 = new ColumnConstraints();
    final ColumnConstraints column2 = new ColumnConstraints();
    column1.setHgrow(Priority.NEVER);
    column2.setHgrow(Priority.SOMETIMES);
    gp.getColumnConstraints().addAll(column1, column2);
    this.insertConfigItemsIntoGrid(gp, this.createConfigurationForm());
    final TitledPane configPane = new TitledPane("Edit Configuration", gp);
    configPane.setGraphic(Icons.getIconGraphics("pencil"));
    configPane.setCollapsible(false);

    final VBox lines = this.createRunForm();
    final TitledPane testPane = new TitledPane("Test Configuration", lines);
    testPane.setGraphic(Icons.getIconGraphics("script_go"));
    testPane.setCollapsible(false);

    final VBox panes = new VBox(configPane, testPane);
    panes.setSpacing(10d);
    final ScrollPane sp = new ScrollPane(panes);
    sp.setPadding(new Insets(10d));
    sp.setFitToWidth(true);
    this.setCenter(sp);
    // CHECKSTYLE:ON
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java

@FXML
void initialize() {
    assert rootStackPaneInTab != null : "fx:id=\"rootStackPaneInTab\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert gridPaneInRootStackPane != null : "fx:id=\"gridPaneInRootStackPane\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert topGridPane != null : "fx:id=\"topGridPane\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert bottomGridPane != null : "fx:id=\"bottomGridPane\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert datePicker != null : "fx:id=\"datePicker\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert dateSelectionMethodComboBox != null : "fx:id=\"dateSelectionMethodComboBox\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert pathComboBox != null : "fx:id=\"pathComboBox\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert selectableModuleListView != null : "fx:id=\"selectableModuleListView\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert statusesToggleGroupVBox != null : "fx:id=\"statusesToggleGroupVBox\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";
    assert statedInferredToggleGroupVBox != null : "fx:id=\"statedInferredToggleGroupVBox\" was not injected: check your FXML file 'ViewCoordinatePreferencesPluginView.fxml'.";

    RowConstraints gridPaneRowConstraints = new RowConstraints();
    gridPaneRowConstraints.setVgrow(Priority.NEVER);

    addGridPaneRowConstraintsToAllRows(gridPaneInRootStackPane, gridPaneRowConstraints);
    addGridPaneRowConstraintsToAllRows(topGridPane, gridPaneRowConstraints);
    addGridPaneRowConstraintsToAllRows(bottomGridPane, gridPaneRowConstraints);

    //      currentPathProperty.addListener((observable, oldValue, newValue) -> {
    //         log.debug("currentPathProperty changed from {} to {}", oldValue, newValue);
    //      });//  www  . j  a v  a2 s  .  c  o m
    //      currentStatedInferredOptionProperty.addListener((observable, oldValue, newValue) -> {
    //         log.debug("currentStatedInferredOptionProperty changed from {} to {}", oldValue, newValue);
    //      });
    //      currentTimeProperty.addListener((observable, oldValue, newValue) -> {
    //         log.debug("currentTimeProperty changed from {} to {}", oldValue, newValue);
    //      });
    //      currentStatusesProperty.addListener((observable, oldValue, newValue) -> {
    //         log.debug("currentStatusesProperty changed from {} to {}", Arrays.toString(oldValue.toArray()), Arrays.toString(newValue.toArray()));
    //      });

    initializeDatePicker();
    initializeDateSelectionMethodComboBox();
    initializePathComboBox();
    initializeSelectableModuleListView();
    initializeStatusesToggleGroup();
    initializeStatedInferredToggleGroup();
    initializeValidBooleanBinding();
}

From source file:de.ks.idnadrev.information.chart.ChartDataEditor.java

protected void addRowConstraint() {
    dataContainer.getRowConstraints().add(new RowConstraints(30, Control.USE_COMPUTED_SIZE,
            Control.USE_COMPUTED_SIZE, Priority.NEVER, VPos.CENTER, true));
}

From source file:uk.co.everywheremusic.viewcontroller.SetupScene.java

private boolean validateForm() {

    boolean valid = true;
    String errorMessage = "";

    File musicDir = new File(txtFolder.getText());
    if (!musicDir.isDirectory()) {
        valid = false;//from   w  ww.  j a v a2  s.c  o m
        errorMessage += Globals.SETUP_ERR_INVALID_FOLDER + "\n\n";
    }

    String password = txtPassword.getText();
    String confirmPassword = txtConfirmPassword.getText();
    if (!password.equals(confirmPassword)) {
        valid = false;
        errorMessage += "Passwords do not match\n\n";
    }

    if (password.equals("")) {
        valid = false;
        errorMessage += "Enter a password\n\n";
    }

    if (!valid) {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle(Globals.SETUP_ALERT_TITLE);
        alert.setHeaderText(Globals.SETUP_ALERT_HEADER_TEXT);

        TextArea text = new TextArea(errorMessage);
        text.setEditable(false);
        text.setWrapText(true);
        GridPane.setVgrow(text, Priority.NEVER);
        GridPane.setHgrow(text, Priority.NEVER);

        GridPane content = new GridPane();
        content.setMaxWidth(Double.MAX_VALUE);
        content.add(text, 0, 0);

        alert.getDialogPane().setContent(content);
        alert.showAndWait();
    }

    return valid;

}

From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java

public TitledPane createPanelForConfiguration() {
    final GridPane gp = new GridPane();
    gp.setAlignment(Pos.BASELINE_LEFT);/*ww w  . j ava  2s .com*/
    final double hGapOfGridPane = 10d;
    gp.setHgap(hGapOfGridPane);
    final double vGapOfGridPane = 15d;
    gp.setVgap(vGapOfGridPane);
    final double paddingOfGridPane = 5d;
    gp.setPadding(new Insets(paddingOfGridPane));
    final ColumnConstraints column1 = new ColumnConstraints();
    final ColumnConstraints column2 = new ColumnConstraints();
    column1.setHgrow(Priority.NEVER);
    column2.setHgrow(Priority.SOMETIMES);
    gp.getColumnConstraints().addAll(column1, column2);
    this.insertConfigItemsIntoGrid(gp, this.createConfigurationForm());
    final TitledPane configPane = new TitledPane("Edit Configuration", gp);
    configPane.setGraphic(Icons.getIconGraphics("pencil"));
    configPane.setCollapsible(false);
    return configPane;
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java

private AddSememePopup() {
    super();/*from w  w  w  .j a va2 s  . com*/
    BorderPane root = new BorderPane();

    VBox topItems = new VBox();
    topItems.setFillWidth(true);

    title_ = new Label("Create new sememe instance");
    title_.getStyleClass().add("titleLabel");
    title_.setAlignment(Pos.CENTER);
    title_.prefWidthProperty().bind(topItems.widthProperty());
    topItems.getChildren().add(title_);
    VBox.setMargin(title_, new Insets(10, 10, 10, 10));

    gp_ = new GridPane();
    gp_.setHgap(10.0);
    gp_.setVgap(10.0);
    VBox.setMargin(gp_, new Insets(5, 5, 5, 5));
    topItems.getChildren().add(gp_);

    Label referencedComponent = new Label("Referenced Component");
    referencedComponent.getStyleClass().add("boldLabel");
    gp_.add(referencedComponent, 0, 0);

    unselectableComponentLabel_ = new CopyableLabel();
    unselectableComponentLabel_.setWrapText(true);
    AppContext.getService(DragRegistry.class).setupDragOnly(unselectableComponentLabel_, () -> {
        if (editRefex_ == null) {
            return focusNid_ + "";
        } else {
            return Get.identifierService().getConceptNid(editRefex_.getSememe().getAssemblageSequence()) + "";
        }
    });
    //delay adding till we know which row

    Label assemblageConceptLabel = new Label("Assemblage Concept");
    assemblageConceptLabel.getStyleClass().add("boldLabel");
    gp_.add(assemblageConceptLabel, 0, 1);

    selectableConcept_ = new ConceptNode(null, true, refexDropDownOptions, null);

    selectableConcept_.getConceptProperty().addListener(new ChangeListener<ConceptSnapshot>() {
        @Override
        public void changed(ObservableValue<? extends ConceptSnapshot> observable, ConceptSnapshot oldValue,
                ConceptSnapshot newValue) {
            if (createRefexFocus_ != null && createRefexFocus_ == ViewFocus.REFERENCED_COMPONENT) {
                if (selectableConcept_.isValid().get()) {
                    //Its a valid concept, but is it a valid assemblage concept?
                    try {
                        assemblageInfo_ = DynamicSememeUsageDescription
                                .read(selectableConcept_.getConceptNoWait().getNid());
                        assemblageIsValid_.set(true);
                        if (assemblageInfo_.getReferencedComponentTypeRestriction() != null) {
                            String result = DynamicSememeValidatorType.COMPONENT_TYPE
                                    .passesValidatorStringReturn(new DynamicSememeNid(focusNid_),
                                            new DynamicSememeString(assemblageInfo_
                                                    .getReferencedComponentTypeRestriction().name()),
                                            null, null); //don't need coordinates for component type validator
                            if (result.length() > 0) {
                                selectableConcept_.isValid()
                                        .setInvalid("The selected assemblage requires the component type to be "
                                                + assemblageInfo_.getReferencedComponentTypeRestriction()
                                                        .toString()
                                                + ", which doesn't match the referenced component.");
                                logger_.info("The selected assemblage requires the component type to be "
                                        + assemblageInfo_.getReferencedComponentTypeRestriction().toString()
                                        + ", which doesn't match the referenced component.");
                                assemblageIsValid_.set(false);
                            }
                        }
                    } catch (Exception e) {
                        selectableConcept_.isValid().setInvalid(
                                "The selected concept is not properly constructed for use as an Assemblage concept");
                        logger_.info("Concept not a valid concept for a sememe assemblage", e);
                        assemblageIsValid_.set(false);
                    }
                } else {
                    assemblageInfo_ = null;
                    assemblageIsValid_.set(false);
                }
                buildDataFields(assemblageIsValid_.get(), null);
            }
        }
    });

    selectableComponent_ = new TextField();

    selectableComponentNodeValid_ = new ValidBooleanBinding() {
        {
            setComputeOnInvalidate(true);
            bind(selectableComponent_.textProperty());
            invalidate();
        }

        @Override
        protected boolean computeValue() {
            if (createRefexFocus_ != null && createRefexFocus_ == ViewFocus.ASSEMBLAGE
                    && !conceptNodeIsConceptType_) {
                //If the assembly nid was what was set - the component node may vary - validate if we are using the text field 
                String value = selectableComponent_.getText().trim();
                if (value.length() > 0) {
                    try {
                        if (Utility.isUUID(value)) {
                            String result = DynamicSememeValidatorType.COMPONENT_TYPE
                                    .passesValidatorStringReturn(new DynamicSememeUUID(UUID.fromString(value)),
                                            new DynamicSememeString(assemblageInfo_
                                                    .getReferencedComponentTypeRestriction().name()),
                                            null, null); //component type validator doesn't use vc, so null is ok
                            if (result.length() > 0) {
                                setInvalidReason(result);
                                logger_.info(result);
                                return false;
                            }
                        } else if (Utility.isInt(value)) {
                            String result = DynamicSememeValidatorType.COMPONENT_TYPE
                                    .passesValidatorStringReturn(new DynamicSememeNid(Integer.parseInt(value)),
                                            new DynamicSememeString(assemblageInfo_
                                                    .getReferencedComponentTypeRestriction().name()),
                                            null, null); //component type validator doesn't use vc, so null is ok
                            if (result.length() > 0) {
                                setInvalidReason(result);
                                logger_.info(result);
                                return false;
                            }
                        } else {
                            setInvalidReason(
                                    "Value cannot be parsed as a component identifier.  Must be a UUID or a valid NID");
                            return false;
                        }
                    } catch (Exception e) {
                        logger_.error("Error checking component type validation", e);
                        setInvalidReason("Unexpected error validating entry");
                        return false;
                    }
                } else {
                    setInvalidReason("Component identifier is required");
                    return false;
                }
            }
            clearInvalidReason();
            return true;
        }
    };

    selectableComponentNode_ = ErrorMarkerUtils.setupErrorMarker(selectableComponent_, null,
            selectableComponentNodeValid_);

    //delay adding concept / component till we know if / where
    ColumnConstraints cc = new ColumnConstraints();
    cc.setHgrow(Priority.NEVER);
    cc.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(referencedComponent));
    gp_.getColumnConstraints().add(cc);

    cc = new ColumnConstraints();
    cc.setHgrow(Priority.ALWAYS);
    gp_.getColumnConstraints().add(cc);

    Label l = new Label("Data Fields");
    l.getStyleClass().add("boldLabel");
    VBox.setMargin(l, new Insets(5, 5, 5, 5));
    topItems.getChildren().add(l);

    root.setTop(topItems);

    sp_ = new ScrollPane();
    sp_.visibleProperty().bind(assemblageIsValid_);
    sp_.setFitToHeight(true);
    sp_.setFitToWidth(true);
    root.setCenter(sp_);

    allValid_ = new UpdateableBooleanBinding() {
        {
            addBinding(assemblageIsValid_, selectableConcept_.isValid(), selectableComponentNodeValid_);
        }

        @Override
        protected boolean computeValue() {
            if (assemblageIsValid_.get() && (conceptNodeIsConceptType_ ? selectableConcept_.isValid().get()
                    : selectableComponentNodeValid_.get())) {
                boolean allDataValid = true;
                for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) {
                    if (ssp.get().length() > 0) {
                        allDataValid = false;
                        break;
                    }
                }
                if (allDataValid) {
                    clearInvalidReason();
                    return true;
                }
            }
            setInvalidReason("All errors must be corrected before save is allowed");
            return false;
        }
    };

    GridPane bottomRow = new GridPane();
    //spacer col
    bottomRow.add(new Region(), 0, 0);

    Button cancelButton = new Button("Cancel");
    cancelButton.setOnAction((action) -> {
        close();
    });
    GridPane.setMargin(cancelButton, new Insets(5, 20, 5, 0));
    GridPane.setHalignment(cancelButton, HPos.RIGHT);
    bottomRow.add(cancelButton, 1, 0);

    Button saveButton = new Button("Save");
    saveButton.disableProperty().bind(allValid_.not());
    saveButton.setOnAction((action) -> {
        doSave();
    });
    Node wrappedSave = ErrorMarkerUtils.setupDisabledInfoMarker(saveButton, allValid_.getReasonWhyInvalid());
    GridPane.setMargin(wrappedSave, new Insets(5, 0, 5, 20));
    bottomRow.add(wrappedSave, 2, 0);

    //spacer col
    bottomRow.add(new Region(), 3, 0);

    cc = new ColumnConstraints();
    cc.setHgrow(Priority.SOMETIMES);
    cc.setFillWidth(true);
    bottomRow.getColumnConstraints().add(cc);
    cc = new ColumnConstraints();
    cc.setHgrow(Priority.NEVER);
    bottomRow.getColumnConstraints().add(cc);
    cc = new ColumnConstraints();
    cc.setHgrow(Priority.NEVER);
    bottomRow.getColumnConstraints().add(cc);
    cc = new ColumnConstraints();
    cc.setHgrow(Priority.SOMETIMES);
    cc.setFillWidth(true);
    bottomRow.getColumnConstraints().add(cc);
    root.setBottom(bottomRow);

    Scene scene = new Scene(root);
    scene.getStylesheets().add(AddSememePopup.class.getResource("/isaac-shared-styles.css").toString());
    setScene(scene);
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java

private AddRefexPopup() {
    super();/*from  w w  w .  ja v  a 2 s  .  c  om*/
    BorderPane root = new BorderPane();

    VBox topItems = new VBox();
    topItems.setFillWidth(true);

    title_ = new Label("Create new sememe instance");
    title_.getStyleClass().add("titleLabel");
    title_.setAlignment(Pos.CENTER);
    title_.prefWidthProperty().bind(topItems.widthProperty());
    topItems.getChildren().add(title_);
    VBox.setMargin(title_, new Insets(10, 10, 10, 10));

    gp_ = new GridPane();
    gp_.setHgap(10.0);
    gp_.setVgap(10.0);
    VBox.setMargin(gp_, new Insets(5, 5, 5, 5));
    topItems.getChildren().add(gp_);

    Label referencedComponent = new Label("Referenced Component");
    referencedComponent.getStyleClass().add("boldLabel");
    gp_.add(referencedComponent, 0, 0);

    unselectableComponentLabel_ = new CopyableLabel();
    unselectableComponentLabel_.setWrapText(true);
    AppContext.getService(DragRegistry.class).setupDragOnly(unselectableComponentLabel_, () -> {
        if (editRefex_ == null) {
            if (createRefexFocus_.getComponentNid() != null) {
                return createRefexFocus_.getComponentNid() + "";
            } else {
                return createRefexFocus_.getAssemblyNid() + "";
            }
        } else {
            return editRefex_.getRefex().getAssemblageNid() + "";
        }
    });
    //delay adding till we know which row

    Label assemblageConceptLabel = new Label("Assemblage Concept");
    assemblageConceptLabel.getStyleClass().add("boldLabel");
    gp_.add(assemblageConceptLabel, 0, 1);

    selectableConcept_ = new ConceptNode(null, true, refexDropDownOptions, null);

    selectableConcept_.getConceptProperty().addListener(new ChangeListener<ConceptVersionBI>() {
        @Override
        public void changed(ObservableValue<? extends ConceptVersionBI> observable, ConceptVersionBI oldValue,
                ConceptVersionBI newValue) {
            if (createRefexFocus_ != null && createRefexFocus_.getComponentNid() != null) {
                if (selectableConcept_.isValid().get()) {
                    //Its a valid concept, but is it a valid assemblage concept?
                    try {
                        assemblageInfo_ = RefexDynamicUsageDescriptionBuilder
                                .readRefexDynamicUsageDescriptionConcept(
                                        selectableConcept_.getConceptNoWait().getNid());
                        assemblageIsValid_.set(true);
                        if (assemblageInfo_.getReferencedComponentTypeRestriction() != null) {
                            String result = RefexDynamicValidatorType.COMPONENT_TYPE
                                    .passesValidatorStringReturn(
                                            new RefexDynamicNid(createRefexFocus_.getComponentNid()),
                                            new RefexDynamicString(assemblageInfo_
                                                    .getReferencedComponentTypeRestriction().name()),
                                            null); //component type validator doesn't use vc, so null is ok
                            if (result.length() > 0) {
                                selectableConcept_.isValid()
                                        .setInvalid("The selected assemblage requires the component type to be "
                                                + assemblageInfo_.getReferencedComponentTypeRestriction()
                                                        .toString()
                                                + ", which doesn't match the referenced component.");
                                logger_.info("The selected assemblage requires the component type to be "
                                        + assemblageInfo_.getReferencedComponentTypeRestriction().toString()
                                        + ", which doesn't match the referenced component.");
                                assemblageIsValid_.set(false);
                            }
                        }
                    } catch (Exception e) {
                        selectableConcept_.isValid().setInvalid(
                                "The selected concept is not properly constructed for use as an Assemblage concept");
                        logger_.info("Concept not a valid concept for a sememe assemblage", e);
                        assemblageIsValid_.set(false);
                    }
                } else {
                    assemblageInfo_ = null;
                    assemblageIsValid_.set(false);
                }
                buildDataFields(assemblageIsValid_.get(), null);
            }
        }
    });

    selectableComponent_ = new TextField();

    selectableComponentNodeValid_ = new ValidBooleanBinding() {
        {
            setComputeOnInvalidate(true);
            bind(selectableComponent_.textProperty());
            invalidate();
        }

        @Override
        protected boolean computeValue() {
            if (createRefexFocus_ != null && createRefexFocus_.getAssemblyNid() != null
                    && !conceptNodeIsConceptType_) {
                //If the assembly nid was what was set - the component node may vary - validate if we are using the text field 
                String value = selectableComponent_.getText().trim();
                if (value.length() > 0) {
                    try {
                        if (Utility.isUUID(value)) {
                            String result = RefexDynamicValidatorType.COMPONENT_TYPE
                                    .passesValidatorStringReturn(new RefexDynamicUUID(UUID.fromString(value)),
                                            new RefexDynamicString(assemblageInfo_
                                                    .getReferencedComponentTypeRestriction().name()),
                                            null); //component type validator doesn't use vc, so null is ok
                            if (result.length() > 0) {
                                setInvalidReason(result);
                                logger_.info(result);
                                return false;
                            }
                        } else if (Utility.isInt(value)) {
                            String result = RefexDynamicValidatorType.COMPONENT_TYPE
                                    .passesValidatorStringReturn(new RefexDynamicNid(Integer.parseInt(value)),
                                            new RefexDynamicString(assemblageInfo_
                                                    .getReferencedComponentTypeRestriction().name()),
                                            null); //component type validator doesn't use vc, so null is ok
                            if (result.length() > 0) {
                                setInvalidReason(result);
                                logger_.info(result);
                                return false;
                            }
                        } else {
                            setInvalidReason(
                                    "Value cannot be parsed as a component identifier.  Must be a UUID or a valid NID");
                            return false;
                        }
                    } catch (Exception e) {
                        logger_.error("Error checking component type validation", e);
                        setInvalidReason("Unexpected error validating entry");
                        return false;
                    }
                } else {
                    setInvalidReason("Component identifier is required");
                    return false;
                }
            }
            clearInvalidReason();
            return true;
        }
    };

    selectableComponentNode_ = ErrorMarkerUtils.setupErrorMarker(selectableComponent_, null,
            selectableComponentNodeValid_);

    //delay adding concept / component till we know if / where
    ColumnConstraints cc = new ColumnConstraints();
    cc.setHgrow(Priority.NEVER);
    cc.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(referencedComponent));
    gp_.getColumnConstraints().add(cc);

    cc = new ColumnConstraints();
    cc.setHgrow(Priority.ALWAYS);
    gp_.getColumnConstraints().add(cc);

    Label l = new Label("Data Fields");
    l.getStyleClass().add("boldLabel");
    VBox.setMargin(l, new Insets(5, 5, 5, 5));
    topItems.getChildren().add(l);

    root.setTop(topItems);

    sp_ = new ScrollPane();
    sp_.visibleProperty().bind(assemblageIsValid_);
    sp_.setFitToHeight(true);
    sp_.setFitToWidth(true);
    root.setCenter(sp_);

    allValid_ = new UpdateableBooleanBinding() {
        {
            addBinding(assemblageIsValid_, selectableConcept_.isValid(), selectableComponentNodeValid_);
        }

        @Override
        protected boolean computeValue() {
            if (assemblageIsValid_.get() && (conceptNodeIsConceptType_ ? selectableConcept_.isValid().get()
                    : selectableComponentNodeValid_.get())) {
                boolean allDataValid = true;
                for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) {
                    if (ssp.get().length() > 0) {
                        allDataValid = false;
                        break;
                    }
                }
                if (allDataValid) {
                    clearInvalidReason();
                    return true;
                }
            }
            setInvalidReason("All errors must be corrected before save is allowed");
            return false;
        }
    };

    GridPane bottomRow = new GridPane();
    //spacer col
    bottomRow.add(new Region(), 0, 0);

    Button cancelButton = new Button("Cancel");
    cancelButton.setOnAction((action) -> {
        close();
    });
    GridPane.setMargin(cancelButton, new Insets(5, 20, 5, 0));
    GridPane.setHalignment(cancelButton, HPos.RIGHT);
    bottomRow.add(cancelButton, 1, 0);

    Button saveButton = new Button("Save");
    saveButton.disableProperty().bind(allValid_.not());
    saveButton.setOnAction((action) -> {
        doSave();
    });
    Node wrappedSave = ErrorMarkerUtils.setupDisabledInfoMarker(saveButton, allValid_.getReasonWhyInvalid());
    GridPane.setMargin(wrappedSave, new Insets(5, 0, 5, 20));
    bottomRow.add(wrappedSave, 2, 0);

    //spacer col
    bottomRow.add(new Region(), 3, 0);

    cc = new ColumnConstraints();
    cc.setHgrow(Priority.SOMETIMES);
    cc.setFillWidth(true);
    bottomRow.getColumnConstraints().add(cc);
    cc = new ColumnConstraints();
    cc.setHgrow(Priority.NEVER);
    bottomRow.getColumnConstraints().add(cc);
    cc = new ColumnConstraints();
    cc.setHgrow(Priority.NEVER);
    bottomRow.getColumnConstraints().add(cc);
    cc = new ColumnConstraints();
    cc.setHgrow(Priority.SOMETIMES);
    cc.setFillWidth(true);
    bottomRow.getColumnConstraints().add(cc);
    root.setBottom(bottomRow);

    Scene scene = new Scene(root);
    scene.getStylesheets().add(AddRefexPopup.class.getResource("/isaac-shared-styles.css").toString());
    setScene(scene);
}