Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer and SelectionProvider
TreeViewer and SelectionProvider [message #8882] Thu, 21 May 2009 10:38 Go to next message
Rudi Missing name is currently offline Rudi Missing nameFriend
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
Re: TreeViewer and SelectionProvider [message #8903 is a reply to message #8882] Thu, 21 May 2009 12:00 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
Replied in rcp newsgroup.


Rudi,
Please avoid posting to multiple newsgroups. If you have to, then
do it in the same message. So that replies are sent to all the newsgroups.

- Prakash

---
http://blog.eclipse-tips.com
Re: TreeViewer and SelectionProvider [message #9047 is a reply to message #8903] Fri, 22 May 2009 15:08 Go to previous messageGo to next message
Rudi Missing name is currently offline Rudi Missing nameFriend
Messages: 17
Registered: July 2009
Junior Member
Hi Prakash,

sorry for posting this twice, but I thought that it augments the
probability of a reply ;) I didn't know that it is possible to post a
message in multiple newgroups. Next time I'll look for this.

Thank you for your reply on the other post.
Rudi
Re: TreeViewer and SelectionProvider [message #9190 is a reply to message #9047] Mon, 25 May 2009 21:38 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

haha, no, don't look for it. Pick the best newsgroup and post only once if
you can.

--
Best Regards,

Wim Jongman
http://www.remainsoftware.com
http://www.industrial-tsi.com
"Rudi " <rudi.steiner@gmail.com> wrote in message
news:3254fcfe855da395fe3767dc8a83a178$1@www.eclipse.org...
> Hi Prakash,
>
> sorry for posting this twice, but I thought that it augments the
> probability of a reply ;) I didn't know that it is possible to post a
> message in multiple newgroups. Next time I'll look for this.
>
> Thank you for your reply on the other post.
> Rudi
>
Previous Topic:OwnerDrawLabelProvider -> set other things than text
Next Topic:Opening A View Programatically
Goto Forum:
  


Current Time: Fri Apr 19 20:14:50 GMT 2024

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

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

Back to the top