Class AbstractFeature
java.lang.Object
org.eclipse.graphiti.features.impl.AbstractFeature
- All Implemented Interfaces:
IFeature,IFeatureProviderHolder,IDescription,IName
- Direct Known Subclasses:
AbstractAddFeature,AbstractCopyFeature,AbstractCreateConnectionFeature,AbstractCreateFeature,AbstractCustomFeature,AbstractDirectEditingFeature,AbstractLayoutFeature,AbstractMoveShapeFeature,AbstractPasteFeature,AbstractPrintFeature,AbstractSaveImageFeature,AbstractUpdateFeature,DefaultAddBendpointFeature,DefaultDeleteFeature,DefaultMoveAnchorFeature,DefaultMoveBendpointFeature,DefaultMoveConnectionDecoratorFeature,DefaultReconnectionFeature,DefaultRemoveBendpointFeature,DefaultRemoveFeature,DefaultResizeShapeFeature,ReconnectionFeatureForPattern
Abstract base class for all features. Prefer extending this class over
inheriting interface
IFeature.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PictogramElementaddGraphicalRepresentation(IAreaContext context, Object newObject) Adds the graphical representation.booleanDecides if the current feature can be undone - this is the undo of the execute operation.protected Object[]Gets the all business objects for pictogram element.protected ObjectGets the business object for pictogram element.Gets the description.protected DiagramGets the diagram.protected IDiagramBehaviorGets the diagram behavior.Gets the feature provider.getName()Gets the name.protected IProgressGets the progress callback.protected booleanGets the user decision.booleanIs queried by the framework after a feature has been executed to find out if this feature should appear in the undo stack of e.g.booleanisAvailable(IContext context) Decides if the current feature is available with the given context.protected IReasonLayouts the givenPictogramElement.protected voidlink(PictogramElement pe, Object businessObject) Links the givenPictogramElementto the given business or domain object.protected voidlink(PictogramElement pe, Object[] businessObjects) Links the givenPictogramElementto the given business or domain objects.protected ColormanageColor(int red, int green, int blue) Manage color.protected ColormanageColor(IColorConstant colorConstant) Manage color.protected FontmanageDefaultFont(Diagram diagram) Provides the font instance for the default font (Arial in size 8) by either creating a new one and aggregating it to the diagram or finding it in the diagrams list of fonts.manageFont(Diagram diagram, String name, int size) Provides a font instance by either creating a new one and aggregating it to the diagram or finding it in the diagrams list of fonts.manageFont(Diagram diagram, String name, int size, boolean isItalic, boolean isBold) Provides a font instance by either creating a new one and aggregating it to the diagram or finding it in the diagrams list of fonts.voidsetProgressCallback(IProgress progress) Sets the progress callback.toString()protected voidUpdates the given pictogram element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.graphiti.features.IFeature
canExecute, execute
-
Constructor Details
-
AbstractFeature
Creates a newAbstractFeature.- Parameters:
fp- the fp
-
-
Method Details
-
canUndo
Description copied from interface:IFeatureDecides if the current feature can be undone - this is the undo of the execute operation. -
hasDoneChanges
public boolean hasDoneChanges()Description copied from interface:IFeatureIs queried by the framework after a feature has been executed to find out if this feature should appear in the undo stack of e.g. an editor. By default all features should appear there (see implementation inAbstractFeature), but features may decide to override this behavior. Note that this is a dynamic attribute of the feature that is queried each time after the feature has been executed.IMPORTANT NOTE: The implementor of the feature is responsible for correctly implementing this method! It might lead to inconsistencies in the command stack if this method returns
falsealthough the feature did changes.- Specified by:
hasDoneChangesin interfaceIFeature- Returns:
trueif the feature should appear in the undo stack,falseotherwise
-
getDescription
Description copied from interface:IDescriptionGets the description.- Specified by:
getDescriptionin interfaceIDescription- Returns:
- the description
-
getFeatureProvider
Description copied from interface:IFeatureProviderHolderGets the feature provider.- Specified by:
getFeatureProviderin interfaceIFeatureProviderHolder- Returns:
- the feature provider
-
getName
Description copied from interface:INameGets the name. -
isAvailable
Description copied from interface:IFeatureDecides if the current feature is available with the given context.- Specified by:
isAvailablein interfaceIFeature- Parameters:
context- this is the general input for this method- Returns:
- true if it is available, false if not
- See Also:
-
setProgressCallback
Sets the progress callback.- Parameters:
progress- the new progress callback
-
toString
-
addGraphicalRepresentation
Adds the graphical representation.- Parameters:
context- the contextnewObject- the new object- Returns:
- the added pictogram element
-
getAllBusinessObjectsForPictogramElement
Gets the all business objects for pictogram element.- Parameters:
pe- the pe- Returns:
- the all business objects for pictogram element
-
getBusinessObjectForPictogramElement
Gets the business object for pictogram element.- Parameters:
pe- the pe- Returns:
- the business object for pictogram element
-
getDiagram
Gets the diagram.- Returns:
- the diagram
-
getDiagramBehavior
Gets the diagram behavior.- Returns:
- the diagram behavior
- Since:
- 0.10
-
getProgressCallback
Gets the progress callback.- Returns:
- the progress callback
-
getUserDecision
protected boolean getUserDecision()Gets the user decision.- Returns:
- the user decision
-
layoutPictogramElement
Layouts the givenPictogramElement. This implementation asks the feature provider for available layout features and processes the first one.- Parameters:
pe- thePictogramElementto layout- Returns:
- a
IReasonobject that indicates if a layout operation has been performed (IReason.toBoolean()istrue) - Since:
- 0.9 this method returns now the
IReasonobject, before it simply returned null
-
link
Links the givenPictogramElementto the given business or domain object. After doing that, the domain object can be retrieved from thePictogramElementusing the methodsgetBusinessObjectForPictogramElement(PictogramElement)andgetAllBusinessObjectsForPictogramElement(PictogramElement); alsoILinkService.getPictogramElements(Diagram, org.eclipse.emf.ecore.EObject)andILinkService.getPictogramElements(Diagram, java.util.List, boolean)will return thePictogramElementfor the domain object.
Note: Identity of domain or business objects is determined by default using the methodEcoreUtil.equals(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject), which relies on the compared EMF objects having different IDs or attributes. The way Graphiti used to compare EMF business objects can be changed by overridingIToolBehaviorProvider.equalsBusinessObjects(Object, Object).- Parameters:
pe- thePictogramElementto link to the domain objectbusinessObject- the business object to link to thePictogramElement
-
link
Links the givenPictogramElementto the given business or domain objects. After doing that, the domain object can be retrieved from thePictogramElementusing the methodsgetBusinessObjectForPictogramElement(PictogramElement)andgetAllBusinessObjectsForPictogramElement(PictogramElement); alsoILinkService.getPictogramElements(Diagram, org.eclipse.emf.ecore.EObject)andILinkService.getPictogramElements(Diagram, java.util.List, boolean)will return thePictogramElementfor the domain object.
Note: Identity of domain or business objects is determined by default using the methodEcoreUtil.equals(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject), which relies on the compared EMF objects having different IDs or attributes. The way Graphiti used to compare EMF business objects can be changed by overridingIToolBehaviorProvider.equalsBusinessObjects(Object, Object).- Parameters:
pe- thePictogramElementto link to the domain objectbusinessObjects- the business objects to link to thePictogramElement
-
manageColor
Manage color.- Parameters:
colorConstant- the color constant- Returns:
- the color
-
manageColor
Manage color.- Parameters:
red- the redgreen- the greenblue- the blue- Returns:
- the color
-
manageDefaultFont
Provides the font instance for the default font (Arial in size 8) by either creating a new one and aggregating it to the diagram or finding it in the diagrams list of fonts.- Parameters:
diagram- the diagram that aggregates the fonts- Returns:
- the font instance
- Since:
- 0.10
-
manageFont
Provides a font instance by either creating a new one and aggregating it to the diagram or finding it in the diagrams list of fonts.- Parameters:
diagram- the diagram that aggregates the fontsname- the name of the fontsize- the size of the font- Returns:
- the font instance
- Since:
- 0.10
-
manageFont
Provides a font instance by either creating a new one and aggregating it to the diagram or finding it in the diagrams list of fonts.- Parameters:
diagram- the diagram that aggregates the fontsname- the name of the fontsize- the size of the fontisItalic- the is italicisBold- the is bold- Returns:
- the font instance
- Since:
- 0.10
-
updatePictogramElement
Updates the given pictogram element. This implementation asks the feature provider for available update features and processes the first one.- Parameters:
pe- the pe
-