Eclipse 3.3 commands and property testers [message #466222] |
Mon, 16 April 2007 17:20 |
Christopher Hammack Messages: 1 Registered: July 2009 |
Junior Member |
|
|
I am trying to utilize the new org.eclipse.ui.menus/commands interfaces in
Eclipse 3.3m6.
I have been experimenting with the IElementUpdater interface with success
to update the labels and decorations of menus. However, I also need to
control the enablement of the menu, and so I have attempted to implement a
PropertyTester. However, no matter what I do, it appears that the
PropertyTester is never actually used.
My PropertyTester only returns true or false, but the value never seems to
actually be used for the enablement of the menu (it is always disabled).
I also inserted some println statements in there, which are never printed
to stdout.
Here is my property tester:
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="com.foo.menus.MenuPropertyTester"
id="com.foo.menus.MenuPropertyTester"
namespace="com.foo.menus"
properties="test123"
type="java.lang.Object">
</propertyTester>
</extension>
Here is my handler:
<handler
class="com.foo.menus.MenuRetrievalHandler"
commandId="com.foo.menus.bundleProductRetrieval">
<enabledWhen>
<with
variable="activeContexts">
<test
property="com.foo.menus.test123">
</test>
</with>
</enabledWhen>
</handler>
And here is the class:
public class MenuPropertyTester extends PropertyTester {
public MenuPropertyTester() {
System.out.println("!!! Constructor Called");
}
/* (non-Javadoc)
* @see
org.eclipse.core.expressions.IPropertyTester#test(java.lang. Object,
java.lang.String, java.lang.Object[], java.lang.Object)
*/
@Override
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
System.out.println("!!! test Called");
return true;
}
}
Any suggestions would be greatly appreciated!
|
|
|
Re: Eclipse 3.3 commands and property testers [message #466310 is a reply to message #466222] |
Tue, 17 April 2007 14:19 |
|
Christopher Hammack wrote:
> <extension
> point="org.eclipse.core.expressions.propertyTesters">
> <propertyTester
> class="com.foo.menus.MenuPropertyTester"
> id="com.foo.menus.MenuPropertyTester"
> namespace="com.foo.menus"
> properties="test123"
> type="java.lang.Object">
> </propertyTester>
> </extension>
>
>
> Here is my handler:
> <handler
> class="com.foo.menus.MenuRetrievalHandler"
> commandId="com.foo.menus.bundleProductRetrieval">
> <enabledWhen>
> <with
> variable="activeContexts">
> <test
> property="com.foo.menus.test123">
> </test>
> </with>
> </enabledWhen>
> </handler>
>
>
Your definitions look fine. Things I would try in order:
1) change the variable from activeContexts to activePart (I don't know
that it makes a difference, but I'd try it anyway :-)
2) See if it's just a bundle activation delay, try adding an
org.eclipse.ui.startup extension (and point it to a dummy class, not
your plugin activator class). It might be it is not loading the
property tester, although I thought it should default to true if it wasn't.
3) check your workspace logs for any errors ... <workspace>/.metadata/.log
4) If that doesn't work I would try downloading today's I build into a
temp location (I20070417-0800) and testing it from that platform. There
were a couple of bugs fixed with contexts and plugin loading in the last
2 weeks that wouldn't be in 3.3M6
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Re: Eclipse 3.3 commands and property testers [message #466472 is a reply to message #466390] |
Thu, 19 April 2007 14:43 |
|
check out org.eclipse.ui.tests ...
org.eclipse.ui.tests.menus.ToggleContextHandler and these two plugin.xml
snippets use it:
<command
categoryId="org.eclipse.ui.category.window"
defaultHandler="org.eclipse.ui.tests.menus.ToggleContextHandler "
id="org.eclipse.ui.tests.menus.toggleContext"
name="Toggle Context">
<commandParameter
id="toggleContext.contextId"
name="Context Id"
optional="false"
values="org.eclipse.ui.tests.menus.ContextIdValues">
</commandParameter>
</command>
menuContribution:
<command
commandId="org.eclipse.ui.tests.menus.toggleContext"
icon="icons/binary_co.gif"
id="toggle.test.t2"
label="Toggle Test2"
mnemonic="g"
style="toggle"
tooltip="Toggle contexts.test2">
<parameter
name="toggleContext.contextId"
value="org.eclipse.ui.menus.contexts.test2">
</parameter>
</command>
I have them in my view toolbar and the icon gets checked/unchecked.
Later,
PW
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.03009 seconds