当前位置: 代码迷 >> Eclipse >> EditingSupport有关问题
  详细解决方案

EditingSupport有关问题

热度:25   发布时间:2016-04-23 13:54:45.0
EditingSupport问题
我现在想的是直接在tableviewer上直接编辑 

继承EditingSupport
TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);

col.setEditingSupport(new RevisionEditingSupport(viewer));

public class QuantityEditingSupport extends EditingSupport {

private final TableViewer viewer;

public QuantityEditingSupport(TableViewer viewer) {
super(viewer);
this.viewer = viewer;
}

@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(viewer.getTable());
}

@Override
protected boolean canEdit(Object element) {
return true;
}

@Override
protected Object getValue(Object element) {
return ((Indent) element).getQuantity();
}

@Override
protected void setValue(Object element, Object value) {
((Indent) element).setQuantity(Integer.parseInt(value.toString()));
viewer.refresh();
}
}

为什么不能编辑表格啊,这一列是int类型,但是String类型列可以编辑,谢谢

------解决方案--------------------
protected Object getValue(Object element) {
return ((Indent) element).getQuantity();
}

这里返回转成String类型
------解决方案--------------------
swing找大胡子
  相关解决方案