Retarget Action and Handler [message #328711] |
Mon, 02 June 2008 12:10  |
Eclipse User |
|
|
|
Hi all,
we have to use retarget actions (cut, copy, etc.) from ActionFactory in
the ActionBarAdvisor of our Application for several reason. Until know
we registered a global action handler through
IViewSite.getActionBars().setGlobalActionHandler() and everything works
as expected (e.g. enablement of 'cut' in the main toolbar).
Now I want to use the handler service to activate my handler, because of
an embedded control that runs either in a view or in a dialog. So I take
the handler service from IViewSite.getService() and give to the embedded
control which activates the handler (e.g. for cut). In the local context
menu of the embedded control a command contribution item is used to add
cut, copy, etc. and it works as expected, but in the main menu and the
main toolbar the enablement state of the retarget actions does not change.
What is right way to use retarget actions with handlers?
TIA,
Marco
|
|
|
|
|
Re: Retarget Action and Handler [message #329140 is a reply to message #329034] |
Fri, 13 June 2008 12:58  |
Eclipse User |
|
|
|
Marco Lehmann wrote:
> Hello Paul,
>
> that's a pity. After some research, a wrapped (via delegate)
> org.eclipse.ui.internal.actions.CommandAction did the trick.
> Is there hope for better "legacy" support?
if someone writes it, sure :-) But while there is support on the
command side for dealing with actions, there is limited opportunity to
do the same thing in the action code (it is much older, and hence more
stable/brittle).
There's hope for migration off of the legacy dependencies, for example
in 3.4 the WorkbenchActionBuilder doesn't use the RetargetActions from
ActionFactory (which remain available in ActionFactory for API reasons).
Instead a CommandContributionItem is used for most of the
RetargetAction menu items (like cut, copy, paste, print, etc), which
responds to the command enabled state (where it is a true handler or an
action wrapped in a handler-bridge). All that to say
CommandContributionItems work with actions and handlers, but
RetargetActions don't work nearly as well with commands.
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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
|
Powered by
FUDForum. Page generated in 0.03066 seconds