Example usage for javafx.scene.control Label Label

List of usage examples for javafx.scene.control Label Label

Introduction

In this page you can find the example usage for javafx.scene.control Label Label.

Prototype

public Label(String text) 

Source Link

Document

Creates Label with supplied text.

Usage

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

@Override
public Region getContent() {
    if (hBox == null) {
        VBox statedInferredToggleGroupVBox = new VBox();
        statedInferredToggleGroupVBox.setSpacing(4.0);

        //Instantiate Everything
        pathComboBox = new ComboBox<>(); //Path
        statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred
        List<RadioButton> statedInferredOptionButtons = new ArrayList<>();
        datePicker = new DatePicker(); //Date
        timeSelectCombo = new ComboBox<Long>(); //Time

        //Radio buttons
        for (StatedInferredOptions option : StatedInferredOptions.values()) {
            RadioButton optionButton = new RadioButton();
            if (option == StatedInferredOptions.STATED) {
                optionButton.setText("Stated");
            } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) {
                optionButton.setText("Inferred Then Stated");
            } else if (option == StatedInferredOptions.INFERRED) {
                optionButton.setText("Inferred");
            } else {
                throw new RuntimeException("oops");
            }//from ww w .ja  va  2  s  . c  o  m
            optionButton.setUserData(option);
            optionButton.setTooltip(
                    new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption()));
            statedInferredToggleGroup.getToggles().add(optionButton);
            statedInferredToggleGroupVBox.getChildren().add(optionButton);
            statedInferredOptionButtons.add(optionButton);
        }
        statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
            @Override
            public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue,
                    Toggle newValue) {
                currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData());
            }
        });

        //Path Combo Box
        pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() {
            @Override
            public ListCell<UUID> call(ListView<UUID> param) {
                final ListCell<UUID> cell = new ListCell<UUID>() {
                    @Override
                    protected void updateItem(UUID c, boolean emptyRow) {
                        super.updateItem(c, emptyRow);
                        if (c == null) {
                            setText(null);
                        } else {
                            String desc = OTFUtility.getDescription(c);
                            setText(desc);
                        }
                    }
                };
                return cell;
            }
        });

        pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed
            @Override
            protected void updateItem(UUID c, boolean emptyRow) {
                super.updateItem(c, emptyRow);
                if (emptyRow) {
                    setText("");
                } else {
                    String desc = OTFUtility.getDescription(c);
                    setText(desc);
                }
            }
        });
        pathComboBox.setOnAction((event) -> {
            if (!pathComboFirstRun) {
                UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem();
                if (selectedPath != null) {
                    int path = OTFUtility.getConceptVersion(selectedPath).getPathNid();

                    StampBdb stampDb = Bdb.getStampDb();
                    NidSet nidSet = new NidSet();
                    nidSet.add(path);
                    //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also
                    NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE);

                    pathDatesList.clear();
                    //                  disableTimeCombo(true);
                    timeSelectCombo.setValue(Long.MAX_VALUE);

                    for (Integer thisStamp : stamps.getAsSet()) {
                        try {
                            Position stampPosition = stampDb.getPosition(thisStamp);
                            this.stampDate = new Date(stampPosition.getTime());
                            stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault())
                                    .toLocalDate();
                            this.pathDatesList.add(stampDateInstant); //Build DatePicker
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    datePicker.setValue(LocalDate.now());
                }
            } else {
                pathComboFirstRun = false;
            }
        });

        pathComboBox.setTooltip(
                new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\""));

        //Calendar Date Picker
        final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
            @Override
            public DateCell call(final DatePicker datePicker) {
                return new DateCell() {
                    @Override
                    public void updateItem(LocalDate thisDate, boolean empty) {
                        super.updateItem(thisDate, empty);
                        if (pathDatesList != null) {
                            if (pathDatesList.contains(thisDate)) {
                                setDisable(false);
                            } else {
                                setDisable(true);
                            }
                        }
                    }
                };
            }
        };
        datePicker.setDayCellFactory(dayCellFactory);
        datePicker.setOnAction((event) -> {
            if (!datePickerFirstRun) {
                UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem();

                Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault()));
                Long dateSelected = Date.from(instant).getTime();

                if (selectedPath != null && dateSelected != 0) {

                    int path = OTFUtility.getConceptVersion(selectedPath).getPathNid();
                    setTimeOptions(path, dateSelected);
                    try {
                        timeSelectCombo.setValue(times.first()); //Default Dropdown Value
                    } catch (Exception e) {
                        // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled
                        // Right now, Sometimes Time Combo is disabled, so we catch this and eat it
                        // Otherwise make a conditional from the Read Only Boolean Property to check first
                    }
                } else {
                    disableTimeCombo(false);
                    logger.debug("The path isn't set or the date isn't set. Both are needed right now");
                }
            } else {
                datePickerFirstRun = false;
            }
        });

        //Commit-Time ComboBox
        timeSelectCombo.setMinWidth(200);
        timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() {
            @Override
            public ListCell<Long> call(ListView<Long> param) {
                final ListCell<Long> cell = new ListCell<Long>() {
                    @Override
                    protected void updateItem(Long item, boolean emptyRow) {
                        super.updateItem(item, emptyRow);
                        if (item == null) {
                            setText("");
                        } else {
                            if (item == Long.MAX_VALUE) {
                                setText("LATEST TIME");
                            } else {
                                setText(timeFormatter.format(new Date(item)));
                            }
                        }
                    }
                };
                return cell;
            }
        });
        timeSelectCombo.setButtonCell(new ListCell<Long>() {
            @Override
            protected void updateItem(Long item, boolean emptyRow) {
                super.updateItem(item, emptyRow);
                if (item == null) {
                    setText("");
                } else {
                    if (item == Long.MAX_VALUE) {
                        setText("LATEST TIME");
                    } else {
                        setText(timeFormatter.format(new Date(item)));
                    }
                }
            }
        });

        try {
            currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property
            currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty());
        } catch (Exception e) {
            e.printStackTrace();
        }

        // DEFAULT VALUES
        UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile();
        storedTimePref = loggedIn.getViewCoordinateTime();
        storedPathPref = loggedIn.getViewCoordinatePath();

        if (storedPathPref != null) {
            pathComboBox.getItems().clear(); //Set the path Dates by default
            pathComboBox.getItems().addAll(getPathOptions());
            final UUID storedPath = getStoredPath();
            if (storedPath != null) {
                pathComboBox.getSelectionModel().select(storedPath);
            }

            if (storedTimePref != null) {
                final Long storedTime = loggedIn.getViewCoordinateTime();
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date(storedTime));
                cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds
                Long storedTruncTime = cal.getTimeInMillis();

                if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value
                    int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid();
                    setTimeOptions(path, storedTimePref);
                    timeSelectCombo.setValue(storedTruncTime);
                    //                  timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work

                    Date storedDate = new Date(storedTime);
                    datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
                } else {
                    datePicker.setValue(LocalDate.now());
                    timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work
                    timeSelectCombo.setValue(Long.MAX_VALUE);
                    //                  disableTimeCombo(false);
                }
            } else { //Stored Time Pref == null
                logger.error("ERROR: Stored Time Preference = null");
            }
        } else { //Stored Path Pref == null
            logger.error("We could not load a stored path, ISAAC cannot run");
            throw new Error("No stored PATH could be found. ISAAC can't run without a path");
        }

        GridPane gridPane = new GridPane();
        gridPane.setHgap(10);
        gridPane.setVgap(10);

        Label pathLabel = new Label("View Coordinate Path");
        gridPane.add(pathLabel, 0, 0); //Path Label - Row 0
        GridPane.setHalignment(pathLabel, HPos.LEFT);
        gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2

        gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2
        GridPane.setValignment(pathComboBox, VPos.TOP);

        Label datePickerLabel = new Label("View Coordinate Dates");
        gridPane.add(datePickerLabel, 0, 2); //Row 3
        GridPane.setHalignment(datePickerLabel, HPos.LEFT);
        gridPane.add(datePicker, 0, 3); //Row 4

        Label timeSelectLabel = new Label("View Coordinate Times");
        gridPane.add(timeSelectLabel, 1, 2); //Row 3
        GridPane.setHalignment(timeSelectLabel, HPos.LEFT);
        gridPane.add(timeSelectCombo, 1, 3); //Row 4

        // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY
        /*         
                 UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile();
                 StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy();
                 UUID chosenPathUuid = userProfile.getViewCoordinatePath();
                 Long chosenTime = userProfile.getViewCoordinateTime();
                         
                 Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid));
                 gridPane.add(printSelectedPathLabel, 0, 4);
                 GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT);
                 Label printSelectedTimeLabel = null;
                 if(chosenTime != getDefaultTime()) {
                    printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime)));
                 } else {
                    printSelectedTimeLabel = new Label("Time: LONG MAX VALUE");
                 }
                 gridPane.add(printSelectedTimeLabel, 1, 4);
                 GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT);
                 Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy);
                 gridPane.add(printSelectedPolicyLabel, 2, 4);
                 GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT);
                 */
        hBox = new HBox();
        hBox.getChildren().addAll(gridPane);

        allValid_ = new ValidBooleanBinding() {
            {
                bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty);
                setComputeOnInvalidate(true);
            }

            @Override
            protected boolean computeValue() {
                if (currentStatedInferredOptionProperty.get() == null) {
                    this.setInvalidReason("Null/unset/unselected StatedInferredOption");
                    for (RadioButton button : statedInferredOptionButtons) {
                        TextErrorColorHelper.setTextErrorColor(button);
                    }
                    return false;
                } else {
                    for (RadioButton button : statedInferredOptionButtons) {
                        TextErrorColorHelper.clearTextErrorColor(button);
                    }
                }
                if (currentPathProperty.get() == null) {
                    this.setInvalidReason("Null/unset/unselected path");
                    TextErrorColorHelper.setTextErrorColor(pathComboBox);

                    return false;
                } else {
                    TextErrorColorHelper.clearTextErrorColor(pathComboBox);
                }
                if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) {
                    this.setInvalidReason("Invalid path");
                    TextErrorColorHelper.setTextErrorColor(pathComboBox);

                    return false;
                } else {
                    TextErrorColorHelper.clearTextErrorColor(pathComboBox);
                }
                //               if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE)
                //               {
                //                  this.setInvalidReason("View Coordinate Time is unselected");
                //                  TextErrorColorHelper.setTextErrorColor(timeSelectCombo);
                //                  return false;
                //               }
                this.clearInvalidReason();
                return true;
            }
        };
    }
    //      createButton.disableProperty().bind(saveButtonValid.not()));

    // Reload persisted values every time
    final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption();
    for (Toggle toggle : statedInferredToggleGroup.getToggles()) {
        if (toggle.getUserData() == storedStatedInferredOption) {
            toggle.setSelected(true);
        }
    }

    //      pathComboBox.setButtonCell(new ListCell<UUID>() {
    //         @Override
    //         protected void updateItem(UUID c, boolean emptyRow) {
    //            super.updateItem(c, emptyRow); 
    //            if (emptyRow) {
    //               setText("");
    //            } else {
    //               String desc = OTFUtility.getDescription(c);
    //               setText(desc);
    //            }
    //         }
    //      });
    //      timeSelectCombo.setButtonCell(new ListCell<Long>() {
    //         @Override
    //         protected void updateItem(Long item, boolean emptyRow) {
    //            super.updateItem(item, emptyRow); 
    //            if (emptyRow) {
    //               setText("");
    //            } else {
    //               setText(timeFormatter.format(new Date(item)));
    //            }
    //         }
    //      });

    //      datePickerFirstRun = false;
    //      pathComboFirstRun = false;

    return hBox;
}

From source file:webapptest.FXMLDocumentController.java

@FXML //Displays the list of facilities
public void refreshFacility(ActionEvent event) {
    facilityList.getChildren().clear();//from ww w  . j ava2s  . c om

    //get the data of employees from the server
    List<String> temp = new ArrayList<>();
    temp.add("get_all_houses");
    String input = sendData(temp);

    //parse the data into an object
    List<Facility> facs = parseFacilityData(input);

    //display the headings for the employee display
    HBox heading = new HBox();
    Label id = new Label("House ID");
    Label neighborhood = new Label("House Neighborhood");

    heading.getChildren().add(id);
    heading.getChildren().add(neighborhood);

    facilityList.getChildren().add(heading);

    //loop through all available employees and display to screen
    for (Facility fac : facs) {
        HBox tempLine = new HBox();

        TextField hid = new TextField(fac.getHouseID());
        TextField hneighborhood = new TextField(fac.getHouseNeighborhood());

        tempLine.getChildren().add(hid);
        tempLine.getChildren().add(hneighborhood);

        facilityList.getChildren().add(tempLine);
    }
}

From source file:Main.java

private VBox getTransformationControls() {
    xSlider.setShowTickMarks(true);/*  ww  w.  j a v  a2s . c  om*/
    xSlider.setShowTickLabels(true);
    xSlider.snapToTicksProperty().set(true);

    ySlider.setShowTickMarks(true);
    ySlider.setShowTickLabels(true);
    ySlider.snapToTicksProperty().set(true);

    widthSlider.setShowTickMarks(true);
    widthSlider.setShowTickLabels(true);
    widthSlider.snapToTicksProperty().set(true);

    heightSlider.setShowTickMarks(true);
    heightSlider.setShowTickLabels(true);
    heightSlider.snapToTicksProperty().set(true);

    opacitySlider.setShowTickMarks(true);
    opacitySlider.setShowTickLabels(true);
    opacitySlider.snapToTicksProperty().set(true);
    opacitySlider.setMinorTickCount(5);
    opacitySlider.setMajorTickUnit(0.20d);

    strokeSlider.setShowTickMarks(true);
    strokeSlider.setShowTickLabels(true);
    strokeSlider.snapToTicksProperty().set(true);
    strokeSlider.setMinorTickCount(5);
    strokeSlider.setMajorTickUnit(1.0d);

    translateXSlider.setShowTickMarks(true);
    translateXSlider.setShowTickLabels(true);
    translateXSlider.snapToTicksProperty().set(true);

    translateYSlider.setShowTickMarks(true);
    translateYSlider.setShowTickLabels(true);
    translateYSlider.snapToTicksProperty().set(true);

    rotateSlider.setShowTickMarks(true);
    rotateSlider.setShowTickLabels(true);
    rotateSlider.snapToTicksProperty().set(true);
    rotateSlider.setMinorTickCount(5);
    rotateSlider.setMajorTickUnit(30.0);

    scaleXSlider.setShowTickMarks(true);
    scaleXSlider.setShowTickLabels(true);
    scaleXSlider.setMajorTickUnit(0.2d);
    scaleXSlider.setLabelFormatter(new DoubleStringConverter());
    scaleXSlider.snapToTicksProperty().set(true);

    scaleYSlider.setShowTickMarks(true);
    scaleYSlider.setShowTickLabels(true);
    scaleYSlider.setMajorTickUnit(0.2d);
    scaleYSlider.setLabelFormatter(new DoubleStringConverter());
    scaleYSlider.snapToTicksProperty().set(true);

    shearXSlider.setShowTickMarks(true);
    shearXSlider.setShowTickLabels(true);
    shearXSlider.setMajorTickUnit(0.2d);
    shearXSlider.setLabelFormatter(new DoubleStringConverter());
    shearXSlider.snapToTicksProperty().set(true);

    shearYSlider.setShowTickMarks(true);
    shearYSlider.setShowTickLabels(true);
    shearYSlider.setMajorTickUnit(0.2d);
    shearYSlider.setLabelFormatter(new DoubleStringConverter());
    shearYSlider.snapToTicksProperty().set(true);

    HBox xyBox = new HBox();
    xyBox.setSpacing(5);
    xyBox.getChildren().addAll(VBoxBuilder.create().children(xLabel, xSlider).build(),
            VBoxBuilder.create().children(yLabel, ySlider).build());

    HBox whBox = new HBox();
    whBox.setSpacing(5);
    whBox.getChildren().addAll(VBoxBuilder.create().children(widthLabel, widthSlider).build(),
            VBoxBuilder.create().children(heightLabel, heightSlider).build());

    HBox colorBox = new HBox();
    colorBox.setSpacing(5);
    colorBox.getChildren().addAll(VBoxBuilder.create().children(strokeLabel, strokeSlider).build(),
            VBoxBuilder.create().children(new Label("Stroke Color"), rectStrokeColorChoiceBox).build());

    HBox opacityBox = new HBox();
    opacityBox.setSpacing(5);
    opacityBox.getChildren().addAll(VBoxBuilder.create().children(opacityLabel, opacitySlider).build(),
            VBoxBuilder.create().children(new Label("Fill Color"), rectFillColorChoiceBox).build());

    HBox translateBox = new HBox();
    translateBox.setSpacing(5);
    translateBox.getChildren().addAll(VBoxBuilder.create().children(translateXLabel, translateXSlider).build(),
            VBoxBuilder.create().children(translateYLabel, translateYSlider).build());

    HBox rotateBox = new HBox();
    rotateBox.setSpacing(5);
    rotateBox.getChildren().addAll(VBoxBuilder.create().children(rotateLabel, rotateSlider).build());

    HBox scaleBox = new HBox();
    scaleBox.setSpacing(5);
    scaleBox.getChildren().addAll(VBoxBuilder.create().children(scaleXLabel, scaleXSlider).build(),
            VBoxBuilder.create().children(scaleYLabel, scaleYSlider).build());

    HBox shearBox = new HBox();
    shearBox.setSpacing(5);
    shearBox.getChildren().addAll(VBoxBuilder.create().children(shearXLabel, shearXSlider).build(),
            VBoxBuilder.create().children(shearYLabel, shearYSlider).build());

    VBox rectangleBox = new VBox();
    rectangleBox.getChildren().addAll(xyBox, whBox, colorBox, opacityBox);
    TitledPane rectangleProps = new TitledPane("Rectangle", rectangleBox);

    VBox transformBox = new VBox();
    transformBox.getChildren().addAll(translateBox, rotateBox, scaleBox, shearBox);
    TitledPane transformsProps = new TitledPane("Tranformations", transformBox);

    TitledPane showBoundsControls = getShowBoundsControls();
    TitledPane effectPane = getEffectTitledPane();

    Button resetAllButton = new Button("Reset All");
    resetAllButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            resetAll();
        }
    });

    Button saveButton = new Button("Save Layout as Image");
    saveButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            saveLayoutAsImage();
        }
    });

    Button exitButton = new Button("Exit");
    exitButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            Platform.exit();
        }
    });

    /*
    Button printButton = new Button("Print");
    printButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            String str = getDesc("layoutBounds", mainRect.getLayoutBounds()) +
                         getDesc("\nboundsInLocal", mainRect.getBoundsInLocal()) +
                         getDesc("\nboundsInParent", mainRect.getBoundsInParent());
                    
            //printDataTextArea.setText(str);
        }
                
        private String getDesc(String type, Bounds b) {
            String str = type + "[minX=" + b.getMinX() +
                         ", minY=" + b.getMinY() +
                         ", width=" + b.getWidth() +
                         ", height=" + b.getHeight() + "]";
            return str;
        }
    });
    */

    HBox buttonBox = new HBox();
    buttonBox.setSpacing(10);
    buttonBox.getChildren().addAll(resetAllButton, saveButton, exitButton);

    VBox vBox = new VBox();
    vBox.getChildren().addAll(buttonBox, showBoundsControls, rectangleProps, effectPane, transformsProps);
    return vBox;
}

From source file:mesclasses.view.JourneeController.java

private void drawEleveName(SmartGrid grid, Eleve eleve, int rowIndex) {
    //index debute  1, le slot 0,X est rserv pour un separator dans le header
    grid.add(NodeUtil.buildEleveLink(eleve, eleve.lastNameProperty(), Constants.JOURNEE_VIEW), 1, rowIndex,
            HPos.LEFT);/*from  ww  w  .  j  av a 2s .  c o m*/

    grid.add(NodeUtil.buildEleveLink(eleve, eleve.firstNameProperty(), Constants.JOURNEE_VIEW), 2, rowIndex,
            HPos.LEFT);
    RowConstraints rc = new RowConstraints();
    rc.setMinHeight(35.0);
    rc.setPrefHeight(35.0);
    rc.setMaxHeight(35.0);
    grid.getRowConstraints().add(rc);
    if (!eleve.isInClasse(currentDate.getValue())) {
        grid.add(new Label("ne faisait pas partie de la classe  cette date"), 3, rowIndex,
                vieScolaireGrid.getGridWidth() - 3, 1);
    }
}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 * @param strTypeTransf/*from  w ww.jav  a2  s .c o m*/
 * @throws Exception Exceptions
 */
public void afficheFenetre(String strTypeTransf) throws Exception {
    lvListeFichier.getItems().clear();
    stTransformations = new Stage(StageStyle.UTILITY);
    apTransformations = new AnchorPane();
    stTransformations.initModality(Modality.APPLICATION_MODAL);
    stTransformations.setResizable(true);
    apTransformations.setStyle("-fx-background-color : #ff0000;");

    VBox vbFenetre = new VBox();
    HBox hbChoix = new HBox();
    Pane paneChoixFichier = new Pane();
    btnAjouteFichiers = new Button("Ajouter des Fichiers");
    paneChoixTypeFichier = new Pane();
    Label lblType = new Label("Type des Fichiers de sortie");
    rbJpeg = new RadioButton("JPEG (.jpg)");
    rbBmp = new RadioButton("BMP (.bmp)");
    rbTiff = new RadioButton("TIFF (.tif)");
    cbSharpen = new CheckBox("Masque de nettet");
    cbSharpen.setSelected(EditeurPanovisu.isbNetteteTransf());
    slSharpen = new Slider(0, 2, EditeurPanovisu.getNiveauNetteteTransf());
    lblSharpen = new Label();
    double lbl = (Math.round(EditeurPanovisu.getNiveauNetteteTransf() * 20.d) / 20.d);
    lblSharpen.setText(lbl + "");
    slSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf());
    lblSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf());
    Pane paneboutons = new Pane();
    btnAnnuler = new Button("Fermer la fentre");
    btnValider = new Button("Lancer le traitement");

    strTypeTransformation = strTypeTransf;
    Image imgTransf;
    if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) {
        stTransformations.setTitle("Transformation d'quirectangulaire en faces de cube");
        imgTransf = new Image(
                "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/equi2cube.png");
    } else {
        stTransformations.setTitle("Transformation de faces de cube en quirectangulaire");
        imgTransf = new Image(
                "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/cube2equi.png");
    }
    ImageView ivTypeTransfert = new ImageView(imgTransf);
    ivTypeTransfert.setLayoutX(35);
    ivTypeTransfert.setLayoutY(280);
    paneChoixTypeFichier.getChildren().add(ivTypeTransfert);
    apTransformations.setPrefHeight(EditeurPanovisu.getHauteurE2C());
    apTransformations.setPrefWidth(EditeurPanovisu.getLargeurE2C());

    paneChoixFichier.setPrefHeight(350);
    paneChoixFichier.setPrefWidth(410);
    paneChoixFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;");
    paneChoixTypeFichier.setPrefHeight(350);
    paneChoixTypeFichier.setPrefWidth(180);
    paneChoixTypeFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;");
    hbChoix.getChildren().addAll(paneChoixFichier, paneChoixTypeFichier);
    vbFenetre.setPrefHeight(400);
    vbFenetre.setPrefWidth(600);
    apTransformations.getChildren().add(vbFenetre);
    hbChoix.setPrefHeight(350);
    hbChoix.setPrefWidth(600);
    hbChoix.setStyle("-fx-background-color: #d0d0d0;");
    paneboutons.setPrefHeight(50);
    paneboutons.setPrefWidth(600);
    paneboutons.setStyle("-fx-background-color: #d0d0d0;");
    vbFenetre.setStyle("-fx-background-color: #d0d0d0;");
    btnAnnuler.setLayoutX(296);
    btnAnnuler.setLayoutY(10);
    btnValider.setLayoutX(433);
    btnValider.setLayoutY(10);
    lvListeFichier.setPrefHeight(290);
    lvListeFichier.setPrefWidth(380);
    lvListeFichier.setEditable(true);
    lvListeFichier.setLayoutX(14);
    lvListeFichier.setLayoutY(14);
    btnAjouteFichiers.setLayoutX(259);
    btnAjouteFichiers.setLayoutY(319);
    paneChoixFichier.getChildren().addAll(lvListeFichier, btnAjouteFichiers);
    if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) {
        lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropE2C"));
    } else {
        lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropC2E"));
    }
    lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight());
    lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight());
    lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth());
    lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth());
    lblDragDropE2C.setLayoutX(14);
    lblDragDropE2C.setLayoutY(14);
    lblDragDropE2C.setAlignment(Pos.CENTER);
    lblDragDropE2C.setTextFill(Color.web("#c9c7c7"));
    lblDragDropE2C.setTextAlignment(TextAlignment.CENTER);
    lblDragDropE2C.setWrapText(true);
    lblDragDropE2C.setStyle("-fx-font-size : 24px");
    lblDragDropE2C.setStyle("-fx-background-color : rgba(128,128,128,0.1)");
    paneChoixFichier.getChildren().add(lblDragDropE2C);

    lblType.setLayoutX(14);
    lblType.setLayoutY(14);
    rbBmp.setLayoutX(43);
    rbBmp.setLayoutY(43);
    rbBmp.setUserData("bmp");
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("bmp")) {
        rbBmp.setSelected(true);
    }
    rbBmp.setToggleGroup(tgTypeFichier);
    rbJpeg.setLayoutX(43);
    rbJpeg.setLayoutY(71);
    rbJpeg.setUserData("jpg");
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("jpg")) {
        rbJpeg.setSelected(true);
    }
    rbJpeg.setToggleGroup(tgTypeFichier);
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("tif")) {
        rbTiff.setSelected(true);
    }
    rbTiff.setLayoutX(43);
    rbTiff.setLayoutY(99);
    rbTiff.setToggleGroup(tgTypeFichier);
    rbTiff.setUserData("tif");
    tgTypeFichier.selectedToggleProperty().addListener((ov, old_toggle, new_toggle) -> {
        EditeurPanovisu.setStrTypeFichierTransf(tgTypeFichier.getSelectedToggle().getUserData().toString());
    });
    cbSharpen.setLayoutX(43);
    cbSharpen.setLayoutY(127);
    cbSharpen.selectedProperty().addListener((ov, old_val, new_val) -> {
        slSharpen.setDisable(!new_val);
        lblSharpen.setDisable(!new_val);
        EditeurPanovisu.setbNetteteTransf(new_val);
    });

    slSharpen.setShowTickMarks(true);
    slSharpen.setShowTickLabels(true);
    slSharpen.setMajorTickUnit(0.5f);
    slSharpen.setMinorTickCount(4);
    slSharpen.setBlockIncrement(0.05f);
    slSharpen.setSnapToTicks(true);
    slSharpen.setLayoutX(23);
    slSharpen.setLayoutY(157);
    slSharpen.setTooltip(new Tooltip("Choisissez le niveau d'accentuation de l'image"));
    slSharpen.valueProperty().addListener((observableValue, oldValue, newValue) -> {
        if (newValue == null) {
            lblSharpen.setText("");
            return;
        }
        DecimalFormat dfArrondi = new DecimalFormat();
        dfArrondi.setMaximumFractionDigits(2); //arrondi  2 chiffres apres la virgules
        dfArrondi.setMinimumFractionDigits(2);
        dfArrondi.setDecimalSeparatorAlwaysShown(true);

        lblSharpen.setText(dfArrondi.format(Math.round(newValue.floatValue() * 20.f) / 20.f) + "");
        EditeurPanovisu.setNiveauNetteteTransf(newValue.doubleValue());
    });

    slSharpen.setPrefWidth(120);
    lblSharpen.setLayoutX(150);
    lblSharpen.setLayoutY(150);
    lblSharpen.setMinWidth(30);
    lblSharpen.setMaxWidth(30);
    lblSharpen.setTextAlignment(TextAlignment.RIGHT);

    paneChoixTypeFichier.getChildren().addAll(lblType, rbBmp, rbJpeg, rbTiff, cbSharpen, slSharpen, lblSharpen);
    pbBarreImage.setLayoutX(40);
    pbBarreImage.setLayoutY(190);
    pbBarreImage.setStyle("-fx-accent : #0000bb");
    pbBarreImage.setVisible(false);
    paneChoixTypeFichier.getChildren().add(pbBarreImage);
    pbBarreAvancement = new ProgressBar();
    pbBarreAvancement.setLayoutX(40);
    pbBarreAvancement.setLayoutY(220);
    pbBarreImage.setStyle("-fx-accent : #00bb00");
    paneChoixTypeFichier.getChildren().add(pbBarreAvancement);
    pbBarreAvancement.setVisible(false);

    paneboutons.getChildren().addAll(btnAnnuler, btnValider);
    vbFenetre.getChildren().addAll(hbChoix, paneboutons);
    Scene scnTransformations = new Scene(apTransformations);
    stTransformations.setScene(scnTransformations);
    stTransformations.show();

    btnAnnuler.setOnAction((e) -> {
        annulerE2C();
    });
    btnValider.setOnAction((e) -> {
        if (!bTraitementEffectue) {
            validerE2C();
        }
    });
    btnAjouteFichiers.setOnAction((e) -> {
        lblTermine.setText("");
        fileLstFichier = choixFichiers();
        if (fileLstFichier != null) {
            if (bTraitementEffectue) {
                lvListeFichier.getItems().clear();
                bTraitementEffectue = false;
            }
            for (File fileLstFichier1 : fileLstFichier) {
                String strNomFich = fileLstFichier1.getAbsolutePath();
                lvListeFichier.getItems().add(strNomFich);
            }
        }
    });
    lvListeFichier.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListeTransformationCouleur();
        }
    });
    apTransformations.setOnDragOver((event) -> {
        Dragboard dbFichiersTransformation = event.getDragboard();
        if (dbFichiersTransformation.hasFiles()) {
            event.acceptTransferModes(TransferMode.ANY);
        } else {
            event.consume();
        }
    });
    stTransformations.widthProperty().addListener((arg0, arg1, arg2) -> {
        EditeurPanovisu.setLargeurE2C(stTransformations.getWidth());
        apTransformations.setPrefWidth(stTransformations.getWidth());
        vbFenetre.setPrefWidth(stTransformations.getWidth());
        btnAnnuler.setLayoutX(stTransformations.getWidth() - 314);
        btnValider.setLayoutX(stTransformations.getWidth() - 157);
        paneChoixFichier.setPrefWidth(stTransformations.getWidth() - 200);
        lvListeFichier.setPrefWidth(stTransformations.getWidth() - 240);
        lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth());
        lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth());

        btnAjouteFichiers.setLayoutX(stTransformations.getWidth() - 341);
    });

    stTransformations.heightProperty().addListener((arg0, arg1, arg2) -> {
        EditeurPanovisu.setHauteurE2C(stTransformations.getHeight());
        apTransformations.setPrefHeight(stTransformations.getHeight());
        vbFenetre.setPrefHeight(stTransformations.getHeight());
        paneChoixFichier.setPrefHeight(stTransformations.getHeight() - 80);
        hbChoix.setPrefHeight(stTransformations.getHeight() - 80);
        lvListeFichier.setPrefHeight(stTransformations.getHeight() - 140);
        lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight());
        lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight());
        btnAjouteFichiers.setLayoutY(stTransformations.getHeight() - 121);
    });
    stTransformations.setWidth(EditeurPanovisu.getLargeurE2C());
    stTransformations.setHeight(EditeurPanovisu.getHauteurE2C());
    apTransformations.setOnDragDropped((event) -> {
        Dragboard dbFichiersTransformation = event.getDragboard();
        boolean bSucces = false;
        File[] fileLstFich;
        fileLstFich = null;
        if (dbFichiersTransformation.hasFiles()) {
            lblTermine.setText("");
            bSucces = true;
            String[] stringFichiersPath = new String[200];
            int i = 0;
            for (File file1 : dbFichiersTransformation.getFiles()) {
                stringFichiersPath[i] = file1.getAbsolutePath();
                i++;
            }
            int iNb = i;
            i = 0;
            boolean bAttention = false;
            File[] fileLstFich1 = new File[stringFichiersPath.length];
            for (int j = 0; j < iNb; j++) {

                String strNomfich = stringFichiersPath[j];
                File fileTransf = new File(strNomfich);
                String strExtension = strNomfich.substring(strNomfich.lastIndexOf(".") + 1, strNomfich.length())
                        .toLowerCase();
                if (strExtension.equals("bmp") || strExtension.equals("jpg") || strExtension.equals("tif")) {
                    if (i == 0) {
                        strRepertFichier = fileTransf.getParent();
                    }
                    Image img = null;
                    if (strExtension != "tif") {
                        img = new Image("file:" + fileTransf.getAbsolutePath());
                    } else {
                        try {
                            img = ReadWriteImage.readTiff(strNomfich);
                        } catch (ImageReadException ex) {
                            Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        } catch (IOException ex) {
                            Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        }
                    }
                    if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) {
                        if (img.getWidth() == 2 * img.getHeight()) {
                            fileLstFich1[i] = fileTransf;
                            i++;
                        } else {
                            bAttention = true;
                        }
                    } else {
                        if (img.getWidth() == img.getHeight()) {
                            String strNom = fileTransf.getAbsolutePath().substring(0,
                                    fileTransf.getAbsolutePath().length() - 6);
                            boolean bTrouve = false;
                            for (int ik = 0; ik < i; ik++) {
                                String strNom1 = fileLstFich1[ik].getAbsolutePath().substring(0,
                                        fileTransf.getAbsolutePath().length() - 6);
                                if (strNom.equals(strNom1)) {
                                    bTrouve = true;
                                }
                            }
                            if (!bTrouve) {
                                fileLstFich1[i] = fileTransf;
                                i++;
                            }
                        } else {
                            bAttention = true;
                        }

                    }
                }
            }
            if (bAttention) {
                Alert alert = new Alert(AlertType.ERROR);
                alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
                alert.setHeaderText(null);
                alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType"));
                alert.showAndWait();
            }
            fileLstFichier = new File[i];
            System.arraycopy(fileLstFich1, 0, fileLstFichier, 0, i);
        }
        if (fileLstFichier != null) {
            if (bTraitementEffectue) {
                lvListeFichier.getItems().clear();
                bTraitementEffectue = false;
            }
            for (File lstFichier1 : fileLstFichier) {
                String nomFich = lstFichier1.getAbsolutePath();
                lvListeFichier.getItems().add(nomFich);
            }
        }
        lblDragDropE2C.setVisible(false);
        event.setDropCompleted(bSucces);
        event.consume();
    });

}

From source file:webapptest.FXMLDocumentController.java

@FXML //Displays the employees in the database
public void refreshButtonPressed(ActionEvent event) {
    employeeList.getChildren().clear();/*  w w  w .j  a  v a  2 s .co m*/

    //get the data of employees from the server
    List<String> temp = new ArrayList<>();
    temp.add("employee_info");
    String input = sendData(temp);

    //parse the data into an object
    List<Employee> emps = parseEmpData(input);

    //display the headings for the employee display
    HBox heading = new HBox();
    Label id = new Label("Employee ID");
    Label name = new Label("Employee Name");
    Label phone = new Label("Employee Phone Number");
    Label user = new Label("Employee User Name");
    Label manager = new Label("Is Manager?");
    Label backup = new Label("Is Backup?");

    heading.getChildren().add(id);
    heading.getChildren().add(name);
    heading.getChildren().add(phone);
    heading.getChildren().add(user);
    heading.getChildren().add(manager);
    heading.getChildren().add(backup);

    employeeList.getChildren().add(heading);

    //loop through all available employees and display to screen
    for (Employee emp : emps) {
        HBox tempLine = new HBox();

        String managerString;
        if (emp.getManager() == true) {
            managerString = "true";
        } else {
            managerString = "false";
        }
        String backupString;
        if (emp.getBackup() == true) {
            backupString = "true";
        } else {
            backupString = "false";
        }

        TextField tfid = new TextField(Integer.toString(emp.getID()));
        TextField tfname = new TextField(emp.getName());
        TextField tfphone = new TextField(emp.getPhone());
        TextField tfuser = new TextField(emp.getUserName());
        TextField tfmanager = new TextField(managerString);
        TextField tfbackup = new TextField(backupString);

        tempLine.getChildren().add(tfid);
        tempLine.getChildren().add(tfname);
        tempLine.getChildren().add(tfphone);
        tempLine.getChildren().add(tfuser);
        tempLine.getChildren().add(tfmanager);
        tempLine.getChildren().add(tfbackup);

        employeeList.getChildren().add(tempLine);
    }
}

From source file:io.bitsquare.gui.main.overlays.Overlay.java

protected void addHeadLine() {
    if (headLine != null) {
        ++rowIndex;/*from   w  w w  .java  2 s . c om*/

        headLineLabel = new Label(BSResources.get(headLine));
        headLineLabel.setMouseTransparent(true);

        if (headlineStyle != null)
            headLineLabel.setStyle(headlineStyle);

        GridPane.setHalignment(headLineLabel, HPos.LEFT);
        GridPane.setRowIndex(headLineLabel, rowIndex);
        GridPane.setColumnSpan(headLineLabel, 2);
        gridPane.getChildren().addAll(headLineLabel);
    }
}

From source file:com.core.meka.SOMController.java

private void initPopovers() {
    patronesEntrenamientoPopover = new PopOver();

    StackPane pane = new StackPane();
    BorderPane b = new BorderPane();
    b.setPadding(new Insets(10, 20, 10, 20));
    VBox vbox = new VBox();
    Label title = new Label("Configuracion correcta");
    Label content = new Label("Aqui un ejemplo de configuracion");
    Label content1 = new Label("de patrones de entrenamiento de dimension 2");
    content.setPadding(new Insets(5, 0, 0, 0));
    content1.setPadding(new Insets(5, 0, 0, 0));
    content.setWrapText(true);/*from ww  w  .j  a v  a  2 s. c  om*/
    vbox.getChildren().addAll(title, content, content1, new ImageView(new Image("/img/config1.png")));
    b.setCenter(vbox);

    patronesEntrenamientoPopover.setContentNode(b);
}

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   w ww  .  j a  va 2s  . 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. j av  a2  s. c o  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);
    }
}