org.eclipse.graphiti.ui.features

## Class DefaultDeleteFeature

- java.lang.Object
- - org.eclipse.graphiti.features.impl.AbstractFeature
  - - org.eclipse.graphiti.ui.features.DefaultDeleteFeature

All Implemented Interfaces:
  IDeleteFeature, IFeature, IFeatureProviderHolder, IDelete, IDescription, IName

Direct Known Subclasses:
  DeleteFeatureForPattern

    public class DefaultDeleteFeature
    extends AbstractFeature
    implements IDeleteFeature

The Graphiti default implementation of the `IDeleteFeature`. It cares about removing the shape(s) representing the deleted domain object(s) from the diagram (by delegating to the `IRemoveFeature` provided by the `IFeatureProvider`. After that the EMF domain objects will be deleted using standard EMF functionality.
Before the deletion process starts the tool user will be asked if he really wants to delete; the popup appears only once for multi object deletions.

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `canDelete(IDeleteContext context)` Can delete hook.
`boolean` `canExecute(IContext context)` Decides if the current feature can execute with the given context.
`void` `delete(IDeleteContext context)` Hook to implement the actual delete functionality.
`void` `execute(IContext context)` Executes the current feature with the given context.
`java.lang.String` `getDescription()` Gets the description.
`java.lang.String` `getName()` Hook to return the name of the delete operation e.g for display in the context menu.
`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` `isDeleteAbort()` The Graphiti framework will call this method after `IDelete.preDelete(IDeleteContext)` has been called and before the actual delete is done.
`void` `postDelete(IDeleteContext context)` Post delete hook that can be implemented by users to perform any operations that need to be done after the standard delete functionality ends.
`void` `preDelete(IDeleteContext context)` Pre delete hook that can be implemented by users to perform any operations that need to be done before the standard delete functionality starts.

### Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature

`canUndo, getFeatureProvider, isAvailable, manageFont, manageFont, setProgressCallback, 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

`canUndo, isAvailable`

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

`getFeatureProvider`

### Constructor Detail

#### DefaultDeleteFeature

    public DefaultDeleteFeature(IFeatureProvider fp)

Creates a new `DefaultDeleteFeature`.

Parameters:
  `fp` - the feature provider

### Method Detail

#### canDelete

    public boolean canDelete(IDeleteContext context)

Description copied from interface: `IDelete`
Can delete hook. Needs to be implemented in order to decide if a feature can (and wants to) handle a delete request.

Specified by:
  `canDelete` in interface `IDelete`
Parameters:
  `context` - the context describing the request
Returns:
  `true`, if the feature can perform the delete operation

#### delete

    public void delete(IDeleteContext context)

Description copied from interface: `IDelete`
Hook to implement the actual delete functionality.

Specified by:
  `delete` in interface `IDelete`
Parameters:
  `context` - the context

#### preDelete

    public void preDelete(IDeleteContext context)

Description copied from interface: `IDelete`
Pre delete hook that can be implemented by users to perform any operations that need to be done before the standard delete functionality starts. Be sure to call `DefaultDeleteFeature#setDoneChanges(boolean)` in case you modify any EMF objects to enable that the command stack gets updated.

Specified by:
  `preDelete` in interface `IDelete`
Parameters:
  `context` - the context

#### isDeleteAbort

    public boolean isDeleteAbort()

Description copied from interface: `IDelete`
The Graphiti framework will call this method after `IDelete.preDelete(IDeleteContext)` has been called and before the actual delete is done. In case this method returns `true`, the operation will be cancelled by the Graphiti framework by throwing an `OperationCanceledException` that causes am EMF revert of the operation.

Implementing classes might e.g. set a flag in `IDelete.preDelete(IDeleteContext)` as cancellation indication and check that that flag here.

Specified by:
  `isDeleteAbort` in interface `IDelete`
Returns:
  `true` in case you want to cancel the current operation, `false` otherwise.
Since:
  0.12

#### postDelete

    public void postDelete(IDeleteContext context)

Description copied from interface: `IDelete`
Post delete hook that can be implemented by users to perform any operations that need to be done after the standard delete functionality ends.

Specified by:
  `postDelete` in interface `IDelete`
Parameters:
  `context` - the context

#### canExecute

    public boolean canExecute(IContext context)

Description copied from interface: `IFeature`
Decides if the current feature can execute with the given context.

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

#### execute

    public void execute(IContext context)

Description copied from interface: `IFeature`
Executes the current feature with the given context.

Specified by:
  `execute` in interface `IFeature`
Parameters:
  `context` - this is the general input for this method
See Also:
  `IContext`

#### getName

    public java.lang.String getName()

Hook to return the name of the delete operation e.g for display in the context menu. The standard implementation simply returns "Delete".

Specified by:
  `getName` in interface `IName`
Overrides:
  `getName` in class `AbstractFeature`
Returns:
  The diplay name of the operation

#### getDescription

    public java.lang.String getDescription()

Description copied from interface: `IDescription`
Gets the description.

Specified by:
  `getDescription` in interface `IDescription`
Overrides:
  `getDescription` in class `AbstractFeature`
Returns:
  the description

#### 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`
Overrides:
  `hasDoneChanges` in class `AbstractFeature`
Returns:
  `true` if the feature should appear in the undo stack, `false` otherwise