문제

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);

}

도움이 되었습니까?

해결책

Your StringCellEditingSupport class knows when the cell is changed, put your code in the setValue method of that class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top