Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Eclipse Commands Infrastructure

On Thursday March 24 2005 04:50 pm, Scott Delap wrote:
> Our code doesn't take into account defining a Command object for each
> action. This causes and error to be logged the first time isVisible() is
> called. What is the proper way to define command for dynamically created
> actions? It seems when I attempt to lookup a command a CommandWrapper

This should only happen if you define an actionDefinitionId for the 
contribution item.  If it is happening in another case, then this is a bug.

An actionDefinitionId is only intended to link with the command mechanism (or 
the legacy "actionDefinition" mechanism which commands replace).  If an 
actionDefinitionId is being defined when there is no such command, then this 
is a bug in your code.  Not a severe bug, but one that results in the logged 
warning.

The warning occurs because the actionDefinitionId is used by the capabilities 
mechanism to provide filtering, and also provide key bindings.  It is easy 
for programmers to mis-type the definition ID, and so the warning exists to 
notify them when they have made such a mistake.  It is also intended to point 
out to developers when they are using the actionDefinitionId for no good 
reason.


> Finally if anyone could point out any examples in other parts of Eclipse
> (the jdt possibly?) where actions are being dynamically created it would be
> appreciated.  I'd like to rewrite the mess I've inherited in a more correct
> manner.

I've always found Platform/Debug code ("org.eclipse.debug.ui", for example) to 
be a good example of dynamic menu contributions through XML.  However, I 
don't know of any examples of dynamic menus contributed through Java.



cheers,
d.


Back to the top