Package org.eclipse.graphiti.pattern

# Class AbstractConnectionPattern

java.lang.Object
org.eclipse.graphiti.pattern.AbstractBasePattern
org.eclipse.graphiti.pattern.AbstractConnectionPattern

All Implemented Interfaces:
  `IFeatureProviderHolder`, `IAdd`, `ICreateConnection`, `ICreateInfo`, `IConnectionPattern`

public abstract class AbstractConnectionPattern extends AbstractBasePattern implements IConnectionPattern
This is the base class AbstractConnectionPattern that clients writing a pattern for a connection domain object should subclass.

## Constructor Summary

Constructors
Constructor
Description
`AbstractConnectionPattern()`
Creates a new `AbstractConnectionPattern`.

## Method Summary

Modifier and Type
Method
Description
`protected Connection`
`addGraphicalRepresentation(IConnectionContext context, Object newObject)`
Adds the graphical representation of the given new `Object` with the information in the given `IConnectionContext`.
`void`
`attachedToSource(ICreateConnectionContext context)`
Hook that is called by the Graphiti framework as soon as a new connection is attached to its source anchor.
`void`
`canceledAttaching(ICreateConnectionContext context)`
Hook that is called by the Graphiti framework as soon as a connection creation is cancelled.
`boolean`
`canCreate(ICreateConnectionContext context)`
Clients must override this method to indicate that the pattern can be used to create domain objects as defined in the given `ICreateConnectionContext`.
`boolean`
`canStartConnection(ICreateConnectionContext context)`
Clients must override this method to indicate that the pattern can be used to create domain objects starting from what is defined in the given `ICreateConnectionContext`.
`Connection`
`create(ICreateConnectionContext context)`
Clients must override this method to implement the functionality to create a new connection domain object as defined in the given `ICreateConnectionContext`.
`void`
`endConnecting()`
Hook that is called by the Graphiti framework as soon as a new connection is ended.
`protected static AddConnectionContext`
`getAddConnectionContext(ICreateConnectionContext context)`
Creates a new `AddConnectionContext` suitable for adding a connection for this pattern.
`String`
`getCreateDescription()`
Client should override to return a string description of the type of domain object that is created with this pattern.
`String`
`getCreateImageId()`
Client should override to return a string id of the the image icon for the domain object that is created with this pattern.
`String`
`getCreateLargeImageId()`
Client should override to return a string id of the the large image icon for the domain object that is created with this pattern.
`String`
`getCreateName()`
Client should override to return the name of the domain object that is created with this pattern.
`protected void`
`layoutPictogramElement(PictogramElement pe)`
Helper method that triggers a layout of the given `PictogramElement`.
`void`
`startConnecting()`
Hook that is called by the Graphiti framework as soon as a new connection is started.
`protected void`
`updatePictogramElement(PictogramElement pe)`
Helper method that triggers an update of the given `PictogramElement`.

### Methods inherited from class org.eclipse.graphiti.pattern.AbstractBasePattern

`add, canAdd, getBusinessObjectForPictogramElement, getDiagram, getDiagramBehavior, getFeatureProvider, getMappingProvider, link, link, manageColor, manageColor, manageFont, manageFont, setFeatureProvider`

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

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

### Methods inherited from interface org.eclipse.graphiti.func.IAdd

`add, canAdd`

### Methods inherited from interface org.eclipse.graphiti.pattern.IConnectionPattern

`setFeatureProvider`

## Constructor Details

### AbstractConnectionPattern

public AbstractConnectionPattern()
Creates a new `AbstractConnectionPattern`.

## Method Details

### getAddConnectionContext

protected static AddConnectionContext getAddConnectionContext(ICreateConnectionContext context)
Creates a new `AddConnectionContext` suitable for adding a connection for this pattern. The default implementation simply takes the source and target anchors of the provided `ICreateConnectionContext` and adds them to a newly created `AddConnectionContext` object.

Parameters:
  `context` - The create connection context to be used as a basis for adding a connection.
Returns:
  The `AddConnectionContext`.

### canCreate

public boolean canCreate(ICreateConnectionContext context)
Clients must override this method to indicate that the pattern can be used to create domain objects as defined in the given `ICreateConnectionContext`. Corresponds to the method `ICreateConnection.canCreate(ICreateConnectionContext)` . The default implementation simply returns `false`.

Specified by:
  `canCreate` in interface `ICreateConnection`
Parameters:
  `context` - The context holding information on the connection domain object to be created.
Returns:
  `true` in case this pattern can create such a connection domain object, `false` otherwise.

### canStartConnection

public boolean canStartConnection(ICreateConnectionContext context)
Clients must override this method to indicate that the pattern can be used to create domain objects starting from what is defined in the given `ICreateConnectionContext`. Corresponds to the method `ICreateConnection.canStartConnection(ICreateConnectionContext)` . The default implementation simply returns `false`.

Specified by:
  `canStartConnection` in interface `ICreateConnection`
Parameters:
  `context` - The context holding information on the connection domain object to be created.
Returns:
  `true` in case this pattern can create such a connection domain object, `false` otherwise.

### create

public Connection create(ICreateConnectionContext context)
Clients must override this method to implement the functionality to create a new connection domain object as defined in the given `ICreateConnectionContext`. Corresponds to the method `ICreateConnection.create(ICreateConnectionContext)`. The default implementation simply does nothing and returns `null`.

Specified by:
  `create` in interface `ICreateConnection`
Parameters:
  `context` - The context holding information on the connection domain object to be created.
Returns:
  The newly create `Connection` pictogram element.

### addGraphicalRepresentation

protected Connection addGraphicalRepresentation(IConnectionContext context, Object newObject)
Adds the graphical representation of the given new `Object` with the information in the given `IConnectionContext`.

Parameters:
  `context` - The connection context for the new object
  `newObject` - The new object instance itself
Returns:
  The `Connection` prictogram element instance created for the connection domain object.

### layoutPictogramElement

protected void layoutPictogramElement(PictogramElement pe)
Helper method that triggers a layout of the given `PictogramElement`. The default implementation queries the feature provider and tries to find a functionality either in the pattern of an additional `AbstractLayoutFeature` that can handle the request and triggers the operation.

Parameters:
  `pe` - The pictogram element to layout

### updatePictogramElement

protected void updatePictogramElement(PictogramElement pe)
Helper method that triggers an update of the given `PictogramElement`. The default implementation queries the feature provider and tries to find a functionality either in the pattern of an additional `AbstractUpdateFeature` that can handle the request and triggers the operation.

Parameters:
  `pe` - The pictogram element to update

### getCreateDescription

public String getCreateDescription()
Client should override to return a string description of the type of domain object that is created with this pattern. The Graphiti framework uses this information to fill a tooltip for the creation tool entry in the palette. The default implementation simply returns `null` which indicates that no tooltip shall be displayed.

Specified by:
  `getCreateDescription` in interface `ICreateInfo`
Returns:
  A `String` holding the tooltip

### getCreateImageId

public String getCreateImageId()
Client should override to return a string id of the the image icon for the domain object that is created with this pattern. The Graphiti framework uses this information to add an icon to the creation tool entry in the palette. The default implementation simply returns `null` which indicates that no icon shall be displayed.

Specified by:
  `getCreateImageId` in interface `ICreateInfo`
Returns:
  A `String` holding the id of the icon as defined in the AbstractImageProvider.

### getCreateLargeImageId

public String getCreateLargeImageId()
Client should override to return a string id of the the large image icon for the domain object that is created with this pattern. The Graphiti framework uses this information to add a large icon to the creation tool entry in the palette. The default implementation simply returns `null` which indicates that no icon shall be displayed.

Specified by:
  `getCreateLargeImageId` in interface `ICreateInfo`
Returns:
  A `String` holding the id of the large icon as defined in the AbstractImageProvider.

### getCreateName

public String getCreateName()
Client should override to return the name of the domain object that is created with this pattern. The Graphiti framework uses this information to fill the text for the creation tool entry in the palette. The default implementation simply returns `null` which results in an empty entry in the palette.

Specified by:
  `getCreateName` in interface `ICreateInfo`
Returns:
  A `String` holding the name of the domain object.

### startConnecting

public void startConnecting()
Hook that is called by the Graphiti framework as soon as a new connection is started. Corresponds to the method `AbstractCreateConnectionFeature.startConnecting()`. The default implementation simply does nothing.

Specified by:
  `startConnecting` in interface `ICreateConnection`
Since:
  0.9

### endConnecting

public void endConnecting()
Hook that is called by the Graphiti framework as soon as a new connection is ended. Corresponds to the method `AbstractCreateConnectionFeature.endConnecting()`. The default implementation simply does nothing.

Specified by:
  `endConnecting` in interface `ICreateConnection`
Since:
  0.9

### attachedToSource

public void attachedToSource(ICreateConnectionContext context)
Hook that is called by the Graphiti framework as soon as a new connection is attached to its source anchor. Corresponds to the method `AbstractCreateConnectionFeature.attachedToSource(ICreateConnectionContext)` . The default implementation simply does nothing.

Specified by:
  `attachedToSource` in interface `ICreateConnection`
Parameters:
  `context` - the context
Since:
  0.9

### canceledAttaching

public void canceledAttaching(ICreateConnectionContext context)
Hook that is called by the Graphiti framework as soon as a connection creation is cancelled. Corresponds to the method `AbstractCreateConnectionFeature.canceledAttaching(ICreateConnectionContext)` . The default implementation simply does nothing.

Specified by:
  `canceledAttaching` in interface `ICreateConnection`
Parameters:
  `context` - the context
Since:
  0.9