예제 #1
0
  public static List<ContainerShape> findGroupedShapes(ContainerShape groupShape) {
    Diagram diagram = null;
    EObject parent = groupShape.eContainer();
    while (parent != null) {
      if (parent instanceof Diagram) {
        diagram = (Diagram) parent;
        break;
      }
      parent = parent.eContainer();
    }

    // find all shapes that are inside this Group
    // these will be moved along with the Group
    List<ContainerShape> list = new ArrayList<ContainerShape>();
    if (diagram != null && isGroupShape(groupShape)) {
      TreeIterator<EObject> iter = diagram.eAllContents();
      while (iter.hasNext()) {
        EObject child = iter.next();
        if (child instanceof ContainerShape
            && child != groupShape
            && !list.contains(child)
            && !isLabelShape((ContainerShape) child)) {
          ContainerShape shape = (ContainerShape) child;
          if (isGroupShape(shape)) {
            if (GraphicsUtil.contains(groupShape, shape)) {
              if (!list.contains(shape)) {
                list.add(shape);
              }
            }
          } else if (GraphicsUtil.contains(groupShape, shape)) {
            if (!list.contains(shape)) {
              list.add(shape);
            }
            // find this shape's parent ContainerShape if it has one
            while (!(shape.getContainer() instanceof Diagram)) {
              shape = shape.getContainer();
            }
            if (!list.contains(shape) && shape != groupShape) {
              list.add(shape);
            }
          }
        }
      }
    }
    return list;
  }
예제 #2
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);
  }