treeviewer selects first item in tree on open [message #491278] |
Tue, 13 October 2009 22:40 |
Natasha D'Silva Messages: 25 Registered: July 2009 |
Junior Member |
|
|
I have a View that uses a sashform with a treeviewer/textviewer as its control.
The treeviewer has columns, and I notice that when the view is activated, the first item in the view is selected. If I click anywhere in the treeviewer, even in an empty row, the first item is still selected.
Debugging has shown that just clicking anywhere in the treeviewer generates a selection event. I have looked at other eclipse views with a treeviewer with columns and this does not happen. I am wondering if there is a special style bit I am missing on my tree.
Does it matter when I populate the viewer with model elements by calling setInput for the first time?
Here is the code to create the view:
fSashForm = new SashForm(parent, SWT.VERTICAL);
TreeViewer viewer = new TreeViewer(fSashForm, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
// TreeViewer viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.HIDE_SELECTION | SWT.BORDER);
viewer.setContentProvider(fContentProvider);
viewer.setLabelProvider(labelProvider);
initializeActions(viewer);
viewer.getTree().setHeaderVisible(true);
viewer.getTree().setLinesVisible(true);
...setup columns..
TableLayout layout = new TableLayout();
ColumnLayoutData c0Data = new ColumnWeightData(20);
ColumnLayoutData c1Data = new ColumnWeightData(30);
ColumnLayoutData c2Data = new ColumnWeightData(50);
layout.addColumnData(c0Data);
layout.addColumnData(c1Data);
layout.addColumnData(c2Data);
viewer.getTree().setLayout(layout);
viewer.setColumnProperties(COLUMN_PROPERTIES);
viewer.addSelectionChangedListener(getSelectionChangedListener());
viewer.addDoubleClickListener(this);
fDetailText = new TextViewer(fSashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
fDetailText.setEditable(false);
fDetailText.setDocument(new Document());
fDetailText.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
fSashForm.setWeights(new int[]{85,15});
fSashForm.layout(true);
Experimenting with SWT.HIDE_SELECTION did not work, which is expected since its supposed to be for tables only.
Any help/tips would be appreciated,
thanks.
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04126 seconds