/** Handle resize InteractionOperand {@inheritDoc} */
 @Override
 protected Command getResizeCommand(ChangeBoundsRequest request) {
   if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
     EditPart parent = getHost().getParent().getParent();
     return parent.getCommand(request);
   } else {
     if (this.getHost() instanceof InteractionOperandEditPart
         && this.getHost().getParent()
             instanceof CombinedFragmentCombinedFragmentCompartmentEditPart) {
       InteractionOperandEditPart currentIOEP = (InteractionOperandEditPart) this.getHost();
       CombinedFragmentCombinedFragmentCompartmentEditPart compartEP =
           (CombinedFragmentCombinedFragmentCompartmentEditPart) this.getHost().getParent();
       // if first interaction operand and resize direction is NORTH
       if (this.getHost() == OperandBoundsComputeHelper.findFirstIOEP(compartEP)
           && (request.getResizeDirection() & PositionConstants.NORTH) != 0) {
         return getHost().getParent().getParent().getCommand(request);
       } else {
         int heightDelta = request.getSizeDelta().height();
         if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
           return OperandBoundsComputeHelper.createIOEPResizeCommand(
               currentIOEP, heightDelta, compartEP, PositionConstants.NORTH);
         } else if ((request.getResizeDirection() & PositionConstants.SOUTH) != 0) {
           return OperandBoundsComputeHelper.createIOEPResizeCommand(
               currentIOEP, heightDelta, compartEP, PositionConstants.SOUTH);
         }
       }
     }
     return null;
   }
 }
  @Override
  protected Command createChangeConstraintCommand(
      ChangeBoundsRequest request, EditPart child, Object constraint) {

    BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand();
    BControl part = (BControl) child.getModel();
    cmd.setModel(child.getModel());
    cmd.setConstraint((Rectangle) constraint);
    Command result = cmd;

    if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) {
      Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE);
      if (guidePos != null) {
        result = chainGuideAttachmentCommand(request, part, result, true);
      } else if (part.getHorizontalGuide() != null) {
        // SnapToGuides didn't provide a horizontal guide, but this part
        // is attached
        // to a horizontal guide. Now we check to see if the part is
        // attached to
        // the guide along the edge being resized. If that is the case,
        // we need to
        // detach the part from the guide; otherwise, we leave it alone.
        int alignment = part.getHorizontalGuide().getAlignment(part);
        int edgeBeingResized = 0;
        if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) edgeBeingResized = -1;
        else edgeBeingResized = 1;
        if (alignment == edgeBeingResized)
          result = result.chain(new ChangeGuideCommand(part, true));
      }
    }

    if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
      Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE);
      if (guidePos != null) {
        result = chainGuideAttachmentCommand(request, part, result, false);
      } else if (part.getVerticalGuide() != null) {
        int alignment = part.getVerticalGuide().getAlignment(part);
        int edgeBeingResized = 0;
        if ((request.getResizeDirection() & PositionConstants.WEST) != 0) edgeBeingResized = -1;
        else edgeBeingResized = 1;
        if (alignment == edgeBeingResized)
          result = result.chain(new ChangeGuideCommand(part, false));
      }
    }

    if (request.getType().equals(REQ_MOVE_CHILDREN)
        || request.getType().equals(REQ_ALIGN_CHILDREN)) {
      result = chainGuideAttachmentCommand(request, part, result, true);
      result = chainGuideAttachmentCommand(request, part, result, false);
      result = chainGuideDetachmentCommand(request, part, result, true);
      result = chainGuideDetachmentCommand(request, part, result, false);
    }

    return result;
  }
 private ChangeBoundsRequest initConstrainedRequest(ChangeBoundsRequest request) {
   ChangeBoundsRequest req = new ChangeBoundsRequest();
   req.setConstrainedResize(true);
   req.setConstrainedMove(true);
   req.setType(request.getType());
   req.setResizeDirection(request.getResizeDirection());
   req.getExtendedData().put(REGION_RESIZE_PROPAGATOR, getHost());
   req.getExtendedData()
       .put(
           SiriusResizeTracker.CHILDREN_MOVE_MODE_KEY,
           request.getExtendedData().get(SiriusResizeTracker.CHILDREN_MOVE_MODE_KEY));
   req.getExtendedData().put(REGION_RESIZE_INITIAL_REQUEST, request);
   return req;
 }
 // @unused
 public static Request getNewSourceFeedbackRequest(Request request, ShapeNodeEditPart editPart) {
   if (request instanceof ChangeBoundsRequest) {
     ChangeBoundsRequest currRequest = (ChangeBoundsRequest) request;
     Dimension oldDelta = currRequest.getSizeDelta();
     Dimension newDelta =
         getSizeDeltaToFitAnchors(editPart, oldDelta, PreserveAnchorsPositionCommand.PRESERVE_Y);
     // Information for creating a new ChangeBoundsRequest has been taken
     // from org.eclipse.gef.editpolicies.ResizableEditPolicy
     ChangeBoundsRequest newRequest = new ChangeBoundsRequest();
     newRequest.setMoveDelta(currRequest.getMoveDelta());
     newRequest.setSizeDelta(newDelta);
     newRequest.setLocation(currRequest.getLocation());
     newRequest.setExtendedData(currRequest.getExtendedData());
     newRequest.setResizeDirection(currRequest.getResizeDirection());
     newRequest.setType(currRequest.getType());
     return newRequest;
   } else {
     return request;
   }
 }
 /**
  * Shows or updates feedback for a change bounds request. The request is updated by the way so
  * that the shape stays a square.
  *
  * @param request the request
  */
 @Override
 protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
   // adapt the request for a square resize
   Point move = request.getMoveDelta();
   Dimension delta = request.getSizeDelta();
   int dH = delta.height;
   int dW = delta.width;
   int signum = 0;
   if (dH <= 0 && dW <= 0) {
     signum = -1;
   } else {
     signum = 1;
   }
   int positiveResize = Math.max(dH, dW);
   if (positiveResize <= 0) {
     if (dH == 0) {
       positiveResize = -dW;
     } else if (dW == 0) {
       positiveResize = -dH;
     } else {
       positiveResize = Math.min(-dH, -dW);
     }
   }
   int newDH = signum * positiveResize;
   int newDW = newDH;
   int dir = request.getResizeDirection();
   // adjust new position if impacted by resizing
   if ((dir & PositionConstants.NORTH) > 0) {
     move.y += dH - newDH;
   }
   if ((dir & PositionConstants.WEST) > 0) {
     move.x += dW - newDW;
   }
   request.setMoveDelta(move);
   delta.height = newDH;
   delta.width = newDW;
   super.showChangeBoundsFeedback(request);
 }