Ejemplo n.º 1
0
 private boolean isMissingDIElement(BaseElement be) {
   // ignore DataStores - there are bound to be references
   // to these, which *should* be rendered
   if (be instanceof DataStore) return false;
   BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(be);
   if (bpmnDiagram != null) return false;
   // couldn't find a BPMNDiagram entry for this BaseElement
   // check its container to see if it has a BPMNDiagram
   FlowElementsContainer container = this.getRootElementContainer(be);
   bpmnDiagram = DIUtils.findBPMNDiagram(container);
   if (bpmnDiagram != null) {
     // is the BaseElement defined as a BPMNShape or BPMNEdge in its
     // container's BPMNDiagram?
     if (bpmnDiagram.getPlane().getPlaneElement().contains(be)) return false;
   }
   boolean missing = (elements.get(be) == null && diagnostics.get(be) == null);
   if (missing)
     GraphicsUtil.dump(
         "Missing DI element for: "
             + be.eClass().getName()
             + " '"
             + ExtendedPropertiesProvider.getTextValue(be)
             + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   return missing;
 }
Ejemplo n.º 2
0
  private BPMNDiagram createDIDiagram(BaseElement bpmnElement) {

    BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(bpmnElement, true);

    // if this container does not have a BPMNDiagram, create one
    if (bpmnElement instanceof Process) {
      if (bpmnDiagram == null) {
        // unless this Process is referenced by a Pool
        for (Collaboration c :
            ModelUtil.getAllObjectsOfType(bpmnElement.eResource(), Collaboration.class)) {
          for (Participant p : c.getParticipants()) {
            if (!ModelUtil.isParticipantBand(p)) {
              if (p.getProcessRef() == bpmnElement) {
                bpmnDiagram = DIUtils.findBPMNDiagram(p, true);
                break;
              }
            }
          }
          if (bpmnDiagram != null) break;
        }
      } else {
        // Always create a new BPMNDiagram if this Process is being referenced by a Participant Band
        //				for (Collaboration c : ModelUtil.getAllObjectsOfType(bpmnElement.eResource(),
        // Collaboration.class)) {
        //					for (Participant p : c.getParticipants()) {
        //						if (ModelUtil.isParticipantBand(p)) {
        //							if (p.getProcessRef() == bpmnElement) {
        //								bpmnDiagram = null;
        //								break;
        //							}
        //						}
        //					}
        //					if (bpmnDiagram==null)
        //						break;
        //				}
      }
    }

    if (bpmnDiagram == null) {
      FlowElementsContainer container = getRootElementContainer(bpmnElement);
      if (container == null) {
        diagnostics.add(IStatus.ERROR, bpmnElement, Messages.DIGenerator_No_Diagram);
        return this.bpmnDiagram;
      }
      BPMNPlane plane = BpmnDiFactory.eINSTANCE.createBPMNPlane();
      plane.setBpmnElement(container);

      bpmnDiagram = BpmnDiFactory.eINSTANCE.createBPMNDiagram();
      bpmnDiagram.setName(ExtendedPropertiesProvider.getTextValue(container));
      bpmnDiagram.setPlane(plane);

      definitions.getDiagrams().add(bpmnDiagram);
    }

    return bpmnDiagram;
  }
Ejemplo n.º 3
0
 public static boolean isElementExpanded(BaseElement be) {
   if (isExpandableElement(be)) {
     // if the BaseElement has its own BPMNDiagram page it should be considered
     // to be collapsed and should be represented as such.
     // TODO: this condition should be removed once we implement Link events as
     // "off page" connectors.
     BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(be);
     // otherwise check the "isExpanded" state of the BPMNShape element.
     BPMNShape bpmnShape = DIUtils.findBPMNShape(be);
     if (bpmnShape != null && bpmnShape.isIsExpanded() && bpmnDiagram == null) return true;
   }
   return false;
 }
Ejemplo n.º 4
0
  @Override
  public void execute(ICustomContext context) {
    PictogramElement[] pes = context.getPictogramElements();
    if (pes != null && pes.length == 1) {
      PictogramElement pe0 = pes[0];
      Object bo = getBusinessObjectForPictogramElement(pe0);
      if (pe0 instanceof ContainerShape && bo instanceof FlowNode) {
        ContainerShape containerShape = (ContainerShape) pe0;
        FlowNode flowNode = (FlowNode) bo;
        try {
          BPMNShape bpmnShape = DIUtils.findBPMNShape(flowNode);
          if (bpmnShape.isIsExpanded()) {
            Bpmn2Preferences preferences = Bpmn2Preferences.getInstance(getDiagram());
            ShapeStyle ss = preferences.getShapeStyle("TASKS");

            // SubProcess is expanded - resize to standard Task size
            // NOTE: children tasks will be set not-visible in LayoutExpandableActivityFeature

            bpmnShape.setIsExpanded(false);

            GraphicsAlgorithm ga = containerShape.getGraphicsAlgorithm();
            ResizeShapeContext resizeContext = new ResizeShapeContext(containerShape);
            IResizeShapeFeature resizeFeature =
                getFeatureProvider().getResizeShapeFeature(resizeContext);
            IDimension oldSize = FeatureSupport.getCollapsedSize(containerShape);
            int oldWidth = ga.getWidth();
            int oldHeight = ga.getHeight();
            FeatureSupport.setExpandedSize(containerShape, oldWidth, oldHeight);

            int newWidth = ss.getDefaultWidth();
            int newHeight = ss.getDefaultHeight();
            if (newWidth < oldSize.getWidth()) oldSize.setWidth(newWidth);
            if (newHeight < oldSize.getHeight()) oldSize.setHeight(newHeight);
            newWidth = oldSize.getWidth();
            newHeight = oldSize.getHeight();
            resizeContext.setX(ga.getX() + oldWidth / 2 - newWidth / 2);
            resizeContext.setY(ga.getY() + oldHeight / 2 - newHeight / 2);
            resizeContext.setWidth(newWidth);
            resizeContext.setHeight(newHeight);
            resizeFeature.resizeShape(resizeContext);

            UpdateContext updateContext = new UpdateContext(containerShape);
            IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(updateContext);
            if (updateFeature.updateNeeded(updateContext).toBoolean())
              updateFeature.update(updateContext);

            getDiagramEditor().selectPictogramElements(new PictogramElement[] {});
          }

        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
  }
Ejemplo n.º 5
0
  public static boolean isHorizontal(ContainerShape container) {
    EObject parent = container.eContainer();
    if (parent instanceof PictogramElement) {
      // participant bands are always "vertical" so that
      // the label is drawn horizontally by the LayoutFeature
      if (BusinessObjectUtil.getFirstElementOfType(
              (PictogramElement) parent, ChoreographyActivity.class)
          != null) return false;
    }

    String v =
        Graphiti.getPeService()
            .getPropertyValue(container, GraphitiConstants.IS_HORIZONTAL_PROPERTY);
    if (v == null) {
      BPMNShape bpmnShape =
          DIUtils.findBPMNShape(BusinessObjectUtil.getFirstBaseElement(container));
      if (bpmnShape != null) return bpmnShape.isIsHorizontal();
      return Bpmn2Preferences.getInstance(container).isHorizontalDefault();
    }
    return Boolean.parseBoolean(v);
  }
Ejemplo n.º 6
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;
  }