예제 #1
0
  public static void updateDIShape(PictogramElement element) {

    PictogramLink link = element.getLink();
    if (link == null) {
      return;
    }

    BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(element, BPMNShape.class);
    if (bpmnShape == null) {
      return;
    }

    ILocation loc = Graphiti.getLayoutService().getLocationRelativeToDiagram((Shape) element);
    Bounds bounds = bpmnShape.getBounds();

    bounds.setX(loc.getX());
    bounds.setY(loc.getY());

    GraphicsAlgorithm graphicsAlgorithm = element.getGraphicsAlgorithm();
    IDimension size = Graphiti.getGaService().calculateSize(graphicsAlgorithm);
    bounds.setHeight(size.getHeight());
    bounds.setWidth(size.getWidth());

    if (element instanceof ContainerShape) {
      EList<Shape> children = ((ContainerShape) element).getChildren();
      for (Shape shape : children) {
        if (shape instanceof ContainerShape) {
          updateDIShape(shape);
        }
      }
    }
  }
예제 #2
0
  public static void updateDIEdge(Diagram diagram, Connection connection, Class clazz) {
    try {
      ModelHandler modelHandler =
          ModelHandlerLocator.getModelHandler(
              connection.getLink().getBusinessObjects().get(0).eResource());

      EObject be = BusinessObjectUtil.getFirstElementOfType(connection, clazz);
      BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(diagram, (BaseElement) be);
      Point point = DcFactory.eINSTANCE.createPoint();

      List<Point> waypoint = edge.getWaypoint();
      waypoint.clear();

      GraphicsAlgorithm graphicsAlgorithm = connection.getStart().getGraphicsAlgorithm();
      // FIXME connections must create anchors!!!
      if (graphicsAlgorithm != null) {
        point.setX(graphicsAlgorithm.getX());
        point.setY(graphicsAlgorithm.getY());
      } else {
        point.setX(connection.getStart().getParent().getGraphicsAlgorithm().getX());
        point.setY(connection.getStart().getParent().getGraphicsAlgorithm().getY());
      }
      waypoint.add(point);

      if (connection instanceof FreeFormConnectionImpl) {
        FreeFormConnectionImpl freeForm = (FreeFormConnectionImpl) connection;
        EList<org.eclipse.graphiti.mm.algorithms.styles.Point> bendpoints =
            freeForm.getBendpoints();
        for (org.eclipse.graphiti.mm.algorithms.styles.Point bp : bendpoints) {
          addBendPoint(freeForm, point);
        }
      }

      point = DcFactory.eINSTANCE.createPoint();
      graphicsAlgorithm = connection.getEnd().getGraphicsAlgorithm();
      if (graphicsAlgorithm != null) {
        point.setX(graphicsAlgorithm.getX());
        point.setY(graphicsAlgorithm.getY());
      } else {
        point.setX(connection.getEnd().getParent().getGraphicsAlgorithm().getX());
        point.setY(connection.getEnd().getParent().getGraphicsAlgorithm().getY());
      }
      waypoint.add(point);

    } catch (IOException e) {
      Activator.logError(e);
    }
  }
  public Participant getParticipant(final Object o) {
    if (o == null || o instanceof Diagram) {
      return getInternalParticipant();
    }

    Object object = o;
    if (o instanceof Shape) {
      object = BusinessObjectUtil.getFirstElementOfType((PictogramElement) o, BaseElement.class);
    }

    if (object instanceof Participant) {
      return (Participant) object;
    }

    Process process = findElementOfType(Process.class, object);

    for (Participant p : getOrCreateCollaboration().getParticipants()) {
      if (p.getProcessRef() != null && p.getProcessRef().equals(process)) {
        return p;
      }
    }

    return getInternalParticipant();
  }
 @Override
 public boolean canAdd(IAddContext context) {
   return super.canAdd(context)
       || BusinessObjectUtil.containsElementOfType(
           context.getTargetContainer(), FlowElementsContainer.class);
 }