Example usage for javafx.scene.layout GridPane setMargin

List of usage examples for javafx.scene.layout GridPane setMargin

Introduction

In this page you can find the example usage for javafx.scene.layout GridPane setMargin.

Prototype

public static void setMargin(Node child, Insets value) 

Source Link

Document

Sets the margin for the child when contained by a gridpane.

Usage

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

private AddSememePopup() {
    super();/*from www  .  jav a 2s  . c  o m*/
    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   www. j  a v  a 2s  .c  o  m*/
    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);
}

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

protected void addMessage() {
    if (message != null) {
        messageLabel = new Label(truncatedMessage);
        messageLabel.setMouseTransparent(true);
        messageLabel.setWrapText(true);/*from  w  w  w . j  av a  2s.c  o m*/
        GridPane.setHalignment(messageLabel, HPos.LEFT);
        GridPane.setHgrow(messageLabel, Priority.ALWAYS);
        GridPane.setMargin(messageLabel, new Insets(3, 0, 0, 0));
        GridPane.setRowIndex(messageLabel, ++rowIndex);
        GridPane.setColumnIndex(messageLabel, 0);
        GridPane.setColumnSpan(messageLabel, 2);
        gridPane.getChildren().add(messageLabel);
    }
}

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

private void addReportErrorButtons() {
    messageLabel.setText(truncatedMessage
            + "\n\nTo help us to improve the software please report the bug at our issue tracker at Github or send it by email to the developers.\n"
            + "The error message will be copied to clipboard when you click the below buttons.\n"
            + "It will make debugging easier if you can attach the bitsquare.log file which you can find in the application directory.");

    Button githubButton = new Button("Report to Github issue tracker");
    GridPane.setMargin(githubButton, new Insets(20, 0, 0, 0));
    GridPane.setHalignment(githubButton, HPos.RIGHT);
    GridPane.setRowIndex(githubButton, ++rowIndex);
    GridPane.setColumnIndex(githubButton, 1);
    gridPane.getChildren().add(githubButton);

    githubButton.setOnAction(event -> {
        Utilities.copyToClipboard(message);
        GUIUtil.openWebPage("https://github.com/bitsquare/bitsquare/issues");
    });/* www. j a v  a 2s.c om*/

    Button mailButton = new Button("Report by email");
    GridPane.setHalignment(mailButton, HPos.RIGHT);
    GridPane.setRowIndex(mailButton, ++rowIndex);
    GridPane.setColumnIndex(mailButton, 1);
    gridPane.getChildren().add(mailButton);
    mailButton.setOnAction(event -> {
        Utilities.copyToClipboard(message);
        GUIUtil.openMail("manfred@bitsquare.io", "Error report", "Error message:\n" + message);
    });
}

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

protected void addCloseButton() {
    closeButton = new Button(closeButtonText == null ? "Close" : closeButtonText);
    closeButton.setOnAction(event -> doClose());

    if (actionHandlerOptional.isPresent() || actionButtonText != null) {
        actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText);
        actionButton.setDefaultButton(true);
        //TODO app wide focus
        //actionButton.requestFocus();
        actionButton.setOnAction(event -> {
            hide();/*from  w w  w.  ja v  a  2  s  .  c o  m*/
            actionHandlerOptional.ifPresent(Runnable::run);
        });

        Pane spacer = new Pane();
        HBox hBox = new HBox();
        hBox.setSpacing(10);
        hBox.getChildren().addAll(spacer, closeButton, actionButton);
        HBox.setHgrow(spacer, Priority.ALWAYS);

        GridPane.setHalignment(hBox, HPos.RIGHT);
        GridPane.setRowIndex(hBox, ++rowIndex);
        GridPane.setColumnSpan(hBox, 2);
        GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0));
        gridPane.getChildren().add(hBox);
    } else if (!hideCloseButton) {
        closeButton.setDefaultButton(true);
        GridPane.setHalignment(closeButton, HPos.RIGHT);
        if (!showReportErrorButtons)
            GridPane.setMargin(closeButton, new Insets(buttonDistance, 0, 0, 0));
        GridPane.setRowIndex(closeButton, ++rowIndex);
        GridPane.setColumnIndex(closeButton, 1);
        gridPane.getChildren().add(closeButton);
    }
}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid sanctions//from w  w  w.j a  va  2  s . c  om
 * @param eleve
 * @param rowIndex 
 */
private void drawSanctions(Eleve eleve, int rowIndex) {
    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);

    drawEleveName(sanctionsGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    HBox punitionsBox = new HBox();
    punitionsBox.setAlignment(Pos.CENTER_LEFT);
    TextFlow nbPunitions = new TextFlow();
    Label nbPunitionLabel = new Label(
            "" + eleve.getPunitions().stream().filter(p -> p.getSeance() == seanceSelect.getValue()).count());
    nbPunitionLabel.setPrefHeight(20);
    nbPunitions.getChildren().add(new Label(" ("));
    nbPunitions.getChildren().add(nbPunitionLabel);
    nbPunitions.getChildren().add(new Label(")"));

    nbPunitions.visibleProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0"));
    nbPunitions.managedProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0"));

    Button punitionBtn = Btns.punitionBtn();
    punitionBtn.setOnAction((event) -> {
        if (openPunitionDialog(eleve)) {
            int nbPunition = Integer.parseInt(nbPunitionLabel.getText());
            nbPunitionLabel.setText("" + (nbPunition + 1));
        }
    });
    punitionsBox.getChildren().add(punitionBtn);
    punitionsBox.getChildren().add(nbPunitions);

    sanctionsGrid.add(punitionsBox, 3, rowIndex, HPos.LEFT);

    CheckBox motCarnet = new CheckBox();
    Label cumulMot = new Label();
    motCarnet.setSelected(model.getMotForSeance(eleve, seanceSelect.getValue()) != null);
    motCarnet.selectedProperty().addListener((ob, o, checked) -> {
        Mot mot = model.getMotForSeance(eleve, seanceSelect.getValue());
        if (checked && mot == null) {
            model.createMot(eleve, seanceSelect.getValue());
        } else if (mot != null) {
            model.delete(mot);
        }
        writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3);
    });
    sanctionsGrid.add(motCarnet, 4, rowIndex, null);
    writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3);
    sanctionsGrid.add(cumulMot, 5, rowIndex, null);

    CheckBox exclus = new CheckBox();
    TextField motif = new TextField();
    Bindings.bindBidirectional(exclus.selectedProperty(), eleveData.exclusProperty());
    sanctionsGrid.add(exclus, 6, rowIndex, null);
    exclus.selectedProperty().addListener((o, oldV, newV) -> {
        if (!newV && StringUtils.isNotBlank(motif.getText())
                && ModalUtil.confirm("Effacer le motif ?", "Effacer le motif ?")) {
            motif.clear();
        }
    });

    Bindings.bindBidirectional(motif.textProperty(), eleveData.MotifProperty());
    motif.textProperty().addListener((o, oldV, newV) -> {
        if (StringUtils.isNotBlank(newV)) {
            exclus.setSelected(true);
        }
    });
    GridPane.setMargin(motif, new Insets(0, 10, 0, 0));
    sanctionsGrid.add(motif, 7, rowIndex, HPos.LEFT);

}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private void layoutComponents() {
    mainPanel = new JFXPanel();

    int v = 0;//  ww  w . j a v a  2s  . c  o  m
    GridPane.setConstraints(sliderControlPane, 0, v++);
    GridPane.setMargin(sliderControlPane, new Insets(20, 0, 0, 0));
    GridPane.setConstraints(pictures, 0, v++);
    GridPane.setConstraints(animations, 0, v++);
    GridPane.setConstraints(shimmerOptions, 0, v++);
    GridPane.setConstraints(neuralizer, 0, v++);

    gp.setPadding(new Insets(5, 13, 5, 5));
    gp.getChildren().addAll(sliderControlPane, animations, shimmerOptions, pictures, neuralizer);

    hiddenSidesPane = new HiddenSidesPane();
    hiddenSidesPane.setContent(gp);
    hiddenSidesPane.setTop(soundControlPane);
    hiddenSidesPane.setTriggerDistance(25);

    final URI css = JFXUtils.getEntrainerCSS();

    JFXUtils.runLater(new Runnable() {

        @Override
        public void run() {
            group = new Group();

            shimmer.setInUse(true);
            group.getChildren().addAll(background.getPane(), shimmer, hiddenSidesPane);
            Scene scene = new Scene(group);
            if (css != null)
                scene.getStylesheets().add(css.toString());
            mainPanel.setScene(scene);
        }
    });

    getContentPane().add(mainPanel);
}

From source file:org.jacp.demo.components.ContactChartViewComponent.java

protected BarChart<String, Number> createChart() {

    this.xAxis = new CategoryAxis();
    this.yAxis = new NumberAxis();
    this.yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(this.yAxis, "$", null));
    this.bc = new BarChart<String, Number>(this.xAxis, this.yAxis);
    this.bc.setAnimated(true);
    this.bc.setTitle(" ");

    this.xAxis.getStyleClass().add("jacp-bar");
    this.yAxis.getStyleClass().add("jacp-bar");
    this.xAxis.setLabel("Year");
    this.yAxis.setLabel("Price");

    this.series1 = new XYChart.Series<String, Number>();
    this.series1.setName("electronic");
    this.series2 = new XYChart.Series<String, Number>();
    this.series2.setName("clothes");
    this.series3 = new XYChart.Series<String, Number>();
    this.series3.setName("hardware");
    this.series4 = new XYChart.Series<String, Number>();
    this.series4.setName("books");

    GridPane.setHalignment(this.bc, HPos.CENTER);
    GridPane.setVgrow(this.bc, Priority.ALWAYS);
    GridPane.setHgrow(this.bc, Priority.ALWAYS);
    GridPane.setMargin(this.bc, new Insets(0, 6, 0, 0));
    return this.bc;
}

From source file:se.trixon.filebydate.ui.MainApp.java

private void displayOptions() {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.initOwner(mStage);//  w  w w.j  a v  a2 s . c om
    alert.setTitle(Dict.OPTIONS.toString());
    alert.setGraphic(null);
    alert.setHeaderText(null);

    Label label = new Label(Dict.CALENDAR_LANGUAGE.toString());
    LocaleComboBox localeComboBox = new LocaleComboBox();
    CheckBox checkBox = new CheckBox(Dict.DYNAMIC_WORD_WRAP.toString());
    GridPane gridPane = new GridPane();
    //gridPane.setGridLinesVisible(true);
    gridPane.addColumn(0, label, localeComboBox, checkBox);
    GridPane.setMargin(checkBox, new Insets(16, 0, 0, 0));

    final DialogPane dialogPane = alert.getDialogPane();
    dialogPane.setContent(gridPane);

    localeComboBox.setLocale(mOptions.getLocale());
    checkBox.setSelected(mOptions.isWordWrap());

    Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage);
    if (result.get() == ButtonType.OK) {
        mOptions.setLocale(localeComboBox.getLocale());
        mOptions.setWordWrap(checkBox.isSelected());
    }
}

From source file:se.trixon.filebydate.ui.ProfilePanel.java

private void createUI() {
    //setGridLinesVisible(true);

    Label nameLabel = new Label(Dict.NAME.toString());
    Label descLabel = new Label(Dict.DESCRIPTION.toString());
    Label filePatternLabel = new Label(Dict.FILE_PATTERN.toString());
    Label dateSourceLabel = new Label(Dict.DATE_SOURCE.toString());
    mDatePatternLabel = new Label(Dict.DATE_PATTERN.toString());
    Label operationLabel = new Label(Dict.OPERATION.toString());
    Label caseBaseLabel = new Label(Dict.BASENAME.toString());
    Label caseExtLabel = new Label(Dict.EXTENSION.toString());

    mLinksCheckBox = new CheckBox(Dict.FOLLOW_LINKS.toString());
    mRecursiveCheckBox = new CheckBox(Dict.RECURSIVE.toString());
    mReplaceCheckBox = new CheckBox(Dict.REPLACE.toString());

    mCaseBaseComboBox = new ComboBox<>();
    mDatePatternComboBox = new ComboBox<>();
    mDateSourceComboBox = new ComboBox<>();
    mFilePatternComboBox = new ComboBox<>();
    mOperationComboBox = new ComboBox<>();
    mCaseExtComboBox = new ComboBox<>();

    mNameTextField = new TextField();
    mDescTextField = new TextField();

    mSourceChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.SOURCE.toString(), ObjectMode.DIRECTORY,
            SelectionMode.SINGLE);/*from w  ww.ja  va 2  s  .c  o  m*/
    mDestChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.DESTINATION.toString(),
            ObjectMode.DIRECTORY, SelectionMode.SINGLE);

    mFilePatternComboBox.setEditable(true);
    mDatePatternComboBox.setEditable(true);
    //mDatePatternLabel.setPrefWidth(300);

    int col = 0;
    int row = 0;

    add(nameLabel, col, row, REMAINING, 1);
    add(mNameTextField, col, ++row, REMAINING, 1);
    add(descLabel, col, ++row, REMAINING, 1);
    add(mDescTextField, col, ++row, REMAINING, 1);
    add(mSourceChooserPane, col, ++row, REMAINING, 1);
    add(mDestChooserPane, col, ++row, REMAINING, 1);

    GridPane patternPane = new GridPane();
    patternPane.addRow(0, filePatternLabel, dateSourceLabel, mDatePatternLabel);
    patternPane.addRow(1, mFilePatternComboBox, mDateSourceComboBox, mDatePatternComboBox);
    patternPane.setHgap(8);
    addRow(++row, patternPane);

    GridPane.setHgrow(mFilePatternComboBox, Priority.ALWAYS);
    GridPane.setHgrow(mDateSourceComboBox, Priority.ALWAYS);
    GridPane.setHgrow(mDatePatternComboBox, Priority.ALWAYS);

    GridPane.setFillWidth(mFilePatternComboBox, true);
    GridPane.setFillWidth(mDateSourceComboBox, true);
    GridPane.setFillWidth(mDatePatternComboBox, true);

    double width = 100.0 / 3.0;
    ColumnConstraints col1 = new ColumnConstraints();
    col1.setPercentWidth(width);
    ColumnConstraints col2 = new ColumnConstraints();
    col2.setPercentWidth(width);
    ColumnConstraints col3 = new ColumnConstraints();
    col3.setPercentWidth(width);
    patternPane.getColumnConstraints().addAll(col1, col2, col3);

    mFilePatternComboBox.setMaxWidth(Double.MAX_VALUE);
    mDateSourceComboBox.setMaxWidth(Double.MAX_VALUE);
    mDatePatternComboBox.setMaxWidth(Double.MAX_VALUE);
    GridPane subPane = new GridPane();
    //subPane.setGridLinesVisible(true);
    subPane.addRow(0, operationLabel, new Label(), new Label(), new Label(), caseBaseLabel, caseExtLabel);
    subPane.addRow(1, mOperationComboBox, mLinksCheckBox, mRecursiveCheckBox, mReplaceCheckBox,
            mCaseBaseComboBox, mCaseExtComboBox);
    subPane.setHgap(8);
    add(subPane, col, ++row, REMAINING, 1);

    final Insets rowInsets = new Insets(0, 0, 8, 0);

    GridPane.setMargin(mNameTextField, rowInsets);
    GridPane.setMargin(mDescTextField, rowInsets);
    GridPane.setMargin(mSourceChooserPane, rowInsets);
    GridPane.setMargin(mDestChooserPane, rowInsets);
    GridPane.setMargin(patternPane, rowInsets);

    mFilePatternComboBox.setItems(FXCollections.observableArrayList("*", "{*.jpg,*.JPG}", "{*.mp4,*.MP4}"));

    mDatePatternComboBox.setItems(FXCollections.observableArrayList("yyyy/MM/yyyy-MM-dd",
            "yyyy/MM/yyyy-MM-dd/HH", "yyyy/MM/dd", "yyyy/ww", "yyyy/ww/u"));

    mCaseBaseComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values())));
    mCaseExtComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values())));
    mDateSourceComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(DateSource.values())));
    mOperationComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(Command.COPY, Command.MOVE)));
}