【问题标题】:How to know if cell was changed in TableViewer?如何知道 TableViewer 中的单元格是否已更改?
【发布时间】: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);

}

【问题讨论】:

    标签: java jface


    【解决方案1】:

    您的StringCellEditingSupport 类知道单元格何时更改,请将您的代码放入该类的setValue 方法中。

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 1970-01-01
      • 2017-03-23
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 2011-01-26
      • 2016-01-21
      相关资源
      最近更新 更多