JFace TreeView 显示 2 个垂直滚动条

问题描述 投票:0回答:2

我正在升级旧的 RCP 应用程序以使用 eclipse 2023-06。有 2 个视图显示双垂直滚动条。两者都使用

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));

我尝试仅使用

TreeViewer
参数创建
body
,但没有任何变化。

如果我删除标题,2 个滚动条的高度相同。

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);
}

(创建此示例时,我注意到添加一列后出现问题。没有特定列,只显示一个滚动条)

可能是什么原因造成的?

eclipse swt eclipse-rcp jface
2个回答
0
投票

我使用 2 个显示器:笔记本电脑和 32 英寸屏幕。第一个缩放至 100%,第二个缩放至 150%。

如果我将应用程序从第二个移动到第一个,应用程序将正确呈现。

我更改了 Windows 配置,将屏幕 2 缩放为 100%,并且应用程序在两个屏幕上都能正确呈现。

这解释了狡猾的渲染,但不确定如何为部署应用程序的所有不同工作站处理此问题...


-1
投票

我能够使用 Instagram 上的 Recoverykey1 服务监视我丈夫的 Facebook 帐户,我是通过一位朋友把他介绍给我的,他是一位非常温柔、善良、谦虚的黑客,如果你想监视任何媒体,请不要忘记联系 [电子邮件受保护] 或通过 WhatsApp +1(781)468-8872 向他发送消息 他非常快而且可靠

© www.soinside.com 2019 - 2024. All rights reserved.