Java Code Examples for javafx.scene.layout.ColumnConstraints#setHgrow()

The following examples show how to use javafx.scene.layout.ColumnConstraints#setHgrow() . 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: ActivityItemCell.java    From PeerWasp with MIT License 7 votes vote down vote up
private void initializeGrid() {
	grid.setHgap(10);
	grid.setVgap(5);
	grid.setPadding(new Insets(0, 10, 0, 10));

	// icon column
	ColumnConstraints col1 = new ColumnConstraints();
	col1.setFillWidth(false);
	col1.setHgrow(Priority.NEVER);
	grid.getColumnConstraints().add(col1);

	// title column: grows
	ColumnConstraints col2 = new ColumnConstraints();
	col2.setFillWidth(true);
	col2.setHgrow(Priority.ALWAYS);
	grid.getColumnConstraints().add(col2);

	// date column
	ColumnConstraints col3 = new ColumnConstraints();
	col3.setFillWidth(false);
	col3.setHgrow(Priority.NEVER);
	grid.getColumnConstraints().add(col3);
}
 
Example 2
Source File: EasyGridPane.java    From constellation with Apache License 2.0 6 votes vote down vote up
public void addColumnConstraint(boolean fillWidth, HPos alignment, Priority grow, double maxWidth, double minWidth, double prefWidth, double percentWidth) {
    ColumnConstraints constraint = new ColumnConstraints();
    constraint.setFillWidth(fillWidth);
    constraint.setHalignment(alignment);
    constraint.setHgrow(grow);
    constraint.setMaxWidth(maxWidth);
    constraint.setMinWidth(minWidth);
    constraint.setPrefWidth(prefWidth);

    if (percentWidth >= 0) {
        constraint.setPercentWidth(percentWidth);
    }

    getColumnConstraints().add(constraint);
}
 
Example 3
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
}
 
Example 4
Source File: BaseGraphApp.java    From diirt with MIT License 5 votes vote down vote up
public DataSelectionPanel() {
    this.setPadding( new Insets( 5 , 5 , 5 , 5 ) );

    GridPane pnlCenter = new GridPane();
    pnlCenter.setHgap( 5 );
    this.cboSelectData.setPrefWidth( 0 );
    pnlCenter.addRow( 0 , this.lblData , this.cboSelectData , this.cmdConfigure );

    ColumnConstraints allowResize = new ColumnConstraints();
    allowResize.setHgrow( Priority.ALWAYS );
    ColumnConstraints noResize = new ColumnConstraints();
    pnlCenter.getColumnConstraints().addAll( noResize , allowResize , noResize );

    this.setCenter( pnlCenter );

    //allow the combo box to stretch out and fill panel completely
    this.cboSelectData.setMaxSize( Double.MAX_VALUE , Double.MAX_VALUE );
    this.cboSelectData.setEditable( true );

    //watches for when the user selects a new data formula
    cboSelectData.valueProperty().addListener( new ChangeListener< String >() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            pnlGraph.setFormula(newValue);
        }

    });

    this.cmdConfigure.setOnAction( new EventHandler< ActionEvent >() {

        @Override
        public void handle(ActionEvent event) {
            openConfigurationPanel();
        }

    });
}
 
Example 5
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addGridPane() {
    gridPane = new GridPane();
    gridPane.getStyleClass().add("content-pane");
    gridPane.setPadding(new Insets(15, 15, -1, 15));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    scrollPane.setContent(gridPane);
}
 
Example 6
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addGridPane() {
    gridPane = new GridPane();
    gridPane.getStyleClass().add("content-pane");
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    scrollPane.setContent(gridPane);
}
 
Example 7
Source File: CandleTooltip.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
CandleTooltip(StringConverter<Number> priceStringConverter) {
    this.priceStringConverter = priceStringConverter;

    setHgap(Layout.GRID_GAP);

    setVgap(2);

    Label open = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.open"));
    Label close = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.close"));
    Label high = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.high"));
    Label low = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.low"));
    Label average = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.average"));
    Label median = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.median"));
    Label date = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.date"));
    setConstraints(open, 0, 0);
    setConstraints(openValue, 1, 0);
    setConstraints(close, 0, 1);
    setConstraints(closeValue, 1, 1);
    setConstraints(high, 0, 2);
    setConstraints(highValue, 1, 2);
    setConstraints(low, 0, 3);
    setConstraints(lowValue, 1, 3);
    setConstraints(average, 0, 4);
    setConstraints(averageValue, 1, 4);
    setConstraints(median, 0, 5);
    setConstraints(medianValue, 1, 5);
    setConstraints(date, 0, 6);
    setConstraints(dateValue, 1, 6);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    getColumnConstraints().addAll(columnConstraints1, columnConstraints2);

    getChildren().addAll(open, openValue, close, closeValue, high, highValue, low, lowValue, average, averageValue, median, medianValue, date, dateValue);
}
 
Example 8
Source File: ProposalResultsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private GridPane createVotesTable() {
    GridPane votesGridPane = new GridPane();
    votesGridPane.setHgap(5);
    votesGridPane.setVgap(5);
    votesGridPane.setPadding(new Insets(15));

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.ALWAYS);
    votesGridPane.getColumnConstraints().addAll(columnConstraints1);

    int gridRow = 0;

    TableGroupHeadline votesTableHeader = new TableGroupHeadline(Res.get("dao.results.proposals.voting.detail.header"));
    GridPane.setRowIndex(votesTableHeader, gridRow);
    GridPane.setMargin(votesTableHeader, new Insets(8, 0, 0, 0));
    GridPane.setColumnSpan(votesTableHeader, 2);
    votesGridPane.getChildren().add(votesTableHeader);

    TableView<VoteListItem> votesTableView = new TableView<>();
    votesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    votesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    createColumns(votesTableView);
    GridPane.setRowIndex(votesTableView, gridRow);
    GridPane.setMargin(votesTableView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    GridPane.setColumnSpan(votesTableView, 2);
    GridPane.setVgrow(votesTableView, Priority.ALWAYS);
    votesGridPane.getChildren().add(votesTableView);

    votesTableView.setItems(sortedVotes);

    addCloseButton(votesGridPane, ++gridRow);

    return votesGridPane;
}
 
Example 9
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 10
Source File: ConversationBox.java    From constellation with Apache License 2.0 5 votes vote down vote up
public BubbleBox(final ConversationMessage message) {
    setVgap(3);

    final ColumnConstraints spaceColumn = new ColumnConstraints();
    spaceColumn.setHgrow(Priority.ALWAYS);
    spaceColumn.setMinWidth(50);
    spaceColumn.setPrefWidth(50);

    final ColumnConstraints contentColumn = new ColumnConstraints();
    contentColumn.setHalignment(message.getConversationSide() == ConversationSide.LEFT ? HPos.LEFT : HPos.RIGHT);
    contentColumn.setFillWidth(false);
    contentColumn.setHgrow(Priority.NEVER);

    final RowConstraints contentRow = new RowConstraints();
    contentRow.setFillHeight(true);
    contentRow.setMaxHeight(Double.MAX_VALUE);
    contentRow.setValignment(VPos.TOP);

    getRowConstraints().addAll(contentRow);

    if (message.getConversationSide() == ConversationSide.LEFT) {
        contentColumnIndex = 0;
        getColumnConstraints().addAll(contentColumn, spaceColumn);
    } else {
        contentColumnIndex = 1;
        getColumnConstraints().addAll(spaceColumn, contentColumn);
    }

    update(message);
}
 
Example 11
Source File: TradeStepView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
protected TradeStepView(PendingTradesViewModel model) {
    this.model = model;
    preferences = model.dataModel.preferences;
    trade = model.dataModel.getTrade();
    checkNotNull(trade, "Trade must not be null at TradeStepView");

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setFitToHeight(true);
    scrollPane.setFitToWidth(true);

    AnchorPane.setLeftAnchor(scrollPane, 10d);
    AnchorPane.setRightAnchor(scrollPane, 10d);
    AnchorPane.setTopAnchor(scrollPane, 10d);
    AnchorPane.setBottomAnchor(scrollPane, 0d);

    getChildren().add(scrollPane);

    gridPane = new GridPane();

    gridPane.setHgap(Layout.GRID_GAP);
    gridPane.setVgap(Layout.GRID_GAP);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHgrow(Priority.ALWAYS);

    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);

    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);

    scrollPane.setContent(gridPane);

    AnchorPane.setLeftAnchor(this, 0d);
    AnchorPane.setRightAnchor(this, 0d);
    AnchorPane.setTopAnchor(this, -10d);
    AnchorPane.setBottomAnchor(this, 0d);

    addContent();

    errorMessageListener = (observable, oldValue, newValue) -> {
        if (newValue != null)
            new Popup().error(newValue).show();
    };

    clockListener = new ClockWatcher.Listener() {
        @Override
        public void onSecondTick() {
        }

        @Override
        public void onMinuteTick() {
            updateTimeLeft();
        }
    };
}
 
Example 12
Source File: AddPVDialog.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private Node createContent(final Model model, final int count)
{
    final GridPane layout = new GridPane();
    // layout.setGridLinesVisible(true);
    layout.setHgap(5);
    layout.setVgap(5);
    final ColumnConstraints stay = new ColumnConstraints();
    final ColumnConstraints fill = new ColumnConstraints();
    fill.setHgrow(Priority.ALWAYS);
    layout.getColumnConstraints().addAll(stay, stay, fill);

    axis_options = FXCollections.observableArrayList(model.getAxes().stream().map(AxisConfig::getName).collect(Collectors.toList()));
    axis_options.add(0, Messages.AddPV_NewOrEmptyAxis);

    int row = -1;
    for (int i=0; i<count; ++i)
    {
        final String nm = count == 1 ? Messages.Name : Messages.Name + " " + (i+1);
        layout.add(new Label(nm), 0, ++row);
        final TextField name = new TextField();
        name.textProperty().addListener(event -> checkDuplicateName(name));
        name.setTooltip(new Tooltip(formula ? Messages.AddFormula_NameTT : Messages.AddPV_NameTT));
        if (! formula)
            PVAutocompleteMenu.INSTANCE.attachField(name);
        names.add(name);
        layout.add(name, 1, row, 2, 1);

        if (! formula)
        {
            layout.add(new Label(Messages.AddPV_Period), 0, ++row);
            final TextField period = new TextField(Double.toString(Preferences.scan_period));
            period.setTooltip(new Tooltip(Messages.AddPV_PeriodTT));
            periods.add(period);
            period.setDisable(true);
            layout.add(period, 1, row);

            final CheckBox monitor = new CheckBox(Messages.AddPV_OnChange);
            monitor.setTooltip(new Tooltip(Messages.AddPV_OnChangeTT));
            monitor.setSelected(true);
            monitors.add(monitor);
            monitor.setOnAction(event -> period.setDisable(monitor.isSelected()));
            layout.add(monitors.get(i), 2, row);
        }

        layout.add(new Label(Messages.AddPV_Axis), 0, ++row);
        final ChoiceBox<String> axis = new ChoiceBox<>(axis_options);
        axis.setTooltip(new Tooltip(Messages.AddPV_AxisTT));
        axis.getSelectionModel().select(0);
        axes.add(axis);
        layout.add(axes.get(i), 1, row);

        layout.add(new Separator(), 0, ++row, 3, 1);
    }
    return layout;
}
 
Example 13
Source File: WalletPasswordWindow.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void addButtons() {
    BusyAnimation busyAnimation = new BusyAnimation(false);
    Label deriveStatusLabel = new AutoTooltipLabel();

    unlockButton = new AutoTooltipButton(Res.get("shared.unlock"));
    unlockButton.setDefaultButton(true);
    unlockButton.getStyleClass().add("action-button");
    unlockButton.setDisable(true);
    unlockButton.setOnAction(e -> {
        String password = passwordTextField.getText();
        checkArgument(password.length() < 500, Res.get("password.tooLong"));
        KeyCrypterScrypt keyCrypterScrypt = walletsManager.getKeyCrypterScrypt();
        if (keyCrypterScrypt != null) {
            busyAnimation.play();
            deriveStatusLabel.setText(Res.get("password.deriveKey"));
            ScryptUtil.deriveKeyWithScrypt(keyCrypterScrypt, password, aesKey -> {
                if (walletsManager.checkAESKey(aesKey)) {
                    if (aesKeyHandler != null)
                        aesKeyHandler.onAesKey(aesKey);

                    hide();
                } else {
                    busyAnimation.stop();
                    deriveStatusLabel.setText("");

                    UserThread.runAfter(() -> new Popup()
                            .warning(Res.get("password.wrongPw"))
                            .onClose(this::blurAgain).show(), Transitions.DEFAULT_DURATION, TimeUnit.MILLISECONDS);
                }
            });
        } else {
            log.error("wallet.getKeyCrypter() is null, that must not happen.");
        }
    });

    forgotPasswordButton = new AutoTooltipButton(Res.get("password.forgotPassword"));
    forgotPasswordButton.setOnAction(e -> {
        forgotPasswordButton.setDisable(true);
        unlockButton.setDefaultButton(false);
        showRestoreScreen();
    });

    Button cancelButton = new AutoTooltipButton(Res.get("shared.cancel"));
    cancelButton.setOnAction(event -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });

    HBox hBox = new HBox();
    hBox.setMinWidth(560);
    hBox.setPadding(new Insets(0, 0, 0, 0));
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.getChildren().add(unlockButton);
    if (!hideForgotPasswordButton)
        hBox.getChildren().add(forgotPasswordButton);
    if (!hideCloseButton)
        hBox.getChildren().add(cancelButton);
    hBox.getChildren().addAll(busyAnimation, deriveStatusLabel);
    gridPane.getChildren().add(hBox);


    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.LEFT);
    columnConstraints1.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1);
}
 
Example 14
Source File: SelectSongsDialog.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set the songs to be shown in the dialog.
 * <p/>
 * @param songs the list of songs to be shown.
 * @param checkList a list corresponding to the song list - each position is
 * true if the checkbox should be selected, false otherwise.
 * @param defaultVal the default value to use for the checkbox if checkList
 * is null or smaller than the songs list.
 */
public void setSongs(final List<SongDisplayable> songs, final Map<SongDisplayable, Boolean> checkList, final boolean defaultVal) {
    this.songs = songs;
    gridPane.getChildren().clear();
    checkBoxes.clear();
    gridPane.getColumnConstraints().add(new ColumnConstraints(20));
    ColumnConstraints titleConstraints = new ColumnConstraints();
    titleConstraints.setHgrow(Priority.ALWAYS);
    titleConstraints.setPercentWidth(50);
    gridPane.getColumnConstraints().add(titleConstraints);
    ColumnConstraints authorConstraints = new ColumnConstraints();
    authorConstraints.setHgrow(Priority.ALWAYS);
    authorConstraints.setPercentWidth(45);
    gridPane.getColumnConstraints().add(authorConstraints);

    Label titleHeader = new Label(LabelGrabber.INSTANCE.getLabel("title.label"));
    titleHeader.setAlignment(Pos.CENTER);
    Label authorHeader = new Label(LabelGrabber.INSTANCE.getLabel("author.label"));
    authorHeader.setAlignment(Pos.CENTER);
    gridPane.add(titleHeader, 1, 0);
    gridPane.add(authorHeader, 2, 0);

    for(int i = 0; i < songs.size(); i++) {
        SongDisplayable song = songs.get(i);
        CheckBox checkBox = new CheckBox();
        checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {

            @Override
            public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                checkEnableButton();
            }
        });
        if(checkList != null) {
            final Boolean result = checkList.get(song);
            if(result!=null) {
                checkBox.setSelected(!result);
            }
        }
        checkBoxes.add(checkBox);
        gridPane.add(checkBox, 0, i + 1);
        gridPane.add(new Label(song.getTitle()), 1, i + 1);
        gridPane.add(new Label(song.getAuthor()), 2, i + 1);
    }

    for(int i = 0; i < 2; i++) {
        Node n = gridPane.getChildren().get(i);
        if(n instanceof Control) {
            Control control = (Control) n;
            control.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            control.setStyle("-fx-alignment: center;-fx-font-weight: bold;");
        }
        if(n instanceof Pane) {
            Pane pane = (Pane) n;
            pane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            pane.setStyle("-fx-alignment: center;-fx-font-weight: bold;");
        }
    }
    gridScroll.setVvalue(0);
    checkEnableButton();
}
 
Example 15
Source File: AgentRegistrationView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    columnConstraints1.setMaxWidth(500);
    gridPane.getColumnConstraints().addAll(columnConstraints1);
    root.getChildren().add(gridPane);

    addTitledGroupBg(gridPane, gridRow, 4, Res.get("account.arbitratorRegistration.registration", getRole()));
    TextField pubKeyTextField = addTopLabelTextField(gridPane, gridRow, Res.get("account.arbitratorRegistration.pubKey"),
            model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;

    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);

    Tuple3<Label, ListView<String>, VBox> tuple = FormBuilder.addTopLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<>() {
                final Label label = new AutoTooltipLabel();
                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
                final Button removeButton = new AutoTooltipButton("", icon);
                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });

    languageComboBox = FormBuilder.addComboBox(gridPane, ++gridRow);
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText(Res.get("shared.addLanguage"));
    languageComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());

    Tuple2<Button, Button> buttonButtonTuple2 = add2ButtonsAfterGroup(gridPane, ++gridRow,
            Res.get("account.arbitratorRegistration.register"), Res.get("account.arbitratorRegistration.revoke"));
    Button registerButton = buttonButtonTuple2.first;
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());

    Button revokeButton = buttonButtonTuple2.second;
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());

    final TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2,
            Res.get("shared.information"), Layout.GROUP_DISTANCE);

    titledGroupBg.getStyleClass().add("last");

    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText(Res.get("account.arbitratorRegistration.info.msg", getRole().toLowerCase()));
}
 
Example 16
Source File: StringEditorFactory.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_SPACING);

    final ColumnConstraints cc = new ColumnConstraints();
    cc.setHgrow(Priority.ALWAYS);
    controls.getColumnConstraints().add(cc);
    final RowConstraints rc = new RowConstraints();
    rc.setVgrow(Priority.ALWAYS);
    controls.getRowConstraints().add(rc);

    textArea = new TextArea();
    textArea.setWrapText(true);
    textArea.textProperty().addListener((o, n, v) -> {
        update();
    });
    textArea.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
        if (e.getCode() == KeyCode.DELETE) {
            IndexRange selection = textArea.getSelection();
            if (selection.getLength() == 0) {
                textArea.deleteNextChar();
            } else {
                textArea.deleteText(selection);
            }
            e.consume();
        } else if (e.isShortcutDown() && e.isShiftDown() && (e.getCode() == KeyCode.RIGHT)) {
            textArea.selectNextWord();
            e.consume();
        } else if (e.isShortcutDown() && e.isShiftDown() && (e.getCode() == KeyCode.LEFT)) {
            textArea.selectPreviousWord();
            e.consume();
        } else if (e.isShortcutDown() && (e.getCode() == KeyCode.RIGHT)) {
            textArea.nextWord();
            e.consume();
        } else if (e.isShortcutDown() && (e.getCode() == KeyCode.LEFT)) {
            textArea.previousWord();
            e.consume();
        } else if (e.isShiftDown() && (e.getCode() == KeyCode.RIGHT)) {
            textArea.selectForward();
            e.consume();
        } else if (e.isShiftDown() && (e.getCode() == KeyCode.LEFT)) {
            textArea.selectBackward();
            e.consume();
        } else if (e.isShortcutDown() && (e.getCode() == KeyCode.A)) {
            textArea.selectAll();
            e.consume();
        } else if (e.getCode() == KeyCode.ESCAPE) {
            e.consume();
        }
    });

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

    controls.addRow(0, textArea);
    controls.addRow(1, noValueCheckBox);
    return controls;
}
 
Example 17
Source File: IconEditorFactory.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);

    final ColumnConstraints cc = new ColumnConstraints();
    cc.setHgrow(Priority.ALWAYS);
    controls.getColumnConstraints().add(cc);
    final RowConstraints rc = new RowConstraints();
    rc.setVgrow(Priority.ALWAYS);
    controls.getRowConstraints().add(rc);

    // build tree structure of icon
    final IconNode builtInNode = new IconNode("(Built-in)", IconManager.getIconNames(false));

    //convert structure to jfx treeview
    builtInItem = new TreeItem<>(builtInNode);
    addNode(builtInItem, builtInNode);

    // set listview factory to display icon
    listView = new ListView<>();
    listView.setCellFactory(param -> new IconNodeCell());
    listView.getStyleClass().add("rounded");
    listView.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        update();
    });

    treeRoot = new TreeItem<>(new IconNode("Icons", new HashSet<>()));
    treeRoot.setExpanded(true);

    treeView = new TreeView<>();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeView.getStyleClass().add("rounded");
    treeView.setOnMouseClicked((MouseEvent event) -> {
        refreshIconList();
    });

    final SplitPane splitPane = new SplitPane();
    splitPane.setId("hiddenSplitter");
    splitPane.setOrientation(Orientation.HORIZONTAL);
    splitPane.getItems().add(treeView);
    splitPane.getItems().add(listView);
    controls.addRow(0, splitPane);

    final HBox addRemoveBox = createAddRemoveBox();
    controls.addRow(1, addRemoveBox);

    return controls;
}
 
Example 18
Source File: AttributeEditorPanel.java    From constellation with Apache License 2.0 4 votes vote down vote up
private Node createAttributeValueNode(final Object[] values, final AttributeData attribute, final AttributeTitledPane parent, final boolean multiValue) {

        boolean noneSelected = values == null;
        boolean isNull = !noneSelected && (values[0] == null);
        parent.setAttribute(attribute);

        AbstractAttributeInteraction<?> interaction = AbstractAttributeInteraction.getInteraction(attribute.getDataType());

        final String displayText;
        final List<Node> displayNodes;
        if (multiValue) {
            displayText = "<Multiple Values>";
            displayNodes = Collections.emptyList();
        } else if (isNull) {
            displayText = NO_VALUE_TEXT;
            displayNodes = Collections.emptyList();
        } else if (noneSelected) {
            displayText = "<Nothing Selected>";
            displayNodes = Collections.emptyList();
        } else {
            displayText = interaction.getDisplayText(values[0]);
            displayNodes = interaction.getDisplayNodes(values[0], -1, CELL_ITEM_HEIGHT);
        }

        parent.setAttributeValue(displayText);
        final TextField attributeValueText = new TextField(displayText);
        attributeValueText.setEditable(false);
        if (noneSelected || isNull || multiValue) {
            attributeValueText.getStyleClass().add("undisplayedValue");
        }

        if (displayNodes.isEmpty()) {
            return attributeValueText;
        }

        GridPane gridPane = new GridPane();
        gridPane.setAlignment(Pos.CENTER_RIGHT);
        gridPane.setPadding(Insets.EMPTY);
        gridPane.setHgap(CELL_ITEM_SPACING);
        ColumnConstraints displayNodeConstraint = new ColumnConstraints(CELL_ITEM_HEIGHT);
        displayNodeConstraint.setHalignment(HPos.LEFT);
        ColumnConstraints displayTextConstraint = new ColumnConstraints();
        displayTextConstraint.setHalignment(HPos.RIGHT);
        displayTextConstraint.setHgrow(Priority.ALWAYS);
        displayTextConstraint.setFillWidth(true);

        for (int i = 0; i < displayNodes.size(); i++) {
            final Node displayNode = displayNodes.get(i);
            gridPane.add(displayNode, i, 0);
            gridPane.getColumnConstraints().add(displayNodeConstraint);
        }

        gridPane.add(attributeValueText, displayNodes.size(), 0);
        gridPane.getColumnConstraints().add(displayTextConstraint);

        return gridPane;
    }