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 "Menu Contributions"

(Menu XML)
m (Fixed a typo)
(20 intermediate revisions by 10 users not shown)
Line 4: Line 4:
  
 
The 4 extension points that deal with menus now org.eclipse.ui.actionSets, org.eclipse.ui.viewActions, org.eclipse.ui.editorActions, and org.eclipse.ui.popupMenus specify both menu placement and their visibility criteria.  In the new menu mechanism they are separate concepts, placement and visibility.
 
The 4 extension points that deal with menus now org.eclipse.ui.actionSets, org.eclipse.ui.viewActions, org.eclipse.ui.editorActions, and org.eclipse.ui.popupMenus specify both menu placement and their visibility criteria.  In the new menu mechanism they are separate concepts, placement and visibility.
 
 
  
 
= Example Matrix =
 
= Example Matrix =
Line 14: Line 12:
 
|-
 
|-
 
! Example !! comments
 
! Example !! comments
 +
|-
 +
| [[Menu Contributions/Dropdown Command]] || Dropdown tool items can have their menus filled in using menu contributions
 
|-
 
|-
 
| [[Menu Contributions/Problems View Example]] || An example showing how the Problems View might be converted
 
| [[Menu Contributions/Problems View Example]] || An example showing how the Problems View might be converted
Line 20: Line 20:
 
|-
 
|-
 
| [[Menu Contributions/Toggle Mark Occurrences]] || Placing the toggle mark occurrences button
 
| [[Menu Contributions/Toggle Mark Occurrences]] || Placing the toggle mark occurrences button
 +
|-
 +
| [[Menu Contributions/Toggle Button Command]] || Contribute a toggle state menu item thru commands
 +
|-
 +
| [[Menu Contributions/Radio Button Command]] || Similar to updating toggle state, you can create radio buttons using menu contributions
 
|-
 
|-
 
| [[Menu Contributions/Update checked state]] || The active handler can update the checked state (and other attributes) of its button
 
| [[Menu Contributions/Update checked state]] || The active handler can update the checked state (and other attributes) of its button
Line 32: Line 36:
 
|-
 
|-
 
| [[Menu Contributions/RCP removes the Project menu]] || An RCP application removes the Project menu.  Note: this will probably not be in 3.3
 
| [[Menu Contributions/RCP removes the Project menu]] || An RCP application removes the Project menu.  Note: this will probably not be in 3.3
 +
|-
 +
| [[Menu Contributions/Workbench wizard contribution]] || Contributing workbench wizards to Menu
 
|-
 
|-
 
|}
 
|}
Line 47: Line 53:
 
# You can reference a <menu/> by id.
 
# You can reference a <menu/> by id.
 
# If you are just creating menu items for your commands, you can leave them with only a command id.  You don't have to specify an item id.
 
# If you are just creating menu items for your commands, you can leave them with only a command id.  You don't have to specify an item id.
# You can reference an <command/> for placement options (after, before, etc) by id.
+
# You can reference a <command/> for placement options (after, before, etc.) by id.
 
# <separator/> ids only have to be unique within that menu level.  This is changed to name instead of id in '''3.3M5'''.
 
# <separator/> ids only have to be unique within that menu level.  This is changed to name instead of id in '''3.3M5'''.
# You can provide an <command/> label attribute.  If none is provided, it will take the command name.
+
# You can provide a <command/> label attribute.  If none is provided, it will take the command name.
 
# In this design the item contains most of the same rendering information that <action/> did.
 
# In this design the item contains most of the same rendering information that <action/> did.
 
# <menu/> and <command/> can have <visibleWhen/> clauses.  If a menu's <visibleWhen/> evaluates to false, we will never ask the items contained in that menu.
 
# <menu/> and <command/> can have <visibleWhen/> clauses.  If a menu's <visibleWhen/> evaluates to false, we will never ask the items contained in that menu.
# All of the display-able attributes are translatable.
+
# All of the displayable attributes are translatable.
# The mnemonic is specified as you place your <command/> elements in their respective menus, since it is possible that the same command might need a different mnemonic depending on which menu it is placed.  Also, when defaulting to command names they don't contain any mnemonic information.
+
# The mnemonic is specified as you place your <command/> elements in their respective menus, since it is possible that the same command might need a different mnemonic depending on which menu it is placed.  Also, when defaulting to command names, they don't contain any mnemonic information.
 
+
 
+
  
 
Menus cannot be re-used, and so they have an intrinsic id value.  Separators are unique within one menu level, so they also contain their name.
 
Menus cannot be re-used, and so they have an intrinsic id value.  Separators are unique within one menu level, so they also contain their name.
 
 
  
 
=== Menu URIs ===
 
=== Menu URIs ===
Line 93: Line 95:
 
=== Using Expressions in &lt;visibleWhen/&gt; ===
 
=== Using Expressions in &lt;visibleWhen/&gt; ===
  
In '''3.3M6''' an org.eclipse.core.expressions.definitions extension point was added. Used to define a core expression, the definition can then be referenced from other locations.
+
In '''3.3M6''' an org.eclipse.core.expressions.definitions extension point was added. Used to define a [[Platform Expression Framework|core expression]], the definition can then be referenced from other locations.
  
<extension point="org.eclipse.core.expressions.definitions">
+
<source lang="xml">
  <definition id="com.example.context">
+
<extension point="org.eclipse.core.expressions.definitions">
    <with variable="activeContexts">
+
  <definition id="com.example.context">
 +
    <with variable="activeContexts">
 
       <iterate operator="or">
 
       <iterate operator="or">
 
         <equals value="org.eclipse.ui.contexts.actionSet"/>
 
         <equals value="org.eclipse.ui.contexts.actionSet"/>
 
       </iterate>
 
       </iterate>
    <with>
+
    </with>
  </definition>
+
  </definition>
</extension>
+
</extension>
 +
</source>
  
 
This can be called in a core expression like activeWhen, enabledWhen, visibleWhen, etc using the reference element:
 
This can be called in a core expression like activeWhen, enabledWhen, visibleWhen, etc using the reference element:
  
<reference definitionId="com.example.context"/>
+
<source lang="xml">
 +
<reference definitionId="com.example.context"/>
 +
</source>
  
=== Ideas that were considered by not implemented ===
+
=== Ideas that were considered but not implemented ===
  
These ideas were considered by not implemented.
+
These ideas were considered but not implemented.
  
 
==== Menu - JSR198 ====
 
==== Menu - JSR198 ====
Line 122: Line 128:
 
* org.eclipse.ui.views.problems.resolveMarker.item from popup:org.eclipse.ui.views.ProblemView
 
* org.eclipse.ui.views.problems.resolveMarker.item from popup:org.eclipse.ui.views.ProblemView
  
  <menu-hook>
+
<source lang="xml">
    <actions>
+
<menu-hook>
      <action id="org.eclipse.ui.views.problems.sorting.item">
+
  <actions>
        <label>Sorting...</label>
+
    <action id="org.eclipse.ui.views.problems.sorting.item">
        <mnemonic>S</mnemonic>
+
      <label>Sorting...</label>
        <tooltip>Change the Sort order</tooltip>
+
      <mnemonic>S</mnemonic>
        <invoke-class>org.eclipse.ui.views.problems.sorting</invoke-class>
+
      <tooltip>Change the Sort order</tooltip>
      </action>
+
      <invoke-class>org.eclipse.ui.views.problems.sorting</invoke-class>
      <action id="org.eclipse.ui.views.problems.resolveMarker.item">
+
    </action>
        <label>Quick Fix</label>
+
    <action id="org.eclipse.ui.views.problems.resolveMarker.item">
        <mnemonic>Q</mnemonic>
+
      <label>Quick Fix</label>
        <iconpath>$nl$/icons/full/elcl16/smartmode_co.gif</iconpath>
+
      <mnemonic>Q</mnemonic>
        <invoke-class>org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals</invoke-class>
+
      <iconpath>$nl$/icons/full/elcl16/smartmode_co.gif</iconpath>
        <update-class>org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals</update-class>
+
      <invoke-class>org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals</invoke-class>
      </action>
+
      <update-class>org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals</update-class>
    </actions>
+
    </action>
    <menus>
+
  </actions>
      <menubar id="org.eclipse.ui.views.ProblemView">
+
  <menus>
        <menu id="org.eclipse.ui.views.ProblemView">
+
    <menubar id="org.eclipse.ui.views.ProblemView">
          <section id="problem.view.section">
+
      <menu id="org.eclipse.ui.views.ProblemView">
            <command action-ref="org.eclipse.ui.views.problems.sorting.item" />
+
        <section id="problem.view.section">
            <menu id="org.eclipse.ui.views.problems.groupBy.menu">
+
          <command action-ref="org.eclipse.ui.views.problems.sorting.item" />
              <label>Group By</label>
+
          <menu id="org.eclipse.ui.views.problems.groupBy.menu">
              <mnemonic>G</mnemonic>
+
            <label>Group By</label>
            </menu>
+
            <mnemonic>G</mnemonic>
           </section>
+
           </menu>
        </menu>
+
      </menubar>
+
      <popup id="org.eclipse.ui.views.ProblemView">
+
        <section id="group.resolve">
+
          <command action-ref="org.eclipse.ui.views.problems.resolveMarker.item" />
+
 
         </section>
 
         </section>
       </popup>
+
       </menu>
     </menus>
+
    </menubar>
   </menu-hook>
+
    <popup id="org.eclipse.ui.views.ProblemView">
 +
      <section id="group.resolve">
 +
        <command action-ref="org.eclipse.ui.views.problems.resolveMarker.item" />
 +
      </section>
 +
     </popup>
 +
   </menus>
 +
</menu-hook>
 +
</source>
  
 
Some thoughts:
 
Some thoughts:
Line 171: Line 179:
 
For comparison, with Mozilla everywhere there is the probability eclipse will include xulrunner.  Menu definitions that are consistent with XUL look like:
 
For comparison, with Mozilla everywhere there is the probability eclipse will include xulrunner.  Menu definitions that are consistent with XUL look like:
  
  <keyset>
+
<source lang="xml">
    <key id="paste-key" modifiers="accel" key="V" />
+
<keyset>
  </keyset>
+
  <key id="paste-key" modifiers="accel" key="V" />
  <menubar id="org.eclipse.ui.views.ProblemView">
+
</keyset>
    <menupopup id="org.eclipse.ui.views.ProblemView">
+
<menubar id="org.eclipse.ui.views.ProblemView">
      <menuitem id="org.eclipse.ui.views.problems.sorting.item"
+
  <menupopup id="org.eclipse.ui.views.ProblemView">
                accesskey="S"
+
    <menuitem id="org.eclipse.ui.views.problems.sorting.item"
                key="paste-key"
+
        accesskey="S"
                label="Sorting..."
+
        key="paste-key"
                oncommand="invokeCommand('org.eclipse.ui.views.problems.sorting')" />
+
        label="Sorting..."
      <menu id="org.eclipse.ui.views.problems.groupBy.menu"
+
        oncommand="invokeCommand('org.eclipse.ui.views.problems.sorting')" />
            label="Group By"
+
    <menu id="org.eclipse.ui.views.problems.groupBy.menu"
            accesskey="G">
+
        label="Group By"
        <menupopup id="groupby.popup">
+
        accesskey="G">
          <!-- this is where submenu items would go -->
+
      <menupopup id="groupby.popup">
        </menupopup>
+
        <!-- this is where submenu items would go -->
      </menu>
+
      </menupopup>
    </menupopup>
+
    </menu>
  </menubar>
+
  </menupopup>
 
+
</menubar>
 +
</source>
  
 
XUL supports everything as a flavour of a DOM, and javascripting can drive your buttons to perform commands.  I suspect the scripting would allow you to dynamically update menus (dynamic menus) on popup, depending on what events the DOM would report to you.
 
XUL supports everything as a flavour of a DOM, and javascripting can drive your buttons to perform commands.  I suspect the scripting would allow you to dynamically update menus (dynamic menus) on popup, depending on what events the DOM would report to you.
Line 202: Line 211:
 
Here's an example of using expression templates in its own extension point.
 
Here's an example of using expression templates in its own extension point.
  
  <extension point="org.eclipse.core.expression.templates">
+
<source lang="xml">
    <expression id="isPartActive">
+
<extension point="org.eclipse.core.expression.templates">
      <parameter id="partId" />
+
  <expression id="isPartActive">
      <with variable="activePartId">
+
    <parameter id="partId" />
        <equals value="$partId" />
+
    <with variable="activePartId">
      </with>
+
      <equals value="$partId" />
    </expression>
+
    </with>
    <expression id="isActionSetActive">
+
  </expression>
      <parameter id="actionSetId" />
+
  <expression id="isActionSetActive">
      <with variable="activeContexts">
+
    <parameter id="actionSetId" />
        <iterator operator="or">
+
    <with variable="activeContexts">
          <equals value="$actionSetId" />
+
      <iterator operator="or">
        </iterator>
+
        <equals value="$actionSetId" />
      </with>
+
      </iterator>
    </expression>
+
    </with>
    <expression id="isContextActive">
+
  </expression>
      <parameter id="contextId" />
+
  <expression id="isContextActive">
      <with variable="activeContexts">
+
    <parameter id="contextId" />
        <iterator operator="or">
+
    <with variable="activeContexts">
          <equals value="$contextId" />
+
      <iterator operator="or">
        </iterator>
+
        <equals value="$contextId" />
      </with>
+
      </iterator>
    </expression>
+
    </with>
    <expression id="isSelectionAvailable">
+
  </expression>
      <not>
+
  <expression id="isSelectionAvailable">
        <count value="0" />
+
    <not>
      </not>
+
      <count value="0" />
    </expression>
+
    </not>
  </extension>
+
  </expression>
 
+
</extension>
 +
</source>
  
 
This could be used to simplify the handler definitions:
 
This could be used to simplify the handler definitions:
  
  <extension point="org.eclipse.ui.handlers">
+
<source lang="xml">
    <handler commandId="org.eclipse.ui.edit.copy"
+
<extension point="org.eclipse.ui.handlers">
            class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
+
  <handler commandId="org.eclipse.ui.edit.copy"
      <enabledWhen>
+
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
        <evaluate ref="isSelectionAvailable" />
+
    <enabledWhen>
      </enabledWhen>
+
      <evaluate ref="isSelectionAvailable" />
      <activeWhen>
+
    </enabledWhen>
        <evaluate ref="isPartActive">
+
    <activeWhen>
          <parameter id="partId" value="org.eclipse.ui.views.ProblemView" />
+
        </evaluate>
+
      </activeWhen>
+
    </handler>
+
  </extension>
+
 
+
 
+
If we allow recursive template definitions, that would allow you to specify the concrete expression once and then reference it throughout your view.
+
 
+
  <extension point="org.eclipse.core.expression.templates">
+
    <expression id="isProblemViewActive">
+
 
       <evaluate ref="isPartActive">
 
       <evaluate ref="isPartActive">
 
         <parameter id="partId" value="org.eclipse.ui.views.ProblemView" />
 
         <parameter id="partId" value="org.eclipse.ui.views.ProblemView" />
 
       </evaluate>
 
       </evaluate>
     </expression>
+
     </activeWhen>
   </extension>
+
   </handler>
  <extension point="org.eclipse.ui.handlers">
+
</extension>
    <handler commandId="org.eclipse.ui.edit.copy"
+
</source>
            class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
+
 
      <enabledWhen>
+
If we allow recursive template definitions, that would allow you to specify the concrete expression once and then reference it throughout your view.
        <evaluate ref="isSelectionAvailable" />
+
      </enabledWhen>
+
      <activeWhen>
+
        <evaluate ref="isProblemViewActive" />
+
      </activeWhen>
+
    </handler>
+
  </extension>
+
  
 +
<source lang="xml">
 +
<extension point="org.eclipse.core.expression.templates">
 +
  <expression id="isProblemViewActive">
 +
    <evaluate ref="isPartActive">
 +
      <parameter id="partId" value="org.eclipse.ui.views.ProblemView" />
 +
    </evaluate>
 +
  </expression>
 +
</extension>
 +
<extension point="org.eclipse.ui.handlers">
 +
  <handler commandId="org.eclipse.ui.edit.copy"
 +
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
 +
    <enabledWhen>
 +
      <evaluate ref="isSelectionAvailable" />
 +
    </enabledWhen>
 +
    <activeWhen>
 +
      <evaluate ref="isProblemViewActive" />
 +
    </activeWhen>
 +
  </handler>
 +
</extension>
 +
</source>
  
 
This reduces the handler definition even more.
 
This reduces the handler definition even more.
Line 277: Line 289:
 
A similar option to reuse expressions as much as possible without turning them into their own procedural language would be to allow global definitions and then reuse them.  No parameters and no expression composition:
 
A similar option to reuse expressions as much as possible without turning them into their own procedural language would be to allow global definitions and then reuse them.  No parameters and no expression composition:
  
  <extension point="org.eclipse.core.expression.templates">
+
<source lang="xml">
    <expression id="isProblemViewActive">
+
<extension point="org.eclipse.core.expression.templates">
      <with variable="activePartId">
+
  <expression id="isProblemViewActive">
        <equals value="org.eclipse.ui.views.ProblemView" />
+
    <with variable="activePartId">
      </with>
+
      <equals value="org.eclipse.ui.views.ProblemView" />
    </expression>
+
    </with>
    <expression id="isSelectionAvailable">
+
  </expression>
      <not>
+
  <expression id="isSelectionAvailable">
        <count value="0" />
+
    <not>
      </not>
+
      <count value="0" />
    </expression>
+
    </not>
  </extension>
+
  </expression>
  <extension point="org.eclipse.ui.handlers">
+
</extension>
    <handler commandId="org.eclipse.ui.edit.copy"
+
<extension point="org.eclipse.ui.handlers">
            class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
+
  <handler commandId="org.eclipse.ui.edit.copy"
      <enabledWhen ref="isSelectionAvailable" />
+
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
      <activeWhen ref="isProblemViewActive" />
+
    <enabledWhen ref="isSelectionAvailable" />
    </handler>
+
    <activeWhen ref="isProblemViewActive" />
  </extension>
+
  </handler>
 +
</extension>
 +
</source>
  
 
==== Another Expression Alternative: Specify Context at Extension Level ====
 
==== Another Expression Alternative: Specify Context at Extension Level ====
Line 302: Line 316:
 
Since <code>enabledWhen</code> and <code>activeWhen</code> specify context and the simple way to specify context in XML is enclosure, how about scoping context to the extension point rather than the handler:
 
Since <code>enabledWhen</code> and <code>activeWhen</code> specify context and the simple way to specify context in XML is enclosure, how about scoping context to the extension point rather than the handler:
  
  <extension point="org.eclipse.ui.handlers">
+
<source lang="xml">
      <enabledWhen>  <!-- context of all  handlers in this extension -->
+
<extension point="org.eclipse.ui.handlers">
        <not>
+
  <enabledWhen>  <!-- context of all  handlers in this extension -->
          <count value="0" />
+
    <not>
        </not>
+
      <count value="0" />
      </enabledWhen>
+
    </not>
      <activeWhen>
+
  </enabledWhen>
        <with variable="activePartId">
+
  <activeWhen>
          <equals value="org.eclipse.ui.views.ProblemView" />
+
    <with variable="activePartId">
        </with>
+
      <equals value="org.eclipse.ui.views.ProblemView" />
      </activeWhen>
+
    </with>
      <handler commandId="org.eclipse.ui.edit.copy"
+
  </activeWhen>
            class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler" />
+
  <handler commandId="org.eclipse.ui.edit.copy"
      <handler commandId="org.eclipse.ui.edit.paste"
+
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler" />
            class="org.eclipse.ui.views.markers.internal.PasteMarkerHandler" />
+
  <handler commandId="org.eclipse.ui.edit.paste"
      <handler commandId="org.eclipse.ui.edit.delete"
+
      class="org.eclipse.ui.views.markers.internal.PasteMarkerHandler" />
            class="org.eclipse.ui.views.markers.internal.RemoveMarkerHandler" />
+
  <handler commandId="org.eclipse.ui.edit.delete"
      <handler commandId="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
+
      class="org.eclipse.ui.views.markers.internal.RemoveMarkerHandler" />
            class="org.eclipse.ui.views.markers.internal.ResolveMarkerHandler" />
+
  <handler commandId="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
      <handler commandId="org.eclipse.ui.edit.selectAll"
+
      class="org.eclipse.ui.views.markers.internal.ResolveMarkerHandler" />
            class="org.eclipse.ui.views.markers.internal.SelectAllMarkersHandler" />
+
  <handler commandId="org.eclipse.ui.edit.selectAll"
      <handler commandId="org.eclipse.ui.file.properties"
+
      class="org.eclipse.ui.views.markers.internal.SelectAllMarkersHandler" />
            class="org.eclipse.ui.views.markers.internal.ProblemPropertiesHandler" />
+
  <handler commandId="org.eclipse.ui.file.properties"
  </extension>
+
      class="org.eclipse.ui.views.markers.internal.ProblemPropertiesHandler" />
 +
</extension>
 +
</source>
  
 
This gives compact markup without inventing a new language.  Elements nested in the handler element could override the extension-wide settings.
 
This gives compact markup without inventing a new language.  Elements nested in the handler element could override the extension-wide settings.
Line 338: Line 354:
 
#setting the item state (like checked state)
 
#setting the item state (like checked state)
  
In 3.3 the enablement is tied to the command, and for the other behaviours we've decided to go with option 1.
+
In 3.3 the enablement is tied to the command, and for the other behaviours we've decided to go with UIElements approach.
  
Option 1:
+
== UIElements represent each UI visible instance of a command ==
  
The command service keeps a list of registered UI elements, which can be updated by the active handler.  The checked state can be updated through UIElement#setChecked(boolean);
+
The command service keeps a list of registered UI elements, which can be updated by the active handler.  The checked state can be updated through <tt>UIElement#setChecked(boolean);</tt> (note that <tt>updateElement</tt> below is from <tt>IElementUpdater</tt>):
  
private boolean isChecked() {
+
<source lang="java">
return getStore().getBoolean(
+
private boolean isChecked() {
PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+
    return getStore().getBoolean(
}
+
            PreferenceConstants.EDITOR_MARK_OCCURRENCES);
 +
}
 
   
 
   
public void updateElement(UIElement element, Map parameters) {
+
public void updateElement(UIElement element, Map parameters) {
element.setChecked(isChecked());
+
    element.setChecked(isChecked());
}
+
}
 +
</source>
  
When the toggle handler runs, it can request that any UI elements have their appearance updated from its execute(*) method:
+
When the toggle handler runs, it can request that any UI elements have their appearance updated from its <tt>execute(*)</tt> method:
  
ICommandService service = (ICommandService) serviceLocator
+
<source lang="java">
.getService(ICommandService.class);
+
ICommandService service = (ICommandService) serviceLocator
service.refreshElements(
+
        .getService(ICommandService.class);
IJavaEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES,
+
service.refreshElements(IJavaEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, null);
null);
+
</source>
  
 
+
== State associated with the command is propogated to UI visible elements ==
 
+
Option 2:
+
  
 
First define the toggle mark occurrences command.  Pretty straight forward,
 
First define the toggle mark occurrences command.  Pretty straight forward,
Line 369: Line 385:
 
update the label for the menu/toolbar items, we also add the "NAME" state.
 
update the label for the menu/toolbar items, we also add the "NAME" state.
  
  <extension point="org.eclipse.ui.commands">
+
<source lang="xml">
    <command categoryId="org.eclipse.jdt.ui.category.source"
+
<extension point="org.eclipse.ui.commands">
            description="%jdt.ui.ToggleMarkOccurrences.description"
+
  <command categoryId="org.eclipse.jdt.ui.category.source"
            id="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"
+
      description="%jdt.ui.ToggleMarkOccurrences.description"
            name="%jdt.ui.ToggleMarkOccurrences.name">
+
      id="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"
      <state id="NAME" class="org.eclipse.jface.menus.TextState" />
+
      name="%jdt.ui.ToggleMarkOccurrences.name">
      <state id="STYLE" class="org.eclipse.jface.commands.ToggleState:true" />
+
    <state id="NAME" class="org.eclipse.jface.menus.TextState" />
    </command>
+
    <state id="STYLE" class="org.eclipse.jface.commands.ToggleState:true" />
  </extension>
+
  </command>
 +
</extension>
 +
</source>
  
 +
= Work =
  
 +
Progress in 3.3.
  
 +
== Available in 3.3 ==
  
 +
* [[Image:Ok_green.gif]] the editor action bar contributor solution.  EditorActionBarContributor will not be deprecated, but is not used in the commands/handler story.  Menu Contributions have visibility tied to an active editor id, and editor specific handlers can be created in the editor init(*) or createPartControl(*) method using the handler service from getPartSite().getService(IHandlerService.class).
 +
* [[Image:Ok_green.gif]] Attributes for <command/>: '''helpContextId''', '''style''' to support radio buttons and check boxes
 +
* [[Image:Ok_green.gif]] action sets as contexts - action sets are still defined using org.eclipse.ui.actionSets, and each actionSet generates an equivalent context.  showing/hiding actionSets activates/deactivates the equivalent context.
 +
* [[Image:Ok_green.gif]] How do we give Trim widgets/toolbar widgets "focus" for command and handlers?  There was an IFocusService added in 3.3 that allows a trim control to register itself.  When that control has focus, the control and the ID it registered with are provided in the global application context to core expressions and handlers.  This is available, but might not be the optimal solution if you just want cut, copy, and paste to work.
 +
* [[Image:Ok_green.gif]] Shortcuts to define reusable core expressions for <activeWhen/>, <enabledWhen/>, and <visibleWhen/>. This has been added as the org.eclipse.core.expressions.definitions extension point and the core expression <reference/> element.
 +
* [[Image:Ok_green.gif]] the mnemonic field for <command/> elements (decorating)
 +
* [[Image:Ok_green.gif]] display any keybinding for <command/> elements (decorating)
 +
* [[Image:Ok_green.gif]] toolbar <visibleWhen/> expressions
  
 +
== Available in 3.3M5 ==
  
= Work =
+
There is an example of the RCP Mail application template updated for 3.3M5 and converted to use the org.eclipse.ui.menus extension point as much as possible at [http://dev.eclipse.org/viewcvs/index.cgi/platform-ui-home/R3_3/contributions-proposal/ Contribution Example].
  
This is a work list Eric and I threw together.
+
* [[Image:Ok_green.gif]]  changing the menu item or tool item state from a handler, like updating the label or tooltip or checked state.  Commands can contain <state/> elements, but that is not appropriate to use for providing feedback to the user.  This will be done by adapting a callback provided by the UI element.
 +
* [[Image:Ok_green.gif]] the <separator/> element should have a '''name''' not an '''id'''
 +
* [[Image:Ok_green.gif]] support creating radio button or checked menu items
 +
* [[Image:Ok_green.gif]] creating new toolbars in the main coolbar/trim declaratively
 +
* [[Image:Ok_green.gif]] creating new toolbars in the main coolbar/trim programmatically
 +
* [[Image:Ok_green.gif]] org.eclipse.ui.popup.any as a context menu contribution
 +
* [[Image:Ok_green.gif]] Drop down toolbar items
 +
 
 +
We also have action sets activating and de-activating contexts in '''3.3M5''', but we'll need to decide the proper action set story for '''3.3M6'''
 +
 
 +
We are still working on the EditorActionBarContributor story.  It seems like we might be able to deprecate it.  Editor instances can instantiate handlers upon creation for each command they support.
  
 
== Available in 3.3M4 ==
 
== Available in 3.3M4 ==
Line 405: Line 445:
 
There are some specific mappings of elements and attributes on [[Menus Extension Mapping]].
 
There are some specific mappings of elements and attributes on [[Menus Extension Mapping]].
  
== Available in 3.3M5 ==
 
 
There is an example of the RCP Mail application template updated for 3.3M5 and converted to use the org.eclipse.ui.menus extension point as much as possible at [http://dev.eclipse.org/viewcvs/index.cgi/platform-ui-home/R3_3/contributions-proposal/ Contribution Example].
 
 
 
* [[Image:Checkmark-10x10.gif]] changing the menu item or tool item state from a handler, like updating the label or tooltip or checked state.  Commands can contain <state/> elements, but that is not appropriate to use for providing feedback to the user.  This will be done by adapting a callback provided by the UI element.
 
* [[Image:Checkmark-10x10.gif]] the <separator/> element should have a '''name''' not an '''id'''
 
* [[Image:Checkmark-10x10.gif]] support creating radio button or checked menu items
 
* [[Image:Checkmark-10x10.gif]] creating new toolbars in the main coolbar/trim declaratively
 
* [[Image:Checkmark-10x10.gif]] creating new toolbars in the main coolbar/trim programmatically
 
* [[Image:Checkmark-10x10.gif]] org.eclipse.ui.popup.any as a context menu contribution
 
* [[Image:Checkmark-10x10.gif]] Drop down toolbar items
 
 
We also have action sets activating and de-activating contexts in '''3.3M5''', but we'll need to decide the proper action set story for '''3.3M6'''
 
 
We are still working on the EditorActionBarContributor story.  It seems like we might be able to deprecate it.  Editor instances can instantiate handlers upon creation for each command they support.
 
  
 
== Work still to be done ==
 
== Work still to be done ==
  
  
A list of behaviours not supported or shipped with the '''3.3M5''' API.
+
A list of behaviours not supported or shipped with '''3.3'''.
  
* [[Image:Progress.gif]] the editor action bar contributor solution
+
* validate and possibly optimize the context menu population story and lifecycle.  Many context menus set remove all when shown.
* [[Image:Progress.gif]] Attributes for <command/>: '''helpContextId''', '''style''' to support radio buttons and check boxes, '''state''' for checkboxes and radio buttons
+
* [[Image:Progress.gif]] action sets as contexts
+
* [[Image:Progress.gif]] validate and possibly optimize the context menu population story and lifecycle.  Many context menus set remove all when shown.
+
 
* migrate Marker views
 
* migrate Marker views
* How do we give Trim widgets/toolbar widgets "focus" for command and handlers?
+
* migrate standard workbench actions - a few were done
*
+
* [[Image:Glass.gif]] migrate standard workbench actions
+
* Shortcuts to define reusable core expressions for <activeWhen/>, <enabledWhen/>, and <visibleWhen/>
+
 
* Check enabled visibleWhen support
 
* Check enabled visibleWhen support
* the mnemonic field for <command/> elements (decorating)
 
* display any keybinding for <command/> elements (decorating)
 
 
* Shortcuts placed on submenu items (like CTRL+N) (decorating)
 
* Shortcuts placed on submenu items (like CTRL+N) (decorating)
 
* ensure full visibleWhen support in the MenuManagers - i.e. should empty menus display '''(empty)'''
 
* ensure full visibleWhen support in the MenuManagers - i.e. should empty menus display '''(empty)'''
Line 444: Line 460:
 
* the menu override capability - does this tie into the Customize Perspective dialog and action sets
 
* the menu override capability - does this tie into the Customize Perspective dialog and action sets
 
* A set of default programmatic core expressions.  For example, ActionContextExpression or ActivePartExpression
 
* A set of default programmatic core expressions.  For example, ActionContextExpression or ActivePartExpression
* toolbar <visibleWhen/> expressions
 
 
* deprecate the 4 extension: actionSets, viewActions, editorActions, popupMenus
 
* deprecate the 4 extension: actionSets, viewActions, editorActions, popupMenus
 
* read old extensions in terms of new extension
 
* read old extensions in terms of new extension
 
* convert platform UI extensions to new extension
 
* convert platform UI extensions to new extension
 
* migration guide - what are the most common migration paths for Action and IActionDelegate to Command/IHandler.
 
* migration guide - what are the most common migration paths for Action and IActionDelegate to Command/IHandler.
 +
* Attributes for <command/>:  '''state''' for checkboxes and radio buttons
 
* possibly provide an plugin.xml converter for actionSets to menus
 
* possibly provide an plugin.xml converter for actionSets to menus
 
* possibly provide an Action -> Handler converter
 
* possibly provide an Action -> Handler converter
* ensure expressions can be reused
 
 
* [[Image:Error.gif]] status manager contributions
 
* [[Image:Error.gif]] status manager contributions
  
Line 459: Line 474:
 
* [[Image:Glass.gif]] - investigating
 
* [[Image:Glass.gif]] - investigating
 
* [[Image:Progress.gif]] - in progress
 
* [[Image:Progress.gif]] - in progress
* [[Image:Checkmark-10x10.gif]] - completed
+
* [[Image:Ok_green.gif]] - completed
 
* [[Image:Error.gif]] - dropped
 
* [[Image:Error.gif]] - dropped
  
 
+
[[Category:Eclipse Project]]
<!-- to be used when we complete information
+
list at http://dev.eclipse.org/viewcvs/index.cgi/platform-core-home/images/
+
 
+
complete      = http://www.eclipse.org/eclipse/platform-core/images/small_check.gif
+
dropped      = http://www.eclipse.org/eclipse/platform-core/images/small_x.gif
+
in progress  = http://www.eclipse.org/eclipse/platform-core/images/progress.gif
+
Investigating = http://www.eclipse.org/eclipse/platform-core/images/glass.gif
+
 
+
-->
+

Revision as of 15:48, 24 December 2012

Placement examples that describe the proposed new way of placing menu items for 3.3. Please contribute comments and suggestions in the discussion area or on Bug 154130 -KeyBindings- Finish re-work of commands and key bindings.

Placement and visibility

The 4 extension points that deal with menus now org.eclipse.ui.actionSets, org.eclipse.ui.viewActions, org.eclipse.ui.editorActions, and org.eclipse.ui.popupMenus specify both menu placement and their visibility criteria. In the new menu mechanism they are separate concepts, placement and visibility.

Example Matrix

A (hopefully) growing list of menu contribution examples.

Example comments
Menu Contributions/Dropdown Command Dropdown tool items can have their menus filled in using menu contributions
Menu Contributions/Problems View Example An example showing how the Problems View might be converted
Menu Contributions/Populating a dynamic submenu A menu contribution to populate a Problems View dynamic submenu
Menu Contributions/Toggle Mark Occurrences Placing the toggle mark occurrences button
Menu Contributions/Toggle Button Command Contribute a toggle state menu item thru commands
Menu Contributions/Radio Button Command Similar to updating toggle state, you can create radio buttons using menu contributions
Menu Contributions/Update checked state The active handler can update the checked state (and other attributes) of its button
Menu Contributions/Search Menu Adding the Java Search options to the Search menu
Menu Contributions/IFile objectContribution A menu contribution for context menus when the selection is an IFile
Menu Contributions/TextEditor viewerContribution A menu contribution for the text editor context menu
Menu Contributions/Widget in a toolbar A menu contribution adding a control into the main toolbar
Menu Contributions/RCP removes the Project menu An RCP application removes the Project menu. Note: this will probably not be in 3.3
Menu Contributions/Workbench wizard contribution Contributing workbench wizards to Menu

Menu XML

Declarative information ... this needs to be cleaned up.

Declarative menus - some constraints

Some constraints on the system:

  1. Identifiers (id) for <menu/> elements must be globally unique.
  2. Identifiers (id) for <command/> elements must be globally unique if they are specified.
  3. You can reference a <menu/> by id.
  4. If you are just creating menu items for your commands, you can leave them with only a command id. You don't have to specify an item id.
  5. You can reference a <command/> for placement options (after, before, etc.) by id.
  6. <separator/> ids only have to be unique within that menu level. This is changed to name instead of id in 3.3M5.
  7. You can provide a <command/> label attribute. If none is provided, it will take the command name.
  8. In this design the item contains most of the same rendering information that <action/> did.
  9. <menu/> and <command/> can have <visibleWhen/> clauses. If a menu's <visibleWhen/> evaluates to false, we will never ask the items contained in that menu.
  10. All of the displayable attributes are translatable.
  11. The mnemonic is specified as you place your <command/> elements in their respective menus, since it is possible that the same command might need a different mnemonic depending on which menu it is placed. Also, when defaulting to command names, they don't contain any mnemonic information.

Menus cannot be re-used, and so they have an intrinsic id value. Separators are unique within one menu level, so they also contain their name.

Menu URIs

For location placement we need a path and placement modifier, and to specify how the paths are built. First pass we are going to look at URIs.

  • <scheme>:<menu-id>[?<placement-modifier>]

scheme is about how to interpret the URI path. For example, menu, toolbar, popup, status (although status may be deprecated).

menu:

For menu: valid root ids will be any viewId for that view's menu, and org.eclipse.ui.main.menu for the main menu. Then specify the id of the menu this contribution applies to. The placement modifier helps position the menu contribution. ex: after=<id>, where <id> can be a separator name, menu id, or item id. An example of a path: menu:org.eclipse.search.menu?after=contextMenuActionsGroup

Since menu ids must be unique, you can specify your menu location relative to an existing id: menu:org.eclipse.search.menu?after=contextMenuActionsGroup

toolbar:

For toolbar: valid root ids will be any viewId for that view's toolbar, org.eclipse.ui.main.toolbar for the main toolbar, and any toolbar id that is contained in the main toolbar. Toolbars can support invisible separators. Toolbars in the main toolbar (technically a coolbar) can have ids as well as separators, but only one level. For example: toolbar:org.eclipse.ui.edit.text.actionSet.presentation?after=Presentation

In this example, Presentation is an invisible separator in the org.eclipse.ui.edit.text.actionSet.presentation toolbar.

The use of org.eclipse.ui.main.toolbar might change if all "main" toolbars have ids anyway, so the only options for interpretting the toolbar root is 1) the view toolbar or 2) an IDed main toolbar.

popup:

For popup: valid root ids are any registered context id (which defaults to the part id if no context menu id was given at registration time) and org.eclipse.ui.popup.any for all registered context menus. For example, to add to the default Text Editor context menu: popup:#TextEditorContext?after=additions

Popup submenus are treated like menu submenus, except the form continues to be popup:submenuId.

There will be constants defined for the ids that the eclipse workbench provides, probably in org.eclipse.ui.menus.MenuUtil.

Using Expressions in <visibleWhen/>

In 3.3M6 an org.eclipse.core.expressions.definitions extension point was added. Used to define a core expression, the definition can then be referenced from other locations.

<extension point="org.eclipse.core.expressions.definitions">
  <definition id="com.example.context">
    <with variable="activeContexts">
       <iterate operator="or">
         <equals value="org.eclipse.ui.contexts.actionSet"/>
       </iterate>
    </with>
  </definition>
</extension>

This can be called in a core expression like activeWhen, enabledWhen, visibleWhen, etc using the reference element:

<reference definitionId="com.example.context"/>

Ideas that were considered but not implemented

These ideas were considered but not implemented.

Menu - JSR198

Note: for novelty purposes only.

For comparison, there is a JSR describing how IDEs can contribute menus. Below is a sample for 2 items:

  • org.eclipse.ui.views.problems.sorting.item from menu:org.eclipse.ui.views.ProblemView
  • org.eclipse.ui.views.problems.resolveMarker.item from popup:org.eclipse.ui.views.ProblemView
<menu-hook>
  <actions>
    <action id="org.eclipse.ui.views.problems.sorting.item">
      <label>Sorting...</label>
      <mnemonic>S</mnemonic>
      <tooltip>Change the Sort order</tooltip>
      <invoke-class>org.eclipse.ui.views.problems.sorting</invoke-class>
    </action>
    <action id="org.eclipse.ui.views.problems.resolveMarker.item">
      <label>Quick Fix</label>
      <mnemonic>Q</mnemonic>
      <iconpath>$nl$/icons/full/elcl16/smartmode_co.gif</iconpath>
      <invoke-class>org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals</invoke-class>
      <update-class>org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals</update-class>
    </action>
  </actions>
  <menus>
    <menubar id="org.eclipse.ui.views.ProblemView">
      <menu id="org.eclipse.ui.views.ProblemView">
        <section id="problem.view.section">
          <command action-ref="org.eclipse.ui.views.problems.sorting.item" />
          <menu id="org.eclipse.ui.views.problems.groupBy.menu">
            <label>Group By</label>
            <mnemonic>G</mnemonic>
          </menu>
        </section>
      </menu>
    </menubar>
    <popup id="org.eclipse.ui.views.ProblemView">
      <section id="group.resolve">
        <command action-ref="org.eclipse.ui.views.problems.resolveMarker.item" />
      </section>
    </popup>
  </menus>
</menu-hook>

Some thoughts:

  • the actions can only specify one icon
  • the actions can't *quite* link to our commands
  • the menus can't specify dynamic submenus

Menu - XUL

Note: for novelty purposes only.


For comparison, with Mozilla everywhere there is the probability eclipse will include xulrunner. Menu definitions that are consistent with XUL look like:

<keyset>
  <key id="paste-key" modifiers="accel" key="V" />
</keyset>
<menubar id="org.eclipse.ui.views.ProblemView">
  <menupopup id="org.eclipse.ui.views.ProblemView">
    <menuitem id="org.eclipse.ui.views.problems.sorting.item"
        accesskey="S"
        key="paste-key"
        label="Sorting..."
        oncommand="invokeCommand('org.eclipse.ui.views.problems.sorting')" />
    <menu id="org.eclipse.ui.views.problems.groupBy.menu"
        label="Group By"
        accesskey="G">
      <menupopup id="groupby.popup">
        <!-- this is where submenu items would go -->
      </menupopup>
    </menu>
  </menupopup>
</menubar>

XUL supports everything as a flavour of a DOM, and javascripting can drive your buttons to perform commands. I suspect the scripting would allow you to dynamically update menus (dynamic menus) on popup, depending on what events the DOM would report to you.


Expression Templates original suggestion

You can see that the <activeWhen/>, <enabledWhen/>, and probably the <visibleWhen/> are likely to be replicated over and over again. A possible option is some kind of expression template markup ... either in its own extension or supported by our UI extensions that can use core expressions.

Here's an example of using expression templates in its own extension point.

<extension point="org.eclipse.core.expression.templates">
  <expression id="isPartActive">
    <parameter id="partId" />
    <with variable="activePartId">
      <equals value="$partId" />
    </with>
  </expression>
  <expression id="isActionSetActive">
    <parameter id="actionSetId" />
    <with variable="activeContexts">
      <iterator operator="or">
        <equals value="$actionSetId" />
      </iterator>
    </with>
  </expression>
  <expression id="isContextActive">
    <parameter id="contextId" />
    <with variable="activeContexts">
      <iterator operator="or">
        <equals value="$contextId" />
      </iterator>
    </with>
  </expression>
  <expression id="isSelectionAvailable">
    <not>
      <count value="0" />
    </not>
  </expression>
</extension>

This could be used to simplify the handler definitions:

<extension point="org.eclipse.ui.handlers">
  <handler commandId="org.eclipse.ui.edit.copy"
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
    <enabledWhen>
      <evaluate ref="isSelectionAvailable" />
    </enabledWhen>
    <activeWhen>
      <evaluate ref="isPartActive">
        <parameter id="partId" value="org.eclipse.ui.views.ProblemView" />
      </evaluate>
    </activeWhen>
  </handler>
</extension>

If we allow recursive template definitions, that would allow you to specify the concrete expression once and then reference it throughout your view.

<extension point="org.eclipse.core.expression.templates">
  <expression id="isProblemViewActive">
    <evaluate ref="isPartActive">
      <parameter id="partId" value="org.eclipse.ui.views.ProblemView" />
    </evaluate>
  </expression>
</extension>
<extension point="org.eclipse.ui.handlers">
  <handler commandId="org.eclipse.ui.edit.copy"
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
    <enabledWhen>
      <evaluate ref="isSelectionAvailable" />
    </enabledWhen>
    <activeWhen>
      <evaluate ref="isProblemViewActive" />
    </activeWhen>
  </handler>
</extension>

This reduces the handler definition even more.


A similar option to reuse expressions as much as possible without turning them into their own procedural language would be to allow global definitions and then reuse them. No parameters and no expression composition:

<extension point="org.eclipse.core.expression.templates">
  <expression id="isProblemViewActive">
    <with variable="activePartId">
      <equals value="org.eclipse.ui.views.ProblemView" />
    </with>
  </expression>
  <expression id="isSelectionAvailable">
    <not>
      <count value="0" />
    </not>
  </expression>
</extension>
<extension point="org.eclipse.ui.handlers">
  <handler commandId="org.eclipse.ui.edit.copy"
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler">
    <enabledWhen ref="isSelectionAvailable" />
    <activeWhen ref="isProblemViewActive" />
  </handler>
</extension>

Another Expression Alternative: Specify Context at Extension Level

Since enabledWhen and activeWhen specify context and the simple way to specify context in XML is enclosure, how about scoping context to the extension point rather than the handler:

<extension point="org.eclipse.ui.handlers">
  <enabledWhen>  <!-- context of all  handlers in this extension -->
    <not>
      <count value="0" />
    </not>
  </enabledWhen>
  <activeWhen>
    <with variable="activePartId">
      <equals value="org.eclipse.ui.views.ProblemView" />
    </with>
  </activeWhen>
  <handler commandId="org.eclipse.ui.edit.copy"
      class="org.eclipse.ui.views.markers.internal.CopyMarkerHandler" />
  <handler commandId="org.eclipse.ui.edit.paste"
      class="org.eclipse.ui.views.markers.internal.PasteMarkerHandler" />
  <handler commandId="org.eclipse.ui.edit.delete"
      class="org.eclipse.ui.views.markers.internal.RemoveMarkerHandler" />
  <handler commandId="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
      class="org.eclipse.ui.views.markers.internal.ResolveMarkerHandler" />
  <handler commandId="org.eclipse.ui.edit.selectAll"
      class="org.eclipse.ui.views.markers.internal.SelectAllMarkersHandler" />
  <handler commandId="org.eclipse.ui.file.properties"
      class="org.eclipse.ui.views.markers.internal.ProblemPropertiesHandler" />
</extension>

This gives compact markup without inventing a new language. Elements nested in the handler element could override the extension-wide settings.

Updating the menu and toolbar appearance

It was suggested in 3.2 that state on the command could be used to implement the old contribution story behaviours:

  1. changing label text and tooltips
  2. changing icons
  3. changing enablement
  4. setting the item state (like checked state)

In 3.3 the enablement is tied to the command, and for the other behaviours we've decided to go with UIElements approach.

UIElements represent each UI visible instance of a command

The command service keeps a list of registered UI elements, which can be updated by the active handler. The checked state can be updated through UIElement#setChecked(boolean); (note that updateElement below is from IElementUpdater):

private boolean isChecked() {
    return getStore().getBoolean(
            PreferenceConstants.EDITOR_MARK_OCCURRENCES);
}
 
public void updateElement(UIElement element, Map parameters) {
    element.setChecked(isChecked());
}

When the toggle handler runs, it can request that any UI elements have their appearance updated from its execute(*) method:

ICommandService service = (ICommandService) serviceLocator
        .getService(ICommandService.class);
service.refreshElements(IJavaEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, null);

State associated with the command is propogated to UI visible elements

First define the toggle mark occurrences command. Pretty straight forward, although it needs a "STYLE" state since it can be toggled. To allow handlers to update the label for the menu/toolbar items, we also add the "NAME" state.

<extension point="org.eclipse.ui.commands">
  <command categoryId="org.eclipse.jdt.ui.category.source"
      description="%jdt.ui.ToggleMarkOccurrences.description"
      id="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"
      name="%jdt.ui.ToggleMarkOccurrences.name">
    <state id="NAME" class="org.eclipse.jface.menus.TextState" />
    <state id="STYLE" class="org.eclipse.jface.commands.ToggleState:true" />
  </command>
</extension>

Work

Progress in 3.3.

Available in 3.3

  • Ok green.gif the editor action bar contributor solution. EditorActionBarContributor will not be deprecated, but is not used in the commands/handler story. Menu Contributions have visibility tied to an active editor id, and editor specific handlers can be created in the editor init(*) or createPartControl(*) method using the handler service from getPartSite().getService(IHandlerService.class).
  • Ok green.gif Attributes for <command/>: helpContextId, style to support radio buttons and check boxes
  • Ok green.gif action sets as contexts - action sets are still defined using org.eclipse.ui.actionSets, and each actionSet generates an equivalent context. showing/hiding actionSets activates/deactivates the equivalent context.
  • Ok green.gif How do we give Trim widgets/toolbar widgets "focus" for command and handlers? There was an IFocusService added in 3.3 that allows a trim control to register itself. When that control has focus, the control and the ID it registered with are provided in the global application context to core expressions and handlers. This is available, but might not be the optimal solution if you just want cut, copy, and paste to work.
  • Ok green.gif Shortcuts to define reusable core expressions for <activeWhen/>, <enabledWhen/>, and <visibleWhen/>. This has been added as the org.eclipse.core.expressions.definitions extension point and the core expression <reference/> element.
  • Ok green.gif the mnemonic field for <command/> elements (decorating)
  • Ok green.gif display any keybinding for <command/> elements (decorating)
  • Ok green.gif toolbar <visibleWhen/> expressions

Available in 3.3M5

There is an example of the RCP Mail application template updated for 3.3M5 and converted to use the org.eclipse.ui.menus extension point as much as possible at Contribution Example.

  • Ok green.gif changing the menu item or tool item state from a handler, like updating the label or tooltip or checked state. Commands can contain <state/> elements, but that is not appropriate to use for providing feedback to the user. This will be done by adapting a callback provided by the UI element.
  • Ok green.gif the <separator/> element should have a name not an id
  • Ok green.gif support creating radio button or checked menu items
  • Ok green.gif creating new toolbars in the main coolbar/trim declaratively
  • Ok green.gif creating new toolbars in the main coolbar/trim programmatically
  • Ok green.gif org.eclipse.ui.popup.any as a context menu contribution
  • Ok green.gif Drop down toolbar items

We also have action sets activating and de-activating contexts in 3.3M5, but we'll need to decide the proper action set story for 3.3M6

We are still working on the EditorActionBarContributor story. It seems like we might be able to deprecate it. Editor instances can instantiate handlers upon creation for each command they support.

Available in 3.3M4

The basic menu API will be available in 3.3M4. It includes both declarative org.eclipse.ui.menus extension point with core expression support for visibility, and a programmatic interface accessed through the IMenuService.


We support contributing to the main menu, and the view menu, view toolbar, and any IDed context menu. We support contributing to existing toolbars in the main coolbar, and contributing trim widgets.

Programmatically we support the following types of contributions:

  • MenuManager
  • CommandContributionItem
  • CompoundContributionItem
  • ControlContribution (in 3.3M5)
  • Separator
  • GroupMarker

There are some specific mappings of elements and attributes on Menus Extension Mapping.


Work still to be done

A list of behaviours not supported or shipped with 3.3.

  • validate and possibly optimize the context menu population story and lifecycle. Many context menus set remove all when shown.
  • migrate Marker views
  • migrate standard workbench actions - a few were done
  • Check enabled visibleWhen support
  • Shortcuts placed on submenu items (like CTRL+N) (decorating)
  • ensure full visibleWhen support in the MenuManagers - i.e. should empty menus display (empty)
  • do we want to manage trim with a TrimContributionManager? This removes the coolbar, but has RCP implications.
  • the menu override capability - does this tie into the Customize Perspective dialog and action sets
  • A set of default programmatic core expressions. For example, ActionContextExpression or ActivePartExpression
  • deprecate the 4 extension: actionSets, viewActions, editorActions, popupMenus
  • read old extensions in terms of new extension
  • convert platform UI extensions to new extension
  • migration guide - what are the most common migration paths for Action and IActionDelegate to Command/IHandler.
  • Attributes for <command/>: state for checkboxes and radio buttons
  • possibly provide an plugin.xml converter for actionSets to menus
  • possibly provide an Action -> Handler converter
  • Error.gif status manager contributions


Legend:

  • nothing - TBD
  • Glass.gif - investigating
  • Progress.gif - in progress
  • Ok green.gif - completed
  • Error.gif - dropped

Copyright © Eclipse Foundation, Inc. All Rights Reserved.