Java Code Examples for javafx.scene.control.TableColumn#setOnEditCommit()
The following examples show how to use
javafx.scene.control.TableColumn#setOnEditCommit() .
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: FormulaPane.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private TableView<InputItem> createInputs() { TableColumn<InputItem, String> col = new TableColumn<>(Messages.FormulaTabInput); col.setCellValueFactory(c -> c.getValue().input_name); input_table.getColumns().add(col); col = new TableColumn<>(Messages.FormulaTabVariable); col.setCellValueFactory(c -> c.getValue().variable_name); col.setCellFactory(TextFieldTableCell.forTableColumn()); // When variable is renamed, re-evaluate formula col.setOnEditCommit(event -> parseFormula()); col.setEditable(true); input_table.getColumns().add(col); input_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); input_table.setTooltip(new Tooltip(Messages.FormulaTabTT)); input_table.setEditable(true); // Double-click (on input column) adds that variable name to formula input_table.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> { if (event.getClickCount() == 2) insert(input_table.getSelectionModel().getSelectedItem().variable_name.get()); }); return input_table; }
Example 2
Source File: TableController.java From zest-writer with GNU General Public License v3.0 | 6 votes |
private void addCol() { TableColumn tc = new TableColumn(); tc.setEditable(true); tc.setCellValueFactory(param -> { CellDataFeatures<ZRow, String> dtf = (CellDataFeatures<ZRow, String>) param; return new SimpleStringProperty(dtf.getValue().getRow().get(0)); }); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setOnEditCommit(t -> { CellEditEvent<ZRow, String> evt = (CellEditEvent<ZRow, String>) t; List<String> row = evt.getTableView().getItems().get(evt.getTablePosition().getRow()).getRow(); row.set(evt.getTablePosition().getColumn(), evt.getNewValue()); }); tc.setPrefWidth(150); TextField txf = new TextField(); txf.setPrefWidth(150); txf.setPromptText(Configuration.getBundle().getString("ui.dialog.table_editor.colon") + (tableView.getColumns().size()+1)); tc.setGraphic(txf); tableView.getColumns().addAll(tc); postAddColumn(); }
Example 3
Source File: EventDetectionUI.java From SONDY with GNU General Public License v3.0 | 6 votes |
public final void initializeParameterTable(){ parameterTable.setEditable(true); TableColumn keyColumn = new TableColumn("Parameter"); keyColumn.setMinWidth(Main.columnWidthRIGHT/2-1); keyColumn.setCellValueFactory(new PropertyValueFactory<>("name")); TableColumn valueColumn = new TableColumn("Value"); valueColumn.setMinWidth(Main.columnWidthRIGHT/2-1); valueColumn.setCellFactory(TextFieldTableCell.forTableColumn()); valueColumn.setCellValueFactory(new PropertyValueFactory<>("value")); valueColumn.setOnEditCommit( new EventHandler<CellEditEvent<Parameter, String>>() { @Override public void handle(CellEditEvent<Parameter, String> t) { ((Parameter) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue()); } } ); parameterTable.getColumns().addAll(keyColumn,valueColumn); }
Example 4
Source File: InfluenceAnalysisUI.java From SONDY with GNU General Public License v3.0 | 6 votes |
public final void initializeParameterTable(){ parameterTable.setEditable(true); TableColumn keyColumn = new TableColumn("Parameter"); keyColumn.setMinWidth(Main.columnWidthRIGHT/2-1); keyColumn.setCellValueFactory(new PropertyValueFactory<>("name")); TableColumn valueColumn = new TableColumn("Value"); valueColumn.setMinWidth(Main.columnWidthRIGHT/2-1); valueColumn.setCellFactory(TextFieldTableCell.forTableColumn()); valueColumn.setCellValueFactory(new PropertyValueFactory<>("value")); valueColumn.setOnEditCommit( new EventHandler<TableColumn.CellEditEvent<Parameter, String>>() { @Override public void handle(TableColumn.CellEditEvent<Parameter, String> t) { ((Parameter) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue()); } } ); parameterTable.getColumns().addAll(keyColumn,valueColumn); }
Example 5
Source File: CTimePeriodField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public TableColumn<ObjectTableRow, TimePeriod> getTableColumn( PageActionManager pageactionmanager, boolean largedisplay, int preferedrowheight, String actionkeyforupdate) { TableColumn< ObjectTableRow, TimePeriod> thiscolumn = new TableColumn<ObjectTableRow, TimePeriod>(this.getLabel()); if (actionkeyforupdate != null) { thiscolumn.setEditable(true); thiscolumn.setOnEditCommit(new TableColumnOnEditCommit(this)); } else { thiscolumn.setEditable(false); } int length = 15 * 7; if (length > 300) length = 300; double pixellength = ((new Text(this.label)).getBoundsInLocal().getWidth() + 10) * 1.05; int pixellengthi = (int) pixellength; thiscolumn.setMinWidth(pixellengthi); thiscolumn.setPrefWidth(pixellengthi); thiscolumn.setCellValueFactory(new TableCellValueFactory(this)); thiscolumn.setCellFactory(new TableCellFactory(helper, periodtype)); return thiscolumn; }
Example 6
Source File: CChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public TableColumn<ObjectTableRow, CChoiceFieldValue> getTableColumn( PageActionManager pageactionmanager, boolean largedisplay, int rowheight, String actionkeyforupdate) { TableColumn< ObjectTableRow, CChoiceFieldValue> thiscolumn = new TableColumn<ObjectTableRow, CChoiceFieldValue>(this.getLabel()); if ((actionkeyforupdate != null) && (this.isEditable())) { thiscolumn.setEditable(true); thiscolumn.setOnEditCommit(new TableColumnOnEditCommit(this)); } else { thiscolumn.setEditable(false); } int length = this.maxcharlength * 7; if (length > 300) length = 300; if (this.prefereddisplaysizeintable >= 0) { length = this.prefereddisplaysizeintable * 7; } double pixellength = ((new Text(this.label)).getBoundsInLocal().getWidth() + 10) * 1.05; for (int i = 0; i < this.values.size(); i++) { double valuelength = ((new Text(values.get(i).getDisplayvalue()).getBoundsInLocal().getWidth()) + 10) * 1.05; if (valuelength > pixellength) pixellength = valuelength; } int pixellengthi = (int) pixellength; thiscolumn.setMinWidth(pixellengthi); thiscolumn.setPrefWidth(pixellengthi); logger.fine(" --**-- length for field" + this.getLabel() + " maxcharlength:" + maxcharlength + " pref display in table " + this.prefereddisplaysizeintable + " final length = " + length + " - pixel length" + pixellengthi); thiscolumn.setCellValueFactory(new TableCellValueFactory(this)); thiscolumn.setCellFactory(new TableCellFactory(helper, values)); return thiscolumn; }
Example 7
Source File: StringTable.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @param index Column index, -1 to add to end * @param header Header text */ private void createTableColumn(final int index, final String header) { final TableColumn<List<ObservableCellValue>, CellValue> table_column = new TableColumn<>(header); table_column.setCellValueFactory(VALUE_FACTORY); // Prevent column re-ordering // (handled via moveColumn which also re-orders the data) table_column.setReorderable(false); // By default, use text field editor. setColumnOptions() can replace table_column.setCellFactory(list -> new StringTextCell()); table_column.setOnEditStart(event -> editing = true); table_column.setOnEditCommit(event -> { editing = false; final int col = event.getTablePosition().getColumn(); List<ObservableCellValue> row = event.getRowValue(); if (row == MAGIC_LAST_ROW) { // Entered in last row? Create new row row = createEmptyRow(); final List<List<ObservableCellValue>> data = table.getItems(); data.add(data.size()-1, row); } row.get(col).setValue(event.getNewValue()); fireDataChanged(); // Automatically edit the next row, same column editCell(event.getTablePosition().getRow() + 1, table_column); }); table_column.setOnEditCancel(event -> editing = false); table_column.setSortable(false); if (index >= 0) table.getColumns().add(index, table_column); else table.getColumns().add(table_column); }
Example 8
Source File: TagEditorPane.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public TagEditorPane(Map<String, String> tags) { tagTable.setEditable(true); tagTable.setPrefHeight(200); tagTable.setPrefWidth(200); final TableColumn<Tag, String> nameCol = new TableColumn<>("Name"); nameCol.setCellValueFactory(new PropertyValueFactory<Tag, String>("name")); nameCol.setCellFactory(TextFieldTableCell.<Tag> forTableColumn()); nameCol.setOnEditCommit((t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setName(t.getNewValue()); }); final TableColumn<Tag, String> valueCol = new TableColumn<>("Value"); valueCol.setCellFactory(TextFieldTableCell.<Tag> forTableColumn()); valueCol.setCellValueFactory(new PropertyValueFactory<Tag, String>("value")); valueCol.setOnEditCommit((t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setValue(t.getNewValue()); }); tagTable.getColumns().addAll(nameCol, valueCol); final ObservableList<Tag> data = FXCollections.observableArrayList(); for (final Entry<String, String> entry : tags.entrySet()) data.add(new Tag(entry.getKey(), entry.getValue())); tagTable.setItems(data); tagTable.setOnMouseClicked((event) -> { if (event.getClickCount() == 2) { data.add(new Tag("", "")); } }); getChildren().add(tagTable); }
Example 9
Source File: PaceColumn.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override public TableColumn<SelectionTableRowData, String> getTableColumn() { TableColumn<SelectionTableRowData, String> tableColumn = SelectionTableColumn.super.getTableColumn(); tableColumn.setEditable(true); tableColumn.setOnEditCommit(t -> t.getTableView().getItems().get(t.getTablePosition().getRow()).pace .set(defaultIfBlank(t.getNewValue(), "1"))); return tableColumn; }
Example 10
Source File: PageRangesColumn.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override public TableColumn<SelectionTableRowData, String> getTableColumn() { TableColumn<SelectionTableRowData, String> tableColumn = SelectionTableColumn.super.getTableColumn(); tableColumn.setEditable(true); tableColumn.setOnEditCommit( t -> t.getTableView().getItems().get(t.getTablePosition().getRow()).pageSelection.set(t.getNewValue())); return tableColumn; }
Example 11
Source File: SQLColumnSettingsComponent.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public SQLColumnSettingsComponent() { columnsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); value = new SQLColumnSettings(); TableColumn<SQLRowObject,String> columnName=new TableColumn<SQLRowObject,String> (value.getColumnName(0)); TableColumn<SQLRowObject,SQLExportDataType> columnType=new TableColumn<SQLRowObject,SQLExportDataType> (value.getColumnName(1)); TableColumn<SQLRowObject,String> columnValue= new TableColumn<SQLRowObject,String> (value.getColumnName(2)); columnName.setCellValueFactory(new PropertyValueFactory<>("Name")); //this is needed during connection to a database columnType.setCellValueFactory(new PropertyValueFactory<>("Type")); columnValue.setCellValueFactory(new PropertyValueFactory<>("Value")); columnsTable.getColumns().addAll(columnName,columnType,columnValue); //added all the columns in the table setValue(value); columnsTable.setStyle("-fx-selection-bar: #3399FF; -fx-selection-bar-non-focused: #E3E3E3;"); //CSS color change on selection of row columnsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); columnName.setSortable(false); columnValue.setSortable(false); columnType.setSortable(false); columnName.setReorderable(false); columnValue.setReorderable(false); columnType.setReorderable(false); columnsTable.setPrefSize(550, 220); columnsTable.setFixedCellSize(columnsTable.getFixedCellSize()+20); columnsTable.setStyle("-fx-font: 10 \"Plain\""); //Setting action event on cells columnsTable.getSelectionModel().setCellSelectionEnabled(true); //individual cell selection enabled columnsTable.setEditable(true); //Editors on each cell columnName.setCellFactory(TextFieldTableCell.<SQLRowObject>forTableColumn()); columnName.setOnEditCommit(event -> { getValue().setValueAt(event.getNewValue(), event.getTablePosition().getRow(), 0); setValue(getValue()); //refresh the table }); columnValue.setCellFactory(TextFieldTableCell.<SQLRowObject>forTableColumn()); columnValue.setOnEditCommit(event -> { getValue().setValueAt(event.getNewValue().toUpperCase(), event.getTablePosition().getRow(), 2); setValue(getValue()); //refresh the table }); ArrayList<SQLExportDataType> exportDataTypeValues=new ArrayList<SQLExportDataType>(Arrays.asList(SQLExportDataType.values())); columnType.setCellFactory(ComboBoxTableCell.forTableColumn(FXCollections.observableArrayList(SQLExportDataType.values()))); columnType.setOnEditCommit(event -> { boolean selected = event.getNewValue().isSelectableValue(); if(!selected){ //case of invalid(Title) datatype selection getValue().setValueAt(exportDataTypeValues.get(exportDataTypeValues.indexOf(event.getNewValue())+1),event.getTablePosition().getRow(),1); } else { getValue().setValueAt(event.getNewValue(), event.getTablePosition().getRow(), 1); } setValue(getValue()); }); // Add buttons VBox buttonsPanel=new VBox(20); addColumnButton=new Button("Add"); removeColumnButton=new Button("Remove"); addColumnButton.setOnAction(this::actionPerformed); removeColumnButton.setOnAction(this::actionPerformed); buttonsPanel.getChildren().addAll(addColumnButton,removeColumnButton); this.setRight(buttonsPanel); this.setCenter(columnsTable); BorderPane.setMargin(buttonsPanel, new Insets(10)); }
Example 12
Source File: StringTableDemo.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@Override public void start(Stage stage) throws Exception { TableColumn<List<StringProperty>, String> tc = new TableColumn<>("A"); tc.setCellValueFactory(param -> param.getValue().get(0)); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setOnEditCommit(event -> { final int col = event.getTablePosition().getColumn(); event.getRowValue().get(col).set(event.getNewValue()); }); tc.setEditable(true); table.getColumns().add(tc); tc = new TableColumn<>("B"); tc.setCellValueFactory(param -> param.getValue().get(1)); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setEditable(true); table.getColumns().add(tc); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.setEditable(true); final Scene scene = new Scene(table, 800, 600); stage.setScene(scene); stage.show(); List<StringProperty> row = new ArrayList<>(); row.add(new SimpleStringProperty("One")); row.add(new SimpleStringProperty("Another")); data.add(row); row = new ArrayList<>(); row.add(new SimpleStringProperty("Two")); row.add(new SimpleStringProperty("Something")); data.add(row); final Thread change_cell = new Thread(() -> { while (true) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } Platform.runLater(() -> updateCell(1, 0, LocalDateTime.now().toString().replace('T', ' '))); } }); change_cell.setDaemon(true); change_cell.start(); }
Example 13
Source File: PVTable.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void createTableColumns() { // Selected column final TableColumn<TableItemProxy, Boolean> sel_col = new TableColumn<>(Messages.Selected); sel_col.setCellValueFactory(cell -> cell.getValue().selected); sel_col.setCellFactory(column -> new BooleanTableCell()); table.getColumns().add(sel_col); // PV Name TableColumn<TableItemProxy, String> col = new TableColumn<>(Messages.PV); col.setPrefWidth(250); col.setCellValueFactory(cell_data_features -> cell_data_features.getValue().name); col.setCellFactory(column -> new PVNameTableCell()); col.setOnEditCommit(event -> { final String new_name = event.getNewValue().trim(); final TableItemProxy proxy = event.getRowValue(); if (proxy == TableItemProxy.NEW_ITEM) { if (!new_name.isEmpty()) model.addItem(new_name); // else: No name entered, do nothing } else { // Set name, even if empty, assuming user wants to continue // editing the existing row. // To remove row, use context menu. proxy.getItem().updateName(new_name); proxy.update(proxy.getItem()); // Content of model changed. // Triggers full table update. model.fireModelChange(); } }); // Use natural order for PV name col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); // Description if (Settings.show_description) { col = new TableColumn<>(Messages.Description); col.setCellValueFactory(cell -> cell.getValue().desc_value); table.getColumns().add(col); } // Time Stamp col = new TableColumn<>(Messages.Time); col.setCellValueFactory(cell -> cell.getValue().time); table.getColumns().add(col); // Editable value col = new TableColumn<>(Messages.Value); col.setCellValueFactory(cell -> cell.getValue().value); col.setCellFactory(column -> new ValueTableCell(model)); col.setOnEditCommit(event -> { event.getRowValue().getItem().setValue(event.getNewValue()); // Since updates were suppressed, refresh table model.performPendingUpdates(); }); col.setOnEditCancel(event -> { // Since updates were suppressed, refresh table model.performPendingUpdates(); }); // Use natural order for value col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); // Alarm col = new TableColumn<>(Messages.Alarm); col.setCellValueFactory(cell -> cell.getValue().alarm); col.setCellFactory(column -> new AlarmTableCell()); table.getColumns().add(col); // Saved value col = new TableColumn<>(Messages.Saved); col.setCellValueFactory(cell -> cell.getValue().saved); // Use natural order for saved value col.setComparator(CompareNatural.INSTANCE); saved_value_col = col; table.getColumns().add(col); // Saved value's timestamp col = new TableColumn<>(Messages.Saved_Value_TimeStamp); col.setCellValueFactory(cell -> cell.getValue().time_saved); saved_time_col = col; table.getColumns().add(col); // Completion checkbox final TableColumn<TableItemProxy, Boolean> compl_col = new TableColumn<>(Messages.Completion); compl_col.setCellValueFactory(cell -> cell.getValue().use_completion); compl_col.setCellFactory(column -> new BooleanTableCell()); completion_col = compl_col; table.getColumns().add(compl_col); }
Example 14
Source File: GUI.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private TableView<Instance> createTable() { final TableView<Instance> table = new TableView<>(FXCollections.observableList(model.getInstances())); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); table.getSelectionModel().setCellSelectionEnabled(true); table.setEditable(true); TableColumn<Instance, String> col = new TableColumn<>(Messages.SystemColumn); col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getName())); table.getColumns().add(col); int col_index = 0; for (Column column : model.getColumns()) { final int the_col_index = col_index; col = new TableColumn<>(column.getName()); col.setCellFactory(info -> new PACETableCell()); col.setCellValueFactory(cell -> cell.getValue().getCell(the_col_index).getObservable()); table.getColumns().add(col); if (column.isReadonly()) col.setEditable(false); else { col.setOnEditCommit(event -> { event.getRowValue().getCell(the_col_index).setUserValue(event.getNewValue()); final int row = event.getTablePosition().getRow(); // Start to edit same column in next row if (row < table.getItems().size() - 1) Platform.runLater(() -> table.edit(row+1, event.getTableColumn())); }); } ++col_index; } return table; }
Example 15
Source File: ClientList.java From Maus with GNU General Public License v3.0 | 4 votes |
public TableView getClientList() { tableView = new TableView(); tableView.setEditable(true); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm()); TableColumn<String, String> onlineStatus = new TableColumn<>("Status"); onlineStatus.setMaxWidth(70); onlineStatus.setResizable(false); onlineStatus.setCellValueFactory( new PropertyValueFactory<>("onlineStatus")); TableColumn<ClientObject, String> nickName = new TableColumn<>("Nickname"); nickName.setMinWidth(150); nickName.setMaxWidth(200); nickName.setResizable(false); nickName.setCellValueFactory(new PropertyValueFactory<>("nickName")); nickName.setCellFactory(TextFieldTableCell.forTableColumn()); nickName.setOnEditCommit( t -> t.getTableView().getItems().get( t.getTablePosition().getRow()).setNickName(t.getNewValue()) ); TableColumn<ClientObject, String> IP = new TableColumn<>("IP"); IP.setMinWidth(600); IP.setResizable(false); IP.setCellValueFactory(new PropertyValueFactory<>("IP")); IP.setCellFactory(col -> { final TableCell<ClientObject, String> cell = new TableCell<>(); cell.textProperty().bind(cell.itemProperty()); cell.setOnMouseClicked(event -> { if (event.getButton().equals(MouseButton.SECONDARY) && cell.getTableView().getSelectionModel().getSelectedItem() != null && cell.getTableView().getSelectionModel().getSelectedItem().getClient().isConnected()) { IPContextMenu.getIPContextMenu(cell, event); } }); return cell; }); ObservableList<ClientObject> list = FXCollections.observableArrayList(); list.addAll(CONNECTIONS.values()); tableView.setItems(list); tableView.getColumns().addAll(onlineStatus, nickName, IP); return tableView; }