Action enablement in Views [message #202839] |
Fri, 27 February 2004 02:58  |
Eclipse User |
|
|
|
Originally posted by: sreejaak.yahoo.com
Hi,
I want an action enablement to be based on a selection of the tree viewer
in the perspective. Is it necessary that the selection class has to be an
element class. E.g., IFile, IProject.? Or can I have any other custom
classes?
Do I need to implement any listeners in any of the concerned classes or
can I do it just by putting the action enablement entry into plugin.xml?
I had posted a similar query, didn't get a response so far. Meanwhile I
happened to read that the selection class should be an element class.. Is
this true? If so, why such a restriction? Sorry if the question is a
repetition..
TIA!
Sree
|
|
|
|
|
|
Re: Action enablement in Views [message #203888 is a reply to message #202855] |
Mon, 01 March 2004 02:37  |
Eclipse User |
|
|
|
Originally posted by: sreejaak.yahoo.com
Thanks Dan & Rich for providing the leads. I checked out the options but
none worked for me.
Browsed the Eclipse source code and found that the treeViewer was set as
the SelectionProvider for the ViewSite of the ViewPart object. Without
this, the TreeViewer will not communicate the selection change to the
actions. So in the createPartControl method of my ViewPart-extended class,
I added the following line of code:
getSite().setSelectionProvider(treeViewer);
And it started enabling my menu and toolbar actions based on the selection
made in the treeViewer of my view, according to the "enablement" specified
in plugin.xml
I hope I have struck the hammer on the right nail! Veterans please correct
me if I have made any mistakes.. Hope this helps any others who get stuck
on "enablement" of actions based on objects selected in Editors or Views...
Cheers!
Sree
|
|
|
Powered by
FUDForum. Page generated in 0.04694 seconds