Пример #1
0
 private int createMissingDIElementChildren(
     DiagramElementTreeNode node, int x, int y, List<BaseElement> created) {
   for (DiagramElementTreeNode childNode : node.getChildren()) {
     if (childNode.getChecked()) {
       BPMNShape bpmnShape = createMissingDIElement(childNode, x, y, created);
       if (bpmnShape != null) {
         y += bpmnShape.getBounds().getHeight() + 10;
       }
     }
   }
   return y;
 }
Пример #2
0
  private void createMissingDIElements(DiagramElementTree missing) {

    // look for any BPMN2 elements that do not have corresponding DI elements
    // and create DI elements for them. First, handle the BPMNShape objects:
    int x = 102400;
    int y = 0;
    List<BaseElement> shapes = new ArrayList<BaseElement>();
    for (DiagramElementTreeNode node : missing.getChildren()) {
      if (node.getChecked()) {
        BPMNShape bpmnShape = createMissingDIElement(node, x, y, shapes);
        if (bpmnShape != null) {
          y += bpmnShape.getBounds().getHeight() + 10;
        }
      }
    }

    // Next create the BPMNEdge objects. At this point, all of the source
    // and target elements for the connections should already exist, so
    // we don't have to worry about that.
    List<BaseElement> connections = new ArrayList<BaseElement>();
    for (BaseElement be : shapes) {
      if (be instanceof FlowNode) {
        FlowNode flowNode = (FlowNode) be;
        // find the BPMNDiagram that contains this flow node
        BPMNDiagram bpmnDiagram = createDIDiagram(flowNode);

        for (SequenceFlow sf : flowNode.getIncoming()) {
          if (!connections.contains(sf)) {
            BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, sf);
            if (bpmnEdge != null) connections.add(sf);
          }
        }

        for (SequenceFlow sf : flowNode.getOutgoing()) {
          if (!connections.contains(sf)) {
            BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, sf);
            if (bpmnEdge != null) connections.add(sf);
          }
        }
      } else if (be instanceof ConversationNode) {
        ConversationNode convNode = (ConversationNode) be;
        BPMNDiagram bpmnDiagram = createDIDiagram(convNode);
        for (MessageFlow mf : convNode.getMessageFlowRefs()) {
          if (!connections.contains(mf)) {
            BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, mf);
            if (bpmnEdge != null) connections.add(mf);
          }
        }
      }
    }
    // Finally, Associations are RootElements and since we only include shapes
    // in the missing elements tree, we'll have to revisit all of the RootElements
    TreeIterator<EObject> iter = definitions.eAllContents();
    while (iter.hasNext()) {
      EObject o = iter.next();
      if (o instanceof Association) {
        Association assoc = (Association) o;
        BPMNDiagram bpmnDiagram = createDIDiagram(assoc);
        BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, assoc);
        if (bpmnEdge != null) connections.add(assoc);
      }
    }
  }