#
Element Types

###### Identifier:

org.eclipse.gmf.runtime.emf.type.core.elementTypes

###### Since:

7.0

###### Description:

The `org.eclipse.gmf.runtime.emf.type.core.elementTypes` extension point is used to define application specializations of metamodel types for the following purposes:

1. extend (but not replace) the basic metamodel editing behaviour for elements that match such specializations, and
2. contribute icons and display names for such specializations

The element type specializations may be used for menu or tool palette items for element creation.

Editing behaviour can be extended by associated an `editHelperAdvice` to a specialization, or by contributing an `adviceBinding` that binds an `editHelperAdvice` to an element type. Edit helper advice is applied 'before' and/or 'after' the behaviour that is provided by the default metamodel editing behaviour.

Custom element types may be created by declaring an `IElementTypeFactory` which is responsible for creating all element types declaring the same 'kind' as the factory. Custom parameters may be associated with element types created this way.

###### Configuration Markup:

<!ELEMENT extension (metamodel* , elementTypeFactory* , specializationType*)>

<!ATTLIST extension

point CDATA #REQUIRED

id CDATA #IMPLIED

name CDATA #IMPLIED>

- point - The extension point name, `org.eclipse.gmf.runtime.emf.type.core.elementTypes`.
- id - The extension ID.
- name - The extension name.

<!ELEMENT metamodel (metamodelType* , specializationType* , adviceBinding*)>

<!ATTLIST metamodel

nsURI CDATA #REQUIRED>

This element is used to identify the metamodel for which a set of element types and advice bindings are defined. All eclass and eContainmentFeature values specified in the types must be found within this metamodel.

- nsURI - The namespace URI of the metamodel.

<!ELEMENT elementTypeFactory EMPTY>

<!ATTLIST elementTypeFactory

factory CDATA #REQUIRED

kind CDATA #REQUIRED

params CDATA #IMPLIED>

This element is used to contribute a factory that will create element types declaring the same 'kind' as the factory. Custom parameters may be associated with element types created this way.

- factory - The fully qualified name of a class implementing the `org.eclipse.gmf.runtime.emf.type.core.IElementTypeFactory`.
- kind - String identifying the kind of element that will be created by this factory. Element types will declare the same 'kind' string if they want to be created by this factory.
- params - Comma separated list of custom parameters supported by this element type factory. Parameter values will be read from the element type element and passed to the factory when they are created.

<!ELEMENT metamodelType (param*)>

<!ATTLIST metamodelType

id CDATA #REQUIRED

icon CDATA #IMPLIED

name CDATA #IMPLIED

eclass CDATA #REQUIRED

edithelper CDATA #IMPLIED

kind CDATA #IMPLIED>

This element is used to define a new metamodel element type.

- id - The unique identifier for this metamodel element type.
- icon - The path of this metamodel element type icon, relative to this plugin location.
- name - The I18N display name for this metamodel element type.
- eclass - The name of an `EClass` instance from the metamodel specified in the enclosing metamodel element.
- edithelper - The fully qualified name of a class implementing `org.eclipse.gmf.runtime.emf.type.core.edit.IEditHelper`.
- kind - The kind of element. Used to identify the `IElementTypeFactory` that is used to instantiate the element type. If it is not specified a default factory will be used to create the element.

<!ELEMENT specializationType (specializes+ , (matcher | enablement) , param* , eContainer?)>

<!ATTLIST specializationType

id CDATA #REQUIRED

icon CDATA #IMPLIED

name CDATA #IMPLIED

edithelperadvice CDATA #IMPLIED

kind CDATA #IMPLIED>

This element is used to define a new specialization element type.

- id - The unique specialization edit type identifier.
- icon - The path of this specialization element type icon, relative to this plugin location.
- name - The I18N display name for this specialization element type.
- edithelperadvice - The fully qualified name of a class that implements `org.eclipse.gmf.runtime.emf.type.core.edit.IEditHelperAdvice`. This attribute is used to specify the class that provides editing advice for elements of this type. Editing advice can be contributed before and/or after the default editing behaviour.
- kind - The kind of element. Used to identify the `IElementTypeFactory` that is used to instantiate the element type. If it is not specified a default factory will be used to create the element.

<!ELEMENT adviceBinding ((matcher | enablement) , eContainer)>

<!ATTLIST adviceBinding

typeId CDATA #REQUIRED

class CDATA #REQUIRED

inheritance (all|none) "none"

id CDATA #REQUIRED>

This element is used to bind an `IEditHelperAdvice` with an element type.

- typeId - The element type identifier.
- class - The fully qualified name of a class that implements `org.eclipse.gmf.runtime.emf.type.core.edit.IEditHelperAdvice`. This attribute is used to specify the class that provides editing advice for elements of this type. Editing advice can be contributed before and/or after the default editing behaviour.
- inheritance - Indicates the related element types that should inherite this advice. Does not apply to specialization types, which always inherit (all).
  - all - advice is inherited by all metamodel types whose EClasses are subtypes of the metamodel type to which it was applied, and to all specializations of those metamodel types.
  - none - advice is not inherited by related metamodel types. It is applied only to the metatmodel type and its specializations.
- id - The unique ID of this advice binding.

<!ELEMENT specializes EMPTY>

<!ATTLIST specializes

id CDATA #REQUIRED>

This element is used to identify another element type (metamodel or specialization) that this type specializes.

- id - Identifier of the metamodel type or specialization type that this type specializes.

<!ELEMENT matcher EMPTY>

<!ATTLIST matcher

class CDATA #REQUIRED>

This element is used to specify the class that will determine whether or not an existing model element matches this type.

- class - The fully qualified name of a class that implements `org.eclipse.gmf.runtime.emf.type.core.IElementMatcher`.

<!ELEMENT eContainer (eContainmentFeature* , (matcher | enablement))>

This element is used to describe the qualities of the container model element for which this edit helper advice is relevant.

<!ELEMENT eContainmentFeature EMPTY>

<!ATTLIST eContainmentFeature

qname CDATA #REQUIRED>

This element is used to specify the containment feature for model elements for which this edit helper advice is relevant.

- qname - The name of the containment feature qualified by its EClass name.

<!ELEMENT param EMPTY>

<!ATTLIST param

name CDATA #REQUIRED

value CDATA #REQUIRED>

A custom parameter name and value pair.

- name - The parameter name.
- value - The parameter value.

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

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)>

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)*>

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)*>

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>

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 teh property tester doing the actual testing isn't loaded yet.

- property - the name of an object's property to test.
- args - additional arguments passed to the property tester. Multiple arguments are seperated 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"

<!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 operatand of the equals tests. 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
  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)*>

<!ATTLIST with

variable CDATA #REQUIRED>

This element changes the object to be inspected for all its child element to the object referneced by the given variable. If the variable can not be resolved then the expression will throw a 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)*>

<!ATTLIST resolve

variable CDATA #REQUIRED

args CDATA #IMPLIED>

This element changes the object to be inspected for all its child element to the object referneced by the given variable. If the variable can not be resolved then the expression will throw a ExpressionException when evaluating it. The children of a with 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 seperated 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)*>

<!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 a 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)*>

<!ATTLIST iterate

operator (or|and) >

This element is used to iterate over a variable that is of type java.util.Collection. If the object in focus is not of type java.util.Collection then an ExpressionException will be thrown while evaluating the expression.

- operator - either "and" or "or". The operator defines how the child elements will be combined. If not specified, "and" will be used.

###### Examples:

    <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">

            <metamodel
                    nsURI="http://www.eclipse.org/emf/2002/Ecore">
                 <metamodelType
                         id="org.eclipse.gmf.runtime.emf.type.core.eobject"
                         icon="icons/eobject.gif"
                         name="%EObject"
                         eclass="EObject"
                         edithelper ="org.eclipse.gmf.runtime.emf.type.core.EObjectEditHelper">
                 </metamodelType>

                 <specializationType
                         id="org.eclipse.gmf.runtime.emf.type.core.special"
                         icon="icons/special.gif"
                         name="%Special"
                         edithelperadvice="org.eclipse.gmf.runtime.emf.type.core.SpecialEditHelperAdvice">
                     <specializes id="org.eclipse.gmf.runtime.emf.type.core.eobject"/>
                     <matcher class="org.eclipse.gmf.runtime.emf.type.core.specialMatcher"/>
                 </specializationType>

                 <specializationType
                         id="org.eclipse.gmf.runtime.emf.type.core.special2"
                         icon="icons/special2.gif"
                         name="%Special2"
                         edithelperadvice="org.eclipse.gmf.runtime.emf.type.core.Special2EditHelperAdvice">
                     <specializes id="org.eclipse.gmf.runtime.emf.type.core.eobject"/>
                     <eContainer>
                         <enablement>
                             <test property="special2" value="special2Value"/>
                         </enablement>
                     </eContainer>
                     <enablement>
                        <test property="special2" value="special2Value"/>
                     </enablement>
                 </specializationType>

                 <specializationType
                         id="org.eclipse.gmf.runtime.emf.type.core.customType"
                         icon="icons/customType.gif"
                         name="%CustomType"
                         kind="org.eclipse.gmf.runtime.emf.type.core.CustomElementKind"
                         edithelperadvice="org.eclipse.gmf.runtime.emf.type.core.CustomEditHelperAdvice">
                     <specializes id="org.eclipse.gmf.runtime.emf.type.core.eobject"/>
                     <param
                             name="customParameter1"
                             value="value1">
                     </param>
                     <param
                             name="customParameter2"
                             value="value2">
                     </param>
                 </specializationType>

                 <adviceBinding
                      id="org.eclipse.gmf.runtime.emf.type.core.advisedType"
                      typeId="org.eclipse.gmf.runtime.emf.type.core.eobject"
                      class="org.eclipse.gmf.runtime.emf.type.core.advisedTypeEditHelperAdvice"
                      applyToSubtypes="false">
                      <eContainer>
                           <enablement>
                                <test property="advised" value="advisedValue"/>
                           </enablement>
                      </eContainer>
                  </adviceBinding>
            </metamodel>

             <elementTypeFactory
                   factory="org.eclipse.gmf.runtime.emf.type.core.CustomElementTypeFactory"
                   kind = "org.eclipse.gmf.runtime.emf.type.core.CustomElementKind"
                   params = "customParameter1, customParameter2">
             </elementTypeFactory>
        </extension>

###### API Information:

See the `org.eclipse.gmf.runtime.emf.type.core` package in the `org.eclipse.gmf.runtime.emf.type.core` plug-in for the API description.

Copyright (c) 2005 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 http://www.eclipse.org/legal/epl-v10.html