SWT Tree hides first item when header gets visible [message #1466047] |
Sat, 08 November 2014 23:03 |
Donat Csikos 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();
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02066 seconds