Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Action enablement in Views
Action enablement in Views [message #202839] Fri, 27 February 2004 02:58 Go to next message
Eclipse UserFriend
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 #202855 is a reply to message #202839] Fri, 27 February 2004 04:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sreejaak.yahoo.com

Hi,
Might be a basic question to ask... How do the actions get notified when
the selection in a view changes? I think my action buttons are not getting
notified when the selection in my view changes.. Is there any Eclipse
documentation or examples where I can find relevant information? Please
advise.
Thanks!
Sree

Sree wrote:

> 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 #202973 is a reply to message #202855] Fri, 27 February 2004 08:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

See:

http://www.eclipse.org/articles/Article-action-contribution/ Contributing%20Actions%20to%20the%20Eclipse%20Workbench.html

The articles page in Eclipse corner has many interesting articles on
different topics. you should browse that and see what else may be of
interest to you.



--
Thanks, Rich Kulp

Re: Action enablement in Views [message #203173 is a reply to message #202855] Fri, 27 February 2004 13:17 Go to previous messageGo to next message
Eclipse UserFriend
On 2/27/2004, 1:12:54 AM, sreejaak@yahoo.com (Sree) wrote regarding Re:
Action enablement in Views:


> Hi,
> Might be a basic question to ask... How do the actions get notified when
> the selection in a view changes? I think my action buttons are not
getting
> notified when the selection in my view changes.. Is there any Eclipse
> documentation or examples where I can find relevant information? Please
> advise.
> Thanks!
> Sree

I copied what I found in the Java Browsing views ( JDT ).

IIRC you :
o have your view implement IselectionListener
o In your view's setSite method you add
site.getPage().addSelectionListener( this )
o In your view's dispose method add
getSite().getPage().removeSelectionListener( this )
o Fill in your view's selectionChanged method as you
see fit.

-- Dan S
Re: Action enablement in Views [message #203888 is a reply to message #202855] Mon, 01 March 2004 02:37 Go to previous message
Eclipse UserFriend
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
Previous Topic:is the baseTOCS preference gone?
Next Topic:Getting the workspace path
Goto Forum:
  


Current Time: Sat Jun 07 15:52:41 EDT 2025

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

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

Back to the top