Reputation: 6009
I created a TableViewer ( jface ).
All the columns are editable ( using EditingSupport )
I want to know when cell is changed and then to raise a flag in other column. meaning that you start to write any data in the cell
I know that I need to create event of key changed listener to the cells. ( or there is different way )
How I can have access to the cell ? where do I need to add the event
//The gridViewer Class
public class MyGridViewer extends TableViewer {
public MyGridViewer (Composite parent) {
super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = this.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
this.setContentProvider(new MyModelProvider());
} }
@Override
protected void inputChanged(Object input, Object oldInput) {
removeColumn();
tableCol = new TableViewerColumn(this, SWT.NONE);
column = tableCol.getColumn();
column.setText(dataColumnHeader.getName());
column.setWidth(100);
column.setResizable(true);
column.setMoveable(true);
tableCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
DataRow r = (DataRow) element;
DataCell c = r.getDataCellByName(dataColumnHeader.getName());
if (c != null && c.getValue() != null) {
return c.getValue().toString();
}
return null;
}
});
editingSupport = new StringCellEditingSupport(this, dataColumnHeader);
tableCol.setEditingSupport(editingSupport);
super.inputChanged(input, oldInput);
}
Upvotes: 2
Views: 90
Reputation: 111217
Your StringCellEditingSupport
class knows when the cell is changed, put your code in the setValue
method of that class.
Upvotes: 1