/** {@inheritDoc} */ @Override public void commitEdit(T newValue) { if (!isEditing()) return; final TableView table = getTableView(); if (table != null) { // Inform the TableView of the edit being ready to be committed. CellEditEvent editEvent = new CellEditEvent(table, table.getEditingCell(), TableColumn.editCommitEvent(), newValue); Event.fireEvent(getTableColumn(), editEvent); } // inform parent classes of the commit, so that they can switch us // out of the editing state. // This MUST come before the updateItem call below, otherwise it will // call cancelEdit(), resulting in both commit and cancel events being // fired (as identified in RT-29650) super.commitEdit(newValue); // update the item within this cell, so that it represents the new value updateItem(newValue, false); if (table != null) { // reset the editing cell on the TableView table.edit(-1, null); // request focus back onto the table, only if the current focus // owner has the table as a parent (otherwise the user might have // clicked out of the table entirely and given focus to something else. // It would be rude of us to request it back again. ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(table); } }
/** {@inheritDoc} */ @Override public void cancelEdit() { if (!isEditing()) return; final TableView table = getTableView(); super.cancelEdit(); // reset the editing index on the TableView if (table != null) { TablePosition editingCell = table.getEditingCell(); if (updateEditingIndex) table.edit(-1, null); // request focus back onto the table, only if the current focus // owner has the table as a parent (otherwise the user might have // clicked out of the table entirely and given focus to something else. // It would be rude of us to request it back again. ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(table); CellEditEvent editEvent = new CellEditEvent(table, editingCell, TableColumn.editCancelEvent(), null); Event.fireEvent(getTableColumn(), editEvent); } }
/** {@inheritDoc} */ @Override public void startEdit() { final TableView table = getTableView(); final TableColumn column = getTableColumn(); if (!isEditable() || (table != null && !table.isEditable()) || (column != null && !getTableColumn().isEditable())) { return; } // We check the boolean lockItemOnEdit field here, as whilst we want to // updateItem normally, when it comes to unit tests we can't have the // item change in all circumstances. if (!lockItemOnEdit) { updateItem(); } // it makes sense to get the cell into its editing state before firing // the event to listeners below, so that's what we're doing here // by calling super.startEdit(). super.startEdit(); if (column != null) { CellEditEvent editEvent = new CellEditEvent(table, table.getEditingCell(), TableColumn.editStartEvent(), null); Event.fireEvent(column, editEvent); } }
@Override protected void layoutChildren() { if (itemDirty) { updateItem(); itemDirty = false; } super.layoutChildren(); }
@Override void indexChanged() { super.indexChanged(); // Ideally we would just use the following two lines of code, rather // than the updateItem() call beneath, but if we do this we end up with // RT-22428 where all the columns are collapsed. // itemDirty = true; // requestLayout(); updateItem(); updateSelection(); updateFocus(); }