Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Command Core Expressions"
(→Variables and the Command Framework) |
(→Variables and the Command Framework) |
||
Line 33: | Line 33: | ||
<td> | <td> | ||
'''Note:''' This is currently not used as points to an internal class and the type might change in any released. | '''Note:''' This is currently not used as points to an internal class and the type might change in any released. | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeShell</td> | ||
+ | <td><code>org.eclipse.swt.widgets.Shell</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeWorkbenchWindowShell</td> | ||
+ | <td><code>org.eclipse.swt.widgets.Shell</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeWorkbenchWindow</td> | ||
+ | <td><code>org.eclipse.ui.IWorkbenchWindow</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeWorkbenchWindow.isCoolbarVisible</td> | ||
+ | <td><code>java.lang.Boolean</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeWorkbenchWindow.isPerspectiveBarVisible</td> | ||
+ | <td><code>java.lang.Boolean</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeEditor</td> | ||
+ | <td><code>org.eclipse.ui.IEditorPart</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeEditorId</td> | ||
+ | <td><code>java.lang.String</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activePart</td> | ||
+ | <td><code>org.eclipse.ui.IWorkbenchPart</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activePartId</td> | ||
+ | <td><code>java.lang.String</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeSite</td> | ||
+ | <td><code>org.eclipse.ui.IWorkbenchPartSite</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>selection</td> | ||
+ | <td><code>org.eclipse.jface.viewers.ISelection</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeMenu</td> | ||
+ | <td>A <code>java.util.Collection</code> of <code>java.lang.String</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeMenuSelection</td> | ||
+ | <td><code>org.eclipse.jface.viewers.ISelection</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeMenuEditorInput</td> | ||
+ | <td><code>org.eclipse.jface.viewers.ISelection</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeFocusControl</td> | ||
+ | <td><code>org.eclipse.swt.widgets.Control</code></td> | ||
+ | <td> | ||
+ | </td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td>activeFocusControlId</td> | ||
+ | <td><code>java.lang.String</code></td> | ||
+ | <td> | ||
</td> | </td> | ||
</tr> | </tr> |
Revision as of 10:23, 12 June 2007
Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.
Contents
Expressions and the Command Framework
The Platform Command Framework uses 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.
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 java.util.Collection
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.
The <with/> element can be used to change which variable the child expression elements are evaluating against.
Variables and the Command Framework
The variables used for command framework evaluation are listed in ISources.java
Name | Type | Description |
---|---|---|
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> and <count>, and can also be used with <test> and a |
activeActionSets | An IActionSetDescriptor[] |
Note: This is currently not used as points to an internal class and the type might change in any released. |
activeShell | org.eclipse.swt.widgets.Shell |
|
activeWorkbenchWindowShell | org.eclipse.swt.widgets.Shell |
|
activeWorkbenchWindow | org.eclipse.ui.IWorkbenchWindow |
|
activeWorkbenchWindow.isCoolbarVisible | java.lang.Boolean |
|
activeWorkbenchWindow.isPerspectiveBarVisible | java.lang.Boolean |
|
activeEditor | org.eclipse.ui.IEditorPart |
|
activeEditorId | java.lang.String |
|
activePart | org.eclipse.ui.IWorkbenchPart |
|
activePartId | java.lang.String |
|
activeSite | org.eclipse.ui.IWorkbenchPartSite |
|
selection | org.eclipse.jface.viewers.ISelection |
|
activeMenu | A java.util.Collection of java.lang.String |
|
activeMenuSelection | org.eclipse.jface.viewers.ISelection |
|
activeMenuEditorInput | org.eclipse.jface.viewers.ISelection |
|
activeFocusControl | org.eclipse.swt.widgets.Control |
|
activeFocusControlId | java.lang.String |
Expression examples
Here are some examples. I'll pretend all of the examples are deciding when a handler is active.
Basic IStructuredSelection
A view provides a structured selection through its selection provider. An example would be the InfoView in org.eclipse.ui.examples.contributions. You can browse the plugin.xml and
InfoView.java files. The InfoView provides an IStructuredSelection
with 0 or more org.eclipse.ui.examples.contributions.model.Person
.
When using the default variable, you must treat it as an java.util.Collection
. That means using <count> or <iterate>
<activeWhen> <iterate> <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/> </iterate> </activeWhen>
Package Explorer IStructuredSelection
The Package Explorer is a mixture of org.eclipse.core.resources.IResource
and