如何在不使用选择图层以外的任何图层的情况下冻结任何nattable列

时间:2017-02-17 06:55:07

标签: java eclipse-rcp nattable

我添加了DragDetectListener并在其中运行doCommand。它给出了真实的结果,但是列没有被冻结。 我的代码是:

natTable.addDragDetectListener(new DragDetectListener() {
    @Override
    public void dragDetected(DragDetectEvent paramDragDetectEvent) {
        boolean b = natTable.doCommand(new FreezeColumnCommand(glazedListsGridLayer.getcompositeFreezeLayer(), 0));
    }
});

添加图层堆栈代码:

bodyDataLayer = new DataLayer(bodyDataProvider);
        GlazedListsEventLayer<IzSearchResultRowData> glazedListsEventLayer = new GlazedListsEventLayer<IzSearchResultRowData>(bodyDataLayer, eventList);
        bodyLayer = new DefaultBodyLayerStack(glazedListsEventLayer);
        ColumnOverrideLabelAccumulator bodyLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
        bodyDataLayer.setConfigLabelAccumulator(bodyLabelAccumulator);
        // Column header layer
        selectionLayer = bodyLayer.getSelectionLayer();
        DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(bulkDataManager);
        columnHeaderDataLayer.setRowHeightByPosition(0, 35);
        final FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
        final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(
                freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, compositeFreezeLayer, selectionLayer);

另一件事: 我通过选择层获得位置坐标。当我运行freeze命令时 natTable.doCommand(new FreezeColumnCommand(glazedListsGridLayer.getSelectionLayer(),0));

它给出了错误的结果。

1 个答案:

答案 0 :(得分:0)

很难说没有看到你的图层堆栈。也许你有一个更复杂的层组合,并且由于索引位置转换,命令在途中丢失了。尝试在您提供位置坐标的图层上执行命令。

natTable.addDragDetectListener(new DragDetectListener() {
    @Override
    public void dragDetected(DragDetectEvent paramDragDetectEvent) {
        boolean b = glazedListsGridLayer.getcompositeFreezeLayer().doCommand(
            new FreezeColumnCommand(glazedListsGridLayer.getcompositeFreezeLayer(), 0));
    }
});