Java Code Examples for javafx.scene.layout.GridPane#addRow()

The following examples show how to use javafx.scene.layout.GridPane#addRow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HyperlinkEditorFactory.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    textField = new TextField();
    textField.textProperty().addListener((o, n, v) -> {
        update();
    });

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        textField.setDisable(noValueCheckBox.isSelected());
        update();
    });

    controls.addRow(0, textField);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 2
Source File: TimeEditorFactory.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    final HBox timeSpinnerContainer = createTimeSpinners();

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        hourSpinner.setDisable(noValueCheckBox.isSelected());
        minSpinner.setDisable(noValueCheckBox.isSelected());
        secSpinner.setDisable(noValueCheckBox.isSelected());
        milliSpinner.setDisable(noValueCheckBox.isSelected());
        update();
    });

    controls.addRow(0, timeSpinnerContainer);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 3
Source File: ShortObjectEditorFactory.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    numberField = new TextField();
    numberField.textProperty().addListener((o, n, v) -> {
        update();
    });

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        numberField.setDisable(noValueCheckBox.isSelected());
        update();
    });

    controls.addRow(0, numberField);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 4
Source File: LongObjectEditorFactory.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    numberField = new TextField();
    numberField.textProperty().addListener((o, n, v) -> {
        update();
    });

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        numberField.setDisable(noValueCheckBox.isSelected());
        update();
    });

    controls.addRow(0, numberField);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 5
Source File: LocalDateTimeEditorFactory.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        datePicker.setDisable(noValueCheckBox.isSelected());
        hourSpinner.setDisable(noValueCheckBox.isSelected());
        minSpinner.setDisable(noValueCheckBox.isSelected());
        secSpinner.setDisable(noValueCheckBox.isSelected());
        milliSpinner.setDisable(noValueCheckBox.isSelected());
        update();
    });

    final HBox timeSpinnerContainer = createTimeSpinners();

    controls.addRow(0, timeSpinnerContainer);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 6
Source File: ShortcutInformationPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link GridPane} containing the control buttons for the selected shortcut.
 * These control buttons consist of:
 * <ul>
 * <li>The run button</li>
 * <li>The stop button</li>
 * <li>The uninstall button</li>
 * </ul>
 *
 * @return A new {@link GridPane} containing the control buttons for the selected shortcut
 */
private GridPane createControlButtons() {
    final GridPane controlButtons = new GridPane();
    controlButtons.getStyleClass().add("shortcut-control-button-group");

    ColumnConstraints runColumn = new ColumnConstraintsWithPercentage(25);
    ColumnConstraints stopColumn = new ColumnConstraintsWithPercentage(25);
    ColumnConstraints uninstallColumn = new ColumnConstraintsWithPercentage(25);
    ColumnConstraints editColumn = new ColumnConstraintsWithPercentage(25);

    controlButtons.getColumnConstraints().addAll(runColumn, stopColumn, uninstallColumn, editColumn);

    final Button runButton = new Button(tr("Run"));
    runButton.getStyleClass().addAll("shortcutButton", "runButton");
    runButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutRun())
            .ifPresent(onShortcutRun -> onShortcutRun.accept(getControl().getShortcut())));
    GridPane.setHalignment(runButton, HPos.CENTER);

    final Button stopButton = new Button(tr("Close"));
    stopButton.getStyleClass().addAll("shortcutButton", "stopButton");
    stopButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutStop())
            .ifPresent(onShortcutStop -> onShortcutStop.accept(getControl().getShortcut())));
    GridPane.setHalignment(stopButton, HPos.CENTER);

    final Button uninstallButton = new Button(tr("Uninstall"));
    uninstallButton.getStyleClass().addAll("shortcutButton", "uninstallButton");
    uninstallButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutUninstall())
            .ifPresent(onShortcutUninstall -> onShortcutUninstall.accept(getControl().getShortcut())));
    GridPane.setHalignment(uninstallButton, HPos.CENTER);

    final Button editButton = new Button(tr("Edit"));
    editButton.getStyleClass().addAll("shortcutButton", "editButton");
    editButton.setOnMouseClicked(event -> Optional.ofNullable(getControl().getOnShortcutEdit())
            .ifPresent(onShortcutEdit -> onShortcutEdit.accept(getControl().getShortcut())));
    GridPane.setHalignment(editButton, HPos.CENTER);

    controlButtons.addRow(0, runButton, stopButton, uninstallButton, editButton);

    return controlButtons;
}
 
Example 7
Source File: EditAxis.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the header for the Axis Editor popup, allowing to configure axis label and unit
 *
 * @param axis The axis to be edited
 * @return pane containing label, label editor and unit editor
 */
private Node getLabelEditor(final Axis axis, final boolean isHorizontal) {
    final GridPane header = new GridPane();
    header.setAlignment(Pos.BASELINE_LEFT);
    final TextField axisLabelTextField = new TextField(axis.getName());
    axisLabelTextField.textProperty().bindBidirectional(axis.nameProperty());
    header.addRow(0, new Label(" axis label: "), axisLabelTextField);

    final TextField axisUnitTextField = new TextField(axis.getUnit());
    axisUnitTextField.setPrefWidth(50.0);
    axisUnitTextField.textProperty().bindBidirectional(axis.unitProperty());
    header.addRow(isHorizontal ? 0 : 1, new Label(" unit: "), axisUnitTextField);

    final TextField unitScaling = new TextField();
    unitScaling.setPrefWidth(80.0);
    final CheckBox autoUnitScaling = new CheckBox(" auto");
    if (axis instanceof DefaultNumericAxis) {
        autoUnitScaling.selectedProperty()
                .bindBidirectional(((DefaultNumericAxis) axis).autoUnitScalingProperty());
        unitScaling.textProperty().bindBidirectional(((DefaultNumericAxis) axis).unitScalingProperty(),
                new NumberStringConverter(new DecimalFormat("0.0####E0")));
        unitScaling.disableProperty().bind(autoUnitScaling.selectedProperty());
    } else {
        // TODO: consider adding an interface on whether
        // autoUnitScaling is editable
        autoUnitScaling.setDisable(true);
        unitScaling.setDisable(true);
    }
    final HBox unitScalingBox = new HBox(unitScaling, autoUnitScaling);
    unitScalingBox.setAlignment(Pos.BASELINE_LEFT);
    header.addRow(isHorizontal ? 0 : 2, new Label(" unit scale:"), unitScalingBox);
    return header;
}
 
Example 8
Source File: NumberSpinnerDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX Spinner Demo");
    GridPane root = new GridPane();
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(10, 10, 10, 10));
    final NumberSpinner defaultSpinner = new NumberSpinner();
    final NumberSpinner decimalFormat = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.05"), new DecimalFormat("#,##0.00"));
    final NumberSpinner percent = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getPercentInstance());
    final NumberSpinner localizedCurrency = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getCurrencyInstance(Locale.UK));
    root.addRow(1, new Label("default"), defaultSpinner);
    root.addRow(2, new Label("custom decimal format"), decimalFormat);
    root.addRow(3, new Label("percent"), percent);
    root.addRow(4, new Label("localized currency"), localizedCurrency);
    Button button = new Button("Dump layout bounds");
    button.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            defaultSpinner.dumpSizes();
        }
    });
    root.addRow(5, new Label(), button);

    Scene scene = new Scene(root);
    //String path = NumberSpinnerDemo.class.getResource("/fxui/css/spinner/number_spinner.css").toExternalForm();
    String path = "/fxui/css/spinner/number_spinner.css";
    System.out.println("path = " + path);
    //scene.getStylesheets().add(path);
    scene.getStylesheets().add(getClass().getResource(path).toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 9
Source File: FileObjectView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FileObjectView() throws IOException {

        Label lbName = new Label();
        CheckBox cbSubscribed = new CheckBox("Subscribed?");

        GridPane gridPane = new GridPane();
        gridPane.addRow(0, new Label("Name:"), lbName);
        gridPane.addRow(1, cbSubscribed);

        setCenter(gridPane);

        // create a FileClient to the specified file
        FileClient fileClient = FileClient.create(new File(ROOT_DIR, "user.json"));

        // create a JSON converter that converts a JSON object into a user object
        InputStreamInputConverter<User> converter = new JsonInputConverter<>(User.class);

        // retrieve an object from an ObjectDataReader created from the FileClient
        GluonObservableObject<User> user = DataProvider.retrieveObject(fileClient.createObjectDataReader(converter));

        // when the object is initialized, bind its properties to the JavaFX UI controls
        user.initializedProperty().addListener((obs, oldValue, newValue) -> {
            if (newValue) {
                lbName.textProperty().bind(user.get().nameProperty());
                cbSubscribed.selectedProperty().bindBidirectional(user.get().subscribedProperty());
            }
        });

        // write user to file when selected property of the subscribed checkbox is changed
        cbSubscribed.selectedProperty().addListener((obs, ov, nv) -> {
            user.get().setSubscribed(nv);

            // create a JSON converter that converts the user object into a JSON object
            OutputStreamOutputConverter<User> outputConverter = new JsonOutputConverter<>(User.class);

            // store an object with an ObjectDataWriter created from the FileClient
            DataProvider.storeObject(user.get(), fileClient.createObjectDataWriter(outputConverter));
        });
    }
 
Example 10
Source File: PatientView.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void layoutParts() {
  setSpacing(20);

  GridPane dashboard = new GridPane();
  RowConstraints growingRow = new RowConstraints();
  growingRow.setVgrow(Priority.ALWAYS);
  ColumnConstraints growingCol = new ColumnConstraints();
  growingCol.setHgrow(Priority.ALWAYS);
  dashboard.getRowConstraints().setAll(growingRow, growingRow);
  dashboard.getColumnConstraints().setAll(growingCol, growingCol);

  dashboard.setVgap(60);

  dashboard.setPrefHeight(800);
  dashboard.addRow(0, bloodPressureSystolicControl, bloodPressureDiastolicControl);
  dashboard.addRow(1, weightControl, tallnessControl);


  setHgrow(dashboard, Priority.ALWAYS);

  GridPane form = new GridPane();
  form.setHgap(10);
  form.setVgap(25);
  form.setMaxWidth(410);

  GridPane.setVgrow(imageView, Priority.ALWAYS);
  GridPane.setValignment(imageView, VPos.BOTTOM);

  form.add(firstNameField, 0, 0);
  form.add(lastNameField, 1, 0);
  form.add(yearOfBirthField, 0, 1);
  form.add(genderField, 1, 1);
  form.add(imageView, 0, 2, 2, 1);
  form.add(imgURLField, 0, 3, 2, 1);

  getChildren().addAll(form, dashboard);

}
 
Example 11
Source File: ContainerOverviewPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds the wine architecture information of the container to the {@link GridPane overviewGrid}
 *
 * @param overviewGrid The grid containing the overview information
 */
private void addArchitecture(final GridPane overviewGrid) {
    final int row = overviewGrid.getRowCount();

    final Text architectureDescription = new Text(tr("Wine architecture:"));
    architectureDescription.getStyleClass().add("captionTitle");

    final Label architectureOutput = new Label();
    architectureOutput.textProperty()
            .bind(StringBindings.map(getControl().containerProperty(), WinePrefixContainerDTO::getArchitecture));
    architectureOutput.setWrapText(true);

    overviewGrid.addRow(row, architectureDescription, architectureOutput);
}
 
Example 12
Source File: DualPasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
public DualPasswordInputDialog(final ResourceBundle resources) {
    super();

    newLabel = new Label(resources.getString("dialogEncrypt.passNew"));
    repeatLabel = new Label(resources.getString("dialogEncrypt.passRepeat"));
    newPass = new PasswordField();
    repeatPass = new PasswordField();

    newLabel.getStyleClass().add("label-heading");
    repeatLabel.getStyleClass().add("label-heading");

    grid = new GridPane();
    grid.setHgap(DIALOG_HGAP);
    grid.setVgap(DIALOG_VGAP);
    grid.addRow(0, newLabel, newPass);
    grid.addRow(1, repeatLabel, repeatPass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(newPass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            if (!newPass.getText().trim().isEmpty() && !repeatPass.getText().trim().isEmpty()) {
                if (Objects.equals(newPass.getText(), repeatPass.getText())) {
                    return newPass.getText();
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
        return null;
    });
}
 
Example 13
Source File: ContainerOverviewPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds the path information of the container to the {@link GridPane overviewGrid}
 *
 * @param overviewGrid The grid containing the overview information
 */
private void addPath(final GridPane overviewGrid) {
    final int row = overviewGrid.getRowCount();

    final Text pathDescription = new Text(tr("Path:"));
    pathDescription.getStyleClass().add("captionTitle");

    final Label pathOutput = new Label();
    pathOutput.textProperty().bind(StringBindings.map(getControl().containerProperty(), ContainerDTO::getPath));
    pathOutput.setWrapText(true);

    overviewGrid.addRow(row, pathDescription, pathOutput);
}
 
Example 14
Source File: DecoratorsEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    // get all vertex attributes currently in the graph
    final List<String> attributeNames = new ArrayList<>();
    ReadableGraph rg = GraphManager.getDefault().getActiveGraph().getReadableGraph();
    try {
        for (int i = 0; i < rg.getAttributeCount(GraphElementType.VERTEX); i++) {
            attributeNames.add(rg.getAttributeName(rg.getAttribute(GraphElementType.VERTEX, i)));
        }
    } finally {
        rg.release();
    }
    Collections.sort(attributeNames);
    attributeNames.add(0, NO_DECORATOR);

    final Label nwLabel = new Label("NW:");
    final Label neLabel = new Label("NE:");
    final Label seLabel = new Label("SE:");
    final Label swLabel = new Label("SW:");
    nwCombo = new ComboBox<>(FXCollections.observableList(attributeNames));
    nwCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });
    neCombo = new ComboBox<>(FXCollections.observableList(attributeNames));
    neCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });
    seCombo = new ComboBox<>(FXCollections.observableList(attributeNames));
    seCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });
    swCombo = new ComboBox<>(FXCollections.observableList(attributeNames));
    swCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });

    final GridPane controls = new GridPane();
    controls.getColumnConstraints().add(new ColumnConstraints(50));
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);
    controls.addRow(0, nwLabel, nwCombo);
    controls.addRow(3, neLabel, neCombo);
    controls.addRow(2, seLabel, seCombo);
    controls.addRow(1, swLabel, swCombo);

    return controls;
}
 
Example 15
Source File: TransactionTypeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    typeList = new ListView<>();
    typeList.setCellFactory(p -> new ListCell<SchemaTransactionType>() {
        @Override
        protected void updateItem(final SchemaTransactionType item, boolean empty) {
            super.updateItem(item, empty);
            if (!empty && item != null) {
                setText(item.getName());
            }
        }
    });

    // get all types supported by the current schema
    final List<SchemaTransactionType> types = new ArrayList<>();
    if (GraphManager.getDefault().getActiveGraph() != null && GraphManager.getDefault().getActiveGraph().getSchema() != null) {
        final SchemaFactory schemaFactory = GraphManager.getDefault().getActiveGraph().getSchema().getFactory();
        final Set<Class<? extends SchemaConcept>> concepts = new HashSet<>();
        concepts.addAll(schemaFactory.getRegisteredConcepts());
        SchemaConceptUtilities.getChildConcepts(schemaFactory.getRegisteredConcepts())
                .forEach(childConcept -> concepts.add(childConcept.getClass()));
        types.addAll(SchemaTransactionTypeUtilities.getTypes(concepts));
        types.add(SchemaTransactionTypeUtilities.getDefaultType());
    }

    final Label nameLabel = new Label("Type Name:");
    nameText = new TextField();
    final VBox nameBox = new VBox(CONTROLS_DEFAULT_VERTICAL_SPACING);
    nameBox.getChildren().addAll(nameLabel, nameText);

    nameText.textProperty().addListener(ev -> {
        if (!selectionIsActive) {
            typeList.getSelectionModel().select(null);
        }
        update();
    });

    final Label listLabel = new Label("Schema Types:");
    Collections.sort(types);
    typeList.getItems().addAll(types);

    typeList.getSelectionModel().selectedItemProperty().addListener(ev -> {
        selectionIsActive = true;
        final SchemaTransactionType type = typeList.getSelectionModel().getSelectedItem();
        if (type != null) {
            nameText.setText(type.getName());
        }
        selectionIsActive = false;
    });

    controls.addRow(0, nameBox);
    controls.addRow(1, listLabel);
    controls.addRow(2, typeList);
    return controls;
}
 
Example 16
Source File: DateTimeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        datePicker.setDisable(noValueCheckBox.isSelected());
        hourSpinner.setDisable(noValueCheckBox.isSelected());
        minSpinner.setDisable(noValueCheckBox.isSelected());
        secSpinner.setDisable(noValueCheckBox.isSelected());
        milliSpinner.setDisable(noValueCheckBox.isSelected());
        timeZoneComboBox.setDisable(noValueCheckBox.isSelected());
        update();
    });

    final ObservableList<ZoneId> timeZones = FXCollections.observableArrayList();
    ZoneId.getAvailableZoneIds().forEach(id -> {
        timeZones.add(ZoneId.of(id));
    });
    timeZoneComboBox = new ComboBox<>();
    timeZoneComboBox.setItems(timeZones.sorted(zoneIdComparator));
    final Callback<ListView<ZoneId>, ListCell<ZoneId>> cellFactory = (final ListView<ZoneId> p) -> new ListCell<ZoneId>() {
        @Override
        protected void updateItem(final ZoneId item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                setText(TimeZoneUtilities.getTimeZoneAsString(currentValue == null ? null : currentValue.toLocalDateTime(), item));
            }
        }
    };

    final Label timeZoneComboBoxLabel = new Label("Time Zone:");
    timeZoneComboBoxLabel.setId(LABEL_ID);
    timeZoneComboBoxLabel.setLabelFor(timeZoneComboBoxLabel);

    timeZoneComboBox.setCellFactory(cellFactory);
    timeZoneComboBox.setButtonCell(cellFactory.call(null));
    timeZoneComboBox.getSelectionModel().select(TimeZoneUtilities.UTC);
    timeZoneComboBox.getSelectionModel().selectedItemProperty().addListener(updateTimeFromZone);

    final HBox timeZoneHbox = new HBox(timeZoneComboBoxLabel, timeZoneComboBox);
    timeZoneHbox.setSpacing(5);
    final HBox timeSpinnerContainer = createTimeSpinners();

    controls.addRow(0, timeSpinnerContainer);
    controls.addRow(1, timeZoneHbox);
    controls.addRow(2, noValueCheckBox);
    return controls;
}
 
Example 17
Source File: LayersViewPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
public LayersViewPane(final LayersViewController controller) {

        // create controller
        this.controller = controller;

        // create layer headings
        final Label layerIdHeadingText = new Label("Layer\nID");
        final Label visibilityHeadingText = new Label("Visibility");
        final Label queryHeadingText = new Label("Query");
        final Label descriptionHeadingText = new Label("Description");

        // create gridpane and alignments
        layersGridPane = new GridPane();
        layersGridPane.setHgap(5);
        layersGridPane.setVgap(5);
        layersGridPane.setPadding(new Insets(0, 10, 10, 10));
        layersGridPane.addRow(0, layerIdHeadingText, visibilityHeadingText,
                queryHeadingText, descriptionHeadingText);

        // set heading alignments
        GridPane.setMargin(layerIdHeadingText, new Insets(15, 0, 0, 0));
        layerIdHeadingText.setTextAlignment(TextAlignment.CENTER);
        layerIdHeadingText.setMinWidth(40);
        layerIdHeadingText.setMinHeight(25);
        layerIdHeadingText.setPrefWidth(30);
        visibilityHeadingText.setPrefWidth(55);
        visibilityHeadingText.setMinWidth(50);
        queryHeadingText.setPrefWidth(10000);
        queryHeadingText.setMinWidth(80);
        descriptionHeadingText.setPrefWidth(10000);
        descriptionHeadingText.setMinWidth(80);

        // instantiate list of layers
        layers = new ArrayList<>();

        // set default layers
        setDefaultLayers();

        // create options
        final Button addButton = new Button("Add New Layer");
        addButton.setAlignment(Pos.CENTER_RIGHT);
        addButton.setOnAction(event -> {
            if (layersGridPane.getRowCount() <= 32) {
                createLayer(layers.size() + 1, false, "", "");
                controller.writeState();
            } else {
                final NotifyDescriptor nd = new NotifyDescriptor.Message(
                        "You cannot have more than 32 layers", NotifyDescriptor.WARNING_MESSAGE);
                DialogDisplayer.getDefault().notify(nd);
            }
            event.consume();
        });
        HBox.setHgrow(addButton, Priority.ALWAYS);

        final Button deselectAllButton = new Button("Deselect All Layers");
        deselectAllButton.setAlignment(Pos.CENTER_RIGHT);
        deselectAllButton.setOnAction(event -> {
            for (final LayerDescription layer : layers) {
                layer.setCurrentLayerVisibility(false);
            }
            if (this.layers.isEmpty()) {
                setDefaultLayers();
            } else {
                setLayers(List.copyOf(layers));
            }
            controller.submit();
            controller.execute();

            event.consume();
        });
        HBox.setHgrow(deselectAllButton, Priority.ALWAYS);

        this.options = new HBox(5, addButton, deselectAllButton);
        options.setAlignment(Pos.TOP_LEFT);
        options.setPadding(new Insets(0, 0, 0, 10));

        // add layers grid and options to pane
        this.layersViewPane = new VBox(5, layersGridPane, options);

        // create layout bindings
        layersViewPane.prefWidthProperty().bind(this.widthProperty());
        options.prefWidthProperty().bind(layersViewPane.widthProperty());

        this.setCenter(layersViewPane);
        controller.writeState();
    }
 
Example 18
Source File: VertexTypeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    typeList = new ListView<>();
    typeList.setCellFactory(p -> new ListCell<SchemaVertexType>() {
        @Override
        protected void updateItem(final SchemaVertexType item, boolean empty) {
            super.updateItem(item, empty);
            if (!empty && item != null) {
                setText(item.getName());
            }
        }
    });

    // get all types supported by the current schema
    final List<SchemaVertexType> types = new ArrayList<>();
    if (GraphManager.getDefault().getActiveGraph() != null && GraphManager.getDefault().getActiveGraph().getSchema() != null) {
        final SchemaFactory schemaFactory = GraphManager.getDefault().getActiveGraph().getSchema().getFactory();
        final Set<Class<? extends SchemaConcept>> concepts = new HashSet<>();
        concepts.addAll(schemaFactory.getRegisteredConcepts());
        SchemaConceptUtilities.getChildConcepts(schemaFactory.getRegisteredConcepts())
                .forEach(childConcept -> concepts.add(childConcept.getClass()));
        types.addAll(SchemaVertexTypeUtilities.getTypes(concepts));
        types.add(SchemaVertexTypeUtilities.getDefaultType());
    }

    final Label nameLabel = new Label("Type Name:");
    nameText = new TextField();
    final VBox nameBox = new VBox(10);
    nameBox.getChildren().addAll(nameLabel, nameText);

    nameText.textProperty().addListener(ev -> {
        if (!selectionIsActive) {
            typeList.getSelectionModel().select(null);
        }
        update();
    });

    final Label listLabel = new Label("Schema Types:");
    Collections.sort(types);
    typeList.getItems().addAll(types);

    typeList.getSelectionModel().selectedItemProperty().addListener(ev -> {
        selectionIsActive = true;
        final SchemaVertexType type = typeList.getSelectionModel().getSelectedItem();
        if (type != null) {
            nameText.setText(type.getName());
        }
        selectionIsActive = false;
    });

    controls.addRow(0, nameBox);
    controls.addRow(1, listLabel);
    controls.addRow(2, typeList);
    return controls;
}
 
Example 19
Source File: VertexAttributeNameEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    attributeList = new ListView<>();

    final List<String> attributeNames = new ArrayList<>();
    // get all vertex attributes currently in the graph
    final ReadableGraph rg = GraphManager.getDefault().getActiveGraph().getReadableGraph();
    try {
        for (int i = 0; i < rg.getAttributeCount(GraphElementType.VERTEX); i++) {
            attributeNames.add(rg.getAttributeName(rg.getAttribute(GraphElementType.VERTEX, i)));
        }
    } finally {
        rg.release();
    }

    final Label nameLabel = new Label("Attribute name:");
    nameText = new TextField();
    final VBox nameBox = new VBox(10);
    nameBox.getChildren().addAll(nameLabel, nameText);

    nameText.textProperty().addListener(ev -> {
        if (!selectionIsActive) {
            attributeList.getSelectionModel().select(null);
        }
        update();
    });

    final Label listLabel = new Label("Current attributes:");
    Collections.sort(attributeNames);
    attributeList.getItems().addAll(attributeNames);

    attributeList.getSelectionModel().selectedItemProperty().addListener(ev -> {
        selectionIsActive = true;
        final String attributeName = attributeList.getSelectionModel().getSelectedItem();
        if (attributeName != null) {
            nameText.setText(attributeName);
        }
        selectionIsActive = false;
    });

    controls.addRow(0, nameBox);
    controls.addRow(1, listLabel);
    controls.addRow(2, attributeList);
    return controls;
}
 
Example 20
Source File: AttributeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    GridPane controls = new GridPane();
    controls.setHgap(5);
    controls.setVgap(CONTROLPANE_SPACING);

    Label nameLabel = new Label("Attribute Name:");
    Label typeLabel = new Label("Attribute Type:");
    Label descLabel = new Label("Attribute Description:");
    Label defaultLabel = new Label("Default Value:");

    nameText = new TextField();
    nameText.textProperty().addListener((o, n, v) -> {
        update();
    });
    typeCombo = new ComboBox<>();
    typeCombo.setDisable(!isTypeModifiable);
    typeCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });
    descText = new TextField();
    descText.textProperty().addListener((o, n, v) -> {
        update();
    });
    setDefaultButton = new Button("Set Default");
    setDefaultButton.setOnAction(getSelectDefaultHandler());
    clearDefaultButton = new Button("Clear Default");
    clearDefaultButton.setOnAction(e -> {
        defaultValue = null;
        clearDefaultButton.setDisable(true);
        update();
    });

    // Populate the type combo with all of the possible graph types.
    final ArrayList<String> attributeTypes = new ArrayList<>();
    AttributeRegistry.getDefault().getAttributes().entrySet().stream().forEach(entry -> {
        final Class<? extends AttributeDescription> attrTypeDescr = entry.getValue();
        final boolean isObject = ObjectAttributeDescription.class.isAssignableFrom(attrTypeDescr);
        if (!isObject) {
            final String attrTypeName = entry.getKey();
            attributeTypes.add(attrTypeName);
        }
    });
    Collections.sort(attributeTypes);
    typeCombo.setItems(FXCollections.observableList(attributeTypes));

    controls.addRow(0, nameLabel, nameText);
    controls.addRow(1, typeLabel, typeCombo);
    controls.addRow(2, descLabel, descText);
    controls.addRow(3, defaultLabel, new HBox(5, setDefaultButton, clearDefaultButton));
    return controls;
}