|
Re: Property testers Versus Source Providers [message #655138 is a reply to message #655041] |
Fri, 18 February 2011 13:26 |
|
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
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.02048 seconds