use of javafx.scene.control.TableColumn in project org.csstudio.display.builder by kasemir.
the class ColorMapDialog method createContent.
private Node createContent() {
// Table for selecting a predefined color map
predefined_table = new TableView<>();
final TableColumn<PredefinedColorMaps.Predefined, String> name_column = new TableColumn<>(Messages.ColorMapDialog_PredefinedMap);
name_column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getDescription()));
predefined_table.getColumns().add(name_column);
predefined_table.getItems().addAll(PredefinedColorMaps.PREDEFINED);
predefined_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
// Table for viewing/editing color sections
sections_table = new TableView<>();
// Value of color section
final TableColumn<ColorSection, String> value_column = new TableColumn<>(Messages.ColorMapDialog_Value);
value_column.setCellValueFactory(param -> new SimpleStringProperty(Integer.toString(param.getValue().value)));
value_column.setCellFactory(TextFieldTableCell.forTableColumn());
value_column.setOnEditCommit(event -> {
final int index = event.getTablePosition().getRow();
try {
final int value = Math.max(0, Math.min(255, Integer.parseInt(event.getNewValue().trim())));
color_sections.set(index, new ColorSection(value, color_sections.get(index).color));
color_sections.sort((sec1, sec2) -> sec1.value - sec2.value);
updateMapFromSections();
} catch (NumberFormatException ex) {
// Ignore, field will reset to original value
}
});
// Color of color section
final TableColumn<ColorSection, ColorPicker> color_column = new TableColumn<>(Messages.ColorMapDialog_Color);
color_column.setCellValueFactory(param -> {
final ColorSection segment = param.getValue();
return new SimpleObjectProperty<ColorPicker>(createColorPicker(segment));
});
color_column.setCellFactory(column -> new ColorTableCell());
sections_table.getColumns().add(value_column);
sections_table.getColumns().add(color_column);
sections_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
sections_table.setItems(color_sections);
sections_table.setEditable(true);
add = new Button(Messages.ColorMapDialog_Add, JFXUtil.getIcon("add.png"));
add.setMaxWidth(Double.MAX_VALUE);
remove = new Button(Messages.ColorMapDialog_Remove, JFXUtil.getIcon("delete.png"));
remove.setMaxWidth(Double.MAX_VALUE);
final VBox buttons = new VBox(10, add, remove);
// Upper section with tables
final HBox tables_and_buttons = new HBox(10, predefined_table, sections_table, buttons);
HBox.setHgrow(predefined_table, Priority.ALWAYS);
HBox.setHgrow(sections_table, Priority.ALWAYS);
// Lower section with resulting color map
final Region fill1 = new Region(), fill2 = new Region(), fill3 = new Region();
HBox.setHgrow(fill1, Priority.ALWAYS);
HBox.setHgrow(fill2, Priority.ALWAYS);
HBox.setHgrow(fill3, Priority.ALWAYS);
final HBox color_title = new HBox(fill1, new Label(Messages.ColorMapDialog_Result), fill2);
color_bar = new Region();
color_bar.setMinHeight(COLOR_BAR_HEIGHT);
color_bar.setMaxHeight(COLOR_BAR_HEIGHT);
color_bar.setPrefHeight(COLOR_BAR_HEIGHT);
final HBox color_legend = new HBox(new Label("0"), fill3, new Label("255"));
final VBox box = new VBox(10, tables_and_buttons, new Separator(), color_title, color_bar, color_legend);
VBox.setVgrow(tables_and_buttons, Priority.ALWAYS);
return box;
}
use of javafx.scene.control.TableColumn in project org.csstudio.display.builder by kasemir.
the class ScriptsDialog method createPVsTable.
/**
* @return Node for UI elements that edit the PVs of a script
*/
private Region createPVsTable() {
final TableColumn<PVTableItem, Integer> indexColumn = new TableColumn<>("#");
indexColumn.setEditable(false);
indexColumn.setSortable(false);
indexColumn.setCellFactory(new LineNumberTableCellFactory<>(true));
indexColumn.setMaxWidth(26);
indexColumn.setMinWidth(26);
// Create table with editable 'name' column
pvs_name_col = new TableColumn<>(Messages.ScriptsDialog_ColPV);
pvs_name_col.setSortable(false);
pvs_name_col.setCellValueFactory(new PropertyValueFactory<PVTableItem, String>("name"));
pvs_name_col.setCellFactory((col) -> new AutoCompletedTableCell(menu, btn_pv_add));
pvs_name_col.setOnEditCommit(event -> {
final int row = event.getTablePosition().getRow();
pv_items.get(row).nameProperty().set(event.getNewValue());
fixupPVs(row);
});
pvs_trigger_col = new TableColumn<>(Messages.ScriptsDialog_ColTrigger);
pvs_trigger_col.setSortable(false);
pvs_trigger_col.setCellValueFactory(new PropertyValueFactory<PVTableItem, Boolean>("trigger"));
pvs_trigger_col.setCellFactory(CheckBoxTableCell.<PVTableItem>forTableColumn(pvs_trigger_col));
pvs_trigger_col.setResizable(false);
pvs_trigger_col.setMaxWidth(70);
pvs_trigger_col.setMinWidth(70);
// Table column for 'trigger' uses CheckBoxTableCell that directly modifies the Observable Property
pvs_table = new TableView<>(pv_items);
pvs_table.getColumns().add(indexColumn);
pvs_table.getColumns().add(pvs_name_col);
pvs_table.getColumns().add(pvs_trigger_col);
pvs_table.setEditable(true);
pvs_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
pvs_table.setTooltip(new Tooltip(Messages.ScriptsDialog_PVsTT));
pvs_table.setPlaceholder(new Label(Messages.ScriptsDialog_NoPVs));
// Buttons
btn_pv_add = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
btn_pv_add.setMaxWidth(Double.MAX_VALUE);
btn_pv_add.setAlignment(Pos.CENTER_LEFT);
btn_pv_add.setOnAction(event -> {
final PVTableItem newItem = new PVTableItem("new-PV", true);
pv_items.add(newItem);
pvs_table.getSelectionModel().select(newItem);
final int newRow = pvs_table.getSelectionModel().getSelectedIndex();
ModelThreadPool.getTimer().schedule(() -> {
Platform.runLater(() -> pvs_table.edit(newRow, pvs_name_col));
}, 123, TimeUnit.MILLISECONDS);
});
btn_pv_remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
btn_pv_remove.setMaxWidth(Double.MAX_VALUE);
btn_pv_remove.setMinWidth(96);
btn_pv_remove.setAlignment(Pos.CENTER_LEFT);
btn_pv_remove.setDisable(true);
btn_pv_remove.setOnAction(event -> {
final int sel = pvs_table.getSelectionModel().getSelectedIndex();
if (sel >= 0) {
pv_items.remove(sel);
fixupPVs(sel);
}
});
btn_pv_up = new Button(Messages.MoveUp, JFXUtil.getIcon("up.png"));
btn_pv_up.setMaxWidth(Double.MAX_VALUE);
btn_pv_up.setAlignment(Pos.CENTER_LEFT);
btn_pv_up.setDisable(true);
btn_pv_up.setOnAction(event -> TableHelper.move_item_up(pvs_table, pv_items));
btn_py_down = new Button(Messages.MoveDown, JFXUtil.getIcon("down.png"));
btn_py_down.setMaxWidth(Double.MAX_VALUE);
btn_py_down.setAlignment(Pos.CENTER_LEFT);
btn_py_down.setDisable(true);
btn_py_down.setOnAction(event -> TableHelper.move_item_down(pvs_table, pv_items));
btn_check_connections = new CheckBox(Messages.ScriptsDialog_CheckConnections);
btn_check_connections.setSelected(true);
btn_check_connections.setOnAction(event -> {
selected_script_item.check_connections = btn_check_connections.isSelected();
});
final VBox buttons = new VBox(10, btn_pv_add, btn_pv_remove, btn_pv_up, btn_py_down);
final HBox pvs_buttons = new HBox(10, pvs_table, buttons);
HBox.setHgrow(pvs_table, Priority.ALWAYS);
HBox.setHgrow(buttons, Priority.NEVER);
final VBox content = new VBox(10, pvs_buttons, btn_check_connections);
VBox.setVgrow(pvs_buttons, Priority.ALWAYS);
content.setDisable(true);
return content;
}
use of javafx.scene.control.TableColumn 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;
}
use of javafx.scene.control.TableColumn 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);
}
use of javafx.scene.control.TableColumn in project bisq-desktop by bisq-network.
the class TraderDisputeView method getSelectColumn.
// /////////////////////////////////////////////////////////////////////////////////////////
// Table
// /////////////////////////////////////////////////////////////////////////////////////////
private TableColumn<Dispute, Dispute> getSelectColumn() {
TableColumn<Dispute, Dispute> column = new AutoTooltipTableColumn<Dispute, Dispute>(Res.get("shared.select"));
column.setMinWidth(80);
column.setMaxWidth(80);
column.setSortable(false);
column.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
@Override
public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
return new TableCell<Dispute, Dispute>() {
Button button;
@Override
public void updateItem(final Dispute item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
if (button == null) {
button = new AutoTooltipButton(Res.get("shared.select"));
setGraphic(button);
}
button.setOnAction(e -> tableView.getSelectionModel().select(item));
} else {
setGraphic(null);
if (button != null) {
button.setOnAction(null);
button = null;
}
}
}
};
}
});
return column;
}
Aggregations