Package org.eclipse.graphiti.features.impl

## Class DefaultReconnectionFeature

- java.lang.Object
- - org.eclipse.graphiti.features.impl.AbstractFeature
  - - org.eclipse.graphiti.features.impl.DefaultReconnectionFeature

All Implemented Interfaces:
  `IFeature`, `IFeatureProviderHolder`, `IReconnectionFeature`, `IReconnection`, `IDescription`, `IName`

    public class DefaultReconnectionFeature
    extends AbstractFeature
    implements IReconnectionFeature

The default implementation for the `IReconnectionFeature` interface. Is used by default by the framework for any reconnection requests triggered in the diagram. May be subclassed and adapted by clients.

### Constructor Summary

Constructors
`DefaultReconnectionFeature​(IFeatureProvider fp)` Creates a new `DefaultReconnectionFeature`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `canceledReconnect​(IReconnectionContext context)` Called by the framework in case a started reconnection operation has been cancelled, e.g.
`boolean` `canExecute​(IContext context)` Called by the framework to check if this feature can perform the currently triggered reconnection request.
`boolean` `canReconnect​(IReconnectionContext context)` Called by the framework to check if this feature can perform the currently triggered reconnection request.
`boolean` `canStartReconnect​(IReconnectionContext context)` Called by the framework after the connection has been selected.
`void` `execute​(IContext context)` Called by the framework to execute this feature to perform the currently triggered reconnection request.
`java.lang.String` `getName()` Returns the display name of the feature to use e.g.
`protected Anchor` `getNewAnchor​(IReconnectionContext context)` Can be overridden by the user to influence the target anchor to use for the reconnect.
`void` `postReconnect​(IReconnectionContext context)` Hook that is called by the `reconnect(IReconnectionContext)` method after the actual reconnect is done.
`void` `preReconnect​(IReconnectionContext context)` Hook that is called by the `reconnect(IReconnectionContext)` method before the actual reconnect is done.
`void` `reconnect​(IReconnectionContext context)` Called by the framework to perform the currently triggered reconnection request.

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

`addGraphicalRepresentation, canUndo, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDescription, getDiagram, getDiagramBehavior, getFeatureProvider, getProgressCallback, getUserDecision, hasDoneChanges, isAvailable, layoutPictogramElement, link, link, manageColor, manageColor, manageDefaultFont, manageFont, manageFont, setProgressCallback, toString, updatePictogramElement`

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

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

### Methods inherited from interface org.eclipse.graphiti.IDescription

`getDescription`

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

`canUndo, hasDoneChanges, isAvailable`

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

`getFeatureProvider`

### Constructor Detail

#### DefaultReconnectionFeature

    public DefaultReconnectionFeature​(IFeatureProvider fp)

Creates a new `DefaultReconnectionFeature`.

Parameters:
  `fp` - the feature provider to use

### Method Detail

#### canReconnect

    public boolean canReconnect​(IReconnectionContext context)

Called by the framework to check if this feature can perform the currently triggered reconnection request. The default implementation checks if

- A connection and a new target anchor are passed in the given `IReconnectionContext`
- The connection passed in the context has a start and end anchor
- The new anchor is not located directly in the diagram

Can be overridden by clients to add additional checks.

Specified by:
  `canReconnect` in interface `IReconnection`
Parameters:
  `context` - the context object holding all the reconnection information
Returns:
  `true` if the feature is able to deal with the reconnection request, `false` otherwise or if the tool needs to prohibit the reconnection for the given situation.

#### getNewAnchor

    protected Anchor getNewAnchor​(IReconnectionContext context)

Can be overridden by the user to influence the target anchor to use for the reconnect.

Parameters:
  `context` - the context holding the reconnection information
Returns:
  the new anchor to use as target for the reconnect

#### reconnect

    public final void reconnect​(IReconnectionContext context)

Called by the framework to perform the currently triggered reconnection request. The default implementation calls the `preReconnect(IReconnectionContext)` and `postReconnect(IReconnectionContext)` hooks. The reconnect is done by either replacing the start anchor (in case it matches the old anchor passed in the context) or the end anchor with the new anchor.

Specified by:
  `reconnect` in interface `IReconnection`
Parameters:
  `context` - the context object holding all the reconnection information

#### preReconnect

    public void preReconnect​(IReconnectionContext context)

Hook that is called by the `reconnect(IReconnectionContext)` method before the actual reconnect is done. Can be overridden by clients to add additional functionality.

Specified by:
  `preReconnect` in interface `IReconnection`
Parameters:
  `context` - the context object holding all the reconnection information

#### postReconnect

    public void postReconnect​(IReconnectionContext context)

Hook that is called by the `reconnect(IReconnectionContext)` method after the actual reconnect is done. Can be overridden by clients to add additional functionality.

Specified by:
  `postReconnect` in interface `IReconnection`
Parameters:
  `context` - the context object holding all the reconnection information

#### canExecute

    public boolean canExecute​(IContext context)

Called by the framework to check if this feature can perform the currently triggered reconnection request. Delegates to the `canReconnect(IReconnectionContext)` method in case the passed context is a `IReconnectionContext`.

Specified by:
  `canExecute` in interface `IFeature`
Parameters:
  `context` - the context object holding all the reconnection information
Returns:
  `true` if the feature is able to deal with the reconnection request, `false` otherwise or if the tool needs to prohibit the reconnection for the given situation.
See Also:
  `IContext`

#### execute

    public void execute​(IContext context)

Called by the framework to execute this feature to perform the currently triggered reconnection request. Delegates to the `reconnect(IReconnectionContext)` method in case the passed context is a `IReconnectionContext`.

Specified by:
  `execute` in interface `IFeature`
Parameters:
  `context` - the context object holding all the reconnection information
See Also:
  `IContext`

#### getName

    public java.lang.String getName()

Returns the display name of the feature to use e.g. within a context menu.

Specified by:
  `getName` in interface `IName`
Overrides:
  `getName` in class `AbstractFeature`
Returns:
  the display name of the feature

#### canceledReconnect

    public void canceledReconnect​(IReconnectionContext context)

Called by the framework in case a started reconnection operation has been cancelled, e.g. by pressing ESC, selecting another tool from the palette etc.

Specified by:
  `canceledReconnect` in interface `IReconnection`
Parameters:
  `context` - the context object holding all the reconnection information
Since:
  0.9

#### canStartReconnect

    public boolean canStartReconnect​(IReconnectionContext context)

Called by the framework after the connection has been selected. Determines whether connection endpoint can be dragged to start reconnection.

Specified by:
  `canStartReconnect` in interface `IReconnection`
Parameters:
  `context` - the context object holding information about the connection and old anchor
Returns:
  `true`
Since:
  0.11