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 (see
addPattern(IPattern)
and
addConnectionPattern(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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activateDirectEditingForPatterns
(PictogramElement mainPictogramElement, Object domainObject) Convenience method to activate the direct editing for the givenPictogramElement
and domain object.void
activateDirectEditingForPatterns
(PictogramElement mainPictogramElement, Object domainObject, String keyProperty) Convenience method to activate the direct editing for the givenPictogramElement
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.protected boolean
checkFeatureAndContext
(IFeature feature, IContext context) Checks if a feature along with its context is available.protected boolean
checkPattern
(IPattern pattern, Object object) Checks the given pattern if it can deal with the given domain object.getAddFeature
(IAddContext context) Tries to retrieve an add feature suiting the given add context from the registered patterns.protected IAddFeature
getAddFeatureAdditional
(IAddContext context) Gets the additional add feature functionality.getBusinessObjectForPictogramElement
(PictogramElement pictogramElement) Helper method to find the domain object for a givenPictogramElement
.protected List<IConnectionPattern>
Returns a new list of the registered patterns that deal with sonnection inside this feature provider.Retrieves an array of create connection features that are available from the registered patterns and the super class of this feature provider.protected ICreateConnectionFeature[]
Gets the additional create connection feature functionality.Retrieves an array of create features that are available from the registered patterns and the super class of this feature provider.protected ICreateFeature[]
Gets the additional create feature functionality.getDeleteFeature
(IDeleteContext context) Tries to retrieve a delete feature suiting the given delete context from the registered patterns.protected IDeleteFeature
getDeleteFeatureAdditional
(IDeleteContext context) Gets the additional delete feature functionality.Tries to retrieve a direct editing feature suiting the given direct editing context from the registered patterns.protected IDirectEditingFeature
Gets the additional direct editing feature functionality.getLayoutFeature
(ILayoutContext context) Tries to retrieve a layout feature suiting the given layout context from the registered patterns.protected ILayoutFeature
getLayoutFeatureAdditional
(ILayoutContext context) Gets the additional layout feature functionality.getMoveShapeFeature
(IMoveShapeContext context) Tries to retrieve a move feature for shapes suiting the given move context from the registered patterns.protected IMoveShapeFeature
Gets the additional move feature functionality for shapes.Gets the pattern for pictogram element.Returns a new list of the registered patterns that deal with shapes inside this feature provider.getRemoveFeature
(IRemoveContext context) Tries to retrieve a remove feature suiting the given remove context from the registered patterns.protected IRemoveFeature
getRemoveFeatureAdditional
(IRemoveContext context) Gets the additional remove feature functionality.getResizeShapeFeature
(IResizeShapeContext context) Tries to retrieve a resize feature for shapes suiting the given resize context from the registered patterns.protected IResizeShapeFeature
Gets the additional resize feature functionality for shapes.getUpdateFeature
(IUpdateContext context) Tries to retrieve an update feature suiting the given update context from the registered patterns.protected IUpdateFeature
getUpdateFeatureAdditional
(IUpdateContext context) Gets the additional update feature functionality.protected void
traceWarning
(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 Details
-
DefaultFeatureProviderWithPatterns
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 Details
-
addPattern
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 aIllegalArgumentException
will be thrown.- Specified by:
addPattern
in interfaceIPatternContainer
- Parameters:
pattern
- The Pattern to add
-
addConnectionPattern
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 aIllegalArgumentException
will be thrown.- Parameters:
pattern
- The Pattern to add
-
getPatterns
Returns a new list of the registered patterns that deal with shapes inside this feature provider.- Returns:
- A
List
of the registered shape-based patterns.
-
getConnectionPatterns
Returns a new list of the registered patterns that deal with sonnection inside this feature provider.- Returns:
- A
List
of the registered connection-based patterns.
-
checkFeatureAndContext
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,false
otherwise.
-
getAddFeature
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:
getAddFeature
in interfaceIFeatureProvider
- Overrides:
getAddFeature
in classAbstractFeatureProvider
- Parameters:
context
- AnIAddContext
describing the needed functionality- Returns:
- An
IAddFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getAddFeatureAdditional
Gets the additional add feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getAddFeature(IAddContext)
.- Parameters:
context
- AnIAddContext
describing the needed functionality- Returns:
- An
IAddFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
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:
getCreateFeatures
in interfaceIFeatureProvider
- Overrides:
getCreateFeatures
in classAbstractFeatureProvider
- Returns:
- An array of
ICreateFeature
s in case a suitable functionality has been found, an empty array otherwise. - See Also:
-
getCreateFeaturesAdditional
Gets the additional create feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getCreateFeatures()
.- Returns:
- An array of
ICreateFeature
s in case a suitable functionality has been found by the super class, an empty array otherwise.
-
getDeleteFeature
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:
getDeleteFeature
in interfaceIFeatureProvider
- Overrides:
getDeleteFeature
in classDefaultFeatureProvider
- Parameters:
context
- AnIDeleteContext
describing the needed functionality- Returns:
- An
IDeleteFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getDeleteFeatureAdditional
Gets the additional delete feature functionality. The default implementation simply delegates toDefaultFeatureProvider.getDeleteFeature(IDeleteContext)
.- Parameters:
context
- AnIDeleteContext
describing the needed functionality- Returns:
- An
IDeleteFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
getRemoveFeature
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:
getRemoveFeature
in interfaceIFeatureProvider
- Overrides:
getRemoveFeature
in classDefaultFeatureProvider
- Parameters:
context
- AnIRemoveContext
describing the needed functionality- Returns:
- An
IRemoveFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getRemoveFeatureAdditional
Gets the additional remove feature functionality. The default implementation simply delegates toDefaultFeatureProvider.getRemoveFeature(IRemoveContext)
.- Parameters:
context
- AnIRemoveContext
describing the needed functionality- Returns:
- An
IRemoveFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
getLayoutFeature
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:
getLayoutFeature
in interfaceIFeatureProvider
- Overrides:
getLayoutFeature
in classAbstractFeatureProvider
- Parameters:
context
- AnILayoutContext
describing the needed functionality- Returns:
- An
ILayoutFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getLayoutFeatureAdditional
Gets the additional layout feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getLayoutFeature(ILayoutContext)
.- Parameters:
context
- AnILayoutContext
describing the needed functionality- Returns:
- An
ILayoutFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
getMoveShapeFeature
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:
getMoveShapeFeature
in interfaceIFeatureProvider
- Overrides:
getMoveShapeFeature
in classDefaultFeatureProvider
- Parameters:
context
- AnIMoveShapeContext
describing the needed functionality- Returns:
- An
IMoveShapeFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getMoveShapeFeatureAdditional
Gets the additional move feature functionality for shapes. The default implementation simply delegates toDefaultFeatureProvider.getMoveShapeFeature(IMoveShapeContext)
.- Parameters:
context
- AnIMoveShapeContext
describing the needed functionality- Returns:
- An
IMoveShapeFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
getResizeShapeFeature
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:
getResizeShapeFeature
in interfaceIFeatureProvider
- Overrides:
getResizeShapeFeature
in classDefaultFeatureProvider
- Parameters:
context
- AnIResizeShapeContext
describing the needed functionality- Returns:
- An
IResizeShapeFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
checkPattern
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,false
otherwise.
-
getResizeShapeFeatureAdditional
Gets the additional resize feature functionality for shapes. The default implementation simply delegates toDefaultFeatureProvider.getResizeShapeFeature(IResizeShapeContext)
.- Parameters:
context
- AnIResizeShapeContext
describing the needed functionality- Returns:
- An
IResizeShapeFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
getUpdateFeature
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:
getUpdateFeature
in interfaceIFeatureProvider
- Overrides:
getUpdateFeature
in classDefaultFeatureProvider
- Parameters:
context
- AnIUpdateContext
describing the needed functionality- Returns:
- An
IUpdateFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getUpdateFeatureAdditional
Gets the additional update feature functionality. The default implementation simply delegates toDefaultFeatureProvider.getUpdateFeature(IUpdateContext)
.- Parameters:
context
- AnIUpdateContext
describing the needed functionality- Returns:
- An
IUpdateFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
getPatternForPictogramElement
Description copied from interface:IFeatureProviderWithPatterns
Gets the pattern for pictogram element.- Specified by:
getPatternForPictogramElement
in interfaceIFeatureProviderWithPatterns
- 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 givenPictogramElement
and domain object. The default implementation tries to retrieve the direct editing functionality from the registered patterns for shapes.- Specified by:
activateDirectEditingForPatterns
in interfaceIFeatureProviderWithPatterns
- Parameters:
mainPictogramElement
- The rootPictogramElement
for 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, Object domainObject, String keyProperty) Convenience method to activate the direct editing for the givenPictogramElement
and domain object. The default implementation tries to retrieve the direct editing functionality from the registered patterns for shapes.- Specified by:
activateDirectEditingForPatterns
in interfaceIFeatureProviderWithPatterns
- Parameters:
mainPictogramElement
- The rootPictogramElement
for 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
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:
getCreateConnectionFeatures
in interfaceIFeatureProvider
- Overrides:
getCreateConnectionFeatures
in classAbstractFeatureProvider
- Returns:
- An array of
ICreateConnectionFeature
s in case a suitable functionality has been found, an empty array otherwise. - See Also:
-
getCreateConnectionFeaturesAdditional
Gets the additional create connection feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getCreateConnectionFeatures()
.- Returns:
- An array of
ICreateConnectionFeature
s in case a suitable functionality has been found by the super class, an empty array otherwise.
-
getDirectEditingFeature
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:
getDirectEditingFeature
in interfaceIFeatureProvider
- Overrides:
getDirectEditingFeature
in classAbstractFeatureProvider
- Parameters:
context
- AnIDirectEditingContext
describing the needed functionality- Returns:
- An
IDirectEditingFeature
in case a suitable functionality has been found,null
otherwise. - See Also:
-
getDirectEditingFeatureAdditional
Gets the additional direct editing feature functionality. The default implementation simply delegates toAbstractFeatureProvider.getDirectEditingFeature(IDirectEditingContext)
.- Parameters:
context
- AnIDirectEditingContext
describing the needed functionality- Returns:
- An
IDirectEditingFeature
in case a suitable functionality has been found by the super class,null
otherwise.
-
traceWarning
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
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:
getBusinessObjectForPictogramElement
in interfaceIMappingProvider
- Overrides:
getBusinessObjectForPictogramElement
in classAbstractFeatureProvider
- Parameters:
pictogramElement
- ThePictogramElement
to find the domain object for.- Returns:
- A domain object in case it was found,
null
otherwise. - See Also:
-