Esempio n. 1
0
  public FBounds layoutPattern(LayoutManager manager) {

    double height = timerEvent.getHeight() + LayoutManager.HSPACING;
    double width = timerEvent.getWidth();

    double eventX;

    if (getNestedPatterns().isEmpty()) {
      height += placeHolder.getHeight();
      width = Math.max(width, placeHolder.getWidth());

      placeHolder.setCenter(0, height / 2 - placeHolder.getHeight() / 2);

      eventX = 0;
    } else {
      Pattern p = getNestedPattern();
      FBounds pSize = p.getBounds();
      eventX = -pSize.width / 2 + manager.getOriginOffset(p).x;

      height += pSize.height;
      width = Math.max(width, pSize.width);
      manager.setPatternPosition(p, -pSize.width / 2, height / 2 - pSize.height);
    }

    timerEvent.setCenter(eventX, -height / 2 + timerEvent.getHeight() / 2);

    getBorder().setClientRectangle(-width / 2, -height / 2, width, height);
    return getBorder().getBounds();
  }
Esempio n. 2
0
  protected void createElementsImpl() {
    setBorder(new GroupBorder());
    getBorder().setLabelText(getDefaultName());

    timerEvent = ContentElement.createTimerEvent();
    timerEvent.setLabelText("Timer"); // NOI18N
    appendElement(timerEvent);

    placeHolder = new PlaceHolderElement();
    appendElement(placeHolder);

    BpelEntity activity = ((OnAlarmPick) getOMReference()).getActivity();

    if (activity != null) {
      Pattern p = getModel().createPattern(activity);
      p.setParent(this);
    }
  }
Esempio n. 3
0
 public Area createSelection() {
   Area res = new Area(getBorder().getShape());
   res.subtract(new Area(timerEvent.getShape()));
   return res;
 }
  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));
  }