@Override
  public PictogramElement add(IAddContext context) {
    IPeService peService = Graphiti.getPeService();
    IGaService gaService = Graphiti.getGaService();

    BaseElement element = (BaseElement) context.getNewObject();
    IAddConnectionContext addConContext = (IAddConnectionContext) context;

    Connection connection = peService.createFreeFormConnection(getDiagram());

    Object importProp = context.getProperty(DIImport.IMPORT_PROPERTY);
    if (importProp != null && (Boolean) importProp) {
      connection.setStart(addConContext.getSourceAnchor());
      connection.setEnd(addConContext.getTargetAnchor());
    } else {
      ContainerShape sourceContainer =
          (ContainerShape) addConContext.getSourceAnchor().eContainer();
      ContainerShape targetContainer =
          (ContainerShape) addConContext.getTargetAnchor().eContainer();
      Tuple<FixPointAnchor, FixPointAnchor> anchors =
          AnchorUtil.getSourceAndTargetBoundaryAnchors(
              sourceContainer, targetContainer, connection);

      connection.setStart(anchors.getFirst());
      connection.setEnd(anchors.getSecond());
    }

    if (ModelUtil.hasName(element)) {
      ConnectionDecorator labelDecorator =
          Graphiti.getPeService().createConnectionDecorator(connection, true, 0.5, true);
      Text text = gaService.createText(labelDecorator, ModelUtil.getName(element));
      peService.setPropertyValue(
          labelDecorator, UpdateBaseElementNameFeature.TEXT_ELEMENT, Boolean.toString(true));
      text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    }

    Polyline connectionLine = gaService.createPolyline(connection);
    connectionLine.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

    decorateConnectionLine(connectionLine);

    createDIEdge(connection, element);
    createConnectionDecorators(connection);
    hook(addConContext, connection, element);

    return connection;
  }
  @Override
  public PictogramElement add(IAddContext context) {
    IPeService peService = Graphiti.getPeService();

    BaseElement element = (BaseElement) context.getNewObject();
    IAddConnectionContext addConContext = (IAddConnectionContext) context;

    Connection connection = peService.createFreeFormConnection(getDiagram());

    Object importProp = context.getProperty(DIImport.IMPORT_PROPERTY);
    if (importProp != null && (Boolean) importProp) {
      connection.setStart(addConContext.getSourceAnchor());
      connection.setEnd(addConContext.getTargetAnchor());
    } else {
      ContainerShape sourceContainer =
          (ContainerShape) addConContext.getSourceAnchor().eContainer();
      ContainerShape targetContainer =
          (ContainerShape) addConContext.getTargetAnchor().eContainer();
      Tuple<FixPointAnchor, FixPointAnchor> anchors =
          AnchorUtil.getSourceAndTargetBoundaryAnchors(
              sourceContainer, targetContainer, connection);

      connection.setStart(anchors.getFirst());
      connection.setEnd(anchors.getSecond());
    }

    IGaService gaService = Graphiti.getGaService();
    Polyline connectionLine = gaService.createPolyline(connection);
    connectionLine.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

    decorateConnectionLine(connectionLine);

    createDIEdge(connection, element);
    createConnectionDecorators(connection);
    hook(addConContext, connection, element);

    return connection;
  }