Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Eclipse 3.3 commands and property testers
Eclipse 3.3 commands and property testers [message #466222] Mon, 16 April 2007 17:20 Go to next message
Christopher Hammack is currently offline Christopher HammackFriend
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 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Re: Eclipse 3.3 commands and property testers [message #466390 is a reply to message #466222] Wed, 18 April 2007 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dc.schneid.googlemail.com

Hi,

sorry, this is a bit off topic, but I'm thrilled to hear someone successfully works with IElementUpdater. Have you, by any chance, also manipulated toggle states?

I'm asking because I tried and came across this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=180503

I was wondering wether you found a way to make it work, that is to have the UI toggle state and model state consistent.

Thanks,
David
Re: Eclipse 3.3 commands and property testers [message #466472 is a reply to message #466390] Thu, 19 April 2007 14:43 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Previous Topic:eclipse instance location
Next Topic:Key bindings to dialog controls?
Goto Forum:
  


Current Time: Thu Apr 25 15:23:48 GMT 2024

Powered by FUDForum. Page generated in 0.03009 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top