【发布时间】:2014-02-14 12:18:42
【问题描述】:
我创建了一个 TableViewer ( jface )。
所有列都是可编辑的(使用 EditingSupport)
我想知道单元格何时更改,然后在其他列中升旗。意味着您开始在单元格中写入任何数据
我知道我需要为单元格创建键更改侦听器的事件。 (或者有不同的方式)
我如何才能访问该单元格?我需要在哪里添加事件
//gridViewer类
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);
}
【问题讨论】: