TreeViewer and SelectionProvider [message #8882] |
Thu, 21 May 2009 10:38 |
Rudi Missing name Messages: 17 Registered: July 2009 |
Junior Member |
|
|
Hello,
I have the following problem. In my app. I use the OutlineView by adding
this to my IPerspectiveFactory:
layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.LEFT, 0.2f,
layout.getEditorArea());
The Outline I provide by extending
org.eclipse.ui.views.contentoutline.ContentOutlinePage. In createControl()
I configure the TreeViewer and set it as a SelectionProvider
@Override
public void createControl(Composite parent) {
super.createControl(parent);
TreeViewer viewer = getTreeViewer();
viewer.setContentProvider(new ContentProvider());
viewer.setLabelProvider(new LabelProvider());
viewer.setSorter(new OutlineViewerSorter());
viewer.setInput(editor.getPlan());
getSite().setSelectionProvider(viewer);
}
Depending on the selection in the OutlineView, I show some commands in the
toolbar of the OutlineView. I implemented this by using the extensionpoint
org.eclipse.ui.menus, adding a menuContribution. To this menucontribution
a added a command and to this command i added a visibleWhen which checks
the current selection. Everything works fine so far.
The problem is, that the selection from the OutlineView is not cleaned up
when the editor is closed and the corresponding instance of the
OutlinePage is disposed. The selection is still available and therefore
the command in the toolbar of the outlineView is still visible. If I click
on the command, the selection is also available in the commandhandler.
Shouldn't the TreeViewer or rather the underlying tree reset the selection
when it is disposed?
I tried to reset the selection in the dispose()-Method of the OutlinePage
but I can't find a way to do this. I expected something like
ISelectionService selectionService =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSele ctionService();
selectionService.setSelection(null);
Could you please give me a hint?
Thank you in advance,
Rudi
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03066 seconds