* @see org.eclipse.graphiti.func.IAdd#add(org.eclipse.graphiti.features.context.IAddContext)
*/
@Override
public PictogramElement add(IAddContext context) {
IAddConnectionContext addConContext = (IAddConnectionContext) context;
Flow addedEReference = (Flow) context.getNewObject();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
// CONNECTION WITH POLYLINE
Connection connection = peCreateService.createFreeFormConnection(getDiagram());
connection.setStart(addConContext.getSourceAnchor());
connection.setEnd(addConContext.getTargetAnchor());
IGaService gaService = Graphiti.getGaService();
Polyline polyline = gaService.createPolyline(connection);
polyline.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
polyline.setForeground(manageColor(StyleUtil.getColorConstant(PreferenceManager.getInstance().loadPreferenceAsString(PreferencesConstants.EDITOR_CONNECTION_COLOR))));
// create link and wire it
link(connection, addedEReference);
// add dynamic text decorator for the reference name
ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true);
Text text = gaService.createDefaultText(getDiagram(), getDiagram().getGraphicsAlgorithm());
textDecorator.setConnection(connection);
text.setStyle(StyleUtil.getStyleForCamelText((getDiagram())));
gaService.setLocation(text, 10, 0);
// set reference name in the text decorator
Flow flow = (Flow) context.getNewObject();
text.setValue(flow.getName());
// add static graphical decorators (composition and navigable)
ConnectionDecorator cd;
cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true);
createArrow(cd);