简体   繁体   English

如何为星云NatTable中的未装饰项配置缩进

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

I am trying to style a NatTable tree so that the indentation of non-decorated items matches that of decorated items. 我正在尝试设置NatTable树的样式,以使未装饰项目的缩进与装饰项目的缩进匹配。 So items without children and items with children have the same indentation, basically. 因此,没有孩子的物品和有孩子的物品基本上具有相同的缩进。

The example that I am following using the following configuration: 我正在使用以下配置的示例:

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. A是预期的布局,B是我当前得到的布局。

To achieve this you need to pass a leaf image to the TreeImagePainter 为此,您需要将叶子图像传递给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$

The provided leaf image is actually an empty image that is used as spacer. 提供的叶子图像实际上是用作间隔符的空白图像。 Using this also the children of expanded nodes will get an additional spacing. 也使用此扩展节点的子级将获得额外的间距。 But that is needed to make it possible to differentiate between children of expanded nodes and nodes without children. 但这需要使之能够区分扩展节点的子节点和没有子节点的节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM