Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Plug-in Developer Guide
Previous Page Home Next Page

Menus

Identifier:
org.eclipse.ui.menus

Since:
3.3

Description:

This extension point allows the plug-in developer to add (contribute) a variety of custom additions to the eclipse framework:

  • Main Menu
  • Main Toolbars
  • View Menus/Toolbars:
    • View Dropdown Menu
    • View Toolbar
    • Context Menu(s)
  • Trim

It provides a common implementation for and acts as a replacement of the following (legacy) eclipse extension points:

  • org.eclipse.ui.ActionSets
  • org.eclipse.ui.EditorActions
  • org.eclipse.ui.popupMenus (including 'objectContributions')
  • org.eclipse.ui.viewActions

The general strategy for this mechanism is to separate the 'location' where the contributions should be inserted from the visibility and enablement state of the element. Each contribution first defines its insertion location through a Menu 'URI', a string (loosely) formatted according to the jave.net.URI format:

"[Scheme]:[ID]?[ArgList]"

  • Scheme - The 'type' of the UI component into which the contributions will be added. It may be either "menu", "popup" or "toolbar". While 'popup' is indeed a form of menu it is provided to allow a distinction between a view's 'chevron' menu (for which we use the "menu" scheme) and its default context menu which, by convention, should be registered using the "popup" scheme.
  • ID - This is the id of menu or toolbar into which the contributions should be added. By convention views should use their view id as the id of the root of their chevron and default popup menu. Note that there is no explicit distinction between contributions supporting editors and 'normal' contributions into the Menu Menu or Toolbar; both global contributions and editor contributions would use the "org.eclipse.ui.main.menu" id or "org.eclipse.ui.main.toolbar". A special id used with popup:, "org.eclipse.ui.popup.any", is reserved to handle contributions which are candidates to appear on any (top level) context menu. Note that these contributions are expected to implement a 'visibleWhen' expression sufficient to limit their visibility to appropriate menus
  • Query - This field allows fine-grained definition of the specific location within a given menu. It has the form "[placement]=[id]" where placement is one of "before" or "after" and the id is expected to be the id of some IContributionItem in the menu.

This will define the location at which the contributions will appear in the eclipse UI. Once the insertion point has been defined the rest of the contributions describe the UI elements that will be added at that location. Each element supports a 'visibleWhen' expression that determines at run time whether a particular item should appear in the menu based on the system's current state (selection, active view/editor, context...). See org.eclipse.ui.ISources for a list of currently supported variables.

Configuration Markup:

<!ELEMENT extension ( group* , widget* , menuContribution*)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED

>

  • point - org.eclipse.ui.menus
  • id - An optional identifier of the extension instance.
  • name - An optional name of the extension instance.

The group element is deprecated

<!ELEMENT group ( location*)>

<!ATTLIST group

id                CDATA #REQUIRED

separatorsVisible (true | false) "true"

>

A logical group. It can either be visible (e.g., separators are drawn before and after, as appropriate) or invisible. By default, logical groups are visible.

A group can contain menus, items and other groups.

This element is deprecated. Groups are now expressed as id'd 'separator' elements. The menu insertion URI can be used to define an insertion point either 'before' or 'after' any id'd element and placing it after the separator is the same as contributing it to the group.

See the documentation for the 'locationURI' attribute of 'menuAddition' for more details on how to define insertion points and how they relate to the menu structure.


  • id - A unique identifier for this group. It is recommended that the identifier be prefixed by the plug-in name, to guarantee uniqueness. For example, a group contributed by org.eclipse.ui might be called org.eclipse.ui.group1.
  • separatorsVisible - Whether separators should be drawn around the group. The workbench will take care of deciding whether a separator needs to be drawn at the top or bottom -- accounting for the top and bottom of the menu and duplicate separators. By default, separators are visible.

The widget element is deprecated

<!ELEMENT widget ( location* , class? , visibleWhen? , layout?)>

<!ATTLIST widget

id    CDATA #REQUIRED

class CDATA #REQUIRED

>

A menu or trim element that is given direct access to the widgets. For example, this can be used to render a combo box. NOTE: If a widget element becomes visible in the user interface, this will lead to plug-in loading. Use this element with caution, as it can cause performance problems. When used as trim the widget will only cause the plug-in to load when it becomes visible in the UI.

NOTE: This element is deprecated. Clients should contribute a Toolbar to one of the trim areas and place a control contribution inside it. See the Trim Contribution example for details.


  • id - A unique identifier for this widget. It is recommended that the identifier be prefixed by the plug-in name, to guarantee uniqueness. For example, a widget contributed by org.eclipse.ui might be called org.eclipse.ui.widget1.

    If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element (or at the end of the logical group containing this element using the 'endof' value).

  • class - This class is loaded to fill the appropriate spot in the menu or trim when it shows. While, strictly speaking, this class must implement IWorkbenchWidget you should use the default implementation; AbstractWorkbenchTrimWidget as the base from which to derive your widget implementation. This implementation handles the 'init' method and caches the result for use through its getWorkbenchWindow method.

The layout element is deprecated

<!ELEMENT layout EMPTY>

<!ATTLIST layout

fillMajor (true | false)

fillMinor (true | false)

>

This element can be used to specify various layout options for elements added into trim locations.


  • fillMajor - The widget will stretch to use up any additional space available along its major dimension in the group's area (i.e. it will use the extra horizontal space for horizontally oriented trim areas). Default is false.
  • fillMinor - The widget will stretch to use up any additional space available along its minor dimension in the group's area (i.e. it will use the extra vertical space for horizontally oriented trim areas). Default is false.

The location element is deprecated

<!ELEMENT location ( order? , ( bar | part | popup))>

<!ATTLIST location

mnemonic   CDATA #IMPLIED

imageStyle CDATA #IMPLIED

>

A location in which a menu, group, item or widget can appear. This element is used to control location-specific information.

This element is deprecated. Users of this extension point should now define the location at which their contributions should appear using the 'locationURI' specification.


  • Deprecated mnemonic - The mnemonic that should be associated with this element in the given location. A mnemonic should be a single character.
  • Deprecated imageStyle - The image style to associate with this location. It is possible for commands to have different styles of images associated with them. For example, a different icon could be selected for the tool bar and for the menu. This is especially important for developers using drop-down tool items in the tool bar, as they may wish to display an icon more appropriate for the drop-down.

The bar element is deprecated

<!ELEMENT bar EMPTY>

<!ATTLIST bar

type (menu|trim)

path CDATA #IMPLIED

>

A leaf element within a location. This can be the menu bar or the trim area. If unqualified, this indicates the top-level menu bar or trim. If this is qualified with a part element, then this indicates that part's menu or trim.


  • Deprecated type -

    NOTE: This is not only deprecated but has no value in the current implementation (the only acceptable value is 'trim' which is the default. You may safely remove this from any declarations.

    What type of bar to contribute to. This can be menu or trim. If contributing to the menu, then the item will be parented to some widget structure. In general, this means using widget elements does not make much sense, and an icon for an item's command is not strictly necessary. The default value is menu.

    If contributing to the trim, then the bar will generally not require a command or an icon, it should be filled with a widget that displays the trim information.

    Within the trim, the workbench defines five general groups which correspond to various positions around the window:

    • command1 - This represents the (horizontal) trim area that the main toolbars are placed into.
    • command2 - This represents the (horizontal) trim area that the Perspective Switcher is in by default.
    • vertical1 - This represents the (vertical) trim area that is on the left side when the text direction is Left->Right and on the right side for Right->Left text.
    • vertical2 - This represents the (vertical) trim area that is on the opposite side of the workbench from vertical1.
    • status - This represents the (horizontal) trim area along the bottom edge of the workbench.
    By positioning the trim contribution within or with respect to these groups, the position is inferred by the workbench.

  • Deprecated path - This represents the id of a group that the widget is to be placed into.

<!ELEMENT class ( parameter*)>

<!ATTLIST class

class CDATA #REQUIRED

>

A class element supporting the executable extension parsing syntax for both widget and dynamic elements.


  • class - The class to load as an IExecutableExtension.

<!ELEMENT visibleWhen ( not | or | and | instanceof | test | systemTest | equals | count | with | resolve | adapt | iterate | reference)?>

<!ATTLIST visibleWhen

checkEnabled (true | false) "false"

>

A core Expression that controls the visibility of the given element.


  • checkEnabled - If this attribute is set to true, then there should be no sub-elements. This just checks the enabled state of the command, and makes the corresponding element visible if the command is enabled.

The part element is deprecated

<!ELEMENT part ( popup | bar)>

<!ATTLIST part

id    CDATA #IMPLIED

class CDATA #IMPLIED

>

An element within a location. This qualifies the location to refer to a particular workbench part. This can be either a view or an editor. The qualification can use either the class name of the part (including inheritance), or it can refer to the identifier for the view or editor.

Only one of id and class can be specified.

NOTE: This element is deprecated. It had been used for a previous technique for adding trim elements. Instead, clients should contribute a Toolbar to one of the trim areas and place a control contribution inside it. See the Trim Contribution example for details.


  • id - The identifier of the view or editor.
  • class - The class of the part. This can be a superclass, interface or superinterface of the part, and it will still match.

<!ELEMENT parameter EMPTY>

<!ATTLIST parameter

name  IDREF #REQUIRED

value CDATA #REQUIRED

>

A parameter to either an executable extension or a command -- depending on where it appears in the extension.


  • name - The name is either the name of the parameter to pass to the executable extension, or the identifier of the parameter for the command.
  • value - The value to pass for this parameter.

The order element is deprecated

<!ELEMENT order EMPTY>

<!ATTLIST order

position   (start|end|before|after)

relativeTo CDATA #IMPLIED

>

NOTE: This element is deprecated in favor of using the 'locationURI' to specify the location at which contributions should be placed.

Controls the position of a widget within a particular group.


  • position -

    This attribute accepts the following values: start (put the element at the beginning of the container); end (put the element at the end of its container); after (put the element after the sibling element whose id matches ref); and, before (put the element before the sibling element whose id matches ref). Relative ordering can be applied to any type of menu element.

    In the event of conflicts, Eclipse will chose an arbitrary order. The only guarantee is that, in the event of a conflict, the order will remain the same as long as the following holds:

    • The Eclipse version is the same.
    • The list of elements is the same (i.e., no dynamic elements, no plug-ins added or removed).
  • relativeTo - The identifier of the element to which this position is relative. This value is required if the position is before or after.

The popup element is deprecated

<!ELEMENT popup EMPTY>

<!ATTLIST popup

id   CDATA #IMPLIED

path CDATA #IMPLIED

>

Part of a location. It indicates that the menu, group, item or widget should appear in the popup menu.

NOTE: This element is deprecated. It had been used for a previous technique for adding trim elements. Instead, clients should contribute a Toolbar to one of the trim areas and place a control contribution inside it. See the Trim Contribution example for details.


  • id - The identifier of the popup menu. If none is specified, then it will appear in all popup menus.
  • path - The path within the popup menu to place the element. If not specified, then this is added to the "additions" group.

<!ELEMENT menuContribution ( menu* , command* , separator* , dynamic* , toolbar* , control*)>

<!ATTLIST menuContribution

locationURI CDATA #REQUIRED

class       CDATA #IMPLIED

>

Defines an ordered set of additions to the command UI structure. The defined elements will be added into the command UI structure at the location specified by the locationURI element.

This should be the starting point for all contributions into menus, toolbars or trim, wherever they occur in the UI.


  • locationURI - A URI specification that defines the insertion point at which the contained additions will be added. The format for the URI is comprised of three basic parts: Scheme: One of "menu", "popup" or "toolbar. Indicates the type of the manager used to handle the contributions Id: This is either the id of an existing menu, a view id or the id of the editor 'type' Query: The query format is <placement>=<id> where: <placement> is either "before" or "after" and <id> is the id of an existing menu item
  • class - If this optional attribute is specified the provided class will be instantiated and used to provide menu contributions at this location. If provided, all child elements will be ignored.

<!ELEMENT menu ( visibleWhen? , ( menu? | command? | separator? | dynamic?)*)?>

<!ATTLIST menu

label     CDATA #REQUIRED

id        CDATA #IMPLIED

mnemonic  CDATA #IMPLIED

icon      CDATA #IMPLIED

tooltip   CDATA #IMPLIED

commandId IDREF #IMPLIED

>

Defines a new menu contribution at the given insertion point.


  • label - The label to be displayed for this element when it is placed in either a menu or a toolbar. This value should be translatable.
  • id - The 'id' of this menu contribution. If defined then it can be extended through other 'menuAddition' elements or the id can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element.
  • mnemonic - The character of the Label that should be given the mnemonic affordance. This is to allow the menu system to re-define the value during translation without having to understand the various platforms' conventions for menu label definition (i.e. using the '&' character...).
  • icon - A plugin relative path to the image to be used as the icon for this menu in either a menu or a toolbar.
  • tooltip - The tooltip to be displayed for this element when it is placed in a toolbar. This value should be translatable.
  • commandId - Th commandId is used to update the submenu text with a keyboard shortcut. The command should have a handler that can launch a quickmenu version of this menu.

<!ELEMENT command ( visibleWhen? , parameter*)>

<!ATTLIST command

label         CDATA #IMPLIED

commandId     IDREF #REQUIRED

id            CDATA #IMPLIED

mnemonic      CDATA #IMPLIED

icon          CDATA #IMPLIED

disabledIcon  CDATA #IMPLIED

hoverIcon     CDATA #IMPLIED

tooltip       CDATA #IMPLIED

helpContextId CDATA #IMPLIED

style         (push|radio|toggle|pulldown) "push"

mode          (FORCE_TEXT)

>

Defines a new Command Contribution at the defined insertion point.


  • label - The label to be displayed for this element when it is placed in either a menu. This value should be translatable.
  • commandId - This is the id of the Command that is to be bound to this element. This is the hook into the Commands/Handlers/Key binding services that actually do the work should this item be selected. In many cases this command will have been defined in a previous extension declaration.
  • id - The 'id' of this contribution. If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element.
  • mnemonic - The character of the Label that should be given the mnemonic affordance. This is to allow the menu system to re-define the value during translation without having to understand the various platforms' conventions for menu label definition (i.e. using the '&' character...).
  • icon - a relative path of an icon used to visually represent the action in its context. If omitted and the action appears in the toolbar, the Workbench will use a placeholder icon. The path is relative to the location of the plugin.xml file of the contributing plug-in, or the ISharedImages constant.
  • disabledIcon - a relative path of an icon used to visually represent the action in its context when the action is disabled. If omitted, the normal icon will simply appear greyed out. The path is relative to the location of the plugin.xml file of the contributing plug-in. The disabled icon will appear in toolbars but not in menus. Icons for disabled actions in menus will be supplied by the OS.
  • hoverIcon - a relative path of an icon used to visually represent the action in its context when the mouse pointer is over the action. If omitted, the normal icon will be used. The path is relative to the location of the plugin.xml file of the contributing plug-in.
  • tooltip - The tooltip to be displayed for this element when it is placed in a toolbar. This value should be translatable.
  • helpContextId - a unique identifier indicating the help context for this action. If the action appears as a menu item, then pressing F1 while the menu item is highlighted will display help. This overrides the help context id provided by the active handler or command.
  • style - an attribute to define the user interface style type for the action. If omitted, then it is push by default. The attribute value will be one of the following:
    push - as a regular menu item or tool item.
    radio - as a radio style menu item or tool item. Actions with the radio style within the same menu or toolbar group behave as a radio set. The initial value is specified by the state attribute.
    toggle - as a checked style menu item or as a toggle tool item. The initial value is specified by the state attribute.
    pulldown - (ToolBar only) Creates a ToolItem with the SWT.DROP_DOWN affordance. The URI of the menu is "menu:" + this item's ID.
  • mode - For commands appearing in a toolbar, FORCE_TEXT will show text even if there is an icon. See CommandContributionItem.

<!ELEMENT separator EMPTY>

<!ATTLIST separator

name    CDATA #REQUIRED

visible (true | false)

>

Inserts a separator at the current insertion point.


  • name - The 'id' of this contribution. If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element (or at the end of the logical group containing this element using the 'endof' value).

    Separator contributions that have an id define the start of a logical group so the result of using the 'endof' value for placement is to search forward in the current menu to locate the next id'd separator and to place the inserted elements before that element. If no trailing separator is found then the items are placed at the end of the menu.

  • visible - Indicates whether or not the separator should be visible in the UI. false by default.

<!ELEMENT toolbar ( visibleWhen? , ( command? | separator? | dynamic? | control?)*)?>

<!ATTLIST toolbar

id CDATA #REQUIRED

>

Contributes a new ToolBar at the current insertion point. This element is only currently valid for CoolBarManagers, which can contain toolbars. For example, the trim location URIs specified in org.eclipse.ui.menus.MenuUtil.


  • id - The 'id' of this toolbar contribution. If defined then it can be extended through other 'menuAddition' elements or the id can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element.

<!ELEMENT control ( visibleWhen?)>

<!ATTLIST control

id    CDATA #IMPLIED

class CDATA #REQUIRED

>

Used to contribute controls to ToolBars in the workbench. The 'class' attribute must be a derivative of the WorkbenchWindowControlContribution base class.

NOTE: Due to platform restrictions control contributions are only supported for toolbars; Attempts to contribute controls into a menu or popup will be treated as a NO-OP.


  • id - The 'id' of this menu contribution. If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element.
  • class - The class which will be used to create the control that is to be hosted in a ToolBar. This must be a subclass of WorkbenchWindowControlContribution which provides information as to the control's location (i.e. which workbench window it's being hosted in and the side of the window that it is currently being displayed on.

<!ELEMENT dynamic ( class? , visibleWhen?)>

<!ATTLIST dynamic

id    CDATA #REQUIRED

class CDATA #REQUIRED

>

The element provides a mechanism that will call back into the defined class to provide an IContributionItem to be shown when the menu or toolbar is built. The defined class must be a derivative of the org.eclipse.jface.action.ContributionItem base class. It can also use org.eclipse.ui.action.CompoundContributionItem and provide an implementation for the abstract getContributionItems method to provide a dynamic menu item.


  • id - A unique identifier for this contribution. It is recommended that the identifier be prefixed by the plug-in name, to guarantee uniqueness. For example, a widget contributed by org.eclipse.ui might be called org.eclipse.ui.widget1.

    If defined then it can be used as a reference in the Query part of the location defining whether the additions are to go before or after this element (or at the end of the logical group containing this element using the 'endof' value).

  • class - This class is expected to be a subclass of ContributionItem. The item may implement IWorkbenchContribution to be provided an IServiceLocator.

<!ELEMENT enablement ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

A generic root element. The element can be used inside an extension point to define its enablement expression. The children of an enablement expression are combined using the and operator.



<!ELEMENT not ( not | and | or | instanceof | test | systemTest | equals | count | with | resolve | adapt | iterate | reference)>

This element represent a NOT operation on the result of evaluating it's sub-element expression.



<!ELEMENT and ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

This element represent an AND operation on the result of evaluating all it's sub-elements expressions.



<!ELEMENT or ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

This element represent an OR operation on the result of evaluating all it's sub-element expressions.



<!ELEMENT instanceof EMPTY>

<!ATTLIST instanceof

value CDATA #REQUIRED

>

This element is used to perform an instanceof check of the object in focus. The expression returns EvaluationResult.TRUE if the object's type is a sub type of the type specified by the attribute value. Otherwise EvaluationResult.FALSE is returned.


  • value - a fully qualified name of a class or interface.

<!ELEMENT test EMPTY>

<!ATTLIST test

property              CDATA #REQUIRED

args                  CDATA #IMPLIED

value                 CDATA #IMPLIED

forcePluginActivation (true | false)

>

This element is used to evaluate the property state of the object in focus. The set of testable properties can be extended using the propery tester extension point. The test expression returns EvaluationResult.NOT_LOADED if the property tester doing the actual testing isn't loaded yet and the attribute forcePluginActivation is set to false. If forcePluginActivation is set to true and the evaluation context used to evaluate this expression support plug-in activation then evaluating the property will result in activating the plug-in defining the tester.


  • property - the name of an object's property to test.
  • args - additional arguments passed to the property tester. Multiple arguments are separated by commas. Each individual argument is converted into a Java base type using the same rules as defined for the value attribute of the test expression.
  • value - the expected value of the property. Can be omitted if the property is a boolean property. The test expression is supposed to return EvaluationResult.TRUE if the property matches the value and EvaluationResult.FALSE otherwise. The value attribute is converted into a Java base type using the following rules:
    • the string "true" is converted into Boolean.TRUE
    • the string "false" is converted into Boolean.FALSE
    • if the string contains a dot then the interpreter tries to convert the value into a Float object. If this fails the string is treated as a java.lang.String
    • if the string only consists of numbers then the interpreter converts the value in an Integer object.
    • in all other cases the string is treated as a java.lang.String
    • the conversion of the string into a Boolean, Float, or Integer can be suppressed by surrounding the string with single quotes. For example, the attribute value="'true'" is converted into the string "true"
  • forcePluginActivation - a flag indicating whether the plug-in contributing the property tester should be loaded if necessary. As such, this flag should be used judiciously, in order to avoid unnecessary plug-in activations. Most clients should avoid setting this flag to true. This flag is only honored if the evaluation context used to evaluate this expression allows plug-in activation. Otherwise the flag is ignored and no plug-in loading takes place.

<!ELEMENT systemTest EMPTY>

<!ATTLIST systemTest

property CDATA #REQUIRED

value    CDATA #REQUIRED

>

Tests a system property by calling the System.getProperty method and compares the result with the value specified through the value attribute.


  • property - the name of an system property to test.
  • value - the expected value of the property. The value is interpreted as a string value.

<!ELEMENT equals EMPTY>

<!ATTLIST equals

value CDATA #REQUIRED

>

This element is used to perform an equals check of the object in focus. The expression returns EvaluationResult.TRUE if the object is equal to the value provided by the attribute value. Otherwise EvaluationResult.FALSE is returned.


  • value - the expected value. The value provided as a string is converted into a Java base type using the same rules as for the value attribute of the test expression.

<!ELEMENT count EMPTY>

<!ATTLIST count

value CDATA #REQUIRED

>

This element is used to test the number of elements in a collection.


  • value - an expression to specify the number of elements in a list. Following wildcard characters can be used:
    *
    any number of elements
    ?
    no elements or one element
    +
    one or more elements
    !
    no elements
    -N)
    less than N elements
    (N-
    greater than N elements
    integer value
    the list must contain the exact number of elements

<!ELEMENT with ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

<!ATTLIST with

variable CDATA #REQUIRED

>

This element changes the object to be inspected for all its child element to the object referenced by the given variable. If the variable can not be resolved then the expression will throw an ExpressionException when evaluating it. The children of a with expression are combined using the and operator.


  • variable - the name of the variable to be used for further inspection. It is up to the evaluator of an extension point to provide the variable in the variable pool.

<!ELEMENT resolve ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

<!ATTLIST resolve

variable CDATA #REQUIRED

args     CDATA #IMPLIED

>

This element changes the object to be inspected for all its child element to the object referenced by the given variable. If the variable can not be resolved then the expression will throw an ExpressionException when evaluating it. The children of a resolve expression are combined using the and operator.


  • variable - the name of the variable to be resolved. This variable is then used as the object in focus for child element evaluation. It is up to the evaluator of an extension point to provide a corresponding variable resolver (see IVariableResolver) through the evaluation context passed to the root expression element when evaluating the expression.
  • args - additional arguments passed to the variable resolver. Multiple arguments are separated by commas. Each individual argument is converted into a Java base type using the same rules as defined for the value attribute of the test expression.

<!ELEMENT adapt ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

<!ATTLIST adapt

type CDATA #REQUIRED

>

This element is used to adapt the object in focus to the type specified by the attribute type. The expression returns not loaded if either the adapter or the type referenced isn't loaded yet. It throws an ExpressionException during evaluation if the type name doesn't exist at all. The children of an adapt expression are combined using the and operator.


  • type - the type to which the object in focus is to be adapted.

<!ELEMENT iterate ( not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

<!ATTLIST iterate

operator (or|and)

ifEmpty  (true | false)

>

This element is used to iterate over a variable that is of type java.util.Collection, or a variable that adapts to org.eclipse.core.expressions.IIterable. If the object in focus is not one of the above then a CoreException with an ExpressionStatus will be thrown while evaluating the expression. The child expressions of an iterate expression are combined using the and operator.


  • operator - either "and" or "or". The operator defines how the results of all the child expressions applied to each child of the Collection or IIterable will be combined and what (if any) short circuit evaluation will be used. If not specified, "and" will be used.
  • ifEmpty - the value return from the iterate expression if the collection is empty. If not specified then true is returned when the operator equals "and" and false is return if the operator equals "or".

<!ELEMENT reference EMPTY>

<!ATTLIST reference

definitionId IDREF #REQUIRED

>

This element is used to reference an expression from the org.eclipse.core.expressions.definitions extension point. The expression definition will be evaluated within the current expression element using the current evaluation context.


  • definitionId - The unique id of an expression from org.eclipse.core.expressions.definitions.

Examples:

A basic extension looks like this.


   <extension
         id=
"add.item"

         point=
"org.eclipse.ui.menus"
>
      <menuContribution
         locationURI=
"menu:someorg.somemenu.id?after=additions"
>
         <command
               commandId=
"someorg.someid.someCommand"

               icon=
"icons/anything.gif"

               id=
"someorg.someid.BasicCmdItem"

               label=
"Simple Item"

               mnemonic=
"S"
>
         </command>
      </menuContribution>
   </extension>

This is the simplest example; adding a command contribution after an existing menu's additions group.


Copyright (c) 2005,2007 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-v10.html


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire