# 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.

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

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