javafx.scene.control.TableColumn.CellEditEvent Java Examples
The following examples show how to use
javafx.scene.control.TableColumn.CellEditEvent.
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: CTimePeriodField.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
@Override public void handle(CellEditEvent<ObjectTableRow, TimePeriod> event) { try { boolean changed = false; if (event.getOldValue() == null) if (event.getNewValue() != null) changed = true; if (event.getOldValue() != null) if (!(event.getOldValue().equals(event.getNewValue()))) changed = true; if (changed) { ObjectTableRow objecttochange = event.getRowValue(); objecttochange.updateField(thistimeperiodfield.getFieldname(), event.getNewValue()); logger.info("Updated timeperiod for field " + thistimeperiodfield.getFieldname() + ", new value = " + event.getNewValue()); } else { logger.info("received edit event where old values and new values are the same"); } } catch (RuntimeException e) { logger.severe("exception in updating TimePeriod " + thistimeperiodfield.getFieldname() + " : " + e.getClass() + ": " + e.getMessage()); ExceptionLogger.setInLogs(e, logger); } }
Example #2
Source File: TableAutoCommitCell.java From MyBox with Apache License 2.0 | 6 votes |
@Override public void commitEdit(final T valNew) { if (isEditing()) { super.commitEdit(valNew); } else { final TableView<S> tbl = getTableView(); if (tbl != null) { final TablePosition<S, T> pos = new TablePosition<>(tbl, getTableRow().getIndex(), getTableColumn()); // instead of tbl.getEditingCell() final CellEditEvent<S, T> ev = new CellEditEvent<>(tbl, pos, TableColumn.editCommitEvent(), valNew); Event.fireEvent(getTableColumn(), ev); } updateItem(valNew, false); if (tbl != null) { tbl.edit(-1, null); } // TODO ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(tbl); } }
Example #3
Source File: PVTableItem.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public void commitEdit ( String newValue ) { if (!isEditing() && !newValue.equals(getItem())) { TableView<PVTableItem> table = getTableView(); if (table != null) { TableColumn<PVTableItem, String> column = getTableColumn(); TableColumn.CellEditEvent<PVTableItem, String> event = new CellEditEvent<PVTableItem, String>(table, new TablePosition<PVTableItem, String>(table, getIndex(), column), TableColumn.editCommitEvent(), newValue); Event.fireEvent(column, event); } } else { super.commitEdit(newValue); } Platform.runLater( ( ) -> focusedOnCommit.requestFocus()); }
Example #4
Source File: EditCell.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public void commitEdit(T item) { // This block is necessary to support commit on losing focus, because the baked-in mechanism // sets our editing state to false before we can intercept the loss of focus. // The default commitEdit(...) method simply bails if we are not editing... if (!isEditing() && !item.equals(getItem())) { TableView<S> table = getTableView(); if (table != null) { TableColumn<S, T> column = getTableColumn(); CellEditEvent<S, T> event = new CellEditEvent<S, T>(table, new TablePosition<S, T>(table, getIndex(), column), TableColumn.editCommitEvent(), item); Event.fireEvent(column, event); } } else { super.commitEdit(item); } setContentDisplay(ContentDisplay.TEXT_ONLY); }
Example #5
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 #6
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 #7
Source File: TooltippedTextFieldTableCell.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
@Override public void commitEdit(String item) { // This block is necessary to support commit on losing focus, because the baked-in mechanism // sets our editing state to false before we can intercept the loss of focus. // The default commitEdit(...) method simply bails if we are not editing... if (!isEditing() && !item.equals(getItem())) { TableView<SelectionTableRowData> table = getTableView(); if (table != null) { TableColumn<SelectionTableRowData, String> column = getTableColumn(); CellEditEvent<SelectionTableRowData, String> event = new CellEditEvent<>(table, new TablePosition<>(table, getIndex(), column), TableColumn.editCommitEvent(), item); Event.fireEvent(column, event); } } super.commitEdit(item); setContentDisplay(ContentDisplay.TEXT_ONLY); }
Example #8
Source File: CChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public void handle(CellEditEvent<ObjectTableRow, CChoiceFieldValue> event) { try { boolean changed = false; if (event.getOldValue() == null) if (event.getNewValue() != null) changed = true; if (event.getOldValue() != null) if (!(event.getOldValue().equals(event.getNewValue()))) changed = true; if (changed) { ObjectTableRow objecttochange = event.getRowValue(); objecttochange.updateField(thischoicefield.getFieldname(), event.getNewValue()); logger.info("Updated choice value for field " + thischoicefield.getFieldname() + ", new value = " + event.getNewValue()); } else { logger.info("received edit event where old values and new values are the same"); } } catch (RuntimeException e) { logger.severe("exception in updating ChoiceField " + thischoicefield.getFieldname() + " : " + e.getClass().getName() + ": " + e.getMessage()); for (int i = 0; i < e.getStackTrace().length; i++) if (e.getStackTrace()[i].toString().startsWith("org.openlowcode")) logger.severe(" - " + e.getStackTrace()[i].toString()); } }
Example #9
Source File: DirectChoiceBoxTableCell.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override protected void updateItem(final T value, final boolean empty) { super.updateItem(value, empty); if (empty) setGraphic(null); else { choicebox.setValue(value); setGraphic(choicebox); choicebox.setOnAction(event -> { // 'onAction' is invoked from setValue as called above, // but also when table updates its cells. // Ignore those. // Also ignore dummy updates to null which happen // when the list of choices changes if (! choicebox.isShowing() || choicebox.getValue() == null) return; final TableRow<S> row = getTableRow(); if (row == null) return; // Fire 'onEditCommit' final TableView<S> table = getTableView(); final TableColumn<S, T> col = getTableColumn(); final TablePosition<S, T> pos = new TablePosition<>(table, row.getIndex(), col); Objects.requireNonNull(col.getOnEditCommit(), "Must define onEditCommit handler") .handle(new CellEditEvent<>(table, pos, TableColumn.editCommitEvent(), choicebox.getValue())); }); } }
Example #10
Source File: BigTableController.java From examples-javafx-repos1 with Apache License 2.0 | 3 votes |
static <T, S> T getObjectAtEvent(CellEditEvent<T, S> evt) { TableView<T> tableView = evt.getTableView(); ObservableList<T> items = tableView.getItems(); TablePosition<T,S> tablePosition = evt.getTablePosition(); int rowId = tablePosition.getRow(); T obj = items.get(rowId); return obj; }