|
|
Re: Dynamic ContributionItem menus keyboard Accelerators [message #513354 is a reply to message #513241] |
Tue, 09 February 2010 20:16 |
ali Mising name Messages: 38 Registered: July 2009 |
Member |
|
|
Hi PW,
Thanks for the quick reply. I agree that that Commands and Handlers seem to be the best way of doing this, unfortunately I have been unable to find a way to determine which Shell / IworkbenchWindow each Command is associated with. I need this information to properly enable and disable the menu and toolbar items. I am aware of how to use the HandlerUtil class to determine the active IworkbenchWindow and validate ALL instances of handled commands, but I am trying to avoid this solution because I'd like the menu and toolbar items to be correctly validated on background windows based on the state of those windows and not just the state of the active window.
I'm unsure if this is clear. For example, the Eclipse IDE uses the Commands and Handlers in many of it's toolbar contributions. Try opening two windows for the same workspace, one with an open java editor and one with no open editors. Note that the toolbar enablement of all background windows incorrectly reflects the state of the active window. This is fine from a usability point of view because the enablement is corrected when the inactive windows become active, but I don't think it's a good practice or promoted a good user experience. Note that the save button behaves correctly because it is an embedded ControlContributionItem. I'm intending to contribute many menu items in my project and I'd rather avoid placing many of these heavyweight controls in my menus.
I've read the links you sent me, but I'm still not sure how to solve this issue (sorry if I missed something).
I'd just like to be able to menu and toolbar items that can be properly validated (enabled / disabled) to their parent window, without that window needing to be active.
And, if I am forced to use dynamic ContributionItems, I'm in need of a way to associate keyboard accelerators to the menu items.
Any advice would be greatly appreciated.
Thanks.
|
|
|
Re: Dynamic ContributionItem menus keyboard Accelerators [message #513568 is a reply to message #513354] |
Wed, 10 February 2010 10:28 |
|
ali wrote:
> Hi PW,
> ALL instances of handled commands, but I am trying to avoid this
> solution because I'd like the menu and toolbar items to be correctly
> validated on background windows based on the state of those windows and
> not just the state of the active window.
I understand. Currently, the background window toolitem state won't
(shouldn't) change based on what is happening in the active window, but
it won't update either if it was supposed to change.
> behaves correctly because it is an embedded ControlContributionItem. I'm
> intending to contribute many menu items in my project and I'd rather
> avoid placing many of these heavyweight controls in my menus.
You cannot contribute controls to menus, and the problem doesn't show up
in menus anyway, only tool bars because they're visible all the time.
> And, if I am forced to use dynamic ContributionItems, I'm in need of a
> way to associate keyboard accelerators to the menu items.
It wouldn't be a dynamic item, and ActionContributionItem works (Actions
are tightly coupled MVC, and like the Save tool item are tied to
whatever instantiated them). They're bound to their instantiating
window in their ActionBarAdvisor ... if you want to tightly bind actions
to your window only, you would probably still do it in there.
register(IAction) will also make your action available to the command
system as an ActionHandler (if you define a command and set the
actionDefinitionId on your Action).
You could then link your command to your keybindings.
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Powered by
FUDForum. Page generated in 0.03368 seconds