我已经尝试过:在配置注册表中设置主题配置和使用边框样式注册样式。但我没有看到边界。还有什么我想念的吗?
在我的 postConstruct 方法中,我初始化 NatTable 如下:
final ThemeConfiguration modernTheme = new ModernNatTableThemeConfiguration(imageRightUp, imageTreeRightDown);
TextPainter textPainter = new TextPainter(true, false);
ImagePainter imagePainter = new ImagePainter(threeDots);
CellPainterDecorator cellPainterDecorator = new CellPainterDecorator(textPainter, CellEdgeEnum.RIGHT, imagePainter);
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
cellPainterDecorator,
DisplayMode.NORMAL,
LABEL_1);
Style style = new Style();
style.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.getColor(44, 104, 125));
style.setAttributeValue(
CellStyleAttributes.FOREGROUND_COLOR,
GUIHelper.COLOR_WHITE);
style.setAttributeValue(
CellStyleAttributes.BORDER_STYLE,
new BorderStyle(5, GUIHelper.COLOR_BLACK, LineStyleEnum.SOLID));
configRegistry.registerConfigAttribute(
// attribute to apply
CellConfigAttributes.CELL_STYLE,
// value of the attribute
style,
// apply during normal rendering i.e not
// during selection or edit
DisplayMode.NORMAL,
// apply the above for all cells with this label
LABEL_1);
configRegistry.registerConfigAttribute(
// attribute to apply
CellConfigAttributes.CELL_STYLE,
// value of the attribute
style,
// apply during normal rendering i.e not
// during selection or edit
DisplayMode.NORMAL,
// apply the above for all cells with this label
LABEL_2);
NatTable natTable = new NatTable(parent, viewportLayer, false);
GridData d = new GridData(SWT.FILL, SWT.FILL, true, true, 1,1);
natTable.setLayoutData(d);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultTreeLayerConfiguration(treeLayer));
natTable.setTheme(modernTheme);
natTable.configure();
这也是主题配置:
public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfiguration {
public ModernNatTableThemeConfiguration( Image imageRightUp, Image imageTreeRightDown ){
TreeImagePainter treeImagePainter = new TreeImagePainter(
false,
imageRightUp, imageTreeRightDown, null); //$NON-NLS-1$//$NON-NLS-2$
this.treeStructurePainter = new BackgroundPainter(new PaddingDecorator(
new IndentedTreeImagePainter(10, null, CellEdgeEnum.LEFT,
treeImagePainter, false, 2, true), 0, 5, 0, 5, false));
TreeImagePainter treeSelectionImagePainter = new TreeImagePainter(
false,
imageRightUp, imageTreeRightDown, null); //$NON-NLS-1$//$NON-NLS-2$
this.treeStructureSelectionPainter = new BackgroundPainter(
new PaddingDecorator(new IndentedTreeImagePainter(10, null,
CellEdgeEnum.LEFT, treeSelectionImagePainter, false, 2,
true), 0, 5, 0, 5, false));
this.treeBgColor = GUIHelper.getColor(44, 104, 125);
this.treeFgColor = GUIHelper.getColor(44, 104, 125);
}
}