org.eclipse.graphiti.pattern

## Class DefaultFeatureProviderWithPatterns

- java.lang.Object
- - org.eclipse.graphiti.features.impl.AbstractFeatureProvider
  - - org.eclipse.graphiti.ui.features.DefaultFeatureProvider
    - - org.eclipse.graphiti.pattern.DefaultFeatureProviderWithPatterns

All Implemented Interfaces:
  IFeatureProvider, IMappingProvider, IFeatureProviderWithPatterns, IPatternContainer

    public class DefaultFeatureProviderWithPatterns
    extends DefaultFeatureProvider
    implements IFeatureProviderWithPatterns

The class DefaultFeatureProviderWithPatterns is the base class for a feature provider that uses patterns. It is also possible to implement aspects of the functionality triggered here using features by simply returning these features here. In case of pattern-based functionality clients in general need to implement nothing here, because the registered patterns (see `addPattern(IPattern)` and `addConnectionPattern(IConnectionPattern)`) delegate to the pattern automatically.

### Constructor Summary

Constructors
Constructor and Description
`DefaultFeatureProviderWithPatterns(IDiagramTypeProvider dtp)` Creates a new instance of `DefaultFeatureProviderWithPatterns`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `activateDirectEditingForPatterns(PictogramElement mainPictogramElement, Object domainObject)` Convenience method to activate the direct editing for the given `PictogramElement` and domain object.
`void` `activateDirectEditingForPatterns(PictogramElement mainPictogramElement, Object domainObject, String keyProperty)` Convenience method to activate the direct editing for the given `PictogramElement` and domain object.
`void` `addConnectionPattern(IConnectionPattern pattern)` Adds a pattern defined to handle connections to the list of registered patterns.
`void` `addPattern(IPattern pattern)` Adds a pattern defined to handle shapes to the list of registered patterns.
`IAddFeature` `getAddFeature(IAddContext context)` Tries to retrieve an add feature suiting the given add context from the registered patterns.
`Object` `getBusinessObjectForPictogramElement(PictogramElement pictogramElement)` Helper method to find the domain object for a given `PictogramElement`.
`ICreateConnectionFeature[]` `getCreateConnectionFeatures()` Retrieves an array of create connection features that are available from the registered patterns and the super class of this feature provider.
`ICreateFeature[]` `getCreateFeatures()` Retrieves an array of create features that are available from the registered patterns and the super class of this feature provider.
`IDeleteFeature` `getDeleteFeature(IDeleteContext context)` Tries to retrieve a delete feature suiting the given delete context from the registered patterns.
`IDirectEditingFeature` `getDirectEditingFeature(IDirectEditingContext context)` Tries to retrieve a direct editing feature suiting the given direct editing context from the registered patterns.
`ILayoutFeature` `getLayoutFeature(ILayoutContext context)` Tries to retrieve a layout feature suiting the given layout context from the registered patterns.
`IMoveShapeFeature` `getMoveShapeFeature(IMoveShapeContext context)` Tries to retrieve a move feature for shapes suiting the given move context from the registered patterns.
`IPattern` `getPatternForPictogramElement(PictogramElement pe)` Gets the pattern for pictogram element.
`IRemoveFeature` `getRemoveFeature(IRemoveContext context)` Tries to retrieve a remove feature suiting the given remove context from the registered patterns.
`IResizeShapeFeature` `getResizeShapeFeature(IResizeShapeContext context)` Tries to retrieve a resize feature for shapes suiting the given resize context from the registered patterns.
`IUpdateFeature` `getUpdateFeature(IUpdateContext context)` Tries to retrieve an update feature suiting the given update context from the registered patterns.

### Methods inherited from class org.eclipse.graphiti.ui.features.DefaultFeatureProvider

`getAddBendpointFeature, getCopyFeature, getCustomFeatures, getMoveAnchorFeature, getMoveBendpointFeature, getMoveConnectionDecoratorFeature, getPasteFeature, getPrintFeature, getRemoveBendpointFeature, getSaveImageFeature`

### Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeatureProvider

`addIfPossible, canAdd, canLayout, canUpdate, dispose, getAllBusinessObjectsForPictogramElement, getAllPictogramElementsForBusinessObject, getDiagramTypeProvider, getDirectEditingInfo, getDragAndDropFeatures, getPictogramElementForBusinessObject, getReconnectionFeature, hasPictogramElementForBusinessObject, layoutIfPossible, link, link, updateIfPossible, updateIfPossibleAndNeeded, updateNeeded`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultFeatureProviderWithPatterns

    public DefaultFeatureProviderWithPatterns(IDiagramTypeProvider dtp)

Creates a new instance of `DefaultFeatureProviderWithPatterns`. This is usually done from the diagram type provider.

Parameters:
  `dtp` - The diagram type provider associated with this feature provider.

### Method Detail

#### addPattern

    public void addPattern(IPattern pattern)

Adds a pattern defined to handle shapes to the list of registered patterns. For adding connection-based patterns see `addConnectionPattern(IConnectionPattern)`. The pattern must not be `null`, or a `IllegalArgumentException` will be thrown.

Specified by:
  `addPattern` in interface `IPatternContainer`
Parameters:
  `pattern` - The Pattern to add

#### addConnectionPattern

    public void addConnectionPattern(IConnectionPattern pattern)

Adds a pattern defined to handle connections to the list of registered patterns. For adding shape-based patterns see `addPattern(IPattern)`. The pattern must not be `null`, or a `IllegalArgumentException` will be thrown.

Parameters:
  `pattern` - The Pattern to add

#### getAddFeature

    public IAddFeature getAddFeature(IAddContext context)

Tries to retrieve an add feature suiting the given add context from the registered patterns. First the shape patterns, then the connection patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getAddFeatureAdditional(IAddContext)`).

Specified by:
  `getAddFeature` in interface `IFeatureProvider`
Overrides:
  `getAddFeature` in class `AbstractFeatureProvider`
Parameters:
  `context` - An `IAddContext` describing the needed functionality
Returns:
  An `IAddFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IAddFeature`

#### getCreateFeatures

    public ICreateFeature[] getCreateFeatures()

Retrieves an array of create features that are available from the registered patterns and the super class of this feature provider. Only the shape patterns are queried. Then the call is delegated to the super class (via the method `getCreateConnectionFeaturesAdditional()`).

Specified by:
  `getCreateFeatures` in interface `IFeatureProvider`
Overrides:
  `getCreateFeatures` in class `AbstractFeatureProvider`
Returns:
  An array of `ICreateFeature`s in case a suitable functionality has been found, an empty array otherwise.
See Also:
  `ICreateFeature`

#### getDeleteFeature

    public IDeleteFeature getDeleteFeature(IDeleteContext context)

Tries to retrieve a delete feature suiting the given delete context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getDeleteFeatureAdditional(IDeleteContext)`).

Specified by:
  `getDeleteFeature` in interface `IFeatureProvider`
Overrides:
  `getDeleteFeature` in class `DefaultFeatureProvider`
Parameters:
  `context` - An `IDeleteContext` describing the needed functionality
Returns:
  An `IDeleteFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IDeleteFeature`

#### getRemoveFeature

    public IRemoveFeature getRemoveFeature(IRemoveContext context)

Tries to retrieve a remove feature suiting the given remove context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getRemoveFeatureAdditional(IRemoveContext)`).

Specified by:
  `getRemoveFeature` in interface `IFeatureProvider`
Overrides:
  `getRemoveFeature` in class `DefaultFeatureProvider`
Parameters:
  `context` - An `IRemoveContext` describing the needed functionality
Returns:
  An `IRemoveFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IRemoveFeature`

#### getLayoutFeature

    public ILayoutFeature getLayoutFeature(ILayoutContext context)

Tries to retrieve a layout feature suiting the given layout context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getLayoutFeatureAdditional(ILayoutContext)`).

Specified by:
  `getLayoutFeature` in interface `IFeatureProvider`
Overrides:
  `getLayoutFeature` in class `AbstractFeatureProvider`
Parameters:
  `context` - An `ILayoutContext` describing the needed functionality
Returns:
  An `ILayoutFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `ILayoutFeature`

#### getMoveShapeFeature

    public IMoveShapeFeature getMoveShapeFeature(IMoveShapeContext context)

Tries to retrieve a move feature for shapes suiting the given move context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getMoveShapeFeatureAdditional(IMoveShapeContext)`).

Specified by:
  `getMoveShapeFeature` in interface `IFeatureProvider`
Overrides:
  `getMoveShapeFeature` in class `DefaultFeatureProvider`
Parameters:
  `context` - An `IMoveShapeContext` describing the needed functionality
Returns:
  An `IMoveShapeFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IMoveShapeFeature`

#### getResizeShapeFeature

    public IResizeShapeFeature getResizeShapeFeature(IResizeShapeContext context)

Tries to retrieve a resize feature for shapes suiting the given resize context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getResizeShapeFeatureAdditional(IResizeShapeContext)`).

Specified by:
  `getResizeShapeFeature` in interface `IFeatureProvider`
Overrides:
  `getResizeShapeFeature` in class `DefaultFeatureProvider`
Parameters:
  `context` - An `IResizeShapeContext` describing the needed functionality
Returns:
  An `IResizeShapeFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IResizeShapeFeature`

#### getUpdateFeature

    public IUpdateFeature getUpdateFeature(IUpdateContext context)

Tries to retrieve an update feature suiting the given update context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getUpdateFeatureAdditional(IUpdateContext)`).

Specified by:
  `getUpdateFeature` in interface `IFeatureProvider`
Overrides:
  `getUpdateFeature` in class `DefaultFeatureProvider`
Parameters:
  `context` - An `IUpdateContext` describing the needed functionality
Returns:
  An `IUpdateFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IUpdateFeature`

#### getPatternForPictogramElement

    public IPattern getPatternForPictogramElement(PictogramElement pe)

Description copied from interface: `IFeatureProviderWithPatterns`
Gets the pattern for pictogram element.

Specified by:
  `getPatternForPictogramElement` in interface `IFeatureProviderWithPatterns`
Parameters:
  `pe` - the pictogram element
Returns:
  the pattern for pictogram element

#### activateDirectEditingForPatterns

    public void activateDirectEditingForPatterns(PictogramElement mainPictogramElement,
                                                 Object domainObject)

Convenience method to activate the direct editing for the given `PictogramElement` and domain object. The default implementation tries to retrieve the direct editing functionality from the registered patterns for shapes.

Specified by:
  `activateDirectEditingForPatterns` in interface `IFeatureProviderWithPatterns`
Parameters:
  `mainPictogramElement` - The root `PictogramElement` for which direct editing shall be triggered. This pictogram element is used to find a suitable pattern for this request via `AbstractPattern.isPatternRoot(PictogramElement)`.
  `domainObject` - The domain object behind the direct editing request. This object is passed to the `IDirectEditingInfo`.

#### activateDirectEditingForPatterns

    public void activateDirectEditingForPatterns(PictogramElement mainPictogramElement,
                                                 Object domainObject,
                                                 String keyProperty)

Convenience method to activate the direct editing for the given `PictogramElement` and domain object. The default implementation tries to retrieve the direct editing functionality from the registered patterns for shapes.

Specified by:
  `activateDirectEditingForPatterns` in interface `IFeatureProviderWithPatterns`
Parameters:
  `mainPictogramElement` - The root `PictogramElement` for which direct editing shall be triggered. This pictogram element is used to find a suitable pattern for this request via `AbstractPattern.isPatternRoot(PictogramElement)`.
  `domainObject` - The domain object behind the direct editing request. This object is passed to the `IDirectEditingInfo`.
  `keyProperty` - An additional key property that is passed to the `IDirectEditingInfo`.

#### getCreateConnectionFeatures

    public ICreateConnectionFeature[] getCreateConnectionFeatures()

Retrieves an array of create connection features that are available from the registered patterns and the super class of this feature provider. Only the connection patterns are queried. Then the call is delegated to the super class (via the method `getCreateConnectionFeaturesAdditional()`).

Specified by:
  `getCreateConnectionFeatures` in interface `IFeatureProvider`
Overrides:
  `getCreateConnectionFeatures` in class `AbstractFeatureProvider`
Returns:
  An array of `ICreateConnectionFeature`s in case a suitable functionality has been found, an empty array otherwise.
See Also:
  `ICreateConnectionFeature`

#### getDirectEditingFeature

    public IDirectEditingFeature getDirectEditingFeature(IDirectEditingContext context)

Tries to retrieve a direct editing feature suiting the given direct editing context from the registered patterns. Only the shape patterns are queried. If no suitable pattern functionality is found the call is delegated to the super class (via the method `getDirectEditingFeatureAdditional(IDirectEditingContext)`).

Specified by:
  `getDirectEditingFeature` in interface `IFeatureProvider`
Overrides:
  `getDirectEditingFeature` in class `AbstractFeatureProvider`
Parameters:
  `context` - An `IDirectEditingContext` describing the needed functionality
Returns:
  An `IDirectEditingFeature` in case a suitable functionality has been found, `null` otherwise.
See Also:
  `IDirectEditingFeature`

#### getBusinessObjectForPictogramElement

    public Object getBusinessObjectForPictogramElement(PictogramElement pictogramElement)

Helper method to find the domain object for a given `PictogramElement`. The default implementation first delegates to `AbstractFeatureProvider.getBusinessObjectForPictogramElement(PictogramElement)` and then directly tries to follow an eventually set link property, see `ILinkService.setLinkProperty(PictogramElement, String)`.

Specified by:
  `getBusinessObjectForPictogramElement` in interface `IMappingProvider`
Overrides:
  `getBusinessObjectForPictogramElement` in class `AbstractFeatureProvider`
Parameters:
  `pictogramElement` - The `PictogramElement` to find the domain object for.
Returns:
  A domain object in case it was found, `null` otherwise.
See Also:
  `IMappingProvider.link(PictogramElement, Object)`