Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Tree hides first item when header gets visible
SWT Tree hides first item when header gets visible [message #1466047] Sat, 08 November 2014 23:03 Go to next message
Donat Csikos is currently offline Donat CsikosFriend
Messages: 14
Registered: February 2012
Junior Member
Hi Everybody,

Recently I was playing around with Eclipse plug-ins and JFace viewers when I noticed something strange. I tried to create an actions which shows/hides the header of a table tree, but the header made the first tree item hidden.

I tried fixing it with redrawing and refreshing the controls but they seemed to have no effect. I created a small example how to reproduce it (below) to let you guys have a look. I would any appreciate any comments on this.

Cheers!

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;

public class TreeHeaderShowExample {
    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell();
        
        shell.setLayout(new GridLayout(1, false));
        
        Button showHeaderButton = new Button(shell, 0);
        showHeaderButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        showHeaderButton.setText("Toggle header");
        
        final Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
        
        TreeColumn column = new TreeColumn(tree, SWT.NONE);
        column.setWidth(200);;
        column.setText("SampleText");
        
        TreeItem item = new TreeItem(tree, SWT.NONE, 0);
        item.setText("first");
        item = new TreeItem(tree, SWT.NONE);
        item.setText("second");
        
        showHeaderButton.addSelectionListener(new SelectionAdapter() {
            
            @Override
            public void widgetSelected(SelectionEvent e) {
                tree.setHeaderVisible(!tree.getHeaderVisible());
            }
        });
        
        shell.open();
        while (!shell.isDisposed()) {
            if (display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
}
Re: SWT Tree hides first item when header gets visible [message #1588063 is a reply to message #1466047] Tue, 27 January 2015 18:34 Go to previous messageGo to next message
Jim Klo is currently offline Jim KloFriend
Messages: 49
Registered: September 2012
Member
You don't mention your runtime environment, but I suspect this is your issue? https://bugs.eclipse.org/bugs/show_bug.cgi?id=446534
Re: SWT Tree hides first item when header gets visible [message #1622095 is a reply to message #1588063] Wed, 18 February 2015 08:57 Go to previous message
Donat Csikos is currently offline Donat CsikosFriend
Messages: 14
Registered: February 2012
Junior Member
Hi Jim,

I believe this is the very same problem as mine. Thank you very much!
Cheers,


Donat
Previous Topic:Progress Bar with Cancel Button using SWT implementation issue
Next Topic:DND, multiple Transfer classes
Goto Forum:
  


Current Time: Tue Mar 19 07:43:47 GMT 2024

Powered by FUDForum. Page generated in 0.02066 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top