getGlobalActionHandler [message #266361] |
Tue, 10 August 2004 21:15  |
Eclipse User |
|
|
|
Hello,
How do I get a reference programatically to the Workbench Actions that I
contributed to an org.eclipse.ui.actionSets?
IActionBars has a method that seems to be the right way:
getGlobalActionHandler
public IAction getGlobalActionHandler(String actionId)Returns the global
action handler for the action with the given id.
Parameters:
actionId - an action id declared in the registry
Returns:
an action handler which implements the action id, or null if none is
registered
See Also:
IWorkbenchActionConstants, setGlobalActionHandler
To get a reference to an IActionBars I had to downcast IWorkbenchPage to
WorkbenchPage (which doesn't seem right).
private IAction getGlobalActionHandler(String string) {
return
((WorkbenchPage)UIPlugin.getDefault().getWorkbench().getActi veWorkbenchWindo
w().getActivePage())
.getActionBars().getGlobalActionHandler(string);
}
Then: getActionBars() returns a WWinActionBars.
the WWinActionBars implementation of getGlobalActionHandler(string) returns
null. (is not implemented).
Obviously I am looking in the wrong place.
Thanks,
Arturo.
|
|
|
|
Re: getGlobalActionHandler [message #266509 is a reply to message #266488] |
Wed, 11 August 2004 12:27  |
Eclipse User |
|
|
|
Hi,
Here is something that worked... but it is so kludgy that I am sure that I
am still looking at the wrong place.
The same action that I created before... now I need to manually register it
with some global action handler...
I found some code in WorkbenchWindow that registers the Action... so I
copied it here:
NOTE: this seems wrong (if somebody knows a better way to do this, please
advise)...
IWorkbenchCommandSupport commandSupport =
Workbench.getInstance().getCommandSupport();
IHandler handler = new ActionHandler(refresh);
Shell shell = getViewer().getControl().getShell();
String actionDefinitionId = refresh.getActionDefinitionId();
HandlerSubmission handlerSubmission = new HandlerSubmission(null,
shell, null, actionDefinitionId, handler, Priority.LEGACY);
commandSupport.addHandlerSubmission(handlerSubmission);
Arturo.
"Arturo" <arturo@pragmafs.com> wrote in message
news:cfdd7a$6o0$1@eclipse.org...
> Hi,
>
> Here is another wrong place where I have looked:
>
> instantiated an IAction programatically (And added it to a ContextMenu)
> created a corresponding command in the plugin.xml
(org.eclipse.ui.commands)
> in the constructor for the Action added the instruction:
> setActionDefinitionId("com.pragmafs.ui.tasks.refresh");
>
> with the same definitionId specified in the command.
>
> Now, I can see the key binding text in the context menu. But it is still
> not activated when I hit the corresponding keys.
>
>
> Thanks,
>
> Arturo.
>
>
>
> "Arturo" <arturo@pragmafs.com> wrote in message
> news:cfbrg8$spe$1@eclipse.org...
> > Hello,
> >
> > How do I get a reference programatically to the Workbench Actions that I
> > contributed to an org.eclipse.ui.actionSets?
> >
> > IActionBars has a method that seems to be the right way:
> > getGlobalActionHandler
> > public IAction getGlobalActionHandler(String actionId)Returns the global
> > action handler for the action with the given id.
> >
> > Parameters:
> > actionId - an action id declared in the registry
> > Returns:
> > an action handler which implements the action id, or null if none is
> > registered
> > See Also:
> > IWorkbenchActionConstants, setGlobalActionHandler
> >
> > To get a reference to an IActionBars I had to downcast IWorkbenchPage to
> > WorkbenchPage (which doesn't seem right).
> >
> > private IAction getGlobalActionHandler(String string) {
> > return
> >
>
((WorkbenchPage)UIPlugin.getDefault().getWorkbench().getActi veWorkbenchWindo
> > w().getActivePage())
> > .getActionBars().getGlobalActionHandler(string);
> > }
> >
> >
> > Then: getActionBars() returns a WWinActionBars.
> >
> > the WWinActionBars implementation of getGlobalActionHandler(string)
> returns
> > null. (is not implemented).
> >
> >
> > Obviously I am looking in the wrong place.
> >
> >
> > Thanks,
> >
> >
> > Arturo.
> >
> >
> >
> >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03600 seconds