Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Command Core Expressions"

(Variables and the Command Framework)
(Variables and the Command Framework)
Line 18: Line 18:
 
<th>Type</th>
 
<th>Type</th>
 
<th>Description</th>
 
<th>Description</th>
 +
<th>Since</th>
 
</tr>
 
</tr>
  
Line 26: Line 27:
 
This is a collection of the active context IDs as strings.  Most commonly used with &lt;iterate&gt; and &lt;count&gt;, and can also be used with &lt;test&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.
 
This is a collection of the active context IDs as strings.  Most commonly used with &lt;iterate&gt; and &lt;count&gt;, and can also be used with &lt;test&gt; and a <code>org.eclipse.common.expressions.PropertyTester</code>.
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 34: Line 36:
 
'''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>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 41: Line 44:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 48: Line 52:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 55: Line 60:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 62: Line 68:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.3</td>
 
</tr>
 
</tr>
  
Line 69: Line 76:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.3</td>
 
</tr>
 
</tr>
  
Line 76: Line 84:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 83: Line 92:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 90: Line 100:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 97: Line 108:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 104: Line 116:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 111: Line 124:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 118: Line 132:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.2</td>
 
</tr>
 
</tr>
  
Line 125: Line 140:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.3</td>
 
</tr>
 
</tr>
  
Line 132: Line 148:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.3</td>
 
</tr>
 
</tr>
  
Line 139: Line 156:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.3</td>
 
</tr>
 
</tr>
  
Line 146: Line 164:
 
<td>
 
<td>
 
</td>
 
</td>
 +
<td>3.3</td>
 
</tr>
 
</tr>
  

Revision as of 10:26, 12 June 2007

Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin.

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 Since
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 org.eclipse.common.expressions.PropertyTester.

3.2
activeActionSets An IActionSetDescriptor[]

Note: This is currently not used as points to an internal class and the type might change in any released.

3.2
activeShell org.eclipse.swt.widgets.Shell 3.2
activeWorkbenchWindowShell org.eclipse.swt.widgets.Shell 3.2
activeWorkbenchWindow org.eclipse.ui.IWorkbenchWindow 3.2
activeWorkbenchWindow.isCoolbarVisible java.lang.Boolean 3.3
activeWorkbenchWindow.isPerspectiveBarVisible java.lang.Boolean 3.3
activeEditor org.eclipse.ui.IEditorPart 3.2
activeEditorId java.lang.String 3.2
activePart org.eclipse.ui.IWorkbenchPart 3.2
activePartId java.lang.String 3.2
activeSite org.eclipse.ui.IWorkbenchPartSite 3.2
selection org.eclipse.jface.viewers.ISelection 3.2
activeMenu A java.util.Collection of java.lang.String 3.2
activeMenuSelection org.eclipse.jface.viewers.ISelection 3.3
activeMenuEditorInput org.eclipse.jface.viewers.ISelection 3.3
activeFocusControl org.eclipse.swt.widgets.Control 3.3
activeFocusControlId java.lang.String 3.3

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

Back to the top