org.eclipse.graphiti.features.impl

## 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

    public abstract class AbstractFeature
    extends java.lang.Object
    implements IFeature

Abstract base class for all features. Prefer extending this class over inheriting interface `IFeature`.

### Constructor Summary

Constructors
Constructor and Description
`AbstractFeature(IFeatureProvider fp)` Creates a new `AbstractFeature`.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `canUndo(IContext context)` Decides if the current feature can be undone - this is the undo of the execute operation.
`java.lang.String` `getDescription()` Gets the description.
`IFeatureProvider` `getFeatureProvider()` Gets the feature provider.
`java.lang.String` `getName()` Gets the name.
`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.
`Font` `manageFont(Diagram diagram, java.lang.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, java.lang.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.
`java.lang.String` `toString()`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.graphiti.features.IFeature

`canExecute, execute`

### 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 of e.g. an editor. By default all features should appear there (see implementation in `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.

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

#### getDescription

    public java.lang.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 java.lang.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 java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### manageFont

    public Font manageFont(Diagram diagram,
                           java.lang.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.

Parameters:
  `diagram` - the diagram that aggregates the fonts
  `name` - the name of the font
  `size` - the size of the font
Returns:
  the font instance
Since:
  0.10

#### manageFont

    public Font manageFont(Diagram diagram,
                           java.lang.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.

Parameters:
  `diagram` - the diagram that aggregates the fonts
  `name` - the name of the font
  `size` - the size of the font
  `isItalic` - the is italic
  `isBold` - the is bold
Returns:
  the font instance
Since:
  0.10