Example usage for javafx.scene.control Button disableProperty

List of usage examples for javafx.scene.control Button disableProperty

Introduction

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

Prototype

public final BooleanProperty disableProperty() 

Source Link

Document

Defines the individual disabled state of this Node .

Usage

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

public TitledPane createPanelForLaunchingTests() {
    final Button startBtn = new Button("Run Test");
    startBtn.disableProperty().bind(this.testRunService.runningProperty());
    final double startButtonPadding = 8d;
    startBtn.setPadding(new Insets(startButtonPadding));
    startBtn.setGraphic(Icons.getIconGraphics("control_play_blue"));
    HBox.setHgrow(startBtn, Priority.ALWAYS);
    startBtn.setMaxWidth(Double.MAX_VALUE);
    startBtn.setOnAction(event -> {//from w  ww.  j a  v  a 2s.c  om
        final Job job = this.createJobFromConfig();
        this.testRunService.setJob(job);
        this.testRunService.start();
    });
    final HBox startLine = new HBox();
    startLine.getChildren().add(startBtn);
    final VBox runLines = new VBox();
    final double linesSpacing = 10d;
    runLines.setSpacing(linesSpacing);
    final TextFlow resultBar = new TextFlow();
    resultBar.backgroundProperty().bind(this.resultBarBackgroundProperty);
    this.resultBarBackgroundProperty.set(RESULT_BAR_BACKGROUND_IDLE);
    resultBar.setStyle("-fx-border-color: black; -fx-border-width:1");
    final Text resultBarText = new Text();
    resultBarText.textProperty().bind(this.resultBarTextProperty);
    this.resultBarTextProperty.set("Idle");
    resultBar.getChildren().add(resultBarText);
    resultBar.setTextAlignment(TextAlignment.CENTER);
    final double resultBarPadding = 2d;
    resultBar.setPadding(new Insets(resultBarPadding));
    final int logOutputLinesSize = 25;
    this.resultLogOutputText.setPrefRowCount(logOutputLinesSize);
    this.resultLogOutputText.setEditable(false);
    this.resultLogOutputText.setStyle("-fx-font-family: monospace");
    HBox.setHgrow(this.resultLogOutputText, Priority.ALWAYS);
    runLines.getChildren().addAll(startLine, new Text("Recent results:"), resultBar, this.resultLogOutputText);
    final TitledPane runPane = new TitledPane("Run", runLines);
    runPane.setGraphic(Icons.getIconGraphics("lightning_go"));
    runPane.setCollapsible(false);
    return runPane;
}

From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java

private void bindButtonsToContentExistence(FileStorage file, Button... items) {
    for (Button item : items) {
        item.disableProperty().bind(isNull(file.contentProperty()));
    }//from   w  w w .j  a  v a 2s.c om
}

From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java

private void bindButtonsToTableSelection(Button... items) {
    for (Button item : items) {
        item.disableProperty().bind(lessThan(tableView.getSelectionModel().selectedIndexProperty(), 0));
    }// w  w  w  .j  a v a  2  s  . c om
}

From source file:gov.va.isaac.sync.view.SyncView.java

private void initGui() {
    root_ = new BorderPane();
    root_.setPrefWidth(550);//from   www .  jav  a  2s .c  om

    VBox titleBox = new VBox();

    Label title = new Label("Datastore Synchronization");
    title.getStyleClass().add("titleLabel");
    title.setAlignment(Pos.CENTER);
    title.setMaxWidth(Double.MAX_VALUE);
    title.setPadding(new Insets(10));
    titleBox.getChildren().add(title);
    titleBox.getStyleClass().add("headerBackground");

    url_ = AppContext.getAppConfiguration().getCurrentChangeSetUrl();
    String urlType = AppContext.getAppConfiguration().getChangeSetUrlTypeName();

    String syncUsername = ExtendedAppContext.getCurrentlyLoggedInUserProfile().getSyncUsername();
    if (StringUtils.isBlank(syncUsername)) {
        syncUsername = ExtendedAppContext.getCurrentlyLoggedInUser();
    }

    url_ = syncService_.substituteURL(url_, syncUsername);

    Label info = new CopyableLabel("Sync using " + urlType + ": " + url_);
    info.setTooltip(new Tooltip(url_));

    titleBox.getChildren().add(info);

    titleBox.setPadding(new Insets(5, 5, 5, 5));
    root_.setTop(titleBox);

    VBox centerContent = new VBox();
    centerContent.setFillWidth(true);
    centerContent.setPrefWidth(Double.MAX_VALUE);
    centerContent.setPadding(new Insets(10));
    centerContent.getStyleClass().add("itemBorder");
    centerContent.setSpacing(10.0);

    centerContent.getChildren().add(new Label("Status:"));

    summary_ = new TextArea();
    summary_.setWrapText(true);
    summary_.setEditable(false);
    summary_.setMaxWidth(Double.MAX_VALUE);
    summary_.setMaxHeight(Double.MAX_VALUE);
    summary_.setPrefHeight(150.0);

    centerContent.getChildren().add(summary_);
    VBox.setVgrow(summary_, Priority.ALWAYS);

    pb_ = new ProgressBar(0.0);
    pb_.setPrefHeight(20);
    pb_.setMaxWidth(Double.MAX_VALUE);

    centerContent.getChildren().add(pb_);

    root_.setCenter(centerContent);

    //Bottom buttons
    HBox buttons = new HBox();
    buttons.setMaxWidth(Double.MAX_VALUE);
    buttons.setAlignment(Pos.CENTER);
    buttons.setPadding(new Insets(5));
    buttons.setSpacing(30);

    Button cancel = new Button("Close");
    cancel.setOnAction((action) -> {
        if (running_.get()) {
            addLine("Cancelling...");
            cancel.setDisable(true);
            cancelRequested_ = true;
        } else {
            cancel.getScene().getWindow().hide();
            root_ = null;
        }
    });
    buttons.getChildren().add(cancel);

    Button action = new Button("Synchronize");
    action.disableProperty().bind(running_);
    action.setOnAction((theAction) -> {
        summary_.setText("");
        pb_.setProgress(-1.0);
        running_.set(true);
        Utility.execute(() -> sync());
    });
    buttons.getChildren().add(action);

    cancel.minWidthProperty().bind(action.widthProperty());

    running_.addListener(change -> {
        if (running_.get()) {
            cancel.setText("Cancel");
        } else {
            cancel.setText("Close");
        }
        cancel.setDisable(false);
    });

    root_.setBottom(buttons);
}

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

private AddSememePopup() {
    super();//  w  w w. j a  v a2 s. 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  w w w .j a  v  a2 s . 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:org.openwms.client.fx.core.view.CustomerDataScreen.java

private Node createToolbar() {
    Button removeButton;
    ToolBar toolBar = ToolBarBuilder.create()
            .items(ButtonBuilder.create().text("Add Customer").onAction(new EventHandler<ActionEvent>() {
                @Override// www.j a v  a2  s  .c  o m
                public void handle(ActionEvent actionEvent) {
                    controller.addCustomer();
                }
            }).build(), removeButton = ButtonBuilder.create().text("Remove Customer")
                    .onAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent actionEvent) {
                            try {
                                controller.removeCustomer(tableView.getSelectionModel().getSelectedItem());
                                tableView.getSelectionModel()
                                        .select(Math.min(tableView.getSelectionModel().getSelectedIndex(),
                                                tableView.getItems().size() - 1));
                            } catch (AccessDeniedException e) {
                                controller.showErrorDialog();
                            }
                        }
                    }).build())
            .build();
    removeButton.disableProperty().bind(tableView.getSelectionModel().selectedItemProperty().isNull());
    return toolBar;
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private void initGenerateXPathFromStackTrace() {

    ContextMenu menu = new ContextMenu();

    MenuItem item = new MenuItem("Generate from stack trace...");
    item.setOnAction(e -> {/*  w w w.j a v a  2 s .c o m*/
        try {
            Stage popup = new Stage();
            FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
            Parent root = loader.load();
            Button button = (Button) loader.getNamespace().get("generateButton");
            TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea");

            ValidationSupport validation = new ValidationSupport();

            validation.registerValidator(area,
                    Validator.createEmptyValidator("The stack trace may not be empty"));
            button.disableProperty().bind(validation.invalidProperty());

            button.setOnAction(f -> {
                DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText);
                popup.close();
            });

            popup.setScene(new Scene(root));
            popup.initStyle(StageStyle.UTILITY);
            popup.initModality(Modality.WINDOW_MODAL);
            popup.initOwner(designerRoot.getMainStage());
            popup.show();
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
    });

    menu.getItems().add(item);

    xpathExpressionArea.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        if (t.getButton() == MouseButton.SECONDARY) {
            menu.show(xpathExpressionArea, t.getScreenX(), t.getScreenY());
        }
    });
}

From source file:org.nmrfx.processor.gui.spectra.DrawSpectrum.java

public void setController(FXMLController controller) {
    Button cancelButton = controller.getCancelButton();
    cancelButton.setOnAction(actionEvent -> {
        cancelled = true;//  ww w . j a v  a  2  s .  c o  m
        ((Service) makeContours.worker).cancel();
        ((Service) drawContours.worker).cancel();
    });
    cancelButton.disableProperty()
            .bind(((Service) makeContours.worker).stateProperty().isNotEqualTo(Task.State.RUNNING));
}