I have a TableViewer where one of the columns is a DialogCellEditor.
A provider is bounded to the treeviewer.
Whenever user changes a value in the table (dialogcelleditor) I want modify() method to be invoke in order to update the model.
The problem, modify() method is being invoked only once, even if I try to update value of other rows.
Full code is complex, some snippets if more needed please tell.
MyProvider is a provider bounded to a Table.
MyCellEditor extends DialogCellEditor{
protected Object openDialogBox(Control cellEditorWindow) {
editor = ...;
if (editor.open() == Dialog.OK){
this.updateContents(myVal);
this.doSetValue(myVal);
this.focusLost(); // I need this to remove the focus from editor, and invoke modify() of ICellModifier
}
}
}
public MyProvider IStructuredContentProvider,ITableLabelProvider,IContentProvider,ICellModifier {
public void modify(Object element, String property, Object value) {
}
}
Update:
I tried to debug jface code and started with stack trace when modify() method was triggered:
MyProvider.modify(Object, String, Object)
ColumnViewer$2.setValue(Object, Object)
ColumnViewer$2(EditingSupport).saveCellEditorValue(CellEditor, ViewerCell)
TableViewerEditor(ColumnViewerEditor).saveEditorValue(CellEditor)
TableViewerEditor(ColumnViewerEditor).applyEditorValue()
ColumnViewerEditor$2.applyEditorValue()
CellEditor$1.run()
SafeRunner.run(ISafeRunnable)
JFaceUtil$1.run(ISafeRunnable)
SafeRunnable.run(ISafeRunnable)
MyCellEditor(CellEditor).fireApplyEditorValue() line: 333
MyCellEditor(CellEditor).focusLost()
On the next time when I updated the value modify() method wasn't triggered, the issue is with CellEditor.focusLost(): (jface code)
protected void focusLost() {
if (isActivated()) { <= isActivated() is always false, even if I try to call this.activate
fireApplyEditorValue();
deactivate();
}
}
and this is the code of isActivated(): (jface code)
public boolean isActivated() {
// Use the state of the visible style bit (getVisible()) rather than the
// window's actual visibility (isVisible()) to get correct handling when
// an ancestor control goes invisible, see bug 85331.
return control != null && control.getVisible();
}
[Updated on: Tue, 29 July 2014 09:19] by Moderator