Package org.eclipse.gef.editparts

# Class AbstractConnectionEditPart

java.lang.Object
org.eclipse.gef.editparts.AbstractEditPart
org.eclipse.gef.editparts.AbstractGraphicalEditPart
org.eclipse.gef.editparts.AbstractConnectionEditPart

All Implemented Interfaces:
  `IAdaptable`, `ConnectionEditPart`, `EditPart`, `GraphicalEditPart`, `LayerConstants`, `RequestConstants`

public abstract class AbstractConnectionEditPart extends AbstractGraphicalEditPart implements ConnectionEditPart, LayerConstants
The base implementation for `ConnectionEditPart`.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected final class`
`AbstractConnectionEditPart.DefaultAccessibleAnchorProvider`
Provides accessibility support for when connections are also themselves nodes.

## Nested classes/interfaces inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart

`AbstractGraphicalEditPart.AccessibleGraphicalEditPart`

## Nested classes/interfaces inherited from class org.eclipse.gef.editparts.AbstractEditPart

`AbstractEditPart.EditPolicyIterator`

## Field Summary

### Fields inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart

`figure, sourceConnections, targetConnections`

### Fields inherited from class org.eclipse.gef.editparts.AbstractEditPart

`children, FLAG_ACTIVE, FLAG_FOCUS, MAX_FLAG`

### Fields inherited from interface org.eclipse.gef.EditPart

`SELECTED, SELECTED_NONE, SELECTED_PRIMARY`

### Fields inherited from interface org.eclipse.gef.LayerConstants

`CONNECTION_LAYER, FEEDBACK_LAYER, GRID_LAYER, GUIDE_LAYER, HANDLE_LAYER, PRIMARY_LAYER, PRINTABLE_LAYERS, SCALABLE_LAYERS, SCALED_FEEDBACK_LAYER`

### Fields inherited from interface org.eclipse.gef.RequestConstants

`REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER`

## Constructor Summary

Constructors
Constructor
Description
`AbstractConnectionEditPart()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activateFigure()`
Activates the Figure representing this, by setting up the start and end connections, and adding the figure to the Connection Layer.
`void`
`addNotify()`
Called after the EditPart has been added to its parent.
`protected org.eclipse.draw2d.IFigure`
`createFigure()`
Returns a newly created Figure to represent these type of EditParts.
`protected void`
`deactivateFigure()`
Deactivates the Figure representing this, by removing it from the connection layer, and resetting the source and target connections to `null`.
`<T> T`
`getAdapter(Class<T> adapter)`
`AbstractConnectionEditPart` extends getAdapter() to overrides the `AccessibleAnchorProvider` adapter returned by the superclass.
`org.eclipse.draw2d.Connection`
`getConnectionFigure()`
Convenience method for casting this GraphicalEditPart's Figure to a `Connection`
`DragTracker`
`getDragTracker(Request req)`
Overridden to return a default `DragTracker` for GraphicalEditParts.
`EditPart`
`getSource()`
`protected org.eclipse.draw2d.ConnectionAnchor`
`getSourceConnectionAnchor()`
Returns the `ConnectionAnchor` for the source end of the connection.
`EditPart`
`getTarget()`
`protected org.eclipse.draw2d.ConnectionAnchor`
`getTargetConnectionAnchor()`
Returns the `ConnectionAnchor` for the target end of the connection.
`void`
`refresh()`
Extended here to also refresh the ConnectionAnchors.
`protected void`
`refreshSourceAnchor()`
Updates the source ConnectionAnchor.
`protected void`
`refreshTargetAnchor()`
Updates the target ConnectionAnchor.
`void`
`removeNotify()`
Extended here to remove the ConnectionEditPart's connection figure from the connection layer.
`void`
`setParent(EditPart parent)`
Extended to implement automatic addNotify and removeNotify handling.
`void`
`setSource(EditPart editPart)`
Sets the source EditPart of this connection.
`void`
`setTarget(EditPart editPart)`
Sets the target EditPart of this connection.

### Methods inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart

`activate, addChildVisual, addNodeListener, addSourceConnection, addTargetConnection, createConnection, createOrFindConnection, deactivate, fireRemovingSourceConnection, fireRemovingTargetConnection, fireSourceConnectionAdded, fireTargetConnectionAdded, getContentPane, getFigure, getLayer, getModelSourceConnections, getModelTargetConnections, getSourceConnections, getTargetConnections, isSelectable, primAddSourceConnection, primAddTargetConnection, primRemoveSourceConnection, primRemoveTargetConnection, refreshSourceConnections, refreshTargetConnections, registerVisuals, removeChildVisual, removeNodeListener, removeSourceConnection, removeTargetConnection, reorderChild, reorderSourceConnection, reorderTargetConnection, setFigure, setLayoutConstraint, unregisterVisuals`

### Methods inherited from class org.eclipse.gef.editparts.AbstractEditPart

`activateEditPolicies, addChild, addEditPartListener, createChild, createEditPolicies, deactivateEditPolicies, debug, debugFeedback, eraseSourceFeedback, eraseTargetFeedback, fireActivated, fireChildAdded, fireDeactivated, fireRemovingChild, fireSelectionChanged, getAccessibleEditPart, getChildren, getCommand, getEditPolicy, getEditPolicyIterator, getEventListeners, getEventListenersIterable, getFlag, getModel, getModelChildren, getParent, getRoot, getSelected, getTargetEditPart, getViewer, hasFocus, installEditPolicy, isActive, performRequest, refreshChildren, refreshVisuals, register, registerAccessibility, registerModel, removeChild, removeEditPartListener, removeEditPolicy, setFlag, setFocus, setModel, setSelected, showSourceFeedback, showTargetFeedback, toString, understandsRequest, unregister, unregisterAccessibility, unregisterModel`

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

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

### Methods inherited from interface org.eclipse.gef.EditPart

`activate, addEditPartListener, deactivate, eraseSourceFeedback, eraseTargetFeedback, getChildren, getCommand, getEditPolicy, getModel, getParent, getRoot, getSelected, getTargetEditPart, getViewer, hasFocus, installEditPolicy, isActive, isSelectable, performRequest, removeEditPartListener, removeEditPolicy, setFocus, setModel, setSelected, showSourceFeedback, showTargetFeedback, understandsRequest`

### Methods inherited from interface org.eclipse.gef.GraphicalEditPart

`addNodeListener, getContentPane, getFigure, getSourceConnections, getTargetConnections, removeNodeListener, setLayoutConstraint`

## Constructor Details

### AbstractConnectionEditPart

public AbstractConnectionEditPart()

## Method Details

### activateFigure

protected void activateFigure()
Activates the Figure representing this, by setting up the start and end connections, and adding the figure to the Connection Layer.

See Also:
  - `AbstractGraphicalEditPart.deactivate()`

### addNotify

public void addNotify()
Description copied from interface: `EditPart`
Called after the EditPart has been added to its parent. This is used to indicate to the EditPart that it should refresh itself for the first time.

Specified by:
  `addNotify` in interface `EditPart`
Overrides:
  `addNotify` in class `AbstractGraphicalEditPart`
See Also:
  - `EditPart.addNotify()`

### createFigure

protected org.eclipse.draw2d.IFigure createFigure()
Returns a newly created Figure to represent these type of EditParts.

Specified by:
  `createFigure` in class `AbstractGraphicalEditPart`
Returns:
  The created Figure.

### deactivateFigure

protected void deactivateFigure()
Deactivates the Figure representing this, by removing it from the connection layer, and resetting the source and target connections to `null`.

### getAdapter

public <T> T getAdapter(Class<T> adapter)
`AbstractConnectionEditPart` extends getAdapter() to overrides the `AccessibleAnchorProvider` adapter returned by the superclass. When treating a connection as a node for other connections, it makes sense to target its midpoint, and not the edge of its bounds.

Specified by:
  `getAdapter` in interface `IAdaptable`
Overrides:
  `getAdapter` in class `AbstractGraphicalEditPart`
Parameters:
  `adapter` - the adapter Class
Returns:
  the adapter
See Also:
  - `AbstractConnectionEditPart.DefaultAccessibleAnchorProvider`
  - `AbstractGraphicalEditPart.getAdapter(Class)`

### getConnectionFigure

public org.eclipse.draw2d.Connection getConnectionFigure()
Convenience method for casting this GraphicalEditPart's Figure to a `Connection`

Returns:
  the Figure as a Connection

### getDragTracker

public DragTracker getDragTracker(Request req)
Description copied from class: `AbstractGraphicalEditPart`
Overridden to return a default `DragTracker` for GraphicalEditParts.

Specified by:
  `getDragTracker` in interface `EditPart`
Overrides:
  `getDragTracker` in class `AbstractGraphicalEditPart`
Parameters:
  `req` - a `Request` indicating the context of the drag
Returns:
  `null` or a DragTracker
See Also:
  - `EditPart.getDragTracker(Request)`

### getSource

public EditPart getSource()

Specified by:
  `getSource` in interface `ConnectionEditPart`
Returns:
  the EditPart at the source end of this connection.
See Also:
  - `ConnectionEditPart.getSource()`

### getTarget

public EditPart getTarget()

Specified by:
  `getTarget` in interface `ConnectionEditPart`
Returns:
  the EditPart at the target end of this connection.
See Also:
  - `ConnectionEditPart.getTarget()`

### getSourceConnectionAnchor

protected org.eclipse.draw2d.ConnectionAnchor getSourceConnectionAnchor()
Returns the `ConnectionAnchor` for the source end of the connection. If the source is an instance of `NodeEditPart`, that interface will be used to determine the proper ConnectionAnchor. If the source is not an instance of `NodeEditPart`, this method should be overridden to return the correct ConnectionAnchor. Failure to do this will cause a default anchor to be used so that the connection figure will be made visible to the developer.

Returns:
  ConnectionAnchor for the source end of the Connection

### getTargetConnectionAnchor

protected org.eclipse.draw2d.ConnectionAnchor getTargetConnectionAnchor()
Returns the `ConnectionAnchor` for the target end of the connection. If the target is an instance of `NodeEditPart`, that interface will be used to determine the proper ConnectionAnchor. If the target is not an instance of `NodeEditPart`, this method should be overridden to return the correct ConnectionAnchor. Failure to do this will cause a default anchor to be used so that the connection figure will be made visible to the developer.

Returns:
  ConnectionAnchor for the target end of the Connection

### refresh

public void refresh()
Extended here to also refresh the ConnectionAnchors.

Specified by:
  `refresh` in interface `EditPart`
Overrides:
  `refresh` in class `AbstractGraphicalEditPart`
See Also:
  - `EditPart.refresh()`

### refreshSourceAnchor

protected void refreshSourceAnchor()
Updates the source ConnectionAnchor. Subclasses should override `getSourceConnectionAnchor()` if necessary, and not this method.

### refreshTargetAnchor

protected void refreshTargetAnchor()
Updates the target ConnectionAnchor. Subclasses should override `getTargetConnectionAnchor()` if necessary, and not this method.

### removeNotify

public void removeNotify()
Extended here to remove the ConnectionEditPart's connection figure from the connection layer.

Specified by:
  `removeNotify` in interface `EditPart`
Overrides:
  `removeNotify` in class `AbstractGraphicalEditPart`
See Also:
  - `EditPart.removeNotify()`

### setParent

public void setParent(EditPart parent)
Extended to implement automatic addNotify and removeNotify handling.

Specified by:
  `setParent` in interface `EditPart`
Overrides:
  `setParent` in class `AbstractEditPart`
Parameters:
  `parent` - the parent EditPart
See Also:
  - `EditPart.setParent(EditPart)`

### setSource

public void setSource(EditPart editPart)
Sets the source EditPart of this connection.

Specified by:
  `setSource` in interface `ConnectionEditPart`
Parameters:
  `editPart` - EditPart which is the source.

### setTarget

public void setTarget(EditPart editPart)
Sets the target EditPart of this connection.

Specified by:
  `setTarget` in interface `ConnectionEditPart`
Parameters:
  `editPart` - EditPart which is the target.