Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Reusing a propertyTester outside expressions
Reusing a propertyTester outside expressions [message #333264] Tue, 02 December 2008 16:44 Go to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Hi,

is there a way / a common pattern for the following scenario:

I have defined a (EMF-)Object (basically a Bean with several getters and
setters).
Also I have defined a propertyTester which evaluates several of the
bean's properties and then returns a derived flag depending on the
properties' values. This works nicely if the propertyTester is used in
command handler enablement expressions.

Now I want to create a view including a TableViewer which lists several
of those objects and I want to use an italic font, if the propertyTester
evaluates to true. So far, I have duplicated the evaluation code for the
tester to the LabelProvider of the TableViewer to return the appropriate
font. I just wondered, if there is a way of calling the propertyTester
instead, such that I could write

public Font getFont(Object element) {
if ( callToPropertyTester(element) ) {
return italicFont;
}
return JFaceResources.getDefaultFont();
}

Thanks for any hint.

Cheers,
Stefan
Re: Reusing a propertyTester outside expressions [message #333296 is a reply to message #333264] Wed, 03 December 2008 15:29 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you provide the property tester, you could simply do a new
MyPT().test(object, other, information)

(caching the MyPT instance if necessary).

To use it the exact same way as used in the IEvaluationService, you
would have to do something like RegistryPageContributor. Check out:

org.eclipse.ui.internal.dialogs.RegistryPageContributor.init ializeEnablement(IConfigurationElement)
org.eclipse.ui.internal.dialogs.RegistryPageContributor.fail sEnablement(Object)

Property testers are not generally provided as part of the programmatic
expressions API because you can simply write a subclass of
org.eclipse.core.expressions.Expression

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:MultiPageEditorPart with Tree page loses context menu on page change
Next Topic:Eclipse Key Bindings
Goto Forum:
  


Current Time: Thu Apr 25 01:24:45 GMT 2024

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

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

Back to the top