Exemplo n.º 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);
        }
      }
    }
  }
Exemplo n.º 2
0
  private BPMNShape createDIShape(
      BPMNDiagram bpmnDiagram, BaseElement bpmnElement, float x, float y, boolean doImport) {

    BPMNPlane plane = bpmnDiagram.getPlane();
    BPMNShape bpmnShape = null;
    for (DiagramElement de : plane.getPlaneElement()) {
      if (de instanceof BPMNShape) {
        if (bpmnElement == ((BPMNShape) de).getBpmnElement()) {
          bpmnShape = (BPMNShape) de;
          break;
        }
      }
    }

    if (bpmnShape == null) {
      bpmnShape = BpmnDiFactory.eINSTANCE.createBPMNShape();
      bpmnShape.setBpmnElement(bpmnElement);
      Bounds bounds = DcFactory.eINSTANCE.createBounds();
      bounds.setX(x);
      bounds.setY(y);
      ShapeStyle ss = preferences.getShapeStyle(bpmnElement);
      bounds.setWidth(ss.getDefaultWidth());
      bounds.setHeight(ss.getDefaultHeight());
      bpmnShape.setBounds(bounds);
      plane.getPlaneElement().add(bpmnShape);
      preferences.applyBPMNDIDefaults(bpmnShape, null);

      ModelUtil.setID(bpmnShape);
      if (doImport) importer.importShape(bpmnShape);
    }

    return bpmnShape;
  }
Exemplo n.º 3
0
  public static BPMNShape createDIShape(
      Shape shape,
      BaseElement elem,
      int x,
      int y,
      int w,
      int h,
      IFeatureProvider fp,
      Diagram diagram) {

    EList<EObject> businessObjects =
        Graphiti.getLinkService().getLinkForPictogramElement(diagram).getBusinessObjects();
    BPMNShape bpmnShape = null;

    for (EObject eObject : businessObjects) {
      if (eObject instanceof BPMNDiagram) {
        BPMNDiagram bpmnDiagram = (BPMNDiagram) eObject;

        bpmnShape = BpmnDiFactory.eINSTANCE.createBPMNShape();
        //				bpmnShape.setId(EcoreUtil.generateUUID());
        bpmnShape.setBpmnElement(elem);
        Bounds bounds = DcFactory.eINSTANCE.createBounds();
        bounds.setX(x);
        bounds.setY(y);
        bounds.setWidth(w);
        bounds.setHeight(h);
        bpmnShape.setBounds(bounds);

        List<DiagramElement> elements = bpmnDiagram.getPlane().getPlaneElement();
        elements.add(bpmnShape);
        ModelUtil.setID(shape);

        fp.link(shape, new Object[] {elem, bpmnShape});
        break;
      }
    }

    return bpmnShape;
  }