Search in sources :

Example 46 with TableView

use of javafx.scene.control.TableView in project blue by kunstmusik.

the class LineView method editPoints.

private void editPoints() {
    TableView<LinePoint> table = new TableView<>();
    TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
    TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
    table.getColumns().setAll(xCol, yCol);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setItems(getSelectedLine().getObservableList());
    table.setEditable(true);
    xCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("x"));
    xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    xCol.setOnEditCommit(te -> {
        LinePoint lp = te.getRowValue();
        if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
            return;
        }
        lp.setX(Utils.clamp(0.0, te.getNewValue(), 1.0));
    });
    xCol.setEditable(true);
    yCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("y"));
    yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    yCol.setOnEditCommit(te -> {
        te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
    });
    yCol.setEditable(true);
    Dialog<ButtonType> d = new Dialog<>();
    d.initOwner(getScene().getWindow());
    d.initModality(Modality.APPLICATION_MODAL);
    d.getDialogPane().setContent(new ScrollPane(table));
    d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
    d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
    d.setTitle("Edit Points");
    TableModelListener tml = tme -> {
        repaint();
    };
    getSelectedLine().addTableModelListener(tml);
    Optional<ButtonType> res = d.showAndWait();
    getSelectedLine().removeTableModelListener(tml);
}
Also used : DoubleStringConverter(javafx.util.converter.DoubleStringConverter) NumberUtilities(blue.utility.NumberUtilities) ButtonType(javafx.scene.control.ButtonType) LineList(blue.components.lines.LineList) Glow(javafx.scene.effect.Glow) MouseEvent(javafx.scene.input.MouseEvent) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableModelListener(javax.swing.event.TableModelListener) LinePoint(blue.components.lines.LinePoint) TableColumn(javafx.scene.control.TableColumn) DragDirection(blue.components.DragDirection) Utils(org.controlsfx.tools.Utils) BlueFX(blue.jfx.BlueFX) ScrollPane(javafx.scene.control.ScrollPane) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) TableView(javafx.scene.control.TableView) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) MenuItem(javafx.scene.control.MenuItem) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GraphicsContext(javafx.scene.canvas.GraphicsContext) Canvas(javafx.scene.canvas.Canvas) Line(blue.components.lines.Line) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Paint(javafx.scene.paint.Paint) Optional(java.util.Optional) DoubleStringConverter(javafx.util.converter.DoubleStringConverter) TableColumn(javafx.scene.control.TableColumn) LinePoint(blue.components.lines.LinePoint) Dialog(javafx.scene.control.Dialog) ScrollPane(javafx.scene.control.ScrollPane) TableModelListener(javax.swing.event.TableModelListener) ButtonType(javafx.scene.control.ButtonType) TableView(javafx.scene.control.TableView)

Example 47 with TableView

use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.

the class RulesDialog method createExpressionsTable.

/**
 * @return Node for UI elements that edit the expressions
 */
private HBox createExpressionsTable() {
    // Create table with editable rule 'bool expression' column
    final TableColumn<ExprItem<?>, String> bool_exp_col = new TableColumn<>(Messages.RulesDialog_ColBoolExp);
    bool_exp_col.setSortable(false);
    bool_exp_col.setCellValueFactory(new PropertyValueFactory<ExprItem<?>, String>("boolExp"));
    bool_exp_col.setCellFactory(tableColumn -> new TextFieldTableCell<ExprItem<?>, String>(new DefaultStringConverter()) {

        private final ChangeListener<? super Boolean> focusedListener = (ob, o, n) -> {
            if (!n)
                cancelEdit();
        };

        /* Instance initializer. */
        {
            setAlignment(Pos.CENTER_LEFT);
        }

        @Override
        public void cancelEdit() {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.cancelEdit();
        }

        @Override
        public void commitEdit(final String newValue) {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.commitEdit(newValue);
        }

        @Override
        public void startEdit() {
            super.startEdit();
            ((TextField) getGraphic()).focusedProperty().addListener(focusedListener);
        }
    });
    // Create table with editable rule 'value expression' column
    final TableColumn<ExprItem<?>, Node> val_exp_col = new TableColumn<>(Messages.RulesDialog_ColValExp);
    // This statement requires "val_exp_col" be defined.
    bool_exp_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        expression_items.get(row).boolExpProperty().set(event.getNewValue());
        ModelThreadPool.getTimer().schedule(() -> {
            Platform.runLater(() -> val_exp_col.getCellData(row).requestFocus());
        }, 123, TimeUnit.MILLISECONDS);
    });
    val_exp_col.setSortable(false);
    val_exp_col.setCellValueFactory(new PropertyValueFactory<ExprItem<?>, Node>("field"));
    val_exp_col.setCellFactory(tableColumn -> new TableCell<ExprItem<?>, Node>() {

        @Override
        protected void updateItem(final Node item, final boolean empty) {
            // calling super here is very important - don't skip this!
            super.updateItem(item, empty);
            setGraphic(item);
        }
    });
    val_exp_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        expression_items.get(row).fieldProperty().set(event.getNewValue());
        event.consume();
        ModelThreadPool.getTimer().schedule(() -> {
            Platform.runLater(() -> btn_add_exp.requestFocus());
        }, 1230, TimeUnit.MILLISECONDS);
    });
    expressions_table = new TableView<>(expression_items);
    expressions_table.getColumns().add(bool_exp_col);
    expressions_table.getColumns().add(val_exp_col);
    expressions_table.setEditable(true);
    expressions_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    expressions_table.setTooltip(new Tooltip(Messages.RulesDialog_ExpressionsTT));
    expressions_table.setPlaceholder(new Label(Messages.RulesDialog_NoExpressions));
    // Buttons
    btn_add_exp = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
    btn_add_exp.setMaxWidth(Double.MAX_VALUE);
    btn_add_exp.setAlignment(Pos.CENTER_LEFT);
    btn_add_exp.setOnAction(event -> {
        selected_rule_item.addNewExpr(undo);
        expression_items.setAll(selected_rule_item.expressions);
        expressions_table.getSelectionModel().select(expression_items.size() - 1);
        final int newRow = expression_items.size() - 1;
        ModelThreadPool.getTimer().schedule(() -> {
            Platform.runLater(() -> expressions_table.edit(newRow, bool_exp_col));
        }, 123, TimeUnit.MILLISECONDS);
    });
    btn_rm_exp = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    btn_rm_exp.setMaxWidth(Double.MAX_VALUE);
    btn_rm_exp.setMinWidth(96);
    btn_rm_exp.setAlignment(Pos.CENTER_LEFT);
    btn_rm_exp.setDisable(true);
    btn_rm_exp.setOnAction(event -> {
        final int sel = expressions_table.getSelectionModel().getSelectedIndex();
        if (sel >= 0)
            expression_items.remove(sel);
    });
    btn_move_exp_up = new Button(Messages.MoveUp, JFXUtil.getIcon("up.png"));
    btn_move_exp_up.setMaxWidth(Double.MAX_VALUE);
    btn_move_exp_up.setAlignment(Pos.CENTER_LEFT);
    btn_move_exp_up.setDisable(true);
    btn_move_exp_up.setOnAction(event -> TableHelper.move_item_up(expressions_table, expression_items));
    btn_move_exp_down = new Button(Messages.MoveDown, JFXUtil.getIcon("down.png"));
    btn_move_exp_down.setMaxWidth(Double.MAX_VALUE);
    btn_move_exp_down.setAlignment(Pos.CENTER_LEFT);
    btn_move_exp_down.setDisable(true);
    btn_move_exp_down.setOnAction(event -> TableHelper.move_item_down(expressions_table, expression_items));
    final VBox buttons = new VBox(10, btn_add_exp, btn_rm_exp, btn_move_exp_up, btn_move_exp_down);
    final HBox content = new HBox(10, expressions_table, buttons);
    HBox.setHgrow(expressions_table, Priority.ALWAYS);
    HBox.setHgrow(buttons, Priority.NEVER);
    content.setDisable(true);
    return content;
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) UndoableActionManager(org.csstudio.display.builder.util.undo.UndoableActionManager) ScriptPV(org.csstudio.display.builder.model.properties.ScriptPV) LineNumberTableCellFactory(org.csstudio.javafx.LineNumberTableCellFactory) VBox(javafx.scene.layout.VBox) AutoCompletedTableCell(org.csstudio.display.builder.representation.javafx.PVTableItem.AutoCompletedTableCell) RuleInfo(org.csstudio.display.builder.model.rules.RuleInfo) TableHelper(org.csstudio.javafx.TableHelper) ListChangeListener(javafx.collections.ListChangeListener) ComboBox(javafx.scene.control.ComboBox) WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) TableView(javafx.scene.control.TableView) ModelThreadPool(org.csstudio.display.builder.model.util.ModelThreadPool) Pane(javafx.scene.layout.Pane) Orientation(javafx.geometry.Orientation) HBox(javafx.scene.layout.HBox) PVTableItem(org.csstudio.display.builder.representation.javafx.PVTableItem) SplitPane(javafx.scene.control.SplitPane) TextField(javafx.scene.control.TextField) Language(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Collectors(java.util.stream.Collectors) CommonWidgetProperties(org.csstudio.display.builder.model.properties.CommonWidgetProperties) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Region(javafx.scene.layout.Region) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) AutocompleteMenu(org.csstudio.display.builder.representation.javafx.AutocompleteMenu) JFXUtil(org.csstudio.display.builder.representation.javafx.JFXUtil) ObservableList(javafx.collections.ObservableList) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) ExprInfoString(org.csstudio.display.builder.model.rules.RuleInfo.ExprInfoString) StringProperty(javafx.beans.property.StringProperty) ExpressionInfo(org.csstudio.display.builder.model.rules.RuleInfo.ExpressionInfo) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) SyntaxHighlightedMultiLineInputDialog(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog) ExprInfoValue(org.csstudio.display.builder.model.rules.RuleInfo.ExprInfoValue) Plugin.logger(org.csstudio.display.builder.editor.Plugin.logger) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ButtonType(javafx.scene.control.ButtonType) JFXBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.JFXBaseRepresentation) FXCollections(javafx.collections.FXCollections) BackingStoreException(java.util.prefs.BackingStoreException) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) RulesWidgetProperty(org.csstudio.display.builder.model.properties.RulesWidgetProperty) Messages(org.csstudio.display.builder.representation.javafx.Messages) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) Tooltip(javafx.scene.control.Tooltip) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Preferences(java.util.prefs.Preferences) TimeUnit(java.util.concurrent.TimeUnit) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ScriptsDialog(org.csstudio.display.builder.representation.javafx.ScriptsDialog) DialogHelper(org.csstudio.javafx.DialogHelper) Widget(org.csstudio.display.builder.model.Widget) ChangeListener(javafx.beans.value.ChangeListener) PropInfo(org.csstudio.display.builder.model.rules.RuleInfo.PropInfo) HBox(javafx.scene.layout.HBox) Node(javafx.scene.Node) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) ExprInfoString(org.csstudio.display.builder.model.rules.RuleInfo.ExprInfoString) TableColumn(javafx.scene.control.TableColumn) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) Button(javafx.scene.control.Button) TextField(javafx.scene.control.TextField) VBox(javafx.scene.layout.VBox)

Example 48 with TableView

use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.

the class ScriptsDialog method createScriptsTable.

/**
 * @return Node for UI elements that edit the scripts
 */
private Region createScriptsTable() {
    scripts_icon_col = new TableColumn<>();
    scripts_icon_col.setCellValueFactory(cdf -> new SimpleObjectProperty<ImageView>(getScriptImage(cdf.getValue())) {

        {
            bind(Bindings.createObjectBinding(() -> getScriptImage(cdf.getValue()), cdf.getValue().fileProperty()));
        }
    });
    scripts_icon_col.setCellFactory(col -> new TableCell<ScriptItem, ImageView>() {

        /* Instance initializer. */
        {
            setAlignment(Pos.CENTER_LEFT);
        }

        @Override
        protected void updateItem(final ImageView item, final boolean empty) {
            super.updateItem(item, empty);
            super.setGraphic(item);
        }
    });
    scripts_icon_col.setEditable(false);
    scripts_icon_col.setSortable(false);
    scripts_icon_col.setMaxWidth(25);
    scripts_icon_col.setMinWidth(25);
    // Create table with editable script 'file' column
    scripts_name_col = new TableColumn<>(Messages.ScriptsDialog_ColScript);
    scripts_name_col.setCellValueFactory(new PropertyValueFactory<ScriptItem, String>("file"));
    scripts_name_col.setCellFactory(col -> new TextFieldTableCell<ScriptItem, String>(new DefaultStringConverter()) {

        private final ChangeListener<? super Boolean> focusedListener = (ob, o, n) -> {
            if (!n)
                cancelEdit();
        };

        @Override
        public void cancelEdit() {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.cancelEdit();
        }

        @Override
        public void startEdit() {
            super.startEdit();
            ((TextField) getGraphic()).focusedProperty().addListener(focusedListener);
        }

        @Override
        public void commitEdit(final String newValue) {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.commitEdit(newValue);
            Platform.runLater(() -> btn_pv_add.requestFocus());
        }
    });
    scripts_name_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        script_items.get(row).file.set(event.getNewValue());
        fixupScripts(row);
    });
    scripts_table = new TableView<>(script_items);
    scripts_table.getColumns().add(scripts_icon_col);
    scripts_table.getColumns().add(scripts_name_col);
    scripts_table.setEditable(true);
    scripts_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    scripts_table.setTooltip(new Tooltip(Messages.ScriptsDialog_ScriptsTT));
    scripts_table.setPlaceholder(new Label(Messages.ScriptsDialog_NoScripts));
    // Buttons
    addMenuButton = new MenuButton(Messages.Add, JFXUtil.getIcon("add.png"), new MenuItem(Messages.AddPythonFile, JFXUtil.getIcon("file-python.png")) {

        {
            setOnAction(e -> addPythonFile());
        }
    }, new MenuItem(Messages.AddJavaScriptFile, JFXUtil.getIcon("file-javascript.png")) {

        {
            setOnAction(e -> addJavaScriptFile());
        }
    }, new SeparatorMenuItem(), new MenuItem(Messages.AddEmbeddedPython, JFXUtil.getIcon("python.png")) {

        {
            setOnAction(e -> addEmbeddedJython());
        }
    }, new MenuItem(Messages.AddEmbeddedJavaScript, JFXUtil.getIcon("javascript.png")) {

        {
            setOnAction(e -> addEmbeddedJavaScript());
        }
    });
    addMenuButton.setMaxWidth(Double.MAX_VALUE);
    addMenuButton.setAlignment(Pos.CENTER_LEFT);
    btn_script_remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    btn_script_remove.setMaxWidth(Double.MAX_VALUE);
    btn_script_remove.setAlignment(Pos.CENTER_LEFT);
    btn_script_remove.setDisable(true);
    btn_script_remove.setOnAction(event -> {
        final int sel = scripts_table.getSelectionModel().getSelectedIndex();
        if (sel >= 0) {
            script_items.remove(sel);
            fixupScripts(sel);
        }
    });
    btn_edit = new SplitMenuButton(convertToFileMenuItem, new SeparatorMenuItem(), convertToEmbeddedPythonMenuItem, convertToEmbeddedJavaScriptMenuItem);
    btn_edit.setText(Messages.Select);
    btn_edit.setGraphic(JFXUtil.getIcon("select-file.png"));
    btn_edit.setMaxWidth(Double.MAX_VALUE);
    btn_edit.setMinWidth(120);
    btn_edit.setAlignment(Pos.CENTER_LEFT);
    btn_edit.setDisable(true);
    btn_edit.setOnAction(e -> editOrSelect());
    final VBox buttons = new VBox(10, addMenuButton, btn_script_remove, btn_edit);
    final HBox content = new HBox(10, scripts_table, buttons);
    HBox.setHgrow(scripts_table, Priority.ALWAYS);
    HBox.setHgrow(buttons, Priority.NEVER);
    return content;
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) ScriptPV(org.csstudio.display.builder.model.properties.ScriptPV) LineNumberTableCellFactory(org.csstudio.javafx.LineNumberTableCellFactory) VBox(javafx.scene.layout.VBox) AutoCompletedTableCell(org.csstudio.display.builder.representation.javafx.PVTableItem.AutoCompletedTableCell) TableHelper(org.csstudio.javafx.TableHelper) ListChangeListener(javafx.collections.ListChangeListener) TableView(javafx.scene.control.TableView) ModelThreadPool(org.csstudio.display.builder.model.util.ModelThreadPool) HBox(javafx.scene.layout.HBox) SplitPane(javafx.scene.control.SplitPane) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Language(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) MenuButton(javafx.scene.control.MenuButton) ObservableList(javafx.collections.ObservableList) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) StringProperty(javafx.beans.property.StringProperty) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) SyntaxHighlightedMultiLineInputDialog(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ButtonType(javafx.scene.control.ButtonType) JFXBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.JFXBaseRepresentation) FXCollections(javafx.collections.FXCollections) BackingStoreException(java.util.prefs.BackingStoreException) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Bindings(javafx.beans.binding.Bindings) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) Tooltip(javafx.scene.control.Tooltip) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) SplitMenuButton(javafx.scene.control.SplitMenuButton) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Preferences(java.util.prefs.Preferences) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) TimeUnit(java.util.concurrent.TimeUnit) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ImageView(javafx.scene.image.ImageView) DialogHelper(org.csstudio.javafx.DialogHelper) Widget(org.csstudio.display.builder.model.Widget) ChangeListener(javafx.beans.value.ChangeListener) HBox(javafx.scene.layout.HBox) SplitMenuButton(javafx.scene.control.SplitMenuButton) Label(javafx.scene.control.Label) MenuButton(javafx.scene.control.MenuButton) SplitMenuButton(javafx.scene.control.SplitMenuButton) Button(javafx.scene.control.Button) MenuButton(javafx.scene.control.MenuButton) SplitMenuButton(javafx.scene.control.SplitMenuButton) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) Tooltip(javafx.scene.control.Tooltip) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) VBox(javafx.scene.layout.VBox)

Example 49 with TableView

use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.

the class WidgetInfoDialog method createMacros.

private Tab createMacros(Macros orig_macros) {
    final Macros macros = (orig_macros == null) ? new Macros() : orig_macros;
    // Use text field to allow copying the name and value
    // Table uses list of macro names as input
    // Name column just displays the macro name,..
    final TableColumn<String, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
    name.setCellFactory(TextFieldTableCell.forTableColumn());
    name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue()));
    // .. value column fetches the macro value
    final TableColumn<String, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
    value.setCellFactory(TextFieldTableCell.forTableColumn());
    value.setCellValueFactory(param -> new ReadOnlyStringWrapper(macros.getValue(param.getValue())));
    final TableView<String> table = new TableView<>(FXCollections.observableArrayList(macros.getNames()));
    table.getColumns().add(name);
    table.getColumns().add(value);
    table.setEditable(true);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    return new Tab(Messages.WidgetInfoDialog_TabMacros, table);
}
Also used : Tab(javafx.scene.control.Tab) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) Macros(org.csstudio.display.builder.model.macros.Macros) TableColumn(javafx.scene.control.TableColumn) TableView(javafx.scene.control.TableView)

Example 50 with TableView

use of javafx.scene.control.TableView in project bisq-desktop by bisq-network.

the class OfferBookChartView method initialize.

@Override
public void initialize() {
    changeListener = c -> updateChartData();
    currencyListItemsListener = c -> {
        if (model.getSelectedCurrencyListItem().isPresent())
            currencyComboBox.getSelectionModel().select(model.getSelectedCurrencyListItem().get());
    };
    currencyComboBox = new ComboBox<>();
    currencyComboBox.setPromptText(Res.get("list.currency.select"));
    currencyComboBox.setConverter(GUIUtil.getCurrencyListItemConverter(Res.get("shared.oneOffer"), Res.get("shared.multipleOffers"), model.preferences));
    Label currencyLabel = new AutoTooltipLabel(Res.getWithCol("shared.currency"));
    HBox currencyHBox = new HBox();
    currencyHBox.setSpacing(5);
    currencyHBox.setPadding(new Insets(5, -20, -5, 20));
    currencyHBox.setAlignment(Pos.CENTER_LEFT);
    currencyHBox.getChildren().addAll(currencyLabel, currencyComboBox);
    createChart();
    Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(OfferPayload.Direction.BUY);
    Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(OfferPayload.Direction.SELL);
    buyOfferTableView = tupleBuy.first;
    sellOfferTableView = tupleSell.first;
    leftButton = tupleBuy.third;
    rightButton = tupleSell.third;
    leftHeaderLabel = tupleBuy.forth;
    rightHeaderLabel = tupleSell.forth;
    bottomHBox = new HBox();
    // 30
    bottomHBox.setSpacing(20);
    bottomHBox.setAlignment(Pos.CENTER);
    HBox.setHgrow(tupleBuy.second, Priority.ALWAYS);
    HBox.setHgrow(tupleSell.second, Priority.ALWAYS);
    tupleBuy.second.setUserData(OfferPayload.Direction.BUY.name());
    tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
    bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);
    root.getChildren().addAll(currencyHBox, areaChart, bottomHBox);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) VBox(javafx.scene.layout.VBox) TableView(javafx.scene.control.TableView)

Aggregations

TableView (javafx.scene.control.TableView)70 TableColumn (javafx.scene.control.TableColumn)60 Map (java.util.Map)40 List (java.util.List)39 ArrayList (java.util.ArrayList)38 Button (javafx.scene.control.Button)38 Label (javafx.scene.control.Label)38 FXCollections (javafx.collections.FXCollections)37 Insets (javafx.geometry.Insets)36 Collectors (java.util.stream.Collectors)33 Scene (javafx.scene.Scene)33 Tab (javafx.scene.control.Tab)33 BorderPane (javafx.scene.layout.BorderPane)32 Optional (java.util.Optional)31 ObservableValue (javafx.beans.value.ObservableValue)30 VBox (javafx.scene.layout.VBox)29 Collections (java.util.Collections)28 MenuItem (javafx.scene.control.MenuItem)28 HashMap (java.util.HashMap)27 Set (java.util.Set)27