Search code examples
swteclipse-rcpjface

Is MultiColumn- explorer widget available in swt?


As windows provide to view multiple files in column as i attached in the image. Is there any SWT Widget available to display/arrange objects in multi column way similar to windows?

I have already used "Row layout(SWT.Vertical)" but i am facing some performance issue while painting if it has more than 2000+ objects.

While windows explorer doesn't have this kind of performance issue if it has more than 6000 data.

I can't use table viewer as it has each row as one object, but in my requirement I need to have object in each cell

Do let me know if any in-built widget is available in JFace/SWT for multi column view explorer to arrange objects.

Thanks

enter image description here


Solution

  • I didn't able to find direct JFace/SWT widget for this requirement. May be others senior members can give pointers.

    For your requirement Nebula Gallery Widget NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT, as written in its Javadoc

    Code goes below :

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

    Output :

    enter image description here