You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docu: Update core expression document with selection variable and fix markdown
Add org.eclipse.ui.selection variable to the variables table and fix
markdown rendering throughout the document by wrapping XML elements
in backticks so they display correctly. Also update section titles
to use title case for consistency.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/Command_Core_Expressions.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,14 @@ Core expressions are declarative or programmatic expressions based on the org.ec
7
7
Expressions and the Command Framework
8
8
=====================================
9
9
10
-
The [Platform Command Framework](PlatformCommandFramework.md) uses [core expressions](Platform_Expression_Framework.md) for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions.
11
-
The command framework provides the IEvaluationContext that command core expressions are evaluate against.
10
+
The [Platform Command Framework](PlatformCommandFramework.md) uses [core expressions](Platform_Expression_Framework.md) for `enabledWhen` and `activeWhen` for handlers, programmatic activation of contexts, and for `visibleWhen` for menu contributions.
11
+
The command framework provides the `IEvaluationContext` that command core expressions are evaluate against.
12
12
13
-
The IEvaluationContext provides a default variable for evaluations, and a number of named variables.
13
+
The `IEvaluationContext` provides a default variable for evaluations, and a number of named variables.
14
14
In the command framework, we provide the global selection as a `java.util.Collection` as the default variable.
15
15
It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.
16
16
17
-
The <with/> element can be used to change which variable the child expression elements are evaluating against.
17
+
The `<with/>` element can be used to change which variable the child expression elements are evaluating against.
18
18
19
19
Variables and the Command Framework
20
20
===================================
@@ -25,7 +25,7 @@ Some of the variables may not be set, depending on the current application conte
25
25
26
26
| Name | Type | Description | Since |
27
27
| --- | --- | --- | --- |
28
-
| activeContexts | A `java.util.Collection` of `java.lang.String`| This is a collection of the active context IDs as strings. Most commonly used with <iterate/>, <count/>, and <test/> with a combined `org.eclipse.common.expressions.PropertyTester`. In **3.3** action sets are mirrored by contexts whose parent is `org.eclipse.ui.actionSet`, and the active action sets show up in the list of active contexts. | 3.2 |
28
+
| activeContexts | A `java.util.Collection` of `java.lang.String`| This is a collection of the active context IDs as strings. Most commonly used with `<iterate/>`, `<count/>`, and `<test/>` with a combined `org.eclipse.common.expressions.PropertyTester`. In **3.3** action sets are mirrored by contexts whose parent is `org.eclipse.ui.actionSet`, and the active action sets show up in the list of active contexts. | 3.2 |
29
29
| activeActionSets | An `IActionSetDescriptor\[\]`|**Note:** This is currently not used as it points to an internal class and the type might change in any release. | 3.2 |
30
30
| activeShell |`org.eclipse.swt.widgets.Shell`| The currently active shell. It can be a dialog or workbench window shell. | 3.2 |
31
31
| activeWorkbenchWindowShell |`org.eclipse.swt.widgets.Shell`| The active workbench window shell. | 3.2 |
@@ -38,14 +38,15 @@ Some of the variables may not be set, depending on the current application conte
38
38
| activePart |`org.eclipse.ui.IWorkbenchPart`| The active part, which can be the same as the active editor. | 3.2 |
39
39
| activePartId |`java.lang.String`| The ID of the currently active part. | 3.2 |
40
40
| activeSite |`org.eclipse.ui.IWorkbenchPartSite`| The site of the currently active part. | 3.2 |
41
-
| selection |`org.eclipse.jface.viewers.ISelection`| The current global selection. It is often used with <test/> elements with `org.eclipse.core.expressions.PropertyTester`, in programmatic core expressions, and in **3.3** with <iterate/> and <count/> elements. | 3.2 |
42
-
| activeMenu | A `java.util.Collection` of `java.lang.String`| This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with <iterate/>, <count/>, and <test/> with a combined `org.eclipse.common.expressions.PropertyTester`. | 3.2 |
41
+
| org.eclipse.ui.selection |`Object`| The current global selection if the `ESelectionService` is used. It is often used with `<test/>` elements with `org.eclipse.core.expressions.PropertyTester`, in programmatic core expressions, potentially with `<iterate/>` and `<count/>` elements. | 4.0 |
42
+
| selection |`org.eclipse.jface.viewers.ISelection`| The current global selection. It is often used with `<test/>` elements with `org.eclipse.core.expressions.PropertyTester`, in programmatic core expressions, and in **3.3** with `<iterate/>` and `<count/>` elements. | 3.2 |
43
+
| activeMenu | A `java.util.Collection` of `java.lang.String`| This is the list of IDs of the showing context menu. Examples are like #TextEditorRuler or a part ID. Most commonly used with `<iterate/>`, `<count/>`, and `<test/>` with a combined `org.eclipse.common.expressions.PropertyTester`. | 3.2 |
43
44
| activeMenuSelection |`org.eclipse.jface.viewers.ISelection`| 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 `getSite().registerContextMenu(*)`. It is usually the same as the `selection`variable, but not always. This is more for legacy compatibility. | 3.3 |
44
45
| activeMenuEditorInput |`org.eclipse.jface.viewers.ISelection`| 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 `true` during `getEditorSite().registerContextMenu(*)`. This is more for legacy compatibility. | 3.3 |
45
46
| activeFocusControl |`org.eclipse.swt.widgets.Control`| A control that has focus and has been registered with the [IFocusService](https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/swt/IFocusService.java). | 3.3 |
46
47
| activeFocusControlId |`java.lang.String`| The ID of a control that has focus and has been registered with the `org.eclipse.ui.swt.IFocusService`. | 3.3 |
47
48
48
-
Note: All these variables can be used with <test/> and a `org.eclipse.common.expressions.PropertyTester`.
49
+
Note: All these variables can be used with `<test/>` and a `org.eclipse.common.expressions.PropertyTester`.
49
50
50
51
Property Testers
51
52
================
@@ -104,7 +105,7 @@ For example, to test an IResource name the property would be `org.eclipse.core.r
104
105
|**Property**|**Description**||
105
106
| isPerspectiveOpen | Tests if any perspective is open. ||
106
107
107
-
Expression examples
108
+
Expression Examples
108
109
===================
109
110
110
111
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.
@@ -118,7 +119,7 @@ You can browse the [plugin.xml](https://github.com/eclipse-platform/eclipse.plat
118
119
The InfoView provides an `IStructuredSelection` with 0 or more `org.eclipse.ui.examples.contributions.model.Person`.
119
120
120
121
When using the default variable, you must treat it as an `java.util.Collection`.
121
-
That means using <count> or <iterate>
122
+
That means using `<count>` or `<iterate>`
122
123
123
124
```xml
124
125
<activeWhen>
@@ -150,7 +151,7 @@ For example:
150
151
</activeWhen>
151
152
```
152
153
153
-
Active editor type
154
+
Active Editor Type
154
155
------------------
155
156
156
157
If you want your handler to be active for a specific type of editor, you can use **activeEditorId** to target your handler.
@@ -162,7 +163,7 @@ If you want your handler to be active for a specific type of editor, you can use
162
163
</activeWhen>
163
164
```
164
165
165
-
Complex nested boolean expressions
166
+
Complex Nested Boolean Expressions
166
167
----------------------------------
167
168
168
169
You can also write complex nested boolean expressions, like **(a & b & (c | d | (!e)))**:
@@ -188,16 +189,16 @@ New Core Expressions in 3.3
188
189
189
190
In 3.3 there were 2 additions to the core expressions framework.
190
191
191
-
count and iterate
192
+
Count and Iterate
192
193
-----------------
193
194
194
195
Count and iterate have always worked against `java.util.Collection`.
195
-
The <count/> and <iterate> elements can now be used on any variable that adapts to `org.eclipse.core.expressions.ICountable` and `org.eclipse.core.expressions.IIterable` or implements the interfaces directly.
196
+
The `<count/>` and `<iterate>` elements can now be used on any variable that adapts to `org.eclipse.core.expressions.ICountable` and `org.eclipse.core.expressions.IIterable` or implements the interfaces directly.
196
197
It wasn't possible to use the java 1.5 constructs for iterable.
197
198
198
199
The workbench provides an adapter for `ISelection` and `IStructuredSelection`.
199
200
200
-
definitions
201
+
Definitions
201
202
-----------
202
203
203
204
The **org.eclipse.core.expressions.definitions** extension point was introduced.
0 commit comments