List of usage examples for javafx.scene.control TableColumn editCommitEvent
@SuppressWarnings("unchecked") public static <S, T> EventType<CellEditEvent<S, T>> editCommitEvent()
From source file:com.panemu.tiwulfx.table.TableControl.java
private void initColumn(TableColumn<R, ?> clm) { List<TableColumn<R, ?>> lstColumn = new ArrayList<>(); lstColumn.add(clm);// w w w . j a v a 2 s. co m lstColumn = getColumnsRecursively(lstColumn); for (TableColumn column : lstColumn) { if (column instanceof BaseColumn) { final BaseColumn baseColumn = (BaseColumn) column; baseColumn.tableCriteriaProperty().addListener(tableCriteriaListener); baseColumn.sortTypeProperty().addListener(sortTypeChangeListener); baseColumn.addEventHandler(TableColumn.editCommitEvent(), new EventHandler<TableColumn.CellEditEvent<R, ?>>() { @Override public void handle(CellEditEvent<R, ?> t) { try { if (!(t.getTablePosition().getRow() < t.getTableView().getItems().size())) { return; } Object persistentObj = t.getTableView().getItems() .get(t.getTablePosition().getRow()); if ((t.getNewValue() == null && t.getOldValue() == null) || (t.getNewValue() != null && t.getNewValue().equals(t.getOldValue()))) { } if (mode.get().equals(Mode.EDIT) && t.getOldValue() != t.getNewValue() && (t.getOldValue() == null || !t.getOldValue().equals(t.getNewValue()))) { if (!lstChangedRow.contains((R) persistentObj)) { lstChangedRow.add((R) persistentObj); } baseColumn.addRecordChange(persistentObj, t.getOldValue(), t.getNewValue()); } PropertyUtils.setSimpleProperty(persistentObj, baseColumn.getPropertyName(), t.getNewValue()); baseColumn.validate(persistentObj); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { throw new RuntimeException(ex); } } }); } } }