Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Property testers Versus Source Providers(How should menu contributions be enabled/disabled)
Property testers Versus Source Providers [message #655041] Fri, 18 February 2011 07:09 Go to next message
Saurabh Mising name is currently offline Saurabh Mising nameFriend
Messages: 21
Registered: October 2010
Junior Member
I find that Menu contributions can be enabled with property testers as well as with Source Providers. What is the difference in enabling commands with these two techniques?
Which one is a better way to enable /disable commands?
Re: Property testers Versus Source Providers [message #655138 is a reply to message #655041] Fri, 18 February 2011 13:26 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 02/18/2011 02:09 AM, Saurabh wrote:
> I find that Menu contributions can be enabled with property testers as
> well as with Source Providers. What is the difference in enabling
> commands with these two techniques?
> Which one is a better way to enable /disable commands?


Source providers provide variables to the system. It's event driven,
and variables are available in visibleWhen,enabledWhen,activeWhen (they
have a priority). They're also available from the
IEvaluationContext/ExecutionEvent in the handlers.

The active handler controls the enabled state of its command, and has
access to the IEvaluationContext/ExecutionEvent. It does not have
access to properties, except when used as part of an enabledWhen clause
for that handler.

properties can be used in the core expressions, though the property
testers. But they are not event drive. If a property changes, some
external entity has to go through
org.eclipse.ui.services.IEvaluationService.requestEvaluation (String),
which will cause all core expressions that contain that property to
re-evaluate themselves.

One way to look at it: You would create a source provider to make a
variable available: ex: a Person object, or an ID Employee. You would
use a property tester to examine some aspects of the object, like a
Person's name or Employee's shift ... but a "shift" as a variable by
itself doesn't make much sense.


PW



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


Previous Topic:Icons in separate bundle
Next Topic:[Commands] Semantics of IHandlerService.activateHandler
Goto Forum:
  


Current Time: Thu Apr 25 23:55:50 GMT 2024

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

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

Back to the top