You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级至Eclipse 2023-06后TreeViewer出现双垂直滚动条问题

双垂直滚动条问题(Eclipse 2023-06 RCP升级)

我正在将旧RCP应用升级到Eclipse 2023-06版本,发现两个使用TreeViewer的视图出现双垂直滚动条问题。

初始化代码

viewer = new TreeViewer(body, SWT.NORMAL | SWT.FULL_SELECTION);
viewer.setContentProvider(new ProtocolViewContentProvider());
viewer.setLabelProvider(lp);
comparator = new ProtocolViewerComparator();
viewer.setComparator(comparator);

viewer.getTree().setLinesVisible(true);
viewer.getTree().setHeaderVisible(true);
viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));

排查尝试

  • 尝试仅用body参数创建TreeViewer,问题未解决
  • 移除表头后,两个滚动条高度一致
  • SWT Spy输出信息:
Tree {} [layout=null]@140368
    Style: SINGLE | HORIZONTAL | VERTICAL | FULL_SELECTION | LEFT_TO_RIGHT | DOUBLE_BUFFERED 
    Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.FILL grabExcessVerticalSpace=true}
    Bounds: Rectangle {0, 27, 1120, 211}


Children:

Peers:
    Label {TestCases - [Aktuell] }@140364 Layout Data: GridData {horizontalAlignment=SWT.BEGINNING verticalAlignment=GridData.CENTER} Bounds: Rectangle {0, 0, 130, 17}
    *Tree {} [layout=null]@140368 Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.FILL grabExcessVerticalSpace=true} Bounds: Rectangle {0, 27, 1120, 211}

Parent Tree:
    Shell {gitr3a-workspace-developer - TestCases/5BE86209-DD55-4EA8-9BB7-ECA48CE1D883.cfg - Title} [layout=org.eclipse.e4.ui.workbench.renderers.swt.TrimmedPartLayout@2cf78ff]@1122090
         Style: RESIZE | TITLE | CLOSE | MIN | MAX | LEFT_TO_RIGHT 
         Bounds: Rectangle {3621, -1337, 1741, 1568}
         Layout: org.eclipse.e4.ui.workbench.renderers.swt.TrimmedPartLayout@2cf78ff
         LayoutData: null
        Composite {} [layout=FillLayout {type=SWT.HORIZONTAL}]@1055872
             Style: LEFT_TO_RIGHT 
             Bounds: Rectangle {0, 28, 1719, 1428}
             Layout: FillLayout {type=SWT.HORIZONTAL}
             LayoutData: null
            Composite {} [layout=org.eclipse.e4.ui.workbench.renderers.swt.SashLayout@5ec40569]@663364
                 Style: LEFT_TO_RIGHT 
                 Bounds: Rectangle {0, 0, 1719, 1428}
                 Layout: org.eclipse.e4.ui.workbench.renderers.swt.SashLayout@5ec40569
                 LayoutData: null
                Composite {} [layout=StackLayout {topControl=Composite {} [layout=FillLayout {type=SWT.HORIZONTAL}]}]@791434
                     Style: LEFT_TO_RIGHT 
                     Bounds: Rectangle {0, 0, 1719, 1428}
                     Layout: StackLayout {topControl=Composite {} [layout=FillLayout {type=SWT.HORIZONTAL}]}
                     LayoutData: null
                    Composite {} [layout=FillLayout {type=SWT.HORIZONTAL}]@1053782
                         Style: LEFT_TO_RIGHT 
                         Bounds: Rectangle {0, 0, 1719, 1428}
                         Layout: FillLayout {type=SWT.HORIZONTAL}
                         LayoutData: null
                        Composite {} [layout=org.eclipse.e4.ui.workbench.renderers.swt.SashLayout@419a1073]@986112
                             Style: LEFT_TO_RIGHT 
                             Bounds: Rectangle {0, 0, 1719, 1428}
                             Layout: org.eclipse.e4.ui.workbench.renderers.swt.SashLayout@419a1073
                             LayoutData: null
                            CTabFolder {} [layout=org.eclipse.swt.custom.CTabFolderLayout@7aa5596f]@663188
                                 Style: MULTI | TOP | BORDER | NO_REDRAW_RESIZE | LEFT_TO_RIGHT | DOUBLE_BUFFERED 
                                 Bounds: Rectangle {579, 1153, 1140, 275}
                                 Layout: org.eclipse.swt.custom.CTabFolderLayout@7aa5596f
                                 LayoutData: null
                                Composite {} [layout=FillLayout {type=SWT.HORIZONTAL}]@664042
                                     Style: LEFT_TO_RIGHT 
                                     Bounds: Rectangle {10, 26, 1120, 238}
                                     Layout: FillLayout {type=SWT.HORIZONTAL}
                                     LayoutData: null
                                    ContributedPartRenderer$1 {} [layout=FillLayout {type=SWT.VERTICAL}]@598508
                                         Style: LEFT_TO_RIGHT 
                                         Bounds: Rectangle {0, 0, 1120, 238}
                                         Layout: FillLayout {type=SWT.VERTICAL}
                                         LayoutData: null
                                        Composite {} [layout=FillLayout {type=SWT.HORIZONTAL}]@1188326
                                             Style: LEFT_TO_RIGHT 
                                             Bounds: Rectangle {0, 0, 1120, 238}
                                             Layout: FillLayout {type=SWT.HORIZONTAL}
                                             LayoutData: null
                                            Composite {} [layout=GridLayout {makeColumnsEqualWidth=true horizontalSpacing=5 verticalSpacing=10}]@1776752
                                                 Style: LEFT_TO_RIGHT 
                                                 Bounds: Rectangle {0, 0, 1120, 238}
                                                 Layout: GridLayout {makeColumnsEqualWidth=true horizontalSpacing=5 verticalSpacing=10}
                                                 LayoutData: null

复现问题的示例代码

@Override
public void createPartControl(Composite parent) {
    Composite panel = new Composite(parent, 0);
    panel.setLayout(new FillLayout());
    viewer = new TreeViewer(panel);
    viewer.setContentProvider(new ITreeContentProvider() {
        @Override
        public Object[] getChildren(Object parentElement) {
            return new Object[0];
        }
        @Override
        public Object getParent(Object element) {
            return null;
        }
        @Override
        public boolean hasChildren(Object element) {
            return false;
        }
        @Override
        public Object[] getElements(Object inputElement) {
            if(inputElement instanceof Integer[]) {
                return (Object[]) inputElement;
            }
            return new Object[0];
        }
    });
        
    final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
    viewerColumn.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            cell.setText(cell.getElement().toString());
        }
    });
    final TreeColumn column = viewerColumn.getColumn();
    column.setText("HEADER");
    column.setWidth(150);
        
    Integer[] content = new Integer[] {1,2,3,4,5,6,7,8,9,0};
    viewer.setInput(content);
    viewer.getTree().setHeaderVisible(true);
}

关键发现

  • 添加列后问题出现,无列时仅显示一个滚动条

请问该问题可能由什么原因导致?

内容的提问来源于stack exchange,提问作者paul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 09:29:56