我正在尝试设置NatTable树的样式,以使未装饰项目的缩进与装饰项目的缩进匹配。因此,没有孩子的物品和有孩子的物品基本上具有相同的缩进。
以下示例使用以下配置:
public class PerfLogTreeConfiguration extends AbstractRegistryConfiguration {
private static final int fTreeIndent = 10;
private static final int fIconSpacing = 2;
private TreeImagePainter fTreeImagePainter = new TreeImagePainter(false,
GUIHelper.getImage("right"), //$NON-NLS-1$
GUIHelper.getImage("right_down"), null); //$NON-NLS-1$
private IndentedTreeImagePainter indentedTreeImagePainter = new IndentedTreeImagePainter(
fTreeIndent,
null,
CellEdgeEnum.LEFT,
fTreeImagePainter,
false,
fIconSpacing,
true);
private PaddingDecorator paddingDecorator = new PaddingDecorator(
indentedTreeImagePainter,
0,
5,
0,
5,
true);
private ICellPainter fTreeStructurePainter = new BackgroundPainter(paddingDecorator);
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, fTreeStructurePainter,
DisplayMode.NORMAL);
}
A is the intended layour and B is what I am currently getting.
答案 0 :(得分:0)
要实现此目的,您需要将叶子图像传递到TreeImagePainter
TreeImagePainter fTreeImagePainter = new TreeImagePainter(false,
GUIHelper.getImage("right"), //$NON-NLS-1$
GUIHelper.getImage("right_down"), //$NON-NLS-1$
GUIHelper.getImage("leaf")); //$NON-NLS-1$
所提供的叶子图像实际上是用作间隔符的空白图像。也使用此扩展节点的子级将获得额外的间距。但这是必要的,以便可以区分扩展节点的子节点和没有子节点的节点。