如何为 Nebula NatTable 中的非修饰项配置缩进

How to configure indentation for non decorated items in a Nebula NatTable

我正在尝试设置 NatTable 树的样式,以便 non-decorated 项目的缩进与装饰项目的缩进相匹配。因此,没有 children 的项目和带有 children 的项目基本上具有相同的缩进。

我正在使用以下配置的示例:

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.

为此,您需要将叶子图像传递给 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$

提供的叶子图像实际上是用作间隔的空图像。也使用此扩展节点的子节点将获得额外的间距。但这需要能够区分扩展节点的子节点和没有子节点的节点。