是否可以在swt中使用MultiColumn- explorer小部件?

问题描述 投票:1回答:1

正如我在图像中附加的那样,窗口提供了查看列中的多个文件。是否有任何SWT Widget可用于以多列方式显示/排列对象,类似于Windows?

我已经使用了“行布局(SWT.Vertical)”,但是如果它有超过2000个对象,我在绘画时会遇到一些性能问题。

虽然Windows资源管理器有超过6000个数据,但它没有这种性能问题。

我不能使用表查看器,因为它将每行作为一个对象,但在我的要求中,我需要在每个单元格中有对象

如果JFace / SWT中有任何内置窗口小部件可用于多列视图资源管理器来安排对象,请告诉我。

谢谢

enter image description here

swt eclipse-rcp jface
1个回答
1
投票

我无法为此要求找到直接的JFace / SWT小部件。可能是其他高级会员可以指点。

根据您的要求Nebula Gallery Widget NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT, as written in its Javadoc

代码如下:

public class Test {
    public static void main(String[] args) {
        Display display = new Display();
        Image itemImage = new Image(display, Program.findProgram("jpg").getImageData()); //$NON-NLS-1$
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());

        Gallery gallery = new Gallery(shell, SWT.H_SCROLL | SWT.MULTI | SWT.VIRTUAL);

        // Renderers
        NoGroupRenderer gr = new NoGroupRenderer();
        gr.setMinMargin(2);
        gr.setItemHeight(20);
        gr.setItemWidth(100);
        gr.setAutoMargin(true);
        gallery.setGroupRenderer(gr);

        ListItemRenderer ir = new ListItemRenderer();
        gallery.setItemRenderer(ir);

        GalleryItem group = new GalleryItem(gallery, SWT.NONE);

        for (int i = 0; i < 20000; i++) {
            GalleryItem item = new GalleryItem(group, SWT.NONE);
            if (itemImage != null) {
                item.setImage(itemImage);
            }
            item.setText("Item " + i); //$NON-NLS-1$
        }

        shell.pack();
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}

输出:

enter image description here

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