org.eclipse.graphiti.features.impl
Class AbstractFeature

java.lang.Object
  extended by 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, AbstractUpdateFeature, DefaultAddBendpointFeature, DefaultDeleteFeature, DefaultMoveAnchorFeature, DefaultMoveBendpointFeature, DefaultMoveConnectionDecoratorFeature, DefaultPrintFeature, DefaultReconnectionFeature, DefaultRemoveBendpointFeature, DefaultRemoveFeature, DefaultResizeShapeFeature, DefaultSaveImageFeature, ReconnectionFeatureForPattern

public abstract class AbstractFeature
extends Object
implements IFeature

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  IDiagramEditor getDiagramEditor()
          Gets the diagram editor.
 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.
 boolean isAvailable(IContext context)
          Decides if the current feature is available with the given context.
protected  void layoutPictogramElement(PictogramElement pe)
          Layoutes the given pictogram element.
protected  void link(PictogramElement pe, Object businessObject)
          Link.
protected  void link(PictogramElement pe, Object[] businessObjects)
          Link.
protected  Color manageColor(IColorConstant colorConstant)
          Manage color.
protected  Color manageColor(int red, int green, int blue)
          Manage color.
 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

fp

private IFeatureProvider fp

progressCallback

private IProgress progressCallback
Constructor Detail

AbstractFeature

public AbstractFeature(IFeatureProvider fp)
Creates a new AbstractFeature.

Parameters:
fp - the fp
Method Detail

canUndo

public boolean canUndo(IContext context)
Description copied from interface: IFeature
Decides if the current feature can be undone - this is the undo of the execute operation.

Specified by:
canUndo in interface IFeature
Parameters:
context - this is the general input for this method
Returns:
true if the feature can be undone, false if not
See Also:
IContext

hasDoneChanges

public boolean hasDoneChanges()
Description copied from interface: IFeature
Is queried by the framework after a feature has been executed to find out if this feature should appear in the undo stack. By default all features should appear there (see implementation in AbstractFeature), but single 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 will lead to inconsistencies if this method returns false although the feature did changes.

Specified by:
hasDoneChanges in interface IFeature
Returns:
true if the feature should appear in the undo stack, false otherwise

getDescription

public String getDescription()
Description copied from interface: IDescription
Gets the description.

Specified by:
getDescription in interface IDescription
Returns:
the description

getFeatureProvider

public IFeatureProvider getFeatureProvider()
Description copied from interface: IFeatureProviderHolder
Gets the feature provider.

Specified by:
getFeatureProvider in interface IFeatureProviderHolder
Returns:
the feature provider

getName

public String getName()
Description copied from interface: IName
Gets the name.

Specified by:
getName in interface IName
Returns:
the name

isAvailable

public boolean isAvailable(IContext context)
Description copied from interface: IFeature
Decides if the current feature is available with the given context.

Specified by:
isAvailable in interface IFeature
Parameters:
context - this is the general input for this method
Returns:
true if it is available, false if not
See Also:
IContext

setProgressCallback

public void setProgressCallback(IProgress progress)
Sets the progress callback.

Parameters:
progress - the new progress callback

toString

public String toString()
Overrides:
toString in class Object

addGraphicalRepresentation

protected PictogramElement addGraphicalRepresentation(IAreaContext context,
                                                      Object newObject)
Adds the graphical representation.

Parameters:
context - the context
newObject - the new object
Returns:
the added pictogram element

getAllBusinessObjectsForPictogramElement

protected Object[] getAllBusinessObjectsForPictogramElement(PictogramElement pe)
Gets the all business objects for pictogram element.

Parameters:
pe - the pe
Returns:
the all business objects for pictogram element

getBusinessObjectForPictogramElement

protected Object getBusinessObjectForPictogramElement(PictogramElement pe)
Gets the business object for pictogram element.

Parameters:
pe - the pe
Returns:
the business object for pictogram element

getDiagram

protected Diagram getDiagram()
Gets the diagram.

Returns:
the diagram

getDiagramEditor

protected IDiagramEditor getDiagramEditor()
Gets the diagram editor.

Returns:
the diagram editor

getProgressCallback

protected IProgress getProgressCallback()
Gets the progress callback.

Returns:
the progress callback

getUserDecision

protected boolean getUserDecision()
Gets the user decision.

Returns:
the user decision

layoutPictogramElement

protected void layoutPictogramElement(PictogramElement pe)
Layoutes the given pictogram element. This implementation asks the feature provider for available layout features and processes the first one.

Parameters:
pe - the pe

link

protected void link(PictogramElement pe,
                    Object businessObject)
Link.

Parameters:
pe - the pe
businessObject - the business object

link

protected void link(PictogramElement pe,
                    Object[] businessObjects)
Link.

Parameters:
pe - the pe
businessObjects - the business objects

manageColor

protected Color manageColor(IColorConstant colorConstant)
Manage color.

Parameters:
colorConstant - the color constant
Returns:
the color

manageColor

protected Color manageColor(int red,
                            int green,
                            int blue)
Manage color.

Parameters:
red - the red
green - the green
blue - the blue
Returns:
the color

updatePictogramElement

protected void updatePictogramElement(PictogramElement pe)
Updates the given pictogram element. This implementation asks the feature provider for available update features and processes the first one.

Parameters:
pe - the pe


Copyright (c) SAP AG 2005, 2010.