Package 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 (seeaddPattern(IPattern)andaddConnectionPattern(IConnectionPattern)) delegate to the pattern automatically.
-
-
Field Summary
-
Fields inherited from class org.eclipse.graphiti.features.impl.AbstractFeatureProvider
EMPTY_PICTOGRAM_ELEMENTS, NO_OBJECTS
-
-
Constructor Summary
Constructors Constructor Description DefaultFeatureProviderWithPatterns(IDiagramTypeProvider dtp)Creates a new instance ofDefaultFeatureProviderWithPatterns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateDirectEditingForPatterns(PictogramElement mainPictogramElement, java.lang.Object domainObject)Convenience method to activate the direct editing for the givenPictogramElementand domain object.voidactivateDirectEditingForPatterns(PictogramElement mainPictogramElement, java.lang.Object domainObject, java.lang.String keyProperty)Convenience method to activate the direct editing for the givenPictogramElementand domain object.voidaddConnectionPattern(IConnectionPattern pattern)Adds a pattern defined to handle connections to the list of registered patterns.voidaddPattern(IPattern pattern)Adds a pattern defined to handle shapes to the list of registered patterns.protected booleancheckFeatureAndContext(IFeature feature, IContext context)Checks if a feature along with its context is available.protected booleancheckPattern(IPattern pattern, java.lang.Object object)Checks the given pattern if it can deal with the given domain object.IAddFeaturegetAddFeature(IAddContext context)Tries to retrieve an add feature suiting the given add context from the registered patterns.protected IAddFeaturegetAddFeatureAdditional(IAddContext context)Gets the additional add feature functionality.java.lang.ObjectgetBusinessObjectForPictogramElement(PictogramElement pictogramElement)Helper method to find the domain object for a givenPictogramElement.protected java.util.List<IConnectionPattern>getConnectionPatterns()Returns a new list of the registered patterns that deal with sonnection inside this feature provider.ICreateConnectionFeature[]getCreateConnectionFeatures()Retrieves an array of create connection features that are available from the registered patterns and the super class of this feature provider.protected ICreateConnectionFeature[]getCreateConnectionFeaturesAdditional()Gets the additional create connection feature functionality.ICreateFeature[]getCreateFeatures()Retrieves an array of create features that are available from the registered patterns and the super class of this feature provider.protected ICreateFeature[]getCreateFeaturesAdditional()Gets the additional create feature functionality.IDeleteFeaturegetDeleteFeature(IDeleteContext context)Tries to retrieve a delete feature suiting the given delete context from the registered patterns.protected IDeleteFeaturegetDeleteFeatureAdditional(IDeleteContext context)Gets the additional delete feature functionality.IDirectEditingFeaturegetDirectEditingFeature(IDirectEditingContext context)Tries to retrieve a direct editing feature suiting the given direct editing context from the registered patterns.protected IDirectEditingFeaturegetDirectEditingFeatureAdditional(IDirectEditingContext context)Gets the additional direct editing feature functionality.ILayoutFeaturegetLayoutFeature(ILayoutContext context)Tries to retrieve a layout feature suiting the given layout context from the registered patterns.protected ILayoutFeaturegetLayoutFeatureAdditional(ILayoutContext context)Gets the additional layout feature functionality.IMoveShapeFeaturegetMoveShapeFeature(IMoveShapeContext context)Tries to retrieve a move feature for shapes suiting the given move context from the registered patterns.protected IMoveShapeFeaturegetMoveShapeFeatureAdditional(IMoveShapeContext context)Gets the additional move feature functionality for shapes.IPatterngetPatternForPictogramElement(PictogramElement pe)Gets the pattern for pictogram element.protected java.util.List<IPattern>getPatterns()Returns a new list of the registered patterns that deal with shapes inside this feature provider.IRemoveFeaturegetRemoveFeature(IRemoveContext context)Tries to retrieve a remove feature suiting the given remove context from the registered patterns.protected IRemoveFeaturegetRemoveFeatureAdditional(IRemoveContext context)Gets the additional remove feature functionality.IResizeShapeFeaturegetResizeShapeFeature(IResizeShapeContext context)Tries to retrieve a resize feature for shapes suiting the given resize context from the registered patterns.protected IResizeShapeFeaturegetResizeShapeFeatureAdditional(IResizeShapeContext context)Gets the additional resize feature functionality for shapes.IUpdateFeaturegetUpdateFeature(IUpdateContext context)Tries to retrieve an update feature suiting the given update context from the registered patterns.protected IUpdateFeaturegetUpdateFeatureAdditional(IUpdateContext context)Gets the additional update feature functionality.protected voidtraceWarning(java.lang.String string, IPattern pattern, IPattern choosenPattern)Helper method to trace warnings when more than one pattern is executed.-
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, getIndependenceSolver, getLinkService, getPictogramElementForBusinessObject, getReconnectionFeature, hasPictogramElementForBusinessObject, layoutIfPossible, link, link, setIndependenceSolver, updateIfPossible, updateIfPossibleAndNeeded, updateNeeded
-
-
-
-
Constructor Detail
-
DefaultFeatureProviderWithPatterns
public DefaultFeatureProviderWithPatterns(IDiagramTypeProvider dtp)
Creates a new instance ofDefaultFeatureProviderWithPatterns. 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 seeaddConnectionPattern(IConnectionPattern). The pattern must not benull, or aIllegalArgumentExceptionwill be thrown.- Specified by:
addPatternin interfaceIPatternContainer- 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 seeaddPattern(IPattern). The pattern must not benull, or aIllegalArgumentExceptionwill be thrown.- Parameters:
pattern- The Pattern to add
-
getPatterns
protected java.util.List<IPattern> getPatterns()
Returns a new list of the registered patterns that deal with shapes inside this feature provider.- Returns:
- A
Listof the registered shape-based patterns.
-
getConnectionPatterns
protected java.util.List<IConnectionPattern> getConnectionPatterns()
Returns a new list of the registered patterns that deal with sonnection inside this feature provider.- Returns:
- A
Listof the registered connection-based patterns.
-
checkFeatureAndContext
protected boolean checkFeatureAndContext(IFeature feature, IContext context)
Checks if a feature along with its context is available. Delegates to theIFeature.isAvailable(IContext)method.- Parameters:
feature- The feature to checkcontext- The according context- Returns:
true, if the feature is available,falseotherwise.
-
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 methodgetAddFeatureAdditional(IAddContext)).- Specified by:
getAddFeaturein interfaceIFeatureProvider- Overrides:
getAddFeaturein classAbstractFeatureProvider- Parameters:
context- AnIAddContextdescribing the needed functionality- Returns:
- An
IAddFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IAddFeature
-
getAddFeatureAdditional
protected IAddFeature getAddFeatureAdditional(IAddContext context)
Gets the additional add feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getAddFeature(IAddContext).- Parameters:
context- AnIAddContextdescribing the needed functionality- Returns:
- An
IAddFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
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 methodgetCreateConnectionFeaturesAdditional()).- Specified by:
getCreateFeaturesin interfaceIFeatureProvider- Overrides:
getCreateFeaturesin classAbstractFeatureProvider- Returns:
- An array of
ICreateFeatures in case a suitable functionality has been found, an empty array otherwise. - See Also:
ICreateFeature
-
getCreateFeaturesAdditional
protected ICreateFeature[] getCreateFeaturesAdditional()
Gets the additional create feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getCreateFeatures().- Returns:
- An array of
ICreateFeatures in case a suitable functionality has been found by the super class, an empty array otherwise.
-
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 methodgetDeleteFeatureAdditional(IDeleteContext)).- Specified by:
getDeleteFeaturein interfaceIFeatureProvider- Overrides:
getDeleteFeaturein classDefaultFeatureProvider- Parameters:
context- AnIDeleteContextdescribing the needed functionality- Returns:
- An
IDeleteFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IDeleteFeature
-
getDeleteFeatureAdditional
protected IDeleteFeature getDeleteFeatureAdditional(IDeleteContext context)
Gets the additional delete feature functionality. The default implementation simply delegates toDefaultFeatureProvider.getDeleteFeature(IDeleteContext).- Parameters:
context- AnIDeleteContextdescribing the needed functionality- Returns:
- An
IDeleteFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
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 methodgetRemoveFeatureAdditional(IRemoveContext)).- Specified by:
getRemoveFeaturein interfaceIFeatureProvider- Overrides:
getRemoveFeaturein classDefaultFeatureProvider- Parameters:
context- AnIRemoveContextdescribing the needed functionality- Returns:
- An
IRemoveFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IRemoveFeature
-
getRemoveFeatureAdditional
protected IRemoveFeature getRemoveFeatureAdditional(IRemoveContext context)
Gets the additional remove feature functionality. The default implementation simply delegates toDefaultFeatureProvider.getRemoveFeature(IRemoveContext).- Parameters:
context- AnIRemoveContextdescribing the needed functionality- Returns:
- An
IRemoveFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
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 methodgetLayoutFeatureAdditional(ILayoutContext)).- Specified by:
getLayoutFeaturein interfaceIFeatureProvider- Overrides:
getLayoutFeaturein classAbstractFeatureProvider- Parameters:
context- AnILayoutContextdescribing the needed functionality- Returns:
- An
ILayoutFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
ILayoutFeature
-
getLayoutFeatureAdditional
protected ILayoutFeature getLayoutFeatureAdditional(ILayoutContext context)
Gets the additional layout feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getLayoutFeature(ILayoutContext).- Parameters:
context- AnILayoutContextdescribing the needed functionality- Returns:
- An
ILayoutFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
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 methodgetMoveShapeFeatureAdditional(IMoveShapeContext)).- Specified by:
getMoveShapeFeaturein interfaceIFeatureProvider- Overrides:
getMoveShapeFeaturein classDefaultFeatureProvider- Parameters:
context- AnIMoveShapeContextdescribing the needed functionality- Returns:
- An
IMoveShapeFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IMoveShapeFeature
-
getMoveShapeFeatureAdditional
protected IMoveShapeFeature getMoveShapeFeatureAdditional(IMoveShapeContext context)
Gets the additional move feature functionality for shapes. The default implementation simply delegates toDefaultFeatureProvider.getMoveShapeFeature(IMoveShapeContext).- Parameters:
context- AnIMoveShapeContextdescribing the needed functionality- Returns:
- An
IMoveShapeFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
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 methodgetResizeShapeFeatureAdditional(IResizeShapeContext)).- Specified by:
getResizeShapeFeaturein interfaceIFeatureProvider- Overrides:
getResizeShapeFeaturein classDefaultFeatureProvider- Parameters:
context- AnIResizeShapeContextdescribing the needed functionality- Returns:
- An
IResizeShapeFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IResizeShapeFeature
-
checkPattern
protected boolean checkPattern(IPattern pattern, java.lang.Object object)
Checks the given pattern if it can deal with the given domain object. The default implementation simply delegates to the pattern'sIPattern.isMainBusinessObjectApplicable(Object)method.- Parameters:
pattern- The pattern to checkobject- The domain object- Returns:
true, if the pattern can handle the domain object,falseotherwise.
-
getResizeShapeFeatureAdditional
protected IResizeShapeFeature getResizeShapeFeatureAdditional(IResizeShapeContext context)
Gets the additional resize feature functionality for shapes. The default implementation simply delegates toDefaultFeatureProvider.getResizeShapeFeature(IResizeShapeContext).- Parameters:
context- AnIResizeShapeContextdescribing the needed functionality- Returns:
- An
IResizeShapeFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
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 methodgetUpdateFeatureAdditional(IUpdateContext)).- Specified by:
getUpdateFeaturein interfaceIFeatureProvider- Overrides:
getUpdateFeaturein classDefaultFeatureProvider- Parameters:
context- AnIUpdateContextdescribing the needed functionality- Returns:
- An
IUpdateFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IUpdateFeature
-
getUpdateFeatureAdditional
protected IUpdateFeature getUpdateFeatureAdditional(IUpdateContext context)
Gets the additional update feature functionality. The default implementation simply delegates toDefaultFeatureProvider.getUpdateFeature(IUpdateContext).- Parameters:
context- AnIUpdateContextdescribing the needed functionality- Returns:
- An
IUpdateFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
getPatternForPictogramElement
public IPattern getPatternForPictogramElement(PictogramElement pe)
Description copied from interface:IFeatureProviderWithPatternsGets the pattern for pictogram element.- Specified by:
getPatternForPictogramElementin interfaceIFeatureProviderWithPatterns- Parameters:
pe- the pictogram element- Returns:
- the pattern for pictogram element
-
activateDirectEditingForPatterns
public void activateDirectEditingForPatterns(PictogramElement mainPictogramElement, java.lang.Object domainObject)
Convenience method to activate the direct editing for the givenPictogramElementand domain object. The default implementation tries to retrieve the direct editing functionality from the registered patterns for shapes.- Specified by:
activateDirectEditingForPatternsin interfaceIFeatureProviderWithPatterns- Parameters:
mainPictogramElement- The rootPictogramElementfor which direct editing shall be triggered. This pictogram element is used to find a suitable pattern for this request viaAbstractPattern.isPatternRoot(PictogramElement).domainObject- The domain object behind the direct editing request. This object is passed to theIDirectEditingInfo.
-
activateDirectEditingForPatterns
public void activateDirectEditingForPatterns(PictogramElement mainPictogramElement, java.lang.Object domainObject, java.lang.String keyProperty)
Convenience method to activate the direct editing for the givenPictogramElementand domain object. The default implementation tries to retrieve the direct editing functionality from the registered patterns for shapes.- Specified by:
activateDirectEditingForPatternsin interfaceIFeatureProviderWithPatterns- Parameters:
mainPictogramElement- The rootPictogramElementfor which direct editing shall be triggered. This pictogram element is used to find a suitable pattern for this request viaAbstractPattern.isPatternRoot(PictogramElement).domainObject- The domain object behind the direct editing request. This object is passed to theIDirectEditingInfo.keyProperty- An additional key property that is passed to theIDirectEditingInfo.
-
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 methodgetCreateConnectionFeaturesAdditional()).- Specified by:
getCreateConnectionFeaturesin interfaceIFeatureProvider- Overrides:
getCreateConnectionFeaturesin classAbstractFeatureProvider- Returns:
- An array of
ICreateConnectionFeatures in case a suitable functionality has been found, an empty array otherwise. - See Also:
ICreateConnectionFeature
-
getCreateConnectionFeaturesAdditional
protected ICreateConnectionFeature[] getCreateConnectionFeaturesAdditional()
Gets the additional create connection feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getCreateConnectionFeatures().- Returns:
- An array of
ICreateConnectionFeatures in case a suitable functionality has been found by the super class, an empty array otherwise.
-
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 methodgetDirectEditingFeatureAdditional(IDirectEditingContext)).- Specified by:
getDirectEditingFeaturein interfaceIFeatureProvider- Overrides:
getDirectEditingFeaturein classAbstractFeatureProvider- Parameters:
context- AnIDirectEditingContextdescribing the needed functionality- Returns:
- An
IDirectEditingFeaturein case a suitable functionality has been found,nullotherwise. - See Also:
IDirectEditingFeature
-
getDirectEditingFeatureAdditional
protected IDirectEditingFeature getDirectEditingFeatureAdditional(IDirectEditingContext context)
Gets the additional direct editing feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getDirectEditingFeature(IDirectEditingContext).- Parameters:
context- AnIDirectEditingContextdescribing the needed functionality- Returns:
- An
IDirectEditingFeaturein case a suitable functionality has been found by the super class,nullotherwise.
-
traceWarning
protected void traceWarning(java.lang.String string, IPattern pattern, IPattern choosenPattern)Helper method to trace warnings when more than one pattern is executed.- Parameters:
string- The string information to tracepattern- The patternchoosenPattern- The additionally chosen pattern
-
getBusinessObjectForPictogramElement
public java.lang.Object getBusinessObjectForPictogramElement(PictogramElement pictogramElement)
Helper method to find the domain object for a givenPictogramElement. The default implementation first delegates toAbstractFeatureProvider.getBusinessObjectForPictogramElement(PictogramElement)and then directly tries to follow an eventually set link property, seeILinkService.setLinkProperty(PictogramElement, String).- Specified by:
getBusinessObjectForPictogramElementin interfaceIMappingProvider- Overrides:
getBusinessObjectForPictogramElementin classAbstractFeatureProvider- Parameters:
pictogramElement- ThePictogramElementto find the domain object for.- Returns:
- A domain object in case it was found,
nullotherwise. - See Also:
IMappingProvider.link(PictogramElement, Object)
-
-