|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.graphiti.features.impl.AbstractFeature
public abstract class AbstractFeature
Abstract base class for all features. Prefer extending this class over
inheriting interface IFeature
.
Field Summary | |
---|---|
private IFeatureProvider |
fp
|
private IProgress |
progressCallback
|
Constructor Summary | |
---|---|
AbstractFeature(IFeatureProvider fp)
Creates a new AbstractFeature . |
Method Summary | |
---|---|
protected PictogramElement |
addGraphicalRepresentation(IAreaContext context,
Object newObject)
Adds the graphical representation. |
boolean |
canUndo(IContext context)
Decides if the current feature can be undone - this is the undo of the execute operation. |
protected Object[] |
getAllBusinessObjectsForPictogramElement(PictogramElement pe)
Gets the all business objects for pictogram element. |
protected Object |
getBusinessObjectForPictogramElement(PictogramElement pe)
Gets the business object for pictogram element. |
String |
getDescription()
Gets the description. |
protected Diagram |
getDiagram()
Gets the diagram. |
protected IDiagramBehavior |
getDiagramBehavior()
Gets the diagram behavior. |
protected IDiagramEditor |
getDiagramEditor()
Deprecated. Use getDiagramBehavior() instead |
IFeatureProvider |
getFeatureProvider()
Gets the feature provider. |
String |
getName()
Gets the name. |
protected IProgress |
getProgressCallback()
Gets the progress callback. |
protected boolean |
getUserDecision()
Gets the user decision. |
boolean |
hasDoneChanges()
Is 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. |
boolean |
isAvailable(IContext context)
Decides if the current feature is available with the given context. |
protected IReason |
layoutPictogramElement(PictogramElement pe)
Layouts the given PictogramElement . |
protected void |
link(PictogramElement pe,
Object businessObject)
Links the given PictogramElement to the given business or domain
object. |
protected void |
link(PictogramElement pe,
Object[] businessObjects)
Links the given PictogramElement to the given business or domain
objects. |
protected Color |
manageColor(IColorConstant colorConstant)
Manage color. |
protected Color |
manageColor(int red,
int green,
int blue)
Manage color. |
protected Font |
manageDefaultFont(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. |
(package private) Font |
manageDefaultFont(Diagram diagram,
boolean isItalic,
boolean isBold)
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. |
Font |
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. |
Font |
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. |
void |
setProgressCallback(IProgress progress)
Sets the progress callback. |
String |
toString()
|
protected void |
updatePictogramElement(PictogramElement pe)
Updates the given pictogram element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.graphiti.features.IFeature |
---|
canExecute, execute |
Field Detail |
---|
private IFeatureProvider fp
private IProgress progressCallback
Constructor Detail |
---|
public AbstractFeature(IFeatureProvider fp)
AbstractFeature
.
fp
- the fpMethod Detail |
---|
public boolean canUndo(IContext context)
IFeature
canUndo
in interface IFeature
context
- this is the general input for this method
IContext
public boolean hasDoneChanges()
IFeature
AbstractFeature
), 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 false
although the
feature did changes.
hasDoneChanges
in interface IFeature
true
if the feature should appear in the undo stack,
false
otherwisepublic String getDescription()
IDescription
getDescription
in interface IDescription
public IFeatureProvider getFeatureProvider()
IFeatureProviderHolder
getFeatureProvider
in interface IFeatureProviderHolder
public String getName()
IName
getName
in interface IName
public boolean isAvailable(IContext context)
IFeature
isAvailable
in interface IFeature
context
- this is the general input for this method
IContext
public void setProgressCallback(IProgress progress)
progress
- the new progress callbackpublic String toString()
toString
in class Object
protected PictogramElement addGraphicalRepresentation(IAreaContext context, Object newObject)
context
- the contextnewObject
- the new object
protected Object[] getAllBusinessObjectsForPictogramElement(PictogramElement pe)
pe
- the pe
protected Object getBusinessObjectForPictogramElement(PictogramElement pe)
pe
- the pe
protected Diagram getDiagram()
protected IDiagramEditor getDiagramEditor()
getDiagramBehavior()
instead
protected IDiagramBehavior getDiagramBehavior()
protected IProgress getProgressCallback()
protected boolean getUserDecision()
protected IReason layoutPictogramElement(PictogramElement pe)
PictogramElement
. This implementation asks the
feature provider for available layout features and processes the first
one.
pe
- the PictogramElement
to layout
IReason
object that indicates if a layout operation has
been performed (IReason.toBoolean()
is true
)IReason
object, before it
simply returned nullprotected void link(PictogramElement pe, Object businessObject)
PictogramElement
to the given business or domain
object. After doing that, the domain object can be retrieved from the
PictogramElement
using the methods
getBusinessObjectForPictogramElement(PictogramElement)
and
getAllBusinessObjectsForPictogramElement(PictogramElement)
; also
ILinkService#getPictogramElements(Diagram, org.eclipse.emf.ecore.EObject)
and
ILinkService.getPictogramElements(Diagram, java.util.List, boolean)
will return the PictogramElement
for the domain object.EcoreUtil#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 overriding
IToolBehaviorProvider.equalsBusinessObjects(Object, Object)
.
pe
- the PictogramElement
to link to the domain objectbusinessObject
- the business object to link to the PictogramElement
protected void link(PictogramElement pe, Object[] businessObjects)
PictogramElement
to the given business or domain
objects. After doing that, the domain object can be retrieved from the
PictogramElement
using the methods
getBusinessObjectForPictogramElement(PictogramElement)
and
getAllBusinessObjectsForPictogramElement(PictogramElement)
; also
ILinkService#getPictogramElements(Diagram, org.eclipse.emf.ecore.EObject)
and
ILinkService.getPictogramElements(Diagram, java.util.List, boolean)
will return the PictogramElement
for the domain object.EcoreUtil#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 overriding
IToolBehaviorProvider.equalsBusinessObjects(Object, Object)
.
pe
- the PictogramElement
to link to the domain objectbusinessObjects
- the business objects to link to the PictogramElement
protected Color manageColor(IColorConstant colorConstant)
colorConstant
- the color constant
protected Color manageColor(int red, int green, int blue)
red
- the redgreen
- the greenblue
- the blue
protected Font manageDefaultFont(Diagram diagram)
diagram
- the diagram that aggregates the fonts
Font manageDefaultFont(Diagram diagram, boolean isItalic, boolean isBold)
diagram
- the diagram that aggregates the fontsisItalic
- the is italicisBold
- the is bold
public Font manageFont(Diagram diagram, String name, int size)
diagram
- the diagram that aggregates the fontsname
- the name of the fontsize
- the size of the font
public Font manageFont(Diagram diagram, String name, int size, boolean isItalic, boolean isBold)
diagram
- the diagram that aggregates the fontsname
- the name of the fontsize
- the size of the fontisItalic
- the is italicisBold
- the is bold
protected void updatePictogramElement(PictogramElement pe)
pe
- the pe
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |