Runtime

## org.eclipse.gmf.runtime.emf.type.core
Class ElementTypeRegistry

    java.lang.Object
      org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry

public class ElementTypeRegistry
extends java.lang.Object

The registry of application element types, contributed by the `org.eclipse.gmf.runtime.emf.type.core.elementTypes` extension point, or registered directly through `ElementTypeRegistry.register(IMetamodelType)` or `ElementTypeRegistry.register(ISpecializationType)`.

Method Summary
`void` `addElementTypeRegistryListener(IElementTypeRegistryListener l)` Adds `l` as a listener for changes to this registry.
`IElementType[]` `getAllTypesMatching(EObject eObject)` Gets all of the element types (metamodel type and specialization types) that match `eObject` in breadth-first order (specializations before metamodel types).
`IElementType[]` `getAllTypesMatching(EObject eObject, IClientContext clientContext)` Gets all of the element types (metamodel type and specialization types) that match `eObject` in breadth-first order (specializations before metamodel types).
`IElementType[]` `getContainedTypes(EObject eContainer, EReference reference)` Gets the array of types that can be contained in the structural `feature` of `eContainer`.
`IElementType[]` `getContainedTypes(EObject eContainer, EReference reference, IClientContext clientContext)` Gets the array of types that can be contained in the structural `feature` of `eContainer`.
`IEditHelperAdvice[]` `getEditHelperAdvice(EObject eObject)` Gets the edit helper advice for `eObject` in order of most general advice to most specific advice.
`IEditHelperAdvice[]` `getEditHelperAdvice(EObject eObject, IClientContext clientContext)` Gets the edit helper advice for `eObject` in order of most general advice to most specific advice.
`IEditHelperAdvice[]` `getEditHelperAdvice(IElementType type)` Gets the edit helper advice for `type` in order of most general advice to most specific advice.
`IEditHelperAdvice[]` `getEditHelperAdvice(IElementType type, IClientContext clientContext)` Gets the edit helper advice for `type` to which the `clientContext` has been bound, in order of most general advice to most specific advice.
`IEditHelperAdvice[]` `getEditHelperAdvice(java.lang.Object o)` Gets the edit helper advice registered for `o`, which can be either an EObject or an IElementType or an `IEditHelperContext`.
`IElementType` `getElementType(EClass eClass)` Gets the registered element type for `eClass` that has no client contexts explicitly bound to it.
`IElementType` `getElementType(EClass eClass, IClientContext clientContext)` Gets the registered element type for `eClass`.
`IElementType` `getElementType(EObject eObject)` Gets the registered element type for `eObject`.
`IElementType` `getElementType(EObject eObject, IClientContext clientContext)` Gets the registered element type for `eObject` in the `clientContext`.
`IElementType` `getElementType(java.lang.Object o)` Convenience method to get an element type for `o`.
`IElementTypeFactory` `getElementTypeFactory(java.lang.String kindName)` Gets the element type factory registered to create element types of kind `kindName`.
`IElementType[]` `getElementTypes(IClientContext clientContext)` Gets the element types (both metamodel types and specialization types) in the registry that are bound to the `clientContext`.
`static ElementTypeRegistry` `getInstance()` Gets the singleton element type registry.
`IMetamodelType[]` `getMetamodelTypes(IClientContext clientContext)` Gets the metamodel types in the registry that are bound to the `clientContext`.
`ISpecializationType[]` `getSpecializationsOf(java.lang.String id)` Gets an array containing all specializations of the element type for `id`, in breadth-first order.
`ISpecializationType[]` `getSpecializationTypes(IClientContext clientContext)` Gets the specialization types in the registry that are bound to the `clientContext`.
`IElementType` `getType(java.lang.String id)` Gets the element type for `id`.
`boolean` `register(IMetamodelType metamodelType)` Registers `metamodelType` with this registry, if its ID is unique in the registry.
`boolean` `register(ISpecializationType specializationType)` Registers `specializationType` with this registry, if its ID is unique in the registry.
`void` `removeElementTypeRegistryListener(IElementTypeRegistryListener l)` Removes `l` as a listener for changes to this registry.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getInstance

    public static ElementTypeRegistry getInstance()

  Gets the singleton element type registry.

  Returns:
    the singleton element type registry

### getEditHelperAdvice

    public IEditHelperAdvice[] getEditHelperAdvice(IElementType type)

  Gets the edit helper advice for `type` in order of most general advice to most specific advice. This order is used so that the more specific advice can act on or modify the more general advice.

  The client context is inferred from the `type`.

  Parameters:
    `type` - the element type for which to obtain editing advice
  Returns:
    the array of edit helper advice descriptors

### getEditHelperAdvice

    public IEditHelperAdvice[] getEditHelperAdvice(IElementType type,
                                                   IClientContext clientContext)

  Gets the edit helper advice for `type` to which the `clientContext` has been bound, in order of most general advice to most specific advice. This order is used so that the more specific advice can act on or modify the more general advice.

  Parameters:
    `type` - the element type for which to obtain editing advice
    `clientContext` - the client context
  Returns:
    the array of edit helper advice descriptors

### getEditHelperAdvice

    public IEditHelperAdvice[] getEditHelperAdvice(EObject eObject,
                                                   IClientContext clientContext)

  Gets the edit helper advice for `eObject` in order of most general advice to most specific advice. This order is used so that the more specific advice can act on or modify the more general advice.

  Parameters:
    `eObject` - the model element for which to obtain editing advice
    `clientContext` - the client context
  Returns:
    the array of edit helper advice

### getEditHelperAdvice

    public IEditHelperAdvice[] getEditHelperAdvice(EObject eObject)

  Gets the edit helper advice for `eObject` in order of most general advice to most specific advice. This order is used so that the more specific advice can act on or modify the more general advice.

  The client context will be inferred from the `eObject`.

  Parameters:
    `eObject` - the model element for which to obtain editing advice
  Returns:
    the array of edit helper advice

### getEditHelperAdvice

    public IEditHelperAdvice[] getEditHelperAdvice(java.lang.Object o)

  Gets the edit helper advice registered for `o`, which can be either an EObject or an IElementType or an `IEditHelperContext`.

  Parameters:
    `o` - the element or type
  Returns:
    the edit helper advice, or `null` if none.

### getContainedTypes

    public IElementType[] getContainedTypes(EObject eContainer,
                                            EReference reference,
                                            IClientContext clientContext)

  Gets the array of types that can be contained in the structural `feature` of `eContainer`. The result will not include types that represent abstract EClasses.

  Parameters:
    `eContainer` - the container
    `reference` - the feature
    `clientContext` - the client context
  Returns:
    the array of types

### getContainedTypes

    public IElementType[] getContainedTypes(EObject eContainer,
                                            EReference reference)

  Gets the array of types that can be contained in the structural `feature` of `eContainer`. The result will not include types that represent abstract EClasses.

  The client context will be inferred from the `eContainer`.

  Parameters:
    `eContainer` - the container
    `reference` - the feature
  Returns:
    the array of types

### getElementType

    public IElementType getElementType(java.lang.Object o)

  Convenience method to get an element type for `o`.

  If `o` is an `IElementType`, returns `o`.

  If `o` is an `EObject`, returns the metamodel type registered for `o`'s eClass in the client context that is bound to `o`.

  If `o` is an `IEditHelperContext`, returns the element type in `o` if specified. Else, returns the metamodel type registered for the eClass of the EObject specified in `o` in the client context specified in `o`. If no client context is specified, then the client context bound to the EObject is used.

  Use `ElementTypeRegistry.getElementType(EClass, IClientContext)` to get metamodel types registered for a specific `EClass`.

  Parameters:
    `o` - the object for which to find an element type.
  Returns:
    `o` itself if it is an element type, otherwise returns the registered metamodel type

### getElementType

    public IElementType getElementType(EClass eClass)

  Gets the registered element type for `eClass` that has no client contexts explicitly bound to it.

  Parameters:
    `eClass` - the `EClass` whose element type is to be found.
  Returns:
    the metamodel type registered for `eClass`

### getElementType

    public IElementType getElementType(EClass eClass,
                                       IClientContext clientContext)

  Gets the registered element type for `eClass`.

  Parameters:
    `eClass` - the `EClass` whose element type is to be found.
    `clientContext` - the client context
  Returns:
    the metamodel type registered for `eClass`

### getElementType

    public IElementType getElementType(EObject eObject)

  Gets the registered element type for `eObject`.

  The client context will be inferred from the `eObject`.

  Parameters:
    `eObject` - the `EObject` whose element type is to be found.
  Returns:
    the metamodel type registered for `eObject`'s `EClass`

### getElementType

    public IElementType getElementType(EObject eObject,
                                       IClientContext clientContext)

  Gets the registered element type for `eObject` in the `clientContext`.

  Parameters:
    `eObject` - the `EObject` whose element type is to be found.
    `clientContext` - the client context
  Returns:
    the metamodel type registered for `eObject`'s `EClass`

### getAllTypesMatching

    public IElementType[] getAllTypesMatching(EObject eObject,
                                              IClientContext clientContext)

  Gets all of the element types (metamodel type and specialization types) that match `eObject` in breadth-first order (specializations before metamodel types).

  Parameters:
    `eObject` - the model element to match
    `clientContext` - the client context
  Returns:
    all of the element types that match the model element

### getAllTypesMatching

    public IElementType[] getAllTypesMatching(EObject eObject)

  Gets all of the element types (metamodel type and specialization types) that match `eObject` in breadth-first order (specializations before metamodel types).

  The client context will be inferred from the `eObject`.

  Parameters:
    `eObject` - the model element to match
  Returns:
    all of the element types that match the model element

### getSpecializationsOf

    public ISpecializationType[] getSpecializationsOf(java.lang.String id)

  Gets an array containing all specializations of the element type for `id`, in breadth-first order.

  Parameters:
    `id` - the element type ID
  Returns:
    the list of all specializations of this element type

### getMetamodelTypes

    public IMetamodelType[] getMetamodelTypes(IClientContext clientContext)

  Gets the metamodel types in the registry that are bound to the `clientContext`.

  Parameters:
    `clientContext` - the client context
  Returns:
    the metamodel types

### getSpecializationTypes

    public ISpecializationType[] getSpecializationTypes(IClientContext clientContext)

  Gets the specialization types in the registry that are bound to the `clientContext`.

  Parameters:
    `clientContext` - the client context
  Returns:
    the specialization types

### getElementTypes

    public IElementType[] getElementTypes(IClientContext clientContext)

  Gets the element types (both metamodel types and specialization types) in the registry that are bound to the `clientContext`.

  Parameters:
    `clientContext` - the client context
  Returns:
    the element types

### getType

    public IElementType getType(java.lang.String id)

  Gets the element type for `id`. May return `null` if this element is not registered.

  Parameters:
    `id` - the type ID
  Returns:
    the registered type with this ID, or `null` if there is none.

### getElementTypeFactory

    public IElementTypeFactory getElementTypeFactory(java.lang.String kindName)

  Gets the element type factory registered to create element types of kind `kindName`.

  Parameters:
    `kindName` - the element type kind name
  Returns:
    the element type factory for this kind, or `null/code> if there is none`

### register

    public boolean register(IMetamodelType metamodelType)

  Registers `metamodelType` with this registry, if its ID is unique in the registry. The type's EClass does not have to be unique in the registry. Metamodel types in the registry are distinguished by the client context that is bound to the type.

  Notifies clients if the element type was added to the registry.

  Parameters:
    `metamodelType` - the element type to register
  Returns:
    `true` if the type was registered, `false` otherwise

### register

    public boolean register(ISpecializationType specializationType)

  Registers `specializationType` with this registry, if its ID is unique in the registry.

  Notifies clients if the element type was added to the registry.

  Parameters:
    `specializationType` - the element type to register
  Returns:
    `true` if the type was registered, `false` otherwise

### addElementTypeRegistryListener

    public void addElementTypeRegistryListener(IElementTypeRegistryListener l)

  Adds `l` as a listener for changes to this registry. Does nothing if `l` is already registered as a listener.

  Parameters:
    `l` - the new listener

### removeElementTypeRegistryListener

    public void removeElementTypeRegistryListener(IElementTypeRegistryListener l)

  Removes `l` as a listener for changes to this registry. Does nothing if `l` is not registered as a listener.

  Parameters:
    `l` - the listener to remove

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.