|
|
|
Re: Parameters provided to IElementUpdater.updateElement() [message #333001 is a reply to message #332994] |
Wed, 19 November 2008 09:37 |
Daniel Krügler Messages: 853 Registered: July 2009 |
Senior Member |
|
|
Marcel Hoetter wrote:
>> You should have a look at the documentation of UIElement, which
>> is one of the function parameters. The documentation of it's method
>> getServiceLocator() says:
>
> Well, i did have a look at the documentation of IElementUpdater, but...
>
> > The documentation of it's Map parameter says only that it contains all
> > parameters registered with the callback, so this seems of little help
> here.
>
> ...exactly. How and where does one "register parameters with the callback"?
AFAIK you can add parameters via the <parameter> section of the
org.eclipse.ui.menus ext.pt (child of <command>). It should also
be possible to add parameters programmatically (see below).
> Regarding the UIElement and it's getServiceLocator() method:
>
> > I suggest using the official route: Retrieve the IWorkbenchPartSite
> > from the UIElement#getServiceLocator() and you are done.
>
> Thanks for this input! However, I tried this and obviously the
> IServiceLocator returned by this method does not have an
> IWorkbenchPartSite in it's scope. In other words..
>
> public void updateElement(final UIElement element, final Map parameters) {
> final IWorkbenchPartSite partSite =
> (IWorkbenchPartSite)element.getServiceLocator()
> .getService(IWorkbenchPartSite.class);
> ...
> }
>
> ...only returns null. (Or am i doing something wrong here?)
Interesting, I hadn't expected that. I found another example
http://kickjava.com/src/org/eclipse/ui/internal/handlers/Tog gleCoolbarHandler.java.htm
which seems to imply that you need to add the IWorkbenchPartSite
in your AbstractHandler#execute method (untested):
public Object JavaDoc execute(ExecutionEvent event) throws
ExecutionException {
final IWorkbenchSite activeSite = HandlerUtil
.getActiveSiteChecked(event);
[...]
Map filter = new HashMap();
filter.put(IServiceScopes.PARTSITE_SCOPE, activeSite);
commandService.refreshElements(event.getCommand().getId(), filter);
}
HTH,
Daniel
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03796 seconds