Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » enabling menu items dynamically
enabling menu items dynamically [message #466606] Sun, 22 April 2007 15:53 Go to next message
Eclipse UserFriend
Originally posted by: mash_909.yahoo.co.uk

I have what I would think is a fairly standard use case.
I would like menu and toolbar items to become enabled / disabled in
response to user selections (ie in a TreeViewer).

I Googled round but could find nothing specific on this. The best way I
could think of doing it was to make my ActionBarAdvisor subclass
implement ISelectionListener. The logic being that the ActionBarAdvisor
subclass has references to all menu items and can therefore easily
enable/disable them with calls to setEnabled(boolean).

This works but it seems like the wrong way to do this. Is there a
better way of doing this?

thanks
Matt
Re: enabling menu items dynamically [message #466774 is a reply to message #466606] Tue, 24 April 2007 14:08 Go to previous messageGo to next message
Eclipse UserFriend
Matt Hegarty wrote:
> I have what I would think is a fairly standard use case.
> I would like menu and toolbar items to become enabled / disabled in
> response to user selections (ie in a TreeViewer).

Actions provided through XML (actionSets, editorActions, viewActions,
popupMenus) and command handlers provided through
org.eclipse.ui.handlers have XML ways to specify their enablement,
almost always tied to the current selection. They are also implemented
as a flavour of IActionDelegate, and so can update their enablement in
their selectionChanged(*) method.

If you are contributing a JFace Action, you have to update the action
enabled state yourself (using a combination of a selection listener and
IAction#setEnabled(*)).

PW
Re: enabling menu items dynamically [message #466979 is a reply to message #466774] Thu, 26 April 2007 16:41 Go to previous message
Eclipse UserFriend
Originally posted by: mash_909.yahoo.co.uk

Thanks - this makes much more sense.

Paul Webster wrote:
> Matt Hegarty wrote:
>> I have what I would think is a fairly standard use case.
>> I would like menu and toolbar items to become enabled / disabled in
>> response to user selections (ie in a TreeViewer).
>
> Actions provided through XML (actionSets, editorActions, viewActions,
> popupMenus) and command handlers provided through
> org.eclipse.ui.handlers have XML ways to specify their enablement,
> almost always tied to the current selection. They are also implemented
> as a flavour of IActionDelegate, and so can update their enablement in
> their selectionChanged(*) method.
>
> If you are contributing a JFace Action, you have to update the action
> enabled state yourself (using a combination of a selection listener and
> IAction#setEnabled(*)).
>
> PW
Previous Topic:How to get view CTabFolder reference ?
Next Topic:How to view the outline and property sheet views in an RCP application?
Goto Forum:
  


Current Time: Sun May 18 01:00:10 EDT 2025

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

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

Back to the top