https://wiki.eclipse.org/api.php?action=feedcontributions&user=Udo.walker.abas.de&feedformat=atomEclipsepedia - User contributions [en]2024-03-29T08:41:13ZUser contributionsMediaWiki 1.26.4https://wiki.eclipse.org/index.php?title=FAQ_What_is_a_preference_scope%3F&diff=444108FAQ What is a preference scope?2021-10-13T07:52:46Z<p>Udo.walker.abas.de: Fixed link to ProjectScope</p>
<hr />
<div>The preference service uses the notion of <i>preference scopes</i> to describe the various areas where preferences can be saved. The platform includes the following preference scopes:<br />
<br />
* <i>Configuration scope</i>. Preferences stored in this scope are shared by all workspaces that are launched using a particular configuration of Eclipse plug-ins. On a single-user installation, this serves to capture preferences that are common to all workspaces launched by that user. On a multi-user installation, these preferences are shared by all users of the configuration.<br />
<br />
* <i>Instance scope</i>. Preferences in this scope are specific to a single Eclipse workspace. The old API method <tt>getPluginPreferences</tt> on <tt>Plugin</tt> stores its preferences at this scope.<br />
<br />
* <i>Default scope</i>. This scope is not stored on disk at all but can be used to store default values for all your keys. When values are not found in other scopes, the default scope is consulted last to provide reasonable default values.<br />
<br />
* ''BundleDefaultsScope''. Similar to the default scope, these values are not written to disk. They are however read from a particular bundle's "preferences.ini" file.<br />
<br />
* <i>Project scope</i>. This scope stores values that are specific to a single project in your workspace, such as code formatter and compiler settings. Note that this scope is provided by the <tt>org.eclipse.core.resources</tt> plug-in, which is not included in the Eclipse Rich Client Platform. This scope will not exist in applications that don't explicitly include the <tt>resources</tt> plug-in.<br />
<br />
Plug-ins can also define their own preference scopes, using the <tt>org.eclipse.core.runtime.preferences</tt> extension point. If you define your own scope, you can control how and where your preferences are loaded and stored. However, for most clients, the built in scopes will be sufficient.<br />
<br />
The majority of the above scopes can be addressed programatically with a particular implementation of [http://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html IScopeContext]:<br />
*<tt>[http://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/ConfigurationScope.html ConfigurationScope]</tt><br />
*<tt>[http://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/InstanceScope.html InstanceScope]</tt><br />
*<tt>[http://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/DefaultScope.html DefaultScope]</tt><br />
*<tt>[https://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/ProjectScope.html ProjectScope]</tt><br />
<br />
== See Also: ==<br />
*[[FAQ_What_is_a_configuration%3F]]<br />
*[[FAQ_How_do_I_use_the_preference_service%3F]]<br />
<br />
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font></div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=FAQ_What_is_a_preference_scope%3F&diff=444106FAQ What is a preference scope?2021-10-13T07:47:17Z<p>Udo.walker.abas.de: Fixed links to help.</p>
<hr />
<div>The preference service uses the notion of <i>preference scopes</i> to describe the various areas where preferences can be saved. The platform includes the following preference scopes:<br />
<br />
* <i>Configuration scope</i>. Preferences stored in this scope are shared by all workspaces that are launched using a particular configuration of Eclipse plug-ins. On a single-user installation, this serves to capture preferences that are common to all workspaces launched by that user. On a multi-user installation, these preferences are shared by all users of the configuration.<br />
<br />
* <i>Instance scope</i>. Preferences in this scope are specific to a single Eclipse workspace. The old API method <tt>getPluginPreferences</tt> on <tt>Plugin</tt> stores its preferences at this scope.<br />
<br />
* <i>Default scope</i>. This scope is not stored on disk at all but can be used to store default values for all your keys. When values are not found in other scopes, the default scope is consulted last to provide reasonable default values.<br />
<br />
* ''BundleDefaultsScope''. Similar to the default scope, these values are not written to disk. They are however read from a particular bundle's "preferences.ini" file.<br />
<br />
* <i>Project scope</i>. This scope stores values that are specific to a single project in your workspace, such as code formatter and compiler settings. Note that this scope is provided by the <tt>org.eclipse.core.resources</tt> plug-in, which is not included in the Eclipse Rich Client Platform. This scope will not exist in applications that don't explicitly include the <tt>resources</tt> plug-in.<br />
<br />
Plug-ins can also define their own preference scopes, using the <tt>org.eclipse.core.runtime.preferences</tt> extension point. If you define your own scope, you can control how and where your preferences are loaded and stored. However, for most clients, the built in scopes will be sufficient.<br />
<br />
The majority of the above scopes can be addressed programatically with a particular implementation of [http://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html IScopeContext]:<br />
*<tt>[http://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/ConfigurationScope.html ConfigurationScope]</tt><br />
*<tt>[http://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/InstanceScope.html InstanceScope]</tt><br />
*<tt>[http://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/DefaultScope.html DefaultScope]</tt><br />
*<tt>[http://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html ProjectScope]</tt><br />
<br />
== See Also: ==<br />
*[[FAQ_What_is_a_configuration%3F]]<br />
*[[FAQ_How_do_I_use_the_preference_service%3F]]<br />
<br />
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font></div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=FAQ_What_is_a_preference_scope%3F&diff=444105FAQ What is a preference scope?2021-10-13T06:41:27Z<p>Udo.walker.abas.de: Removed escaping of quote.</p>
<hr />
<div>The preference service uses the notion of <i>preference scopes</i> to describe the various areas where preferences can be saved. The platform includes the following preference scopes:<br />
<br />
* <i>Configuration scope</i>. Preferences stored in this scope are shared by all workspaces that are launched using a particular configuration of Eclipse plug-ins. On a single-user installation, this serves to capture preferences that are common to all workspaces launched by that user. On a multi-user installation, these preferences are shared by all users of the configuration.<br />
<br />
* <i>Instance scope</i>. Preferences in this scope are specific to a single Eclipse workspace. The old API method <tt>getPluginPreferences</tt> on <tt>Plugin</tt> stores its preferences at this scope.<br />
<br />
* <i>Default scope</i>. This scope is not stored on disk at all but can be used to store default values for all your keys. When values are not found in other scopes, the default scope is consulted last to provide reasonable default values.<br />
<br />
* ''BundleDefaultsScope''. Similar to the default scope, these values are not written to disk. They are however read from a particular bundle's "preferences.ini" file.<br />
<br />
* <i>Project scope</i>. This scope stores values that are specific to a single project in your workspace, such as code formatter and compiler settings. Note that this scope is provided by the <tt>org.eclipse.core.resources</tt> plug-in, which is not included in the Eclipse Rich Client Platform. This scope will not exist in applications that don't explicitly include the <tt>resources</tt> plug-in.<br />
<br />
Plug-ins can also define their own preference scopes, using the <tt>org.eclipse.core.runtime.preferences</tt> extension point. If you define your own scope, you can control how and where your preferences are loaded and stored. However, for most clients, the built in scopes will be sufficient.<br />
<br />
The majority of the above scopes can be addressed programatically with a particular implementation of [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html IScopeContext]:<br />
*<tt>[http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/ConfigurationScope.html ConfigurationScope]</tt><br />
*<tt>[http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/InstanceScope.html InstanceScope]</tt><br />
*<tt>[http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/DefaultScope.html DefaultScope]</tt><br />
*<tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html ProjectScope]</tt><br />
<br />
== See Also: ==<br />
*[[FAQ_What_is_a_configuration%3F]]<br />
*[[FAQ_How_do_I_use_the_preference_service%3F]]<br />
<br />
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font></div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=ECE2020_EclipseSDK&diff=441249ECE2020 EclipseSDK2020-10-12T12:43:49Z<p>Udo.walker.abas.de: </p>
<hr />
<div>== Eclipse SDK Meetup ==<br />
<br />
A virtual meetup as part of [https://www.eclipsecon.org/2020/community-day EclipseCon 2020] - for people who are interested in what's happening in the Eclipse SDK, looking to contribute or have discussions with the committers and contributors of the Eclipse SDK project.<br />
<br />
Come and meet the Eclipse SDK community, other committers & contributors and share your thoughts/ideas.<br />
<br />
====Schedule====<br />
<br />
{|class="wikitable" border="1" cellpadding="4" cellspacing="4" style="width: 300px; height: 25px;"<br />
|<b>Date</b><br />
|style="text-align: center;"| October 19, 2020, Monday<br />
|-<br />
|<b>Time</b><br />
|style="text-align: center;"| 2.30 pm - 4 pm CET<br />
|}<br />
<br />
====Agenda====<br />
<b>Tentative Agenda</b><br />
<br/><br />
<br />
<div> <br />
{|class="wikitable" border="1" cellpadding="4" cellspacing="4"<br />
! Time<br />
! Topic<br />
! Speaker/Moderator<br />
|-<br />
| 2.30 pm (15 mins)<br />
| Invited Talk: Eclipse - How a Solid Code Base was Built? Hear from one of the early contributors and the former Eclipse platform lead<br />
| Philippe P Mulet<br />
|-<br />
| colspan="3" style="text-align: center;" | <b>Committer Experience (15 mins)</b><br />
|-<br />
| 2.45 pm (7 mins)<br />
| My Committer Experience<br />
| Alexander Fedorov<br />
|-<br />
| 2.52 pm (7 mins)<br />
| My Committer Experience<br />
| style="background: none repeat scroll 0% 0% red;" | <Speaker TBD><br />
|-<br />
| colspan="3" style="text-align: center;" | <b>Lightning Talks (15 mins)</b><br />
|-<br />
| 3 pm (7 mins)<br />
| What's New in the Eclipse Platform Project: An overview of the things that drove the project's community during the past year. Shortened version of [https://www.eclipsecon.org/2020/sessions/what%E2%80%99s-new-eclipse-platform-project ECE2020 talk]<br />
| Karsten Thoms<br />
|-<br />
| 3.07 pm (7 mins)<br />
| Today’s displays are not 92 DPI any more - How to make your SWT application look great on modern displays. Shortened version of [https://www.eclipsecon.org/2020/sessions/today%E2%80%99s-displays-are-not-92-dpi-any-more-how-make-your-swt-application-look-great ECE2020 proposal]<br />
| Matthias Becker<br />
|-<br />
| colspan="3" style="text-align: center;" | <b>Community Interaction (45 mins)</b><br />
|-<br />
| 3.15 pm (15 mins)<br />
| Panel discussion : Eclipse SDK - What's going on now and how can you contribute? <br />
| Manoj N Palat<br />
|-<br />
| 3.30 pm (30 mins)<br />
| Q & A session (Please add your questions below)<br />
| Lakshmi P Shanmugam<br />
|}</div><br />
<br />
====Q & A====<br />
<b>Please add questions for the Q&A session</b><br />
<br/><br />
Questions for the Community Day. (Please add your name against your question)<br />
# What is the E4 story: Vision and plans for the nearest years? (Alexander Fedorov)<br />
# How to measure and visualize the grade of effort invested to the Eclipse project improvements by non-funded committers and contributors? (Alexander Fedorov)<br />
#<br />
#<br />
<br />
====Attendees====<br />
Since the event is virtual this year, we need a number for the estimated attendance.<br />
<br />
<b>Please add your name if you are interested in attending this meet up.</b> <br />
<br />
# Manoj N Palat<br />
# Vikas Chandra<br />
# Lakshmi Shanmugam<br />
# Dani Megert<br />
# Sarika Sinha<br />
# Sravan Kumar Lakkimsetti<br />
# Noopur Gupta<br />
# Karsten Thoms<br />
# Matthias Becker<br />
# Alexander Fedorov<br />
# Jens Lideström<br />
# Sebastian Ratz<br />
# Neeraj Bhusare<br />
# Kenneth Styrberg<br />
# Alexander Kurtakov<br />
# Paul Damrongpiriyapong<br />
# Thomas Watson<br />
# Mickael Istria<br />
# Udo Walker</div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=Platform_Command_Framework&diff=376257Platform Command Framework2015-01-13T09:01:50Z<p>Udo.walker.abas.de: Fixes link to GenericCommandActionDelegate.java</p>
<hr />
<div>= Architecture Overview =<br />
<br />
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-ui-home/R3_1/contributions-proposal/requestForComments_html_m41374bdb.png<br />
<br />
<center>Figure 1: High Level Architecture</center><br />
<br />
= Eclipse Commands Tutorial =<br />
<br />
http://www.vogella.de/articles/EclipseCommands/article.html Tutorial about using Eclipse Commands by Lars Vogel<br />
<br />
= Other Resources =<br />
[http://blog.eclipse-tips.com/search/label/Commands Commands in Action] by [http://blog.eclipse-tips.com/ Prakash G.R.]:<br />
<br />
* [http://blog.eclipse-tips.com/2009/01/commands-part-1-actions-vs-commands.html Commands Part 1: Actions Vs Commands]<br />
* [http://blog.eclipse-tips.com/2009/01/commands-part-2-selection-and.html Commands Part 2: Selection and Enablement of IHandlers]<br />
* [http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html Commands Part 3: Parameters for Commands]<br />
* [http://blog.eclipse-tips.com/2009/01/commands-part-4-misc-items.html Commands Part 4: Misc items ...]<br />
* [http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html Commands Part 5: Authentication in RCP applications]<br />
* [http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html Commands Part 6: Toggle & Radio menu contributions]<br />
* [http://blog.eclipse-tips.com/2009/05/commands-part-7-adding-standard.html Commands Part 7: Adding standard commands]<br />
* [http://blog.eclipse-tips.com/2009/06/keyboard-accessibility-thru-command.html Keyboard accessibility thru Command Framework]<br />
* [http://blog.eclipse-tips.com/2009/12/toggle-commands-toggle-other.html Toggle Commands the toggle other contributions]<br />
<br />
[http://wiki.eclipse.org/Command_Core_Expressions Command Core Expressions]<br />
<br />
[http://wiki.eclipse.org/Platform_Expression_Framework Platform Expression Framework]<br />
<br />
= Commands =<br />
<br />
Commands are managed by the <b>org.eclipse.ui.commands</b> extension point and the ICommandService.<br />
<br />
An example of using the extension point to create a command:<br />
<br />
<source lang="xml"><br />
<extension<br />
point="org.eclipse.ui.commands"><br />
<category<br />
description="Actions take at lunch time."<br />
id="z.ex.view.keybindings.category"<br />
name="Lunch"><br />
</category><br />
<command<br />
categoryId="z.ex.view.keybindings.category"<br />
description="Go for the taco."<br />
id="z.ex.view.keybindings.eatTaco"<br />
name="Eat That Taco"><br />
</command><br />
</extension><br />
</source><br />
<br />
You can programmatically create commands as well. From within a view:<br />
<br />
<source lang="java"><br />
<br />
ICommandService cmdService = (ICommandService) getSite().getService(<br />
ICommandService.class);<br />
Category lunch = cmdService<br />
.getCategory("z.ex.view.keybindings.category");<br />
if (!lunch.isDefined()) {<br />
lunch.define("Lunch", "Actions take at lunch time.");<br />
}<br />
Command eatTaco = cmdService<br />
.getCommand("z.ex.view.keybindings.eatTaco");<br />
if (!eatTaco.isDefined()) {<br />
eatTaco.define("Eat That Taco", "Go for the taco.", lunch);<br />
}<br />
</source><br />
<br />
Note, however, that a plugin that programmatically defines commands is responsible for cleaning them up if the plugin is ever unloaded.<br />
<br />
Also, like IAction you can execute a command directly ... but to get the proper environment it's better to execute it through the IHandlerService. See [[#Handlers]].<br />
<br />
<br />
== Executing a command with parameters ==<br />
<br />
When a Command specifies its parameters, it can also specify a parameter type and/or some valid values. For example, the showView command.<br />
<br />
<source lang="xml"><br />
<command<br />
name="%command.showView.name"<br />
description="%command.showView.description"<br />
categoryId="org.eclipse.ui.category.views"<br />
id="org.eclipse.ui.views.showView"<br />
defaultHandler="org.eclipse.ui.handlers.ShowViewHandler"><br />
<commandParameter<br />
id="org.eclipse.ui.views.showView.viewId"<br />
name="%command.showView.viewIdParameter"<br />
values="org.eclipse.ui.internal.registry.ViewParameterValues" /><br />
</command><br />
</source><br />
<br />
To execute this command, you need to create a ParameterizedCommand with a Parameterization (an instance of a parameter and its value).<br />
<br />
<source lang="java"><br />
ICommandService commandService = ...;<br />
IHandlerService handlerService = ...;<br />
Command showView = commandService<br />
.getCommand("org.eclipse.ui.views.showView");<br />
IParameter viewIdParm = showView<br />
.getParameter("org.eclipse.ui.views.showView.viewId");<br />
<br />
// the viewId parameter provides a list of valid values ... if you<br />
// knew the id of the problem view, you could skip this step.<br />
// This method is supposed to be used in places like the keys<br />
// preference page, to allow the user to select values<br />
IParameterValues parmValues = viewIdParm.getValues();<br />
String viewId = null;<br />
Iterator i = parmValues.getParameterValues().values().iterator();<br />
while (i.hasNext()) {<br />
String id = (String) i.next();<br />
if (id.indexOf("ProblemView") != -1) {<br />
viewId = id;<br />
break;<br />
}<br />
}<br />
<br />
Parameterization parm = new Parameterization(viewIdParm, viewId);<br />
ParameterizedCommand parmCommand = new ParameterizedCommand(<br />
showView, new Parameterization[] { parm });<br />
<br />
handlerService.executeCommand(parmCommand, null);<br />
</source><br />
<br />
This executes the showView command with the problem view id. This is done for us when declaratively specifying a keybinding.<br />
<br />
<source lang="xml"><br />
<key<br />
sequence="M2+M3+Q X"<br />
contextId="org.eclipse.ui.contexts.window"<br />
commandId="org.eclipse.ui.views.showView"<br />
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"><br />
<parameter <br />
id="org.eclipse.ui.views.showView.viewId"<br />
value="org.eclipse.ui.views.ProblemView" /><br />
</key><br />
</source><br />
<br />
== Using an IActionDelegate to execute a command ==<br />
<br />
In 3.1 and 3.2 there is no declarative support for a menu item to execute a command. But you can write an IActionDelegate (like GenericCommandActionDelegate) that can be used in the standard extension points (org.eclipse.ui.actionSets, org.eclipse.ui.popupMenus, org.eclipse.ui.editorActions, and org.eclipse.ui.viewActions) and use it to execute the command.<br />
<br />
We need to do these things to wire our command to a menu item:<br />
# Define an <code>action</code> in an extension point using plugin.xml markup<br />
# Connect this action to our IActionDelegate instance (also in plugin.xml)<br />
# Tell our IActionDelegate which command to execute (also in plugin.xml)<br />
# Code the IActionDelegate class to perform the command execution. (see code example below).<br />
<br />
For example, in the above section we saw the showView command takes one parameter, the view id. Here is how we create an Action to execute it:<br />
<br />
<source lang="xml"><br />
<action<br />
id="org.eclipse.ui.examples.actions.showOutlineView"<br />
label="Show View:Outline"<br />
menubarPath="org.eclipse.ui.examples.actions.showViewMenu/additions"<br />
style="push"><br />
<class class="org.eclipse.ui.tests.api.GenericCommandActionDelegate"><br />
<parameter name="commandId" <br />
value="org.eclipse.ui.views.showView"/><br />
<parameter name="org.eclipse.ui.views.showView.viewId" <br />
value="org.eclipse.ui.views.ContentOutline"/><br />
</class><br />
</action><br />
<action<br />
id="org.eclipse.ui.examples.actions.showBookmarkView"<br />
label="Show View:Bookmark"<br />
menubarPath="org.eclipse.ui.examples.actions.showViewMenu/additions"<br />
style="push"><br />
<class class="org.eclipse.ui.tests.api.GenericCommandActionDelegate"><br />
<parameter name="commandId" <br />
value="org.eclipse.ui.views.showView"/><br />
<parameter name="org.eclipse.ui.views.showView.viewId" <br />
value="org.eclipse.ui.views.BookmarkView"/><br />
</class><br />
</action><br />
</source><br />
<br />
'''Notes:'''<br />
* For commands without parameters, you can use the class attribute short from:<br />
class="org.eclipse.ui.tests.api.GenericCommandActionDelegate:my.commandId"<br />
* your action definition looks more like a keybinding definition. You are specifying the command id and any parameters needed for that action.<br />
* We specifed the action using the <class/> element instead of the class attribute ... you'll get a couple of warnings, ignore them.<br />
<br />
* The <b>definitionId</b> that is currently in the <action/> element is for linking up legacy actions to a keybinding through a command. For example, you've had a ShowMyViewActionDelegate since 3.0, and you want to attach a keybinding to it. We don't want to use that.<br />
<br />
* We have just shown the plugin.xml markup to trigger a command from within an action. Since the action can be inserted into a menu, this approach allows commands to be triggered by menu items. The glue between actions and commands is a single generic IActionDelegate implementation (shown below). All of the specific behavior code is now unified in the command and its handler. We no longer need an action delegate with a specific run() method for every menu item; consequently we don't need to link ActionSets to commands with the definitionId.<br />
<br />
<b>Known Issues:</b><br />
<br />
When you start up eclipse you'll get warnings about your actions not having a class attribute. It's not an error, and won't effect the action performance.<br />
<br />
You'll also see the actions in the Uncategorized section of the keybindings page. You can bind keys to them but they won't work from the keybinding. That's OK, you should be binding keys to the command not the action.<br />
<br />
<br />
=== Generic Command Action Delegate ===<br />
<br />
We'll need a more robust implementation, but in 3.2 your action delegate needs to look something like the class below. I've only tested this with org.eclipse.ui.actionSets, but it should work with the viewActions, editorActions, and popupMenus extension points as well. The latest version of the code lives in HEAD in the org.eclipse.ui.tests plugin: [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/tests/org.eclipse.ui.tests/Eclipse%20UI%20Tests/org/eclipse/ui/tests/api/GenericCommandActionDelegate.java GenericCommandActionDelegate.java]<br />
<br />
<br />
<source lang="java"><br />
/*******************************************************************************<br />
* Copyright (c) 2006 IBM Corporation and others.<br />
* All rights reserved. This program and the accompanying materials<br />
* are made available under the terms of the Eclipse Public License v1.0<br />
* which accompanies this distribution, and is available at<br />
* http://www.eclipse.org/legal/epl-v10.html<br />
*<br />
* Contributors:<br />
* IBM Corporation - initial API and implementation<br />
*******************************************************************************/<br />
package org.eclipse.ui.tests.api;<br />
<br />
import java.util.ArrayList;<br />
import java.util.Iterator;<br />
import java.util.Map;<br />
<br />
import org.eclipse.core.commands.Command;<br />
import org.eclipse.core.commands.IParameter;<br />
import org.eclipse.core.commands.Parameterization;<br />
import org.eclipse.core.commands.ParameterizedCommand;<br />
import org.eclipse.core.commands.common.NotDefinedException;<br />
import org.eclipse.core.runtime.CoreException;<br />
import org.eclipse.core.runtime.IConfigurationElement;<br />
import org.eclipse.core.runtime.IExecutableExtension;<br />
import org.eclipse.jface.action.IAction;<br />
import org.eclipse.jface.viewers.ISelection;<br />
import org.eclipse.ui.IEditorActionDelegate;<br />
import org.eclipse.ui.IEditorPart;<br />
import org.eclipse.ui.IObjectActionDelegate;<br />
import org.eclipse.ui.IViewActionDelegate;<br />
import org.eclipse.ui.IViewPart;<br />
import org.eclipse.ui.IWorkbenchPart;<br />
import org.eclipse.ui.IWorkbenchWindow;<br />
import org.eclipse.ui.IWorkbenchWindowActionDelegate;<br />
import org.eclipse.ui.commands.ICommandService;<br />
import org.eclipse.ui.handlers.IHandlerService;<br />
<br />
/**<br />
* This action delegate can be used to specify a command with or without<br />
* parameters be called from an &lt;action/&gt; specified in actionSets,<br />
* editorActions, viewActions, or popupMenus.<br />
*/<br />
public class GenericCommandActionDelegate implements<br />
IWorkbenchWindowActionDelegate, IViewActionDelegate,<br />
IEditorActionDelegate, IObjectActionDelegate, IExecutableExtension {<br />
<br />
private static final String PARM_COMMAND_ID = "commandId";<br />
<br />
private String commandId = null;<br />
<br />
private Map parameterMap = null;<br />
<br />
private ParameterizedCommand parameterizedCommand = null;<br />
<br />
private IHandlerService handlerService = null;<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()<br />
*/<br />
public void dispose() {<br />
handlerService = null;<br />
parameterizedCommand = null;<br />
parameterMap = null;<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)<br />
*/<br />
public void run(IAction action) {<br />
if (handlerService == null) {<br />
// what, no handler service ... no problem<br />
return;<br />
}<br />
try {<br />
if (commandId != null) {<br />
handlerService.executeCommand(commandId, null);<br />
} else if (parameterizedCommand != null) {<br />
handlerService.executeCommand(parameterizedCommand, null);<br />
}<br />
// else there is no command for this delegate<br />
} catch (Exception e) {<br />
// exceptions reduced for brevity<br />
// and we won't just do a print out :-)<br />
}<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,<br />
* org.eclipse.jface.viewers.ISelection)<br />
*/<br />
public void selectionChanged(IAction action, ISelection selection) {<br />
// we don't care, handlers get their selection from the<br />
// ExecutionEvent application context<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,<br />
* java.lang.String, java.lang.Object)<br />
*/<br />
public void setInitializationData(IConfigurationElement config,<br />
String propertyName, Object data) throws CoreException {<br />
String id = config.getAttribute(IWorkbenchRegistryConstants.ATT_ID);<br />
// save the data until our init(*) call, where we can get<br />
// the services.<br />
if (data instanceof String) {<br />
commandId = (String) data;<br />
} else if (data instanceof Map) {<br />
parameterMap = (Map) data;<br />
if (parameterMap.get(PARM_COMMAND_ID) == null) {<br />
Status status = new Status(IStatus.ERROR,<br />
"org.eclipse.ui.tests", "The '" + id<br />
+ "' action won't work without a commandId");<br />
throw new CoreException(status);<br />
}<br />
} else {<br />
Status status = new Status(<br />
IStatus.ERROR,<br />
"org.eclipse.ui.tests",<br />
"The '"<br />
+ id<br />
+ "' action won't work without some initialization parameters");<br />
throw new CoreException(status);<br />
}<br />
}<br />
<br />
/**<br />
* Build a command from the executable extension information.<br />
* <br />
* @param commandService<br />
* to get the Command object<br />
*/<br />
private void createCommand(ICommandService commandService) {<br />
String id = (String) parameterMap.get(PARM_COMMAND_ID);<br />
if (id == null) {<br />
return;<br />
}<br />
if (parameterMap.size() == 1) {<br />
commandId = id;<br />
return;<br />
}<br />
try {<br />
Command cmd = commandService.getCommand(id);<br />
if (!cmd.isDefined()) {<br />
// command not defined? no problem ...<br />
return;<br />
}<br />
ArrayList parameters = new ArrayList();<br />
Iterator i = parameterMap.entrySet().iterator();<br />
while (i.hasNext()) {<br />
Map.Entry entry = (Map.Entry) i.next();<br />
String parmName = (String) entry.getKey();<br />
if (PARM_COMMAND_ID.equals(parmName)) {<br />
continue;<br />
}<br />
IParameter parm = cmd.getParameter(parmName);<br />
if (parm == null) {<br />
// asking for a bogus parameter? No problem<br />
return;<br />
}<br />
parameters.add(new Parameterization(parm, (String) entry.getValue()));<br />
}<br />
parameterizedCommand = new ParameterizedCommand(cmd,<br />
(Parameterization[]) parameters<br />
.toArray(new Parameterization[parameters.size()]));<br />
} catch (NotDefinedException e) {<br />
// command is bogus? No problem, we'll do nothing.<br />
}<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)<br />
*/<br />
public void init(IWorkbenchWindow window) {<br />
if (handlerService != null) {<br />
// already initialized<br />
return;<br />
}<br />
<br />
handlerService = (IHandlerService) window<br />
.getService(IHandlerService.class);<br />
if (parameterMap != null) {<br />
ICommandService commandService = (ICommandService) window<br />
.getService(ICommandService.class);<br />
createCommand(commandService);<br />
}<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)<br />
*/<br />
public void init(IViewPart view) {<br />
init(view.getSite().getWorkbenchWindow());<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction,<br />
* org.eclipse.ui.IEditorPart)<br />
*/<br />
public void setActiveEditor(IAction action, IEditorPart targetEditor) {<br />
// we don't actually care about the active editor, since that<br />
// information is in the ExecutionEvent application context<br />
// but we need to make sure we're initialized.<br />
if (targetEditor != null) {<br />
init(targetEditor.getSite().getWorkbenchWindow());<br />
}<br />
}<br />
<br />
/*<br />
* (non-Javadoc)<br />
* <br />
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,<br />
* org.eclipse.ui.IWorkbenchPart)<br />
*/<br />
public void setActivePart(IAction action, IWorkbenchPart targetPart) {<br />
// we don't actually care about the active part, since that<br />
// information is in the ExecutionEvent application context<br />
// but we need to make sure we're initialized.<br />
if (targetPart != null) {<br />
init(targetPart.getSite().getWorkbenchWindow());<br />
}<br />
}<br />
}<br />
</source><br />
<br />
= Handlers =<br />
<br />
Handlers are managed by the <b>org.eclipse.ui.handlers</b> extension point and the IHandlerService. Many Handlers can register for a command. At any give time, either 0 or 1 handlers will be active for the command. A handler's active state and enabled state can be controlled declaratively. See [[Command Core Expressions]] for a more complex description of the declarative expressions. Handlers are responsible for interpreting any optional command parameters using the ExecutionEvent parameter.<br />
<br />
<source lang="xml"><br />
<extension<br />
point="org.eclipse.ui.handlers"><br />
<handler<br />
class="z.ex.view.keybindings.handlers.TacoHandler"<br />
commandId="z.ex.view.keybindings.eatTaco"><br />
<activeWhen><br />
<with variable="activeContexts"><br />
<iterate operator="or"><br />
<equals value="z.ex.view.keybindings.contexts.taco"/><br />
</iterate><br />
</with><br />
</activeWhen><br />
</handler><br />
</extension><br />
</source><br />
<br />
Here the handler is checking the activeContexts variable (See [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/ISources.html org.eclipse.ui.ISources]) and if the "taco" context is active, the handler is active.<br />
<br />
The handler itself, <b>TacoHandler</b>, must implement IHandler but would usually be derived from the abstract base class [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/commands/AbstractHandler.html org.eclipse.core.commands.AbstractHandler].<br />
<br />
You can create and activate a handler programmatically:<br />
<br />
<source lang="java"><br />
IHandlerService handlerService = (IHandlerService) getSite()<br />
.getService(IHandlerService.class);<br />
IHandler handler = new AbstractHandler() {<br />
public Object execute(ExecutionEvent event)<br />
throws ExecutionException {<br />
System.out.println("Eat that Taco");<br />
return null;<br />
}<br />
};<br />
handlerService<br />
.activateHandler("z.ex.view.keybindings.eatTaco", handler);<br />
</source><br />
<br />
As of 3.2 (and later releases) we should be calling the IHandlerService to run commands. We should not call the Command object execute method itself.<br />
<br />
<source lang="java"><br />
handlerService.executeCommand("z.ex.view.keybindings.eatTaco", null);<br />
</source><br />
<br />
In 3.1 it is still necessary to call the Command object directly since the IHandlerService didn't support executeCommand(*). But you can provide almost the same execution environment.<br />
<br />
<source lang="java"><br />
Command eatTaco = cmdService<br />
.getCommand("z.ex.view.keybindings.eatTaco");<br />
eatTaco.execute(new ExecutionEvent(Collections.EMPTY_MAP, null, handlerService.getCurrentState()));<br />
</source><br />
<br />
If you want the handler to evaluate an enablement expression you can do that using the expression parameter of the <br />
activateHandler() method. Here is how you need to setup your expression in order to properly work tracking<br />
selection changes:<br />
<br />
<source lang="java"><br />
Expression expr = new Expression() {<br />
public final EvaluationResult evaluate(final IEvaluationContext context) {<br />
Object sel = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);<br />
(return EvaluationResult.TRUE/FALSE depending on how much you like the selection)<br />
}<br />
public void collectExpressionInfo(final ExpressionInfo info) {<br />
// You need this to cause the expr to be evaluated on selection events<br />
info.markDefaultVariableAccessed();<br />
}<br />
};<br />
</source><br />
<br />
= KeyBindings =<br />
<br />
KeyBindings are managed by the <b>org.eclipse.ui.bindings</b> extension point and the IBindingService. Keybindings cannot be updated programmatically.<br />
<br />
<source lang="xml"><br />
<extension<br />
point="org.eclipse.ui.bindings"><br />
<key<br />
commandId="z.ex.view.keybindings.eatTaco"<br />
contextId="z.ex.view.keybindings.contexts.taco"<br />
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"<br />
sequence="CTRL+3"><br />
</key><br />
</extension><br />
</source><br />
<br />
A key binding is active when the context is active. A keybinding is associated with a command (with optional parameters specified by parameter id and value). If a command has a handler while the keybinding is invoked, the handler extracts the command parameters specified by the keybinding from the ExecutionEvent and invokes the appropriate action.<br />
<br />
= Contexts =<br />
<br />
Contexts are managed by the <b>org.eclipse.ui.contexts</b> extension point and the IContextService.<br />
<br />
Most contexts are created by the extension point, and activated programmatically when appropriate. But you can create contexts programmatically as well. The active contexts usually form a tree, although in the case of keybindings this tree is narrowed down to a branch.<br />
<br />
<source lang="xml"><br />
<extension<br />
point="org.eclipse.ui.contexts"><br />
<context<br />
description="To allow the consumption of Tacos"<br />
id="z.ex.view.keybindings.contexts.taco"<br />
name="Mexican Food"<br />
parentId="org.eclipse.ui.contexts.window"><br />
</context><br />
</extension><br />
</source><br />
<br />
For a context that was attached to a view, it would normally be activated in the view's createPartControl(*) method.<br />
<br />
<source lang="java"><br />
IContextService contextService = (IContextService) getSite()<br />
.getService(IContextService.class);<br />
IContextActivation contextActivation = contextService.activateContext("z.ex.view.keybindings.contexts.taco");<br />
</source><br />
<br />
You can only de-activate a context that you are responsible for activating.<br />
<br />
Programmatically, you can create contexts:<br />
<br />
<source lang="java"><br />
Context tacos = contextService<br />
.getContext("z.ex.view.keybindings.contexts.taco");<br />
if (!tacos.isDefined()) {<br />
tacos.define("Mexican Food", "To allow the consumption of Tacos",<br />
"org.eclipse.ui.contexts.window");<br />
}<br />
</source><br />
<br />
Note, however, that a plugin that programmatically defines contexts is responsible for cleaning them up if the plugin is ever unloaded.<br />
<br />
= Menu Contributions =<br />
<br />
See [[Menu Contributions]]<br />
<br />
= Tracing Option =<br />
<br />
There are a couple of reasons why keybindings and commands might not work.<br />
<br />
#Keybindings are in a context that is not active<br />
#There is a keybinding conflict<br />
#No handler is currently active for the command<br />
#There is a handler conflict<br />
<br />
To help track down the problem, you can run with debug tracing options. For example:<br />
<br />
org.eclipse.ui/debug=true<br />
org.eclipse.ui/trace/keyBindings=true<br />
org.eclipse.ui/trace/keyBindings.verbose=true<br />
org.eclipse.ui/trace/sources=true<br />
org.eclipse.ui/trace/handlers=true<br />
org.eclipse.ui/trace/handlers.verbose=true<br />
#org.eclipse.ui/trace/handlers.verbose.commandId=org.eclipse.ui.edit.copy<br />
org.eclipse.ui/trace/handlers.verbose.commandId=org.eclipse.jdt.ui.navigate.open.type<br />
org.eclipse.ui/trace/contexts=true<br />
org.eclipse.ui/trace/contexts.verbose=true<br />
<br />
<br />
I put these options in a <b>debug.options</b> file and run eclipse using:<br />
<source lang="bash"><br />
bash$ eclipse -debug debug.options -data /opt/local/pw_workspace >debug.log 2>&1<br />
</source><br />
This logs the debug output to the debug.log file. This works on windows as well:<br />
<source lang="dos"><br />
C:\development> eclipse33\eclipsec.exe -debug debug.options -data workspaces\pw_workspace >debug.log 2>&1<br />
</source><br />
<b>handlers.verbose.commandId</b> allows you to track the information about a specific command that isn't working. org.eclipse.jdt.ui.navigate.open.type is the open type dialog (normally CTRL+SHIFT+T) and org.eclipse.ui.edit.copy (commented out) is COPY (normally CTRL+C)<br />
<br />
<br />
[[Category:Eclipse Project]]</div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=Command_Core_Expressions&diff=376254Command Core Expressions2015-01-13T08:42:17Z<p>Udo.walker.abas.de: Fixes links to examples.</p>
<hr />
<div>Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.<br />
<br />
= Expressions and the Command Framework =<br />
<br />
The [[Platform Command Framework]] uses [[Platform Expression Framework|core expressions]] for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions. The command framework provides the IEvaluationContext that command core expressions are evaluate against.<br />
<br />
The IEvaluationContext provides a default variable for evaluations, and a number of named variables. In the command framework, we provide the global selection as a <code>java.util.Collection</code> as the default variable. It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.<br />
<br />
The &lt;with/&gt; element can be used to change which variable the child expression elements are evaluating against.<br />
<br />
= Variables and the Command Framework =<br />
<br />
The variables used for command framework evaluation are listed in [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/ISources.java ISources.java]<br />
<br />
Some of the variables may not be set, depending on the current application context when they are evaluated.<br />
<br />
<table border="1"><br />
<tr><br />
<th>Name</th><br />
<th>Type</th><br />
<th>Description</th><br />
<th>Since</th><br />
</tr><br />
<br />
<tr><br />
<td>activeContexts</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is a collection of the active context IDs as strings. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>. In '''3.3''' action sets are mirrored by contexts whose parent is <code>org.eclipse.ui.actionSet</code>, and the active action sets show up in the list of active contexts.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeActionSets</td><br />
<td>An <code>IActionSetDescriptor[]</code></td><br />
<td><br />
'''Note:''' This is currently not used as it points to an internal class and the type might change in any release.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The currently active shell. It can be a dialog or workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindowShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The active workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow</td><br />
<td><code>org.eclipse.ui.IWorkbenchWindow</code></td><br />
<td><br />
The active workbench window.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isCoolbarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports coolbar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isPerspectiveBarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports perspective bar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.activePerspective</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
Reports the name of the current perspective of the active workbench window.<br />
</td><br />
<td>3.4</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditor</td><br />
<td><code>org.eclipse.ui.IEditorPart</code></td><br />
<td><br />
The currently active editor. This is remembered even if the editor is not the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditorId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active editor. This can be used for expressions on the editor type.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePart</td><br />
<td><code>org.eclipse.ui.IWorkbenchPart</code></td><br />
<td><br />
The active part, which can be the same as the active editor.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePartId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeSite</td><br />
<td><code>org.eclipse.ui.IWorkbenchPartSite</code></td><br />
<td><br />
The site of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>selection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
The current global selection. It is often used with &lt;test/&gt; elements with <code>org.eclipse.core.expressions.PropertyTester</code>, in programmatic core expressions, and in '''3.3''' with &lt;iterate/&gt; and &lt;count/&gt; elements.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenu</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuSelection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the selection provider used to register the context menu, usually from <code>getSite().registerContextMenu(*)</code>. It is usually the same as the <code>selection</code>variable, but not always. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuEditorInput</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the editor input, usually if includeEditorInput was set to <code>true</code> during <code>getEditorSite().registerContextMenu(*)</code>. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControl</td><br />
<td><code>org.eclipse.swt.widgets.Control</code></td><br />
<td><br />
A control that has focus and has been registered with the [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/swt/IFocusService.java IFocusService].<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControlId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of a control that has focus and has been registered with the <code>org.eclipse.ui.swt.IFocusService</code>.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
</table><br />
<br />
Note: All these variables can be used with &lt;test/&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
<br />
= Property Testers =<br />
<br />
The Eclipse SDK provides a couple of property testers that can be used in core expressions. The expression defines a property attribute and then takes a combination of args and a value that is tester implementation dependent. The property attribute is the combination of the namespace and property name. For example, to test an IResource name the property would be <code>org.eclipse.core.resources.name</code>.<br />
<br />
<br />
<table border="1"><br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.runtime</td><br />
<td><br />
<code>org.eclipse.core.runtime.Platform</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.runtime.git/tree/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/propertytester/PlatformPropertyTester.java PlatformPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
product<br />
</td><br />
<td colspan="2"><br />
Test the id of the currently active product.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isBundleInstalled<br />
</td><br />
<td colspan="2"><br />
Test if a given bundle is installed in the running environment. Use the args attribute to pass in the bundle id.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IResource</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java ResourcePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
name<br />
</td><br />
<td colspan="2"><br />
A property indicating the file name (value <code>"name"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
path<br />
</td><br />
<td colspan="2"><br />
A property indicating the file path (value <code>"path"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
extension<br />
</td><br />
<td colspan="2"><br />
A property indicating the file extension (value <code>"extension"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
readOnly<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the file is read only (value <code>"readOnly"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectNature<br />
</td><br />
<td colspan="2"><br />
A property indicating the project nature (value <code>"projectNature"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
persistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource (value <code>"persistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
sessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource (value <code>"sessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectSessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource's project. (value <code>"projectSessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IFile</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/FilePropertyTester.java FilePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
contentTypeId<br />
</td><br />
<td colspan="2"><br />
A property indicating that we are looking to verify that the file matches the content type matching the given identifier. The identifier is provided as the expected value.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IProject</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ProjectPropertyTester.java ProjectPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
open<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the project is open (value <code>"open"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.mapping.ResourceMapping</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java ResourceMappingPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbench</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/activities/ActivityPropertyTester.java ActivityPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<tr><br />
<td><br />
isActivityEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the activity in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isCategoryEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the category in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui.workbenchWindow</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbenchWindow</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/OpenPerspectivePropertyTester.java OpenPerspectivePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
isPerspectiveOpen<br />
</td><br />
<td colspan="2"><br />
Tests if any perspective is open.<br />
</td><br />
</tr><br />
<br />
<br />
<br />
</table><br />
<br />
= Expression examples =<br />
<br />
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.<br />
<br />
== Basic IStructuredSelection ==<br />
<br />
A view provides a structured selection through its selection provider. An example would be the InfoView in <b>org.eclipse.ui.examples.contributions</b>. You can browse the [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.ui.examples.contributions/plugin.xml plugin.xml] and<br />
[http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.ui.examples.contributions/src/org/eclipse/ui/examples/contributions/view/InfoView.java InfoView.java] files. The InfoView provides an <code>IStructuredSelection</code> with 0 or more <code>org.eclipse.ui.examples.contributions.model.Person</code>.<br />
<br />
When using the default variable, you must treat it as an <code>java.util.Collection</code>. That means using &lt;count&gt; or &lt;iterate&gt;<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/><br />
</iterate><br />
</activeWhen><br />
</source><br />
== Package Explorer IStructuredSelection ==<br />
<br />
The Package Explorer is a mixture of <code>org.eclipse.core.resources.IResource</code>, <code>org.eclipse.jdt.core.IJavaElement</code> and other classes. If you are trying to find all of the *.java files, you would need to:<br />
<br />
# Iterate through the default variable<br />
# adapt the selection elements to your class, in this case <code>IResource</code><br />
# use one of the org.eclipse.core.resources property testers to test the IResource property<br />
<br />
For example:<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<adapt type="org.eclipse.core.resources.IResource"><br />
<test property="org.eclipse.core.resources.name" <br />
value="*.java"/><br />
</adapt><br />
</iterate><br />
</activeWhen><br />
</source><br />
<br />
== Active editor type ==<br />
<br />
If you want your handler to be active for a specific type of editor, you can use <b>activeEditorId</b> to target your handler.<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<with variable="activeEditorId"><br />
<equals value="org.eclipse.ui.DefaultTextEditor"/><br />
</with><br />
</activeWhen><br />
</source><br />
<br />
== Complex nested boolean expressions ==<br />
<br />
You can also write complex nested boolean expressions, like <tt>'''(a & b & (c | d | (!e)))'''</tt>:<br />
<br />
<source lang="xml"><br />
<and><br />
<test args="a" property="rcpAuthActivitiesExample.test" /><br />
<test args="b" property="rcpAuthActivitiesExample.test" /><br />
<or><br />
<test args="c" property="rcpAuthActivitiesExample.test" /><br />
<test args="d" property="rcpAuthActivitiesExample.test" /><br />
<not><br />
<test args="e" property="rcpAuthActivitiesExample.test" /><br />
</not><br />
</or><br />
</and><br />
</source><br />
<br />
You can build the complete boolean expression out of arbitrary single boolean expressions. Not only property testers like in this example.<br />
<br />
= New Core Expressions in 3.3 =<br />
<br />
In 3.3 there were 2 additions to the core expressions framework.<br />
<br />
== count and iterate ==<br />
<br />
Count and iterate have always worked against <code>java.util.Collection</code>. The &lt;count/&gt; and &lt;iterate&gt; elements can now be used on any variable that adapts to <code>org.eclipse.core.expressions.ICountable</code> and <code>org.eclipse.core.expressions.IIterable</code> or implements the interfaces directly. It wasn't possible to use the java 1.5 constructs for iterable.<br />
<br />
The workbench provides an adapter for <code>ISelection</code> and <code>IStructuredSelection</code>.<br />
<br />
== definitions ==<br />
<br />
The <b>org.eclipse.core.expressions.definitions</b> extension point was introduced. You can create core expression definitions, and then reference them from other core expressions.<br />
<source lang="xml"><br />
<extension point="org.eclipse.core.expressions.definitions"><br />
<definition id="org.eclipse.ui.examples.contributions.view.inView"><br />
<with variable="activePartId"><br />
<equals value="org.eclipse.ui.examples.contributions.view"/><br />
</with><br />
</definition><br />
</extension><br />
</source><br />
<br />
Then:<br />
<source lang="xml"><br />
<activeWhen><br />
<reference definitionId="org.eclipse.ui.examples.contributions.view.inView"/><br />
</activeWhen><br />
</source><br />
The referenced expression will be evaluated at this point.<br />
<br />
<br />
[[Category:Eclipse Project]]</div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=Command_Core_Expressions&diff=376253Command Core Expressions2015-01-13T08:33:45Z<p>Udo.walker.abas.de: Fixes links to source repository.</p>
<hr />
<div>Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.<br />
<br />
= Expressions and the Command Framework =<br />
<br />
The [[Platform Command Framework]] uses [[Platform Expression Framework|core expressions]] for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions. The command framework provides the IEvaluationContext that command core expressions are evaluate against.<br />
<br />
The IEvaluationContext provides a default variable for evaluations, and a number of named variables. In the command framework, we provide the global selection as a <code>java.util.Collection</code> as the default variable. It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.<br />
<br />
The &lt;with/&gt; element can be used to change which variable the child expression elements are evaluating against.<br />
<br />
= Variables and the Command Framework =<br />
<br />
The variables used for command framework evaluation are listed in [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/ISources.java ISources.java]<br />
<br />
Some of the variables may not be set, depending on the current application context when they are evaluated.<br />
<br />
<table border="1"><br />
<tr><br />
<th>Name</th><br />
<th>Type</th><br />
<th>Description</th><br />
<th>Since</th><br />
</tr><br />
<br />
<tr><br />
<td>activeContexts</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is a collection of the active context IDs as strings. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>. In '''3.3''' action sets are mirrored by contexts whose parent is <code>org.eclipse.ui.actionSet</code>, and the active action sets show up in the list of active contexts.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeActionSets</td><br />
<td>An <code>IActionSetDescriptor[]</code></td><br />
<td><br />
'''Note:''' This is currently not used as it points to an internal class and the type might change in any release.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The currently active shell. It can be a dialog or workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindowShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The active workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow</td><br />
<td><code>org.eclipse.ui.IWorkbenchWindow</code></td><br />
<td><br />
The active workbench window.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isCoolbarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports coolbar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isPerspectiveBarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports perspective bar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.activePerspective</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
Reports the name of the current perspective of the active workbench window.<br />
</td><br />
<td>3.4</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditor</td><br />
<td><code>org.eclipse.ui.IEditorPart</code></td><br />
<td><br />
The currently active editor. This is remembered even if the editor is not the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditorId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active editor. This can be used for expressions on the editor type.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePart</td><br />
<td><code>org.eclipse.ui.IWorkbenchPart</code></td><br />
<td><br />
The active part, which can be the same as the active editor.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePartId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeSite</td><br />
<td><code>org.eclipse.ui.IWorkbenchPartSite</code></td><br />
<td><br />
The site of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>selection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
The current global selection. It is often used with &lt;test/&gt; elements with <code>org.eclipse.core.expressions.PropertyTester</code>, in programmatic core expressions, and in '''3.3''' with &lt;iterate/&gt; and &lt;count/&gt; elements.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenu</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuSelection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the selection provider used to register the context menu, usually from <code>getSite().registerContextMenu(*)</code>. It is usually the same as the <code>selection</code>variable, but not always. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuEditorInput</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the editor input, usually if includeEditorInput was set to <code>true</code> during <code>getEditorSite().registerContextMenu(*)</code>. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControl</td><br />
<td><code>org.eclipse.swt.widgets.Control</code></td><br />
<td><br />
A control that has focus and has been registered with the [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/swt/IFocusService.java IFocusService].<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControlId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of a control that has focus and has been registered with the <code>org.eclipse.ui.swt.IFocusService</code>.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
</table><br />
<br />
Note: All these variables can be used with &lt;test/&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
<br />
= Property Testers =<br />
<br />
The Eclipse SDK provides a couple of property testers that can be used in core expressions. The expression defines a property attribute and then takes a combination of args and a value that is tester implementation dependent. The property attribute is the combination of the namespace and property name. For example, to test an IResource name the property would be <code>org.eclipse.core.resources.name</code>.<br />
<br />
<br />
<table border="1"><br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.runtime</td><br />
<td><br />
<code>org.eclipse.core.runtime.Platform</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.runtime.git/tree/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/propertytester/PlatformPropertyTester.java PlatformPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
product<br />
</td><br />
<td colspan="2"><br />
Test the id of the currently active product.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isBundleInstalled<br />
</td><br />
<td colspan="2"><br />
Test if a given bundle is installed in the running environment. Use the args attribute to pass in the bundle id.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IResource</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java ResourcePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
name<br />
</td><br />
<td colspan="2"><br />
A property indicating the file name (value <code>"name"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
path<br />
</td><br />
<td colspan="2"><br />
A property indicating the file path (value <code>"path"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
extension<br />
</td><br />
<td colspan="2"><br />
A property indicating the file extension (value <code>"extension"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
readOnly<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the file is read only (value <code>"readOnly"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectNature<br />
</td><br />
<td colspan="2"><br />
A property indicating the project nature (value <code>"projectNature"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
persistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource (value <code>"persistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
sessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource (value <code>"sessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectSessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource's project. (value <code>"projectSessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IFile</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/FilePropertyTester.java FilePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
contentTypeId<br />
</td><br />
<td colspan="2"><br />
A property indicating that we are looking to verify that the file matches the content type matching the given identifier. The identifier is provided as the expected value.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IProject</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ProjectPropertyTester.java ProjectPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
open<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the project is open (value <code>"open"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.mapping.ResourceMapping</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java ResourceMappingPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbench</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/activities/ActivityPropertyTester.java ActivityPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<tr><br />
<td><br />
isActivityEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the activity in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isCategoryEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the category in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui.workbenchWindow</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbenchWindow</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/OpenPerspectivePropertyTester.java OpenPerspectivePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
isPerspectiveOpen<br />
</td><br />
<td colspan="2"><br />
Tests if any perspective is open.<br />
</td><br />
</tr><br />
<br />
<br />
<br />
</table><br />
<br />
= Expression examples =<br />
<br />
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.<br />
<br />
== Basic IStructuredSelection ==<br />
<br />
A view provides a structured selection through its selection provider. An example would be the InfoView in <b>org.eclipse.ui.examples.contributions</b>. You can browse the [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/plugin.xml?content-type=text%2Fplain&view=co plugin.xml] and<br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/src/org/eclipse/ui/examples/contributions/view/InfoView.java?view=co InfoView.java] files. The InfoView provides an <code>IStructuredSelection</code> with 0 or more <code>org.eclipse.ui.examples.contributions.model.Person</code>.<br />
<br />
When using the default variable, you must treat it as an <code>java.util.Collection</code>. That means using &lt;count&gt; or &lt;iterate&gt;<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/><br />
</iterate><br />
</activeWhen><br />
</source><br />
== Package Explorer IStructuredSelection ==<br />
<br />
The Package Explorer is a mixture of <code>org.eclipse.core.resources.IResource</code>, <code>org.eclipse.jdt.core.IJavaElement</code> and other classes. If you are trying to find all of the *.java files, you would need to:<br />
<br />
# Iterate through the default variable<br />
# adapt the selection elements to your class, in this case <code>IResource</code><br />
# use one of the org.eclipse.core.resources property testers to test the IResource property<br />
<br />
For example:<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<adapt type="org.eclipse.core.resources.IResource"><br />
<test property="org.eclipse.core.resources.name" <br />
value="*.java"/><br />
</adapt><br />
</iterate><br />
</activeWhen><br />
</source><br />
<br />
== Active editor type ==<br />
<br />
If you want your handler to be active for a specific type of editor, you can use <b>activeEditorId</b> to target your handler.<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<with variable="activeEditorId"><br />
<equals value="org.eclipse.ui.DefaultTextEditor"/><br />
</with><br />
</activeWhen><br />
</source><br />
<br />
== Complex nested boolean expressions ==<br />
<br />
You can also write complex nested boolean expressions, like <tt>'''(a & b & (c | d | (!e)))'''</tt>:<br />
<br />
<source lang="xml"><br />
<and><br />
<test args="a" property="rcpAuthActivitiesExample.test" /><br />
<test args="b" property="rcpAuthActivitiesExample.test" /><br />
<or><br />
<test args="c" property="rcpAuthActivitiesExample.test" /><br />
<test args="d" property="rcpAuthActivitiesExample.test" /><br />
<not><br />
<test args="e" property="rcpAuthActivitiesExample.test" /><br />
</not><br />
</or><br />
</and><br />
</source><br />
<br />
You can build the complete boolean expression out of arbitrary single boolean expressions. Not only property testers like in this example.<br />
<br />
= New Core Expressions in 3.3 =<br />
<br />
In 3.3 there were 2 additions to the core expressions framework.<br />
<br />
== count and iterate ==<br />
<br />
Count and iterate have always worked against <code>java.util.Collection</code>. The &lt;count/&gt; and &lt;iterate&gt; elements can now be used on any variable that adapts to <code>org.eclipse.core.expressions.ICountable</code> and <code>org.eclipse.core.expressions.IIterable</code> or implements the interfaces directly. It wasn't possible to use the java 1.5 constructs for iterable.<br />
<br />
The workbench provides an adapter for <code>ISelection</code> and <code>IStructuredSelection</code>.<br />
<br />
== definitions ==<br />
<br />
The <b>org.eclipse.core.expressions.definitions</b> extension point was introduced. You can create core expression definitions, and then reference them from other core expressions.<br />
<source lang="xml"><br />
<extension point="org.eclipse.core.expressions.definitions"><br />
<definition id="org.eclipse.ui.examples.contributions.view.inView"><br />
<with variable="activePartId"><br />
<equals value="org.eclipse.ui.examples.contributions.view"/><br />
</with><br />
</definition><br />
</extension><br />
</source><br />
<br />
Then:<br />
<source lang="xml"><br />
<activeWhen><br />
<reference definitionId="org.eclipse.ui.examples.contributions.view.inView"/><br />
</activeWhen><br />
</source><br />
The referenced expression will be evaluated at this point.<br />
<br />
<br />
[[Category:Eclipse Project]]</div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=Command_Core_Expressions&diff=376235Command Core Expressions2015-01-12T17:00:06Z<p>Udo.walker.abas.de: Fixes links to resource property testers.</p>
<hr />
<div>Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.<br />
<br />
= Expressions and the Command Framework =<br />
<br />
The [[Platform Command Framework]] uses [[Platform Expression Framework|core expressions]] for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions. The command framework provides the IEvaluationContext that command core expressions are evaluate against.<br />
<br />
The IEvaluationContext provides a default variable for evaluations, and a number of named variables. In the command framework, we provide the global selection as a <code>java.util.Collection</code> as the default variable. It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.<br />
<br />
The &lt;with/&gt; element can be used to change which variable the child expression elements are evaluating against.<br />
<br />
= Variables and the Command Framework =<br />
<br />
The variables used for command framework evaluation are listed in [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/ISources.java ISources.java]<br />
<br />
Some of the variables may not be set, depending on the current application context when they are evaluated.<br />
<br />
<table border="1"><br />
<tr><br />
<th>Name</th><br />
<th>Type</th><br />
<th>Description</th><br />
<th>Since</th><br />
</tr><br />
<br />
<tr><br />
<td>activeContexts</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is a collection of the active context IDs as strings. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>. In '''3.3''' action sets are mirrored by contexts whose parent is <code>org.eclipse.ui.actionSet</code>, and the active action sets show up in the list of active contexts.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeActionSets</td><br />
<td>An <code>IActionSetDescriptor[]</code></td><br />
<td><br />
'''Note:''' This is currently not used as it points to an internal class and the type might change in any release.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The currently active shell. It can be a dialog or workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindowShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The active workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow</td><br />
<td><code>org.eclipse.ui.IWorkbenchWindow</code></td><br />
<td><br />
The active workbench window.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isCoolbarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports coolbar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isPerspectiveBarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports perspective bar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.activePerspective</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
Reports the name of the current perspective of the active workbench window.<br />
</td><br />
<td>3.4</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditor</td><br />
<td><code>org.eclipse.ui.IEditorPart</code></td><br />
<td><br />
The currently active editor. This is remembered even if the editor is not the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditorId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active editor. This can be used for expressions on the editor type.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePart</td><br />
<td><code>org.eclipse.ui.IWorkbenchPart</code></td><br />
<td><br />
The active part, which can be the same as the active editor.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePartId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeSite</td><br />
<td><code>org.eclipse.ui.IWorkbenchPartSite</code></td><br />
<td><br />
The site of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>selection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
The current global selection. It is often used with &lt;test/&gt; elements with <code>org.eclipse.core.expressions.PropertyTester</code>, in programmatic core expressions, and in '''3.3''' with &lt;iterate/&gt; and &lt;count/&gt; elements.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenu</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuSelection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the selection provider used to register the context menu, usually from <code>getSite().registerContextMenu(*)</code>. It is usually the same as the <code>selection</code>variable, but not always. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuEditorInput</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the editor input, usually if includeEditorInput was set to <code>true</code> during <code>getEditorSite().registerContextMenu(*)</code>. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControl</td><br />
<td><code>org.eclipse.swt.widgets.Control</code></td><br />
<td><br />
A control that has focus and has been registered with the [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/swt/IFocusService.java IFocusService].<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControlId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of a control that has focus and has been registered with the <code>org.eclipse.ui.swt.IFocusService</code>.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
</table><br />
<br />
Note: All these variables can be used with &lt;test/&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
<br />
= Property Testers =<br />
<br />
The Eclipse SDK provides a couple of property testers that can be used in core expressions. The expression defines a property attribute and then takes a combination of args and a value that is tester implementation dependent. The property attribute is the combination of the namespace and property name. For example, to test an IResource name the property would be <code>org.eclipse.core.resources.name</code>.<br />
<br />
<br />
<table border="1"><br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.runtime</td><br />
<td><br />
<code>org.eclipse.core.runtime.Platform</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/propertytester/PlatformPropertyTester.java?view=co PlatformPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
product<br />
</td><br />
<td colspan="2"><br />
Test the id of the currently active product.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isBundleInstalled<br />
</td><br />
<td colspan="2"><br />
Test if a given bundle is installed in the running environment. Use the args attribute to pass in the bundle id.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IResource</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java ResourcePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
name<br />
</td><br />
<td colspan="2"><br />
A property indicating the file name (value <code>"name"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
path<br />
</td><br />
<td colspan="2"><br />
A property indicating the file path (value <code>"path"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
extension<br />
</td><br />
<td colspan="2"><br />
A property indicating the file extension (value <code>"extension"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
readOnly<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the file is read only (value <code>"readOnly"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectNature<br />
</td><br />
<td colspan="2"><br />
A property indicating the project nature (value <code>"projectNature"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
persistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource (value <code>"persistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
sessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource (value <code>"sessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectSessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource's project. (value <code>"projectSessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IFile</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/FilePropertyTester.java FilePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
contentTypeId<br />
</td><br />
<td colspan="2"><br />
A property indicating that we are looking to verify that the file matches the content type matching the given identifier. The identifier is provided as the expected value.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IProject</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ProjectPropertyTester.java ProjectPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
open<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the project is open (value <code>"open"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.mapping.ResourceMapping</code><br />
</td><br />
<td><br />
[https://git.eclipse.org/c/platform/eclipse.platform.resources.git/tree/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java ResourceMappingPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbench</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/activities/ActivityPropertyTester.java?view=co ActivityPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<tr><br />
<td><br />
isActivityEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the activity in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isCategoryEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the category in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui.workbenchWindow</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbenchWindow</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/OpenPerspectivePropertyTester.java?view=co OpenPerspectivePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
isPerspectiveOpen<br />
</td><br />
<td colspan="2"><br />
Tests if any perspective is open.<br />
</td><br />
</tr><br />
<br />
<br />
<br />
</table><br />
<br />
= Expression examples =<br />
<br />
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.<br />
<br />
== Basic IStructuredSelection ==<br />
<br />
A view provides a structured selection through its selection provider. An example would be the InfoView in <b>org.eclipse.ui.examples.contributions</b>. You can browse the [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/plugin.xml?content-type=text%2Fplain&view=co plugin.xml] and<br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/src/org/eclipse/ui/examples/contributions/view/InfoView.java?view=co InfoView.java] files. The InfoView provides an <code>IStructuredSelection</code> with 0 or more <code>org.eclipse.ui.examples.contributions.model.Person</code>.<br />
<br />
When using the default variable, you must treat it as an <code>java.util.Collection</code>. That means using &lt;count&gt; or &lt;iterate&gt;<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/><br />
</iterate><br />
</activeWhen><br />
</source><br />
== Package Explorer IStructuredSelection ==<br />
<br />
The Package Explorer is a mixture of <code>org.eclipse.core.resources.IResource</code>, <code>org.eclipse.jdt.core.IJavaElement</code> and other classes. If you are trying to find all of the *.java files, you would need to:<br />
<br />
# Iterate through the default variable<br />
# adapt the selection elements to your class, in this case <code>IResource</code><br />
# use one of the org.eclipse.core.resources property testers to test the IResource property<br />
<br />
For example:<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<adapt type="org.eclipse.core.resources.IResource"><br />
<test property="org.eclipse.core.resources.name" <br />
value="*.java"/><br />
</adapt><br />
</iterate><br />
</activeWhen><br />
</source><br />
<br />
== Active editor type ==<br />
<br />
If you want your handler to be active for a specific type of editor, you can use <b>activeEditorId</b> to target your handler.<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<with variable="activeEditorId"><br />
<equals value="org.eclipse.ui.DefaultTextEditor"/><br />
</with><br />
</activeWhen><br />
</source><br />
<br />
== Complex nested boolean expressions ==<br />
<br />
You can also write complex nested boolean expressions, like <tt>'''(a & b & (c | d | (!e)))'''</tt>:<br />
<br />
<source lang="xml"><br />
<and><br />
<test args="a" property="rcpAuthActivitiesExample.test" /><br />
<test args="b" property="rcpAuthActivitiesExample.test" /><br />
<or><br />
<test args="c" property="rcpAuthActivitiesExample.test" /><br />
<test args="d" property="rcpAuthActivitiesExample.test" /><br />
<not><br />
<test args="e" property="rcpAuthActivitiesExample.test" /><br />
</not><br />
</or><br />
</and><br />
</source><br />
<br />
You can build the complete boolean expression out of arbitrary single boolean expressions. Not only property testers like in this example.<br />
<br />
= New Core Expressions in 3.3 =<br />
<br />
In 3.3 there were 2 additions to the core expressions framework.<br />
<br />
== count and iterate ==<br />
<br />
Count and iterate have always worked against <code>java.util.Collection</code>. The &lt;count/&gt; and &lt;iterate&gt; elements can now be used on any variable that adapts to <code>org.eclipse.core.expressions.ICountable</code> and <code>org.eclipse.core.expressions.IIterable</code> or implements the interfaces directly. It wasn't possible to use the java 1.5 constructs for iterable.<br />
<br />
The workbench provides an adapter for <code>ISelection</code> and <code>IStructuredSelection</code>.<br />
<br />
== definitions ==<br />
<br />
The <b>org.eclipse.core.expressions.definitions</b> extension point was introduced. You can create core expression definitions, and then reference them from other core expressions.<br />
<source lang="xml"><br />
<extension point="org.eclipse.core.expressions.definitions"><br />
<definition id="org.eclipse.ui.examples.contributions.view.inView"><br />
<with variable="activePartId"><br />
<equals value="org.eclipse.ui.examples.contributions.view"/><br />
</with><br />
</definition><br />
</extension><br />
</source><br />
<br />
Then:<br />
<source lang="xml"><br />
<activeWhen><br />
<reference definitionId="org.eclipse.ui.examples.contributions.view.inView"/><br />
</activeWhen><br />
</source><br />
The referenced expression will be evaluated at this point.<br />
<br />
<br />
[[Category:Eclipse Project]]</div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=Command_Core_Expressions&diff=376234Command Core Expressions2015-01-12T16:54:49Z<p>Udo.walker.abas.de: Fixes link to ISources.java</p>
<hr />
<div>Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.<br />
<br />
= Expressions and the Command Framework =<br />
<br />
The [[Platform Command Framework]] uses [[Platform Expression Framework|core expressions]] for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions. The command framework provides the IEvaluationContext that command core expressions are evaluate against.<br />
<br />
The IEvaluationContext provides a default variable for evaluations, and a number of named variables. In the command framework, we provide the global selection as a <code>java.util.Collection</code> as the default variable. It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.<br />
<br />
The &lt;with/&gt; element can be used to change which variable the child expression elements are evaluating against.<br />
<br />
= Variables and the Command Framework =<br />
<br />
The variables used for command framework evaluation are listed in [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/ISources.java ISources.java]<br />
<br />
Some of the variables may not be set, depending on the current application context when they are evaluated.<br />
<br />
<table border="1"><br />
<tr><br />
<th>Name</th><br />
<th>Type</th><br />
<th>Description</th><br />
<th>Since</th><br />
</tr><br />
<br />
<tr><br />
<td>activeContexts</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is a collection of the active context IDs as strings. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>. In '''3.3''' action sets are mirrored by contexts whose parent is <code>org.eclipse.ui.actionSet</code>, and the active action sets show up in the list of active contexts.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeActionSets</td><br />
<td>An <code>IActionSetDescriptor[]</code></td><br />
<td><br />
'''Note:''' This is currently not used as it points to an internal class and the type might change in any release.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The currently active shell. It can be a dialog or workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindowShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The active workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow</td><br />
<td><code>org.eclipse.ui.IWorkbenchWindow</code></td><br />
<td><br />
The active workbench window.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isCoolbarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports coolbar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isPerspectiveBarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports perspective bar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.activePerspective</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
Reports the name of the current perspective of the active workbench window.<br />
</td><br />
<td>3.4</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditor</td><br />
<td><code>org.eclipse.ui.IEditorPart</code></td><br />
<td><br />
The currently active editor. This is remembered even if the editor is not the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditorId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active editor. This can be used for expressions on the editor type.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePart</td><br />
<td><code>org.eclipse.ui.IWorkbenchPart</code></td><br />
<td><br />
The active part, which can be the same as the active editor.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePartId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeSite</td><br />
<td><code>org.eclipse.ui.IWorkbenchPartSite</code></td><br />
<td><br />
The site of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>selection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
The current global selection. It is often used with &lt;test/&gt; elements with <code>org.eclipse.core.expressions.PropertyTester</code>, in programmatic core expressions, and in '''3.3''' with &lt;iterate/&gt; and &lt;count/&gt; elements.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenu</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuSelection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the selection provider used to register the context menu, usually from <code>getSite().registerContextMenu(*)</code>. It is usually the same as the <code>selection</code>variable, but not always. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuEditorInput</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the editor input, usually if includeEditorInput was set to <code>true</code> during <code>getEditorSite().registerContextMenu(*)</code>. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControl</td><br />
<td><code>org.eclipse.swt.widgets.Control</code></td><br />
<td><br />
A control that has focus and has been registered with the [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/swt/IFocusService.java IFocusService].<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControlId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of a control that has focus and has been registered with the <code>org.eclipse.ui.swt.IFocusService</code>.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
</table><br />
<br />
Note: All these variables can be used with &lt;test/&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
<br />
= Property Testers =<br />
<br />
The Eclipse SDK provides a couple of property testers that can be used in core expressions. The expression defines a property attribute and then takes a combination of args and a value that is tester implementation dependent. The property attribute is the combination of the namespace and property name. For example, to test an IResource name the property would be <code>org.eclipse.core.resources.name</code>.<br />
<br />
<br />
<table border="1"><br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.runtime</td><br />
<td><br />
<code>org.eclipse.core.runtime.Platform</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/propertytester/PlatformPropertyTester.java?view=co PlatformPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
product<br />
</td><br />
<td colspan="2"><br />
Test the id of the currently active product.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isBundleInstalled<br />
</td><br />
<td colspan="2"><br />
Test if a given bundle is installed in the running environment. Use the args attribute to pass in the bundle id.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IResource</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java?view=co ResourcePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
name<br />
</td><br />
<td colspan="2"><br />
A property indicating the file name (value <code>"name"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
path<br />
</td><br />
<td colspan="2"><br />
A property indicating the file path (value <code>"path"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
extension<br />
</td><br />
<td colspan="2"><br />
A property indicating the file extension (value <code>"extension"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
readOnly<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the file is read only (value <code>"readOnly"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectNature<br />
</td><br />
<td colspan="2"><br />
A property indicating the project nature (value <code>"projectNature"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
persistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource (value <code>"persistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
sessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource (value <code>"sessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectSessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource's project. (value <code>"projectSessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IFile</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/FilePropertyTester.java?view=co FilePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
contentTypeId<br />
</td><br />
<td colspan="2"><br />
A property indicating that we are looking to verify that the file matches the content type matching the given identifier. The identifier is provided as the expected value.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IProject</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ProjectPropertyTester.java?view=co ProjectPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
open<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the project is open (value <code>"open"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.mapping.ResourceMapping</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java?view=co ResourceMappingPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbench</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/activities/ActivityPropertyTester.java?view=co ActivityPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<tr><br />
<td><br />
isActivityEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the activity in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isCategoryEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the category in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui.workbenchWindow</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbenchWindow</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/OpenPerspectivePropertyTester.java?view=co OpenPerspectivePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
isPerspectiveOpen<br />
</td><br />
<td colspan="2"><br />
Tests if any perspective is open.<br />
</td><br />
</tr><br />
<br />
<br />
<br />
</table><br />
<br />
= Expression examples =<br />
<br />
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.<br />
<br />
== Basic IStructuredSelection ==<br />
<br />
A view provides a structured selection through its selection provider. An example would be the InfoView in <b>org.eclipse.ui.examples.contributions</b>. You can browse the [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/plugin.xml?content-type=text%2Fplain&view=co plugin.xml] and<br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/src/org/eclipse/ui/examples/contributions/view/InfoView.java?view=co InfoView.java] files. The InfoView provides an <code>IStructuredSelection</code> with 0 or more <code>org.eclipse.ui.examples.contributions.model.Person</code>.<br />
<br />
When using the default variable, you must treat it as an <code>java.util.Collection</code>. That means using &lt;count&gt; or &lt;iterate&gt;<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/><br />
</iterate><br />
</activeWhen><br />
</source><br />
== Package Explorer IStructuredSelection ==<br />
<br />
The Package Explorer is a mixture of <code>org.eclipse.core.resources.IResource</code>, <code>org.eclipse.jdt.core.IJavaElement</code> and other classes. If you are trying to find all of the *.java files, you would need to:<br />
<br />
# Iterate through the default variable<br />
# adapt the selection elements to your class, in this case <code>IResource</code><br />
# use one of the org.eclipse.core.resources property testers to test the IResource property<br />
<br />
For example:<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<adapt type="org.eclipse.core.resources.IResource"><br />
<test property="org.eclipse.core.resources.name" <br />
value="*.java"/><br />
</adapt><br />
</iterate><br />
</activeWhen><br />
</source><br />
<br />
== Active editor type ==<br />
<br />
If you want your handler to be active for a specific type of editor, you can use <b>activeEditorId</b> to target your handler.<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<with variable="activeEditorId"><br />
<equals value="org.eclipse.ui.DefaultTextEditor"/><br />
</with><br />
</activeWhen><br />
</source><br />
<br />
== Complex nested boolean expressions ==<br />
<br />
You can also write complex nested boolean expressions, like <tt>'''(a & b & (c | d | (!e)))'''</tt>:<br />
<br />
<source lang="xml"><br />
<and><br />
<test args="a" property="rcpAuthActivitiesExample.test" /><br />
<test args="b" property="rcpAuthActivitiesExample.test" /><br />
<or><br />
<test args="c" property="rcpAuthActivitiesExample.test" /><br />
<test args="d" property="rcpAuthActivitiesExample.test" /><br />
<not><br />
<test args="e" property="rcpAuthActivitiesExample.test" /><br />
</not><br />
</or><br />
</and><br />
</source><br />
<br />
You can build the complete boolean expression out of arbitrary single boolean expressions. Not only property testers like in this example.<br />
<br />
= New Core Expressions in 3.3 =<br />
<br />
In 3.3 there were 2 additions to the core expressions framework.<br />
<br />
== count and iterate ==<br />
<br />
Count and iterate have always worked against <code>java.util.Collection</code>. The &lt;count/&gt; and &lt;iterate&gt; elements can now be used on any variable that adapts to <code>org.eclipse.core.expressions.ICountable</code> and <code>org.eclipse.core.expressions.IIterable</code> or implements the interfaces directly. It wasn't possible to use the java 1.5 constructs for iterable.<br />
<br />
The workbench provides an adapter for <code>ISelection</code> and <code>IStructuredSelection</code>.<br />
<br />
== definitions ==<br />
<br />
The <b>org.eclipse.core.expressions.definitions</b> extension point was introduced. You can create core expression definitions, and then reference them from other core expressions.<br />
<source lang="xml"><br />
<extension point="org.eclipse.core.expressions.definitions"><br />
<definition id="org.eclipse.ui.examples.contributions.view.inView"><br />
<with variable="activePartId"><br />
<equals value="org.eclipse.ui.examples.contributions.view"/><br />
</with><br />
</definition><br />
</extension><br />
</source><br />
<br />
Then:<br />
<source lang="xml"><br />
<activeWhen><br />
<reference definitionId="org.eclipse.ui.examples.contributions.view.inView"/><br />
</activeWhen><br />
</source><br />
The referenced expression will be evaluated at this point.<br />
<br />
<br />
[[Category:Eclipse Project]]</div>Udo.walker.abas.dehttps://wiki.eclipse.org/index.php?title=Command_Core_Expressions&diff=376233Command Core Expressions2015-01-12T16:53:08Z<p>Udo.walker.abas.de: Fixes link to IFocusService</p>
<hr />
<div>Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.<br />
<br />
= Expressions and the Command Framework =<br />
<br />
The [[Platform Command Framework]] uses [[Platform Expression Framework|core expressions]] for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions. The command framework provides the IEvaluationContext that command core expressions are evaluate against.<br />
<br />
The IEvaluationContext provides a default variable for evaluations, and a number of named variables. In the command framework, we provide the global selection as a <code>java.util.Collection</code> as the default variable. It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.<br />
<br />
The &lt;with/&gt; element can be used to change which variable the child expression elements are evaluating against.<br />
<br />
= Variables and the Command Framework =<br />
<br />
The variables used for command framework evaluation are listed in [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/ISources.java?view=co ISources.java]<br />
<br />
Some of the variables may not be set, depending on the current application context when they are evaluated.<br />
<br />
<table border="1"><br />
<tr><br />
<th>Name</th><br />
<th>Type</th><br />
<th>Description</th><br />
<th>Since</th><br />
</tr><br />
<br />
<tr><br />
<td>activeContexts</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is a collection of the active context IDs as strings. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>. In '''3.3''' action sets are mirrored by contexts whose parent is <code>org.eclipse.ui.actionSet</code>, and the active action sets show up in the list of active contexts.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeActionSets</td><br />
<td>An <code>IActionSetDescriptor[]</code></td><br />
<td><br />
'''Note:''' This is currently not used as it points to an internal class and the type might change in any release.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The currently active shell. It can be a dialog or workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindowShell</td><br />
<td><code>org.eclipse.swt.widgets.Shell</code></td><br />
<td><br />
The active workbench window shell.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow</td><br />
<td><code>org.eclipse.ui.IWorkbenchWindow</code></td><br />
<td><br />
The active workbench window.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isCoolbarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports coolbar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.isPerspectiveBarVisible</td><br />
<td><code>java.lang.Boolean</code></td><br />
<td><br />
Reports perspective bar visibility for the currently active workbench window.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeWorkbenchWindow.activePerspective</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
Reports the name of the current perspective of the active workbench window.<br />
</td><br />
<td>3.4</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditor</td><br />
<td><code>org.eclipse.ui.IEditorPart</code></td><br />
<td><br />
The currently active editor. This is remembered even if the editor is not the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeEditorId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active editor. This can be used for expressions on the editor type.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePart</td><br />
<td><code>org.eclipse.ui.IWorkbenchPart</code></td><br />
<td><br />
The active part, which can be the same as the active editor.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activePartId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeSite</td><br />
<td><code>org.eclipse.ui.IWorkbenchPartSite</code></td><br />
<td><br />
The site of the currently active part.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>selection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
The current global selection. It is often used with &lt;test/&gt; elements with <code>org.eclipse.core.expressions.PropertyTester</code>, in programmatic core expressions, and in '''3.3''' with &lt;iterate/&gt; and &lt;count/&gt; elements.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenu</td><br />
<td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td><br />
<td><br />
This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with &lt;iterate/&gt;, &lt;count/&gt;, and &lt;test/&gt; with a combined <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
</td><br />
<td>3.2</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuSelection</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the selection provider used to register the context menu, usually from <code>getSite().registerContextMenu(*)</code>. It is usually the same as the <code>selection</code>variable, but not always. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeMenuEditorInput</td><br />
<td><code>org.eclipse.jface.viewers.ISelection</code></td><br />
<td><br />
This is a selection that is available while a context menu is showing. It is the selection from the editor input, usually if includeEditorInput was set to <code>true</code> during <code>getEditorSite().registerContextMenu(*)</code>. This is more for legacy compatibility.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControl</td><br />
<td><code>org.eclipse.swt.widgets.Control</code></td><br />
<td><br />
A control that has focus and has been registered with the [https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/swt/IFocusService.java IFocusService].<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
<tr><br />
<td>activeFocusControlId</td><br />
<td><code>java.lang.String</code></td><br />
<td><br />
The ID of a control that has focus and has been registered with the <code>org.eclipse.ui.swt.IFocusService</code>.<br />
</td><br />
<td>3.3</td><br />
</tr><br />
<br />
</table><br />
<br />
Note: All these variables can be used with &lt;test/&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.<br />
<br />
= Property Testers =<br />
<br />
The Eclipse SDK provides a couple of property testers that can be used in core expressions. The expression defines a property attribute and then takes a combination of args and a value that is tester implementation dependent. The property attribute is the combination of the namespace and property name. For example, to test an IResource name the property would be <code>org.eclipse.core.resources.name</code>.<br />
<br />
<br />
<table border="1"><br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.runtime</td><br />
<td><br />
<code>org.eclipse.core.runtime.Platform</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/propertytester/PlatformPropertyTester.java?view=co PlatformPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
product<br />
</td><br />
<td colspan="2"><br />
Test the id of the currently active product.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isBundleInstalled<br />
</td><br />
<td colspan="2"><br />
Test if a given bundle is installed in the running environment. Use the args attribute to pass in the bundle id.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IResource</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java?view=co ResourcePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
name<br />
</td><br />
<td colspan="2"><br />
A property indicating the file name (value <code>"name"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
path<br />
</td><br />
<td colspan="2"><br />
A property indicating the file path (value <code>"path"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
extension<br />
</td><br />
<td colspan="2"><br />
A property indicating the file extension (value <code>"extension"</code>). "*" and "?" wild cards are supported.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
readOnly<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the file is read only (value <code>"readOnly"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectNature<br />
</td><br />
<td colspan="2"><br />
A property indicating the project nature (value <code>"projectNature"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
persistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource (value <code>"persistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
sessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource (value <code>"sessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectSessionProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a session property on the selected resource's project. (value <code>"projectSessionProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IFile</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/FilePropertyTester.java?view=co FilePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<br />
<tr><br />
<td><br />
contentTypeId<br />
</td><br />
<td colspan="2"><br />
A property indicating that we are looking to verify that the file matches the content type matching the given identifier. The identifier is provided as the expected value.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.IProject</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ProjectPropertyTester.java?view=co ProjectPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
open<br />
</td><br />
<td colspan="2"><br />
A property indicating whether the project is open (value <code>"open"</code>).<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.core.resources</td><br />
<td><br />
<code>org.eclipse.core.resources.mapping.ResourceMapping</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java?view=co ResourceMappingPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
projectPersistentProperty<br />
</td><br />
<td colspan="2"><br />
A property indicating a persistent property on the selected resource's project. (value <code>"projectPersistentProperty"</code>). If two arguments are given, this treats the first as the property name, and the second as the expected property value. If only one argument (or just the expected value) is given, this treats it as the property name, and simply tests for existence of the property on the resource.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbench</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/activities/ActivityPropertyTester.java?view=co ActivityPropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<br />
<tr><br />
<td><br />
isActivityEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the activity in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td><br />
isCategoryEnabled<br />
</td><br />
<td colspan="2"><br />
Test if the category in args is enabled.<br />
</td><br />
</tr><br />
<br />
<tr><br />
<td colspan="3" bgcolor="#000000" height="3px"/><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Namespace</th><br />
<th>Type</th><br />
<th>Implementation</th><br />
</tr><br />
<br />
<tr><br />
<td>org.eclipse.ui.workbenchWindow</td><br />
<td><br />
<code>org.eclipse.ui.IWorkbenchWindow</code><br />
</td><br />
<td><br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/OpenPerspectivePropertyTester.java?view=co OpenPerspectivePropertyTester.java]<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<th>Property</th><br />
<th colspan="2">Description</th><br />
</tr><br />
<br />
<tr><br />
<td><br />
isPerspectiveOpen<br />
</td><br />
<td colspan="2"><br />
Tests if any perspective is open.<br />
</td><br />
</tr><br />
<br />
<br />
<br />
</table><br />
<br />
= Expression examples =<br />
<br />
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.<br />
<br />
== Basic IStructuredSelection ==<br />
<br />
A view provides a structured selection through its selection provider. An example would be the InfoView in <b>org.eclipse.ui.examples.contributions</b>. You can browse the [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/plugin.xml?content-type=text%2Fplain&view=co plugin.xml] and<br />
[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.examples.contributions/src/org/eclipse/ui/examples/contributions/view/InfoView.java?view=co InfoView.java] files. The InfoView provides an <code>IStructuredSelection</code> with 0 or more <code>org.eclipse.ui.examples.contributions.model.Person</code>.<br />
<br />
When using the default variable, you must treat it as an <code>java.util.Collection</code>. That means using &lt;count&gt; or &lt;iterate&gt;<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/><br />
</iterate><br />
</activeWhen><br />
</source><br />
== Package Explorer IStructuredSelection ==<br />
<br />
The Package Explorer is a mixture of <code>org.eclipse.core.resources.IResource</code>, <code>org.eclipse.jdt.core.IJavaElement</code> and other classes. If you are trying to find all of the *.java files, you would need to:<br />
<br />
# Iterate through the default variable<br />
# adapt the selection elements to your class, in this case <code>IResource</code><br />
# use one of the org.eclipse.core.resources property testers to test the IResource property<br />
<br />
For example:<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<iterate><br />
<adapt type="org.eclipse.core.resources.IResource"><br />
<test property="org.eclipse.core.resources.name" <br />
value="*.java"/><br />
</adapt><br />
</iterate><br />
</activeWhen><br />
</source><br />
<br />
== Active editor type ==<br />
<br />
If you want your handler to be active for a specific type of editor, you can use <b>activeEditorId</b> to target your handler.<br />
<br />
<source lang="xml"><br />
<activeWhen><br />
<with variable="activeEditorId"><br />
<equals value="org.eclipse.ui.DefaultTextEditor"/><br />
</with><br />
</activeWhen><br />
</source><br />
<br />
== Complex nested boolean expressions ==<br />
<br />
You can also write complex nested boolean expressions, like <tt>'''(a & b & (c | d | (!e)))'''</tt>:<br />
<br />
<source lang="xml"><br />
<and><br />
<test args="a" property="rcpAuthActivitiesExample.test" /><br />
<test args="b" property="rcpAuthActivitiesExample.test" /><br />
<or><br />
<test args="c" property="rcpAuthActivitiesExample.test" /><br />
<test args="d" property="rcpAuthActivitiesExample.test" /><br />
<not><br />
<test args="e" property="rcpAuthActivitiesExample.test" /><br />
</not><br />
</or><br />
</and><br />
</source><br />
<br />
You can build the complete boolean expression out of arbitrary single boolean expressions. Not only property testers like in this example.<br />
<br />
= New Core Expressions in 3.3 =<br />
<br />
In 3.3 there were 2 additions to the core expressions framework.<br />
<br />
== count and iterate ==<br />
<br />
Count and iterate have always worked against <code>java.util.Collection</code>. The &lt;count/&gt; and &lt;iterate&gt; elements can now be used on any variable that adapts to <code>org.eclipse.core.expressions.ICountable</code> and <code>org.eclipse.core.expressions.IIterable</code> or implements the interfaces directly. It wasn't possible to use the java 1.5 constructs for iterable.<br />
<br />
The workbench provides an adapter for <code>ISelection</code> and <code>IStructuredSelection</code>.<br />
<br />
== definitions ==<br />
<br />
The <b>org.eclipse.core.expressions.definitions</b> extension point was introduced. You can create core expression definitions, and then reference them from other core expressions.<br />
<source lang="xml"><br />
<extension point="org.eclipse.core.expressions.definitions"><br />
<definition id="org.eclipse.ui.examples.contributions.view.inView"><br />
<with variable="activePartId"><br />
<equals value="org.eclipse.ui.examples.contributions.view"/><br />
</with><br />
</definition><br />
</extension><br />
</source><br />
<br />
Then:<br />
<source lang="xml"><br />
<activeWhen><br />
<reference definitionId="org.eclipse.ui.examples.contributions.view.inView"/><br />
</activeWhen><br />
</source><br />
The referenced expression will be evaluated at this point.<br />
<br />
<br />
[[Category:Eclipse Project]]</div>Udo.walker.abas.de