Package org.eclipse.graphiti.pattern

## Class CreateConnectionFeatureForPattern

- java.lang.Object
- - org.eclipse.graphiti.features.impl.AbstractFeature
  - - org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature
    - - org.eclipse.graphiti.pattern.CreateConnectionFeatureForPattern

All Implemented Interfaces:
  `ICreateConnectionFeature`, `ICustomAbortableUndoRedoFeature`, `ICustomUndoRedoFeature`, `IFeature`, `IFeatureProviderHolder`, `ICreateConnection`, `ICreateInfo`, `IDescription`, `IName`

    public class CreateConnectionFeatureForPattern
    extends AbstractCreateConnectionFeature
    implements ICustomAbortableUndoRedoFeature

This feature wraps the create functionality of a pattern for calls of the Graphiti framework. Clients should not need to use this class directly.

### Constructor Summary

Constructors
`CreateConnectionFeatureForPattern​(IFeatureProvider featureProvider, IConnectionPattern pattern)` Creates a new `CreateConnectionFeatureForPattern`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `attachedToSource​(ICreateConnectionContext context)` Will called after a connection was successfully attached to an anchor of a source object. Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction.
`void` `canceledAttaching​(ICreateConnectionContext context)` Will called if the connection creation process was canceled after the successful attachment of the connection to an anchor of a source object.
`boolean` `canCreate​(ICreateConnectionContext context)` Can create.
`boolean` `canRedo​(IContext context)` Decides if the processed feature can be re-done.
`boolean` `canStartConnection​(ICreateConnectionContext context)` Can start connection.
`boolean` `canUndo​(IContext context)` Decides if the current feature can be undone - this is the undo of the execute operation.
`Connection` `create​(ICreateConnectionContext context)` Creates the connection.
`void` `endConnecting()` Will called after a connection creation tool from the palette was deselected. Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction.
`java.lang.String` `getCreateImageId()` Gets the create image id.
`java.lang.String` `getCreateLargeImageId()` Gets the create large image id.
`IConnectionPattern` `getPattern()` Gets the pattern.
`boolean` `isAbort()` The Graphiti framework will call this method after `ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)`/ `ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext)` have been called and before the actual undo/redo operation is triggered.
`void` `postRedo​(IContext context)` This method will be called by the Graphiti framework after the EMF undo has finished.
`void` `postUndo​(IContext context)` This method will be called by the Graphiti framework after the EMF undo is finished.
`void` `preRedo​(IContext context)` This method will be called by the Graphiti framework before the EMF undo has triggered.
`void` `preUndo​(IContext context)` This method will be called by the Graphiti framework before the EMF undo is triggered.
`void` `startConnecting()` Will called after a connection creation tool from the palette was selected. Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction.

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

`canExecute, execute, getCreateDescription, getCreateName, getName`

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

`addGraphicalRepresentation, 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

`hasDoneChanges, isAvailable`

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

`getFeatureProvider`

### Constructor Detail

#### CreateConnectionFeatureForPattern

    public CreateConnectionFeatureForPattern​(IFeatureProvider featureProvider,
                                             IConnectionPattern pattern)

Creates a new `CreateConnectionFeatureForPattern`.

Parameters:
  `featureProvider` - the feature provider
  `pattern` - the connection pattern

### Method Detail

#### canCreate

    public boolean canCreate​(ICreateConnectionContext context)

Description copied from interface: `ICreateConnection`
Can create.

Specified by:
  `canCreate` in interface `ICreateConnection`
Parameters:
  `context` - the context
Returns:
  true, if successful

#### canStartConnection

    public boolean canStartConnection​(ICreateConnectionContext context)

Description copied from interface: `ICreateConnection`
Can start connection.

Specified by:
  `canStartConnection` in interface `ICreateConnection`
Parameters:
  `context` - the context
Returns:
  true, if successful

#### create

    public Connection create​(ICreateConnectionContext context)

Description copied from interface: `ICreateConnection`
Creates the connection.

Specified by:
  `create` in interface `ICreateConnection`
Parameters:
  `context` - the context
Returns:
  The connection that has been created or `null` in case no valid connection can be returned. Currently this return value is not evaluated by the Graphiti framework but it might be used in future versions but only for performance optimizations.

#### getCreateImageId

    public java.lang.String getCreateImageId()

Description copied from interface: `ICreateInfo`
Gets the create image id.

Specified by:
  `getCreateImageId` in interface `ICreateInfo`
Overrides:
  `getCreateImageId` in class `AbstractCreateConnectionFeature`
Returns:
  image for UI representation

#### getCreateLargeImageId

    public java.lang.String getCreateLargeImageId()

Description copied from interface: `ICreateInfo`
Gets the create large image id.

Specified by:
  `getCreateLargeImageId` in interface `ICreateInfo`
Overrides:
  `getCreateLargeImageId` in class `AbstractCreateConnectionFeature`
Returns:
  large image for UI representation

#### isAbort

    public boolean isAbort()

Description copied from interface: `ICustomAbortableUndoRedoFeature`
The Graphiti framework will call this method after `ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)`/ `ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext)` have been called and before the actual undo/redo operation is triggered. 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 `ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)`/ `ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext)` as cancellation indication and check that that flag here.

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

#### 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 `ICustomUndoRedoFeature`
Specified by:
  `canUndo` in interface `IFeature`
Overrides:
  `canUndo` in class `AbstractFeature`
Parameters:
  `context` - this is the general input for this method
Returns:
  true if the feature can be undone, false if not
See Also:
  `IContext`

#### preUndo

    public void preUndo​(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework before the EMF undo is triggered. Customers may revert their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.postUndo(IContext)`.

Specified by:
  `preUndo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### postUndo

    public void postUndo​(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework after the EMF undo is finished. Customers may revert their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.preUndo(IContext)`.

Specified by:
  `postUndo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### canRedo

    public boolean canRedo​(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
Decides if the processed feature can be re-done. This method is called once by the Graphiti framework just before any redo work is started, e.g. before `ICustomUndoRedoFeature.preRedo(IContext)`.

Note that as soon as any feature reports `false` here, also all consecutive entries in the command stack are no longer reachable for redo.

Specified by:
  `canRedo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Returns:
  true if the feature can be re-done, false if not
Since:
  0.8

#### preRedo

    public void preRedo​(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework before the EMF undo has triggered. Customers may re-apply their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.postRedo(IContext)`. (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
  `preRedo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### postRedo

    public void postRedo​(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework after the EMF undo has finished. Customers may re-apply their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.preRedo(IContext)`. (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
  `postRedo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### startConnecting

    public void startConnecting()

Description copied from interface: `ICreateConnection`
Will called after a connection creation tool from the palette was selected.
Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction. In case you want to modify the model (EMF domain objects or Graphiti pictogram objects) you need to do that within a command executed on the editor's command stack to make sure that the modification happens inside an EMF write transaction. Keep in mind that any changes you do within such a command will be create a seperate entry in the undo/redo stack for the editor, which might not be the desired effect.

Specified by:
  `startConnecting` in interface `ICreateConnection`
Overrides:
  `startConnecting` in class `AbstractCreateConnectionFeature`

#### endConnecting

    public void endConnecting()

Description copied from interface: `ICreateConnection`
Will called after a connection creation tool from the palette was deselected.
Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction. In case you want to modify the model (EMF domain objects or Graphiti pictogram objects) you need to do that within a command executed on the editor's command stack to make sure that the modification happens inside an EMF write transaction. Keep in mind that any changes you do within such a command will be create a seperate entry in the undo/redo stack for the editor, which might not be the desired effect.

Specified by:
  `endConnecting` in interface `ICreateConnection`
Overrides:
  `endConnecting` in class `AbstractCreateConnectionFeature`

#### attachedToSource

    public void attachedToSource​(ICreateConnectionContext context)

Description copied from interface: `ICreateConnection`
Will called after a connection was successfully attached to an anchor of a source object.
Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction. In case you want to modify the model (EMF domain objects or Graphiti pictogram objects) you need to do that within a command executed on the editor's command stack to make sure that the modification happens inside an EMF write transaction. Keep in mind that any changes you do within such a command will be create a seperate entry in the undo/redo stack for the editor, which might not be the desired effect.

Specified by:
  `attachedToSource` in interface `ICreateConnection`
Overrides:
  `attachedToSource` in class `AbstractCreateConnectionFeature`
Parameters:
  `context` - the context

#### canceledAttaching

    public void canceledAttaching​(ICreateConnectionContext context)

Description copied from interface: `ICreateConnection`
Will called if the connection creation process was canceled after the successful attachment of the connection to an anchor of a source object. E.g. user pressed ESC, user clicked on an invalid target, focus was lost, ...
Note: In contrast to the standard feature methods like `ICreateConnection.canCreate(ICreateConnectionContext)` and `ICreateConnection.create(ICreateConnectionContext)` this method will not be called in the scope of an EMF transaction. In case you want to modify the model (EMF domain objects or Graphiti pictogram objects) you need to do that within a command executed on the editor's command stack to make sure that the modification happens inside an EMF write transaction. Keep in mind that any changes you do within such a command will be create a seperate entry in the undo/redo stack for the editor, which might not be the desired effect.

Specified by:
  `canceledAttaching` in interface `ICreateConnection`
Overrides:
  `canceledAttaching` in class `AbstractCreateConnectionFeature`
Parameters:
  `context` - the context

#### getPattern

    public IConnectionPattern getPattern()

Gets the pattern.

Returns:
  the pattern
Since:
  0.10