【发布时间】:2017-09-25 23:25:28
【问题描述】:
我正在使用 CheckBoxCellEditor 和 CheckBoxPainter 在 NatTable 中显示布尔属性,如下所示
问题:使用鼠标单击单元格时,它将布尔值显示为如下所示的文本,而不是将状态重置为 false。
下面是我的代码sn-p,
//register the column
ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
bodyLayer.getBodyDataLayer());
bodyLayer.getBodyDataLayer().setConfigLabelAccumulator(columnLabelAccumulator);
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_BOOKMARK_LABEL);
//added the CheckBoxCellEditor and CheckBoxCellPainter to configuration.
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new CheckBoxCellEditor(), DisplayMode.NORMAL,
COLUMN_BOOKMARK_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CheckBoxPainter(ImageUtil.getImage("Images.BookmarkChecked"),
ImageUtil.getImage("Images.BookmarkUnchecked")),
DisplayMode.NORMAL, COLUMN_BOOKMARK_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, COLUMN_BOOKMARK_LABEL);
}
});
我也让 rowselectionProvider 将默认选择设置为第一行,并根据行选择刷新属性 UI。
关于缺少链接的任何指针。TIA
【问题讨论】:
标签: java eclipse checkbox swt nattable