コード例 #1
0
  public void drop() {
    Sequence s = getOwnerPattern().getBpelModel().getBuilder().createSequence();

    ActivityHolder holder = (ActivityHolder) getOwnerPattern().getOMReference();

    Activity oldActivity = (Activity) holder.getActivity().cut();
    Activity newActivity = (Activity) getDraggedPattern().getOMReference();

    holder.setActivity(s);

    if (last) {
      s.addActivity(oldActivity);
      s.addActivity(newActivity);
    } else {
      s.addActivity(newActivity);
      s.addActivity(oldActivity);
    }
  }
コード例 #2
0
  public static void create(
      Pattern draggedPattern, Pattern ownerPattern, Collection<PlaceHolder> placeHolders) {
    if (!(ownerPattern.getOMReference() instanceof ActivityHolder)) {
      return;
    }

    if (draggedPattern.getParent() == ownerPattern) {
      return;
    }

    ActivityHolder holder = (ActivityHolder) ownerPattern.getOMReference();

    BpelEntity child = holder.getActivity();

    if ((child == null)
        || (child instanceof Sequence)
        || (ownerPattern instanceof CollapsedPattern)) {
      return;
    }

    Pattern p = ((CompositePattern) ownerPattern).getNestedPattern(child);

    Connection c1 = getInboundConnection(p);
    Connection c2 = getOutboundConnection(p);

    FPoint center1 = null;
    FPoint center2 = null;

    if (c1 != null) {
      FPath path = c1.getPath();
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;
        BorderElement border = composite.getBorder();

        if (border != null) {
          path = path.subtract(border.getShape());
        }
      }
      double pathLength = path.length();
      center1 = path.point((pathLength >= 20) ? ((pathLength - 10) / pathLength) : 0.5f);
    } else {
      VisualElement e = null;
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;
        e = composite.getBorder();
      }

      if (e == null) {
        e = p.getFirstElement();
      }

      center1 = new FPoint(e.getCenterX(), e.getY() - 10);
    }

    if (c2 != null) {
      FPath path = c2.getPath();
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;
        BorderElement border = composite.getBorder();

        if (border != null) {
          path = path.subtract(border.getShape());
        }
      }
      double pathLength = path.length();
      center2 = path.point((pathLength >= 20) ? (10 / pathLength) : 0.5f);
    } else {
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;

        VisualElement e = composite.getBorder();

        if (e == null) {
          e = p.getLastElement();
        }

        center2 = new FPoint(e.getCenterX(), e.getY() + e.getHeight() + 10);
      } else {
        VisualElement e = p.getLastElement();
        center2 = new FPoint(e.getCenterX(), e.getY() + e.getHeight() + 10);
      }
    }

    placeHolders.add(
        new ImpliciteSequencePlaceHolder(ownerPattern, draggedPattern, center1.x, center1.y));
    placeHolders.add(
        new ImpliciteSequencePlaceHolder(ownerPattern, draggedPattern, center2.x, center2.y, true));
  }