Пример #1
0
  private BPMNEdge createDIEdge(BPMNDiagram bpmnDiagram, BaseElement bpmnElement) {
    BPMNPlane plane = bpmnDiagram.getPlane();
    BPMNEdge bpmnEdge = null;
    for (DiagramElement de : plane.getPlaneElement()) {
      if (de instanceof BPMNEdge) {
        if (bpmnElement == ((BPMNEdge) de).getBpmnElement()) {
          bpmnEdge = (BPMNEdge) de;
          break;
        }
      }
    }

    if (bpmnEdge == null) {
      bpmnEdge = BpmnDiFactory.eINSTANCE.createBPMNEdge();
      bpmnEdge.setBpmnElement(bpmnElement);

      BaseElement sourceElement = null;
      BaseElement targetElement = null;
      if (bpmnElement instanceof SequenceFlow) {
        sourceElement = ((SequenceFlow) bpmnElement).getSourceRef();
        targetElement = ((SequenceFlow) bpmnElement).getTargetRef();
      } else if (bpmnElement instanceof MessageFlow) {
        sourceElement = (BaseElement) ((MessageFlow) bpmnElement).getSourceRef();
        targetElement = (BaseElement) ((MessageFlow) bpmnElement).getTargetRef();
      } else if (bpmnElement instanceof Association) {
        sourceElement = ((Association) bpmnElement).getSourceRef();
        targetElement = ((Association) bpmnElement).getTargetRef();
      }

      if (sourceElement != null && targetElement != null) {
        DiagramElement de;
        de = DIUtils.findPlaneElement(plane.getPlaneElement(), sourceElement);
        bpmnEdge.setSourceElement(de);

        de = DIUtils.findPlaneElement(plane.getPlaneElement(), targetElement);
        bpmnEdge.setTargetElement(de);

        // the source and target elements should already have been created:
        // we know the PictogramElements for these can be found in our elements map
        Shape sourceShape = (Shape) elements.get(sourceElement);
        Shape targetShape = (Shape) elements.get(targetElement);
        //				if (sourceShape!=null && targetShape!=null) {
        //					Tuple<FixPointAnchor,FixPointAnchor> anchors =
        //							AnchorUtil.getSourceAndTargetBoundaryAnchors(sourceShape, targetShape, null);
        //					org.eclipse.graphiti.mm.algorithms.styles.Point sourceLoc =
        // GraphicsUtil.createPoint(anchors.getFirst());
        //					org.eclipse.graphiti.mm.algorithms.styles.Point targetLoc =
        // GraphicsUtil.createPoint(anchors.getSecond());
        //					Point point = DcFactory.eINSTANCE.createPoint();
        //					point.setX(sourceLoc.getX());
        //					point.setY(sourceLoc.getY());
        //					bpmnEdge.getWaypoint().add(point);
        //
        //					point = DcFactory.eINSTANCE.createPoint();
        //					point.setX(targetLoc.getX());
        //					point.setY(targetLoc.getY());
        //					bpmnEdge.getWaypoint().add(point);
        //
        //					plane.getPlaneElement().add(bpmnEdge);
        //
        //					ModelUtil.setID(bpmnEdge);
        //					importer.importConnection(bpmnEdge);
        //				}
      }
    }

    return bpmnEdge;
  }