use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class BaseColumnMapper method generateTableColumns.
/**
* 컬럼 제너레이터
*
* @Date 2015. 10. 8.
* @param classType
* @return
* @User KYJ
*/
@Override
public TableColumn<T, ?> generateTableColumns(Class<?> classType, String columnName, IOptions options) {
TableColumn tableColumn = new TableColumn<>();
// 2015.11.18 커스텀 컬럼은 cellFactory를 가져다 쓰지않음.
tableColumn.setCellFactory(cell -> {
TextFieldTableCell<T, Object> textFieldTableCell = new TextFieldTableCell<>();
textFieldTableCell.setConverter(converter(classType));
return textFieldTableCell;
});
// 2015.11.18 커스텀 컬럼값을 정의한경우 대체.
TableColumn<T, ?> customTableColumn = options.customTableColumn(columnName);
if (customTableColumn != null) {
tableColumn = customTableColumn;
}
// 2015.11.18 커스텀 컬럼은 ValueFactory는 기본적으로 사용
PropertyValueFactory<T, ?> value = new PropertyValueFactory<>(columnName);
tableColumn.setCellValueFactory(value);
tableColumn.setId(columnName);
// 컬럼의 속성을 정의
setColumnProperty(tableColumn, columnName, options);
tableColumn.setResizable(true);
tableColumn.setEditable(false);
tableColumn.setVisible(options.visible(columnName));
return tableColumn;
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class MacroControl method tbResultOnKeyReleased.
public void tbResultOnKeyReleased() {
Skin<?> skin = this.getSkin();
if (!(skin instanceof MacroBaseSkin)) {
return;
}
MacroBaseSkin mskin = (MacroBaseSkin) skin;
TableView<Map<String, String>> tbResult = mskin.getTbResult();
int type = 1;
ObservableList<TablePosition> selectedCells = tbResult.getSelectionModel().getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
TableColumn tableColumn = tablePosition.getTableColumn();
int row = tablePosition.getRow();
int col = tbResult.getColumns().indexOf(tableColumn);
switch(type) {
case 1:
StringBuilder sb = new StringBuilder();
for (TablePosition cell : selectedCells) {
// 행변경시
if (row != cell.getRow()) {
sb.append("\n");
row++;
} else // 열 변경시
if (col != tbResult.getColumns().indexOf(cell.getTableColumn())) {
sb.append("\t");
}
Object cellData = cell.getTableColumn().getCellData(cell.getRow());
sb.append(ValueUtil.decode(cellData, cellData, "").toString());
}
FxClipboardUtil.putString(sb.toString());
break;
case 2:
Object cellData = tableColumn.getCellData(row);
FxClipboardUtil.putString(ValueUtil.decode(cellData, cellData, "").toString());
break;
}
}
use of javafx.scene.control.TableColumn 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);
}
use of javafx.scene.control.TableColumn in project org.csstudio.display.builder by kasemir.
the class RulesDialog method createPVsTable.
/**
* @return Node for UI elements that edit the PVs of a rule
*/
private HBox 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
final TableColumn<PVTableItem, String> name_col = new TableColumn<>(Messages.ScriptsDialog_ColPV);
name_col.setSortable(false);
name_col.setCellValueFactory(new PropertyValueFactory<PVTableItem, String>("name"));
name_col.setCellFactory(col -> new AutoCompletedTableCell(menu, btn_add_pv));
name_col.setOnEditCommit(event -> {
final int row = event.getTablePosition().getRow();
pv_items.get(row).nameProperty().set(event.getNewValue());
fixupPVs(row);
});
// Table column for 'trigger' uses CheckBoxTableCell that directly
// modifies the Observable Property
final TableColumn<PVTableItem, Boolean> trigger_col = new TableColumn<>(Messages.ScriptsDialog_ColTrigger);
trigger_col.setSortable(false);
trigger_col.setCellValueFactory(new PropertyValueFactory<PVTableItem, Boolean>("trigger"));
trigger_col.setCellFactory(CheckBoxTableCell.<PVTableItem>forTableColumn(trigger_col));
trigger_col.setResizable(false);
trigger_col.setMaxWidth(70);
trigger_col.setMinWidth(70);
pvs_table = new TableView<>(pv_items);
pvs_table.getColumns().add(indexColumn);
pvs_table.getColumns().add(name_col);
pvs_table.getColumns().add(trigger_col);
pvs_table.setEditable(true);
pvs_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
pvs_table.setTooltip(new Tooltip(Messages.RulesDialog_PVsTT));
pvs_table.setPlaceholder(new Label(Messages.RulesDialog_NoPVs));
// Buttons
btn_add_pv = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
btn_add_pv.setMaxWidth(Double.MAX_VALUE);
btn_add_pv.setAlignment(Pos.CENTER_LEFT);
btn_add_pv.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, name_col));
}, 123, TimeUnit.MILLISECONDS);
});
btn_rm_pv = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
btn_rm_pv.setMaxWidth(Double.MAX_VALUE);
btn_rm_pv.setMinWidth(96);
btn_rm_pv.setAlignment(Pos.CENTER_LEFT);
btn_rm_pv.setDisable(true);
btn_rm_pv.setOnAction(event -> {
final int sel = pvs_table.getSelectionModel().getSelectedIndex();
if (sel >= 0) {
pv_items.remove(sel);
fixupPVs(sel);
}
});
btn_move_pv_up = new Button(Messages.MoveUp, JFXUtil.getIcon("up.png"));
btn_move_pv_up.setMaxWidth(Double.MAX_VALUE);
btn_move_pv_up.setAlignment(Pos.CENTER_LEFT);
btn_move_pv_up.setDisable(true);
btn_move_pv_up.setOnAction(event -> TableHelper.move_item_up(pvs_table, pv_items));
btn_move_pv_down = new Button(Messages.MoveDown, JFXUtil.getIcon("down.png"));
btn_move_pv_down.setMaxWidth(Double.MAX_VALUE);
btn_move_pv_down.setAlignment(Pos.CENTER_LEFT);
btn_move_pv_down.setDisable(true);
btn_move_pv_down.setOnAction(event -> TableHelper.move_item_down(pvs_table, pv_items));
final VBox buttons = new VBox(10, btn_add_pv, btn_rm_pv, btn_move_pv_up, btn_move_pv_down);
final HBox content = new HBox(10, pvs_table, buttons);
HBox.setHgrow(pvs_table, Priority.ALWAYS);
HBox.setHgrow(buttons, Priority.NEVER);
content.setDisable(true);
return content;
}
use of javafx.scene.control.TableColumn 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;
}
Aggregations