Example usage for javafx.scene.layout Region Region

List of usage examples for javafx.scene.layout Region Region

Introduction

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

Prototype

public Region() 

Source Link

Document

Creates a new Region with an empty Background and and empty Border.

Usage

From source file:com.gmail.frogocomics.schematic.gui.Main.java

@Override
public void start(Stage primaryStage) throws Exception {
    this.primaryStage = primaryStage;
    this.root = new GridPane();
    this.primaryScene = new Scene(this.root, 1000, 600, Color.AZURE);

    Label title = new Label("Schematic Utilities");
    title.setId("schematic-utilities");
    title.setPrefWidth(this.primaryScene.getWidth() + 500);
    this.root.add(title, 0, 0);

    filesSelected.setId("files-selected");
    this.root.add(filesSelected, 0, 1);

    Region spacer1 = new Region();
    spacer1.setPrefWidth(30);//w  ww  .  j av a 2  s .  c o  m
    spacer1.setPrefHeight(30);

    Region spacer2 = new Region();
    spacer2.setPrefWidth(30);
    spacer2.setPrefHeight(30);

    Region spacer3 = new Region();
    spacer3.setPrefWidth(30);
    spacer3.setPrefHeight(250);

    Region spacer4 = new Region();
    spacer4.setPrefWidth(1000);
    spacer4.setPrefHeight(10);

    Region spacer5 = new Region();
    spacer5.setPrefWidth(30);
    spacer5.setPrefHeight(30);

    Region spacer6 = new Region();
    spacer6.setPrefWidth(1000);
    spacer6.setPrefHeight(10);

    Region spacer7 = new Region();
    spacer7.setPrefWidth(1000);
    spacer7.setPrefHeight(100);

    Region spacer8 = new Region();
    spacer8.setPrefWidth(30);
    spacer8.setPrefHeight(30);

    this.root.add(spacer4, 0, 3);

    listView.setId("schematic-list");
    listView.setEditable(false);
    listView.setPrefWidth(500);
    listView.setPrefHeight(250);
    this.root.add(new HBox(spacer3, listView), 0, 4);

    uploadFiles.setPadding(new Insets(5, 5, 5, 5));
    uploadFiles.setPrefWidth(120);
    uploadFiles.setPrefHeight(30);
    uploadFiles.setOnAction((event) -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select schematic(s)");
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("MCEdit Schematic File", "*.schematic"),
                new FileChooser.ExtensionFilter("Biome World Object Version 2", "*.bo2"));
        List<File> selectedFiles = fileChooser.showOpenMultipleDialog(this.primaryStage);
        if (selectedFiles != null) {
            if (selectedFiles.size() == 1) {
                filesSelected.setText("There is currently 1 file selected");
            } else {
                filesSelected.setText(
                        "There are currently " + String.valueOf(selectedFiles.size()) + " files selected");
            }
            ObservableList<SchematicLocation> selectedSchematicFiles = FXCollections.observableArrayList();
            selectedSchematicFiles.addAll(selectedFiles.stream().map(f -> new SchematicLocation(f, f.getName()))
                    .collect(Collectors.toList()));
            listView.setItems(selectedSchematicFiles);
            this.schematics = selectedSchematicFiles;
        }

    });
    this.root.add(new HBox(spacer1, uploadFiles, spacer2,
            new Label("Only .schematic files are allowed at this point!")), 0, 2);

    editing.setPadding(new Insets(5, 5, 5, 5));
    editing.setPrefWidth(240);
    editing.setPrefHeight(30);
    editing.setDisable(true);
    editing.setOnAction(event -> this.primaryStage.setScene(Editing.getScene()));
    this.root.add(new HBox(spacer8, editing), 0, 8);

    loadSchematics.setPadding(new Insets(5, 5, 5, 5));
    loadSchematics.setPrefWidth(120);
    loadSchematics.setPrefHeight(30);
    loadSchematics.setOnAction(event -> {
        if (this.schematics != null) {
            ((Runnable) () -> {
                for (SchematicLocation location : this.schematics) {
                    if (FilenameUtils.isExtension(location.getLocation().getName(), "schematic")) {
                        try {
                            Schematics.schematics.add(McEditSchematicObject.load(location.getLocation()));
                        } catch (ParseException | ClassicNotSupportedException | IOException e) {
                            e.printStackTrace();
                        }
                    } else if (FilenameUtils.isExtension(location.getLocation().getName(), "bo2")) {
                        try {
                            Schematics.schematics.add(BiomeWorldV2Object.load(location.getLocation()));
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).run();
            loadSchematics.setDisable(true);
            uploadFiles.setDisable(true);
            listView.setDisable(true);
            editing.setDisable(false);
        }
    });
    this.root.add(spacer6, 0, 5);
    this.root.add(new HBox(spacer5, loadSchematics), 0, 6);
    this.root.add(spacer7, 0, 7);

    this.primaryScene.getStylesheets()
            .add("https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800");
    this.primaryScene.getStylesheets().add(new File("style.css").toURI().toURL().toExternalForm());
    this.primaryStage.setScene(this.primaryScene);
    this.primaryStage.setResizable(false);
    this.primaryStage.setTitle("Schematic Utilities - by frogocomics");
    this.primaryStage.show();
}

From source file:Main.java

WizardPage(String title) {
    getChildren().add(/*from ww w  .j a  v  a 2 s.  c  o  m*/
            LabelBuilder.create().text(title).style("-fx-font-weight: bold; -fx-padding: 0 0 5 0;").build());
    setId(title);
    setSpacing(5);
    setStyle(
            "-fx-padding:10; -fx-background-color: honeydew; -fx-border-color: derive(honeydew, -30%); -fx-border-width: 3;");

    Region spring = new Region();
    VBox.setVgrow(spring, Priority.ALWAYS);
    getChildren().addAll(getContent(), spring, getButtons());

    priorButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            priorPage();
        }
    });
    nextButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            nextPage();
        }
    });
    cancelButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            getWizard().cancel();
        }
    });
    finishButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            getWizard().finish();
        }
    });
}

From source file:Main.java

HBox getButtons() {
    Region spring = new Region();
    HBox.setHgrow(spring, Priority.ALWAYS);
    HBox buttonBar = new HBox(5);
    cancelButton.setCancelButton(true);//from www.ja  va2s  . c  o  m
    finishButton.setDefaultButton(true);
    buttonBar.getChildren().addAll(spring, priorButton, nextButton, cancelButton, finishButton);
    return buttonBar;
}

From source file:webviewsample.Main.java

private Node createSpacer() {
    Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    return spacer;
}

From source file:com.panemu.tiwulfx.table.TableControl.java

private void initControls() {
    this.getStyleClass().add("table-control");
    btnAdd = buildButton(TiwulFXUtil.getGraphicFactory().createAddGraphic());
    btnDelete = buildButton(TiwulFXUtil.getGraphicFactory().createDeleteGraphic());
    btnEdit = buildButton(TiwulFXUtil.getGraphicFactory().createEditGraphic());
    btnExport = buildButton(TiwulFXUtil.getGraphicFactory().createExportGraphic());
    btnReload = buildButton(TiwulFXUtil.getGraphicFactory().createReloadGraphic());
    btnSave = buildButton(TiwulFXUtil.getGraphicFactory().createSaveGraphic());

    btnFirstPage = new Button();
    btnFirstPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageFirstGraphic());
    btnFirstPage.setOnAction(paginationHandler);
    btnFirstPage.setDisable(true);//from  w w w .  j  av  a 2 s.  c  om
    btnFirstPage.setFocusTraversable(false);
    btnFirstPage.getStyleClass().addAll("pill-button", "pill-button-left");

    btnPrevPage = new Button();
    btnPrevPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPagePrevGraphic());
    btnPrevPage.setOnAction(paginationHandler);
    btnPrevPage.setDisable(true);
    btnPrevPage.setFocusTraversable(false);
    btnPrevPage.getStyleClass().addAll("pill-button", "pill-button-center");

    btnNextPage = new Button();
    btnNextPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageNextGraphic());
    btnNextPage.setOnAction(paginationHandler);
    btnNextPage.setDisable(true);
    btnNextPage.setFocusTraversable(false);
    btnNextPage.getStyleClass().addAll("pill-button", "pill-button-center");

    btnLastPage = new Button();
    btnLastPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageLastGraphic());
    btnLastPage.setOnAction(paginationHandler);
    btnLastPage.setDisable(true);
    btnLastPage.setFocusTraversable(false);
    btnLastPage.getStyleClass().addAll("pill-button", "pill-button-right");

    cmbPage = new ComboBox<>();
    cmbPage.setEditable(true);
    cmbPage.setOnAction(paginationHandler);
    cmbPage.setFocusTraversable(false);
    cmbPage.setDisable(true);
    cmbPage.getStyleClass().addAll("combo-page");
    cmbPage.setPrefWidth(75);

    paginationBox = new HBox();
    paginationBox.setAlignment(Pos.CENTER);
    paginationBox.getChildren().addAll(btnFirstPage, btnPrevPage, cmbPage, btnNextPage, btnLastPage);

    spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    toolbar = new ToolBar(btnReload, btnAdd, btnEdit, btnSave, btnDelete, btnExport, spacer, paginationBox);
    toolbar.getStyleClass().add("table-toolbar");

    footer = new StackPane();
    footer.getStyleClass().add("table-footer");
    lblRowIndex = new Label();
    lblTotalRow = new Label();
    menuButton = new TableControlMenu(this);
    StackPane.setAlignment(lblRowIndex, Pos.CENTER_LEFT);
    StackPane.setAlignment(lblTotalRow, Pos.CENTER);
    StackPane.setAlignment(menuButton, Pos.CENTER_RIGHT);

    lblTotalRow.visibleProperty().bind(progressIndicator.visibleProperty().not());

    progressIndicator.setProgress(-1);
    progressIndicator.visibleProperty().bind(service.runningProperty());
    toolbar.disableProperty().bind(service.runningProperty());
    menuButton.disableProperty().bind(service.runningProperty());

    footer.getChildren().addAll(lblRowIndex, lblTotalRow, menuButton, progressIndicator);
    VBox.setVgrow(tblView, Priority.ALWAYS);
    getChildren().addAll(toolbar, tblView, footer);

}

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

private AddSememePopup() {
    super();//from ww w.j ava2 s  .co  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. java2  s  .co  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:net.thirdy.blackmarket.controls.Dialogs.java

public static void showAbout() {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setGraphic(new Region());
    alert.setTitle("Blackmarket " + BlackmarketApplication.VERSION);
    alert.setContentText("");
    alert.setHeaderText("");

    TextArea textArea = new TextArea("Copyright 2015 Vicente de Rivera III" + "\r\n"
            + "\r\n http://thirdy.github.io/blackmarket" + "\r\n"
            + "\r\n This program is free software; you can redistribute it and/or"
            + "\r\n modify it under the terms of the GNU General Public License"
            + "\r\n as published by the Free Software Foundation; either version 2"
            + "\r\n of the License, or (at your option) any later version." + "\r\n"
            + "\r\n This program is distributed in the hope that it will be useful,"
            + "\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of"
            + "\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
            + "\r\n GNU General Public License for more details." + "\r\n"
            + "\r\n You should have received a copy of the GNU General Public License"
            + "\r\n along with this program; if not, write to the Free Software"
            + "\r\n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA." + "\r\n");
    textArea.setEditable(false);/*w w w .  j  a  v  a  2s.com*/
    textArea.setWrapText(true);

    Hyperlink website = new Hyperlink("Visit Blackmarket Homepage");
    website.setOnAction(e -> {
        try {
            SwingUtil.openUrlViaBrowser("http://thirdy.github.io/blackmarket/");
        } catch (BlackmarketException ex) {
            logger.error(ex.getMessage(), ex);
        }
    });

    Hyperlink exwebsite = new Hyperlink("Visit Exile Tools Homepage");
    exwebsite.setOnAction(e -> {
        try {
            SwingUtil.openUrlViaBrowser("http://exiletools.com/");
        } catch (BlackmarketException ex) {
            logger.error(ex.getMessage(), ex);
        }
    });

    VBox content = new VBox(new ImageView(new Image("/images/blackmarket-logo.png")), new Label(
            "Blackmarket is fan-made software for Path of Exile but is not affiliated with Grinding Gear Games in any way."),
            new Label("A few tips:"), new Label("CTRL + Space - hot key to slide the search control pane"),
            new Label("CTRL + Enter - hot key to run the search"),
            new Label("Advance mode grants you power overwhelming of Elastic Search"),
            new Label("For more information and updates,"), website,
            new Label("Blackmarket uses Exile Tools Shop Indexer Elastic Search API:"), exwebsite,
            new Label("Comics by /u/gallio"),
            new Label("Blackmarket is 100% Free and Open Source Software under GPLv2:"), textArea);
    content.setSpacing(8);
    alert.getDialogPane().setContent(content);
    alert.showAndWait();

}

From source file:org.samcrow.frameviewer.ui.db.DatabaseConnectionDialog.java

public DatabaseConnectionDialog(String connectionTypeName) {
    this.connectionTypeName = connectionTypeName;
    setTitle("Database connection");
    // Placeholder
    root.getChildren().add(new Region());

    // Buttons/*  ww w  .  j a v a 2 s .  c  o m*/
    {
        final HBox buttonBox = new HBox();
        buttonBox.setPadding(new Insets(10));

        cancelButton.setCancelButton(true);
        buttonBox.getChildren().add(cancelButton);
        cancelButton.setOnAction((ActionEvent t) -> {
            hide();
        });

        final Region spacer = new Region();
        buttonBox.getChildren().add(spacer);
        HBox.setHgrow(spacer, Priority.ALWAYS);

        nextButton.setDefaultButton(true);
        buttonBox.getChildren().add(nextButton);

        root.getChildren().add(buttonBox);
    }

    switchToConnection();

    final Scene scene = new Scene(root, 220, root.getPrefHeight());
    setScene(scene);
}

From source file:org.sleuthkit.autopsy.timeline.ui.detailview.AggregateEventNode.java

public AggregateEventNode(final AggregateEvent event, AggregateEventNode parentEventNode,
        EventDetailChart chart) {/*from  ww w . ja v a  2  s.  c  om*/
    this.event = event;
    descLOD.set(event.getLOD());
    this.parentEventNode = parentEventNode;
    this.chart = chart;
    final Region region = new Region();
    HBox.setHgrow(region, Priority.ALWAYS);
    final HBox hBox = new HBox(descrLabel, countLabel, region, minusButton, plusButton);
    hBox.setPrefWidth(USE_COMPUTED_SIZE);
    hBox.setMinWidth(USE_PREF_SIZE);
    hBox.setPadding(new Insets(2, 5, 2, 5));
    hBox.setAlignment(Pos.CENTER_LEFT);

    minusButton.setVisible(false);
    plusButton.setVisible(false);
    minusButton.setManaged(false);
    plusButton.setManaged(false);
    final BorderPane borderPane = new BorderPane(subNodePane, hBox, null, null, null);
    BorderPane.setAlignment(subNodePane, Pos.TOP_LEFT);
    borderPane.setPrefWidth(USE_COMPUTED_SIZE);

    getChildren().addAll(spanRegion, borderPane);

    setAlignment(Pos.TOP_LEFT);
    setMinHeight(24);
    minWidthProperty().bind(spanRegion.widthProperty());
    setPrefHeight(USE_COMPUTED_SIZE);
    setMaxHeight(USE_PREF_SIZE);

    //set up subnode pane sizing contraints
    subNodePane.setPrefHeight(USE_COMPUTED_SIZE);
    subNodePane.setMinHeight(USE_PREF_SIZE);
    subNodePane.setMinWidth(USE_PREF_SIZE);
    subNodePane.setMaxHeight(USE_PREF_SIZE);
    subNodePane.setMaxWidth(USE_PREF_SIZE);
    subNodePane.setPickOnBounds(false);

    //setup description label
    eventTypeImageView.setImage(event.getType().getFXImage());
    descrLabel.setGraphic(eventTypeImageView);
    descrLabel.setPrefWidth(USE_COMPUTED_SIZE);
    descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);

    descrLabel.setMouseTransparent(true);
    setDescriptionVisibility(chart.getDescrVisibility().get());

    //setup backgrounds
    final Color evtColor = event.getType().getColor();
    spanFill = new Background(
            new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY));
    setBackground(
            new Background(new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY)));
    setCursor(Cursor.HAND);
    spanRegion.setStyle("-fx-border-width:2 0 2 2; -fx-border-radius: 2; -fx-border-color: "
            + ColorUtilities.getRGBCode(evtColor) + ";"); // NON-NLS
    spanRegion.setBackground(spanFill);

    //set up mouse hover effect and tooltip
    setOnMouseEntered((MouseEvent e) -> {
        //defer tooltip creation till needed, this had a surprisingly large impact on speed of loading the chart
        installTooltip();
        spanRegion.setEffect(new DropShadow(10, evtColor));
        minusButton.setVisible(true);
        plusButton.setVisible(true);
        minusButton.setManaged(true);
        plusButton.setManaged(true);
        toFront();

    });

    setOnMouseExited((MouseEvent e) -> {
        spanRegion.setEffect(null);
        minusButton.setVisible(false);
        plusButton.setVisible(false);
        minusButton.setManaged(false);
        plusButton.setManaged(false);

    });

    setOnMouseClicked(new EventMouseHandler());

    plusButton.disableProperty().bind(descLOD.isEqualTo(DescriptionLOD.FULL));
    minusButton.disableProperty().bind(descLOD.isEqualTo(event.getLOD()));

    plusButton.setOnMouseClicked(e -> {
        final DescriptionLOD next = descLOD.get().next();
        if (next != null) {
            loadSubClusters(next);
            descLOD.set(next);
        }
    });
    minusButton.setOnMouseClicked(e -> {
        final DescriptionLOD previous = descLOD.get().previous();
        if (previous != null) {
            loadSubClusters(previous);
            descLOD.set(previous);
        }
    });
}