protected Command chainGuideAttachmentCommand(
      Request request, LogicSubpart part, Command cmd, boolean horizontal) {
    Command result = cmd;

    // Attach to guide, if one is given
    Integer guidePos =
        (Integer)
            request
                .getExtendedData()
                .get(
                    horizontal
                        ? SnapToGuides.KEY_HORIZONTAL_GUIDE
                        : SnapToGuides.KEY_VERTICAL_GUIDE);
    if (guidePos != null) {
      int alignment =
          ((Integer)
                  request
                      .getExtendedData()
                      .get(
                          horizontal
                              ? SnapToGuides.KEY_HORIZONTAL_ANCHOR
                              : SnapToGuides.KEY_VERTICAL_ANCHOR))
              .intValue();
      ChangeGuideCommand cgm = new ChangeGuideCommand(part, horizontal);
      cgm.setNewGuide(findGuideAt(guidePos.intValue(), horizontal), alignment);
      result = result.chain(cgm);
    }

    return result;
  }
  /**
   * Returns a composite command with the given initial command and the RegionContainer specific
   * auto-size commands to propagate the auto-size to the regions.
   *
   * @param request the initial request
   * @param autoSizeCommand the initial command
   * @return a composite command with the initial command and the region container specific
   *     additional commands.
   */
  protected Command getRegionContainerAutoSizeCommand(Request request, Command autoSizeCommand) {
    IDiagramElementEditPart host = (IDiagramElementEditPart) getHost();
    TransactionalEditingDomain domain = host.getEditingDomain();
    CompositeTransactionalCommand ctc =
        new CompositeTransactionalCommand(
            domain,
            Messages.RegionContainerResizableEditPolicy_regionContainerAutoSizeCommandLabel);
    ctc.add(new CommandProxy(autoSizeCommand));
    Command regionContainerAutoSizeCommand = new ICommandProxy(ctc);

    // Propagate the auto-size request to the regions.
    Request req = new Request();
    req.setType(request.getType());
    req.getExtendedData().put(REGION_AUTO_SIZE_PROPAGATOR, host);

    Object object = request.getExtendedData().get(REGION_AUTO_SIZE_PROPAGATOR);
    for (EditPart regionPart : getRegionParts()) {
      if (object != regionPart) {
        ctc.add(new CommandProxy(regionPart.getCommand(req)));
      }
    }

    ctc.add(
        CommandFactory.createICommand(
            domain, new RegionContainerUpdateLayoutOperation((Node) host.getModel())));
    return regionContainerAutoSizeCommand;
  }
 /**
  * Extended request data key to hold editpart visual id. Add visual id of edited editpart to
  * extended data of the request so command switch can decide what kind of diagram element is being
  * edited. It is done in those cases when it's not possible to deduce diagram element kind from
  * domain element.
  *
  * @generated
  */
 public Command getCommand(Request request) {
   if (request instanceof ReconnectRequest) {
     Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
     if (view instanceof View) {
       Integer id = new Integer(OrocosComponentModelVisualIDRegistry.getVisualID((View) view));
       request.getExtendedData().put(VISUAL_ID_KEY, id);
     }
   }
   return super.getCommand(request);
 }
 /**
  * Extended request data key to hold editpart visual id. Add visual id of edited editpart to
  * extended data of the request so command switch can decide what kind of diagram element is being
  * edited. It is done in those cases when it's not possible to deduce diagram element kind from
  * domain element. Add the reoriented view to the request extended data so that the view currently
  * edited can be distinguished from other views of the same element and these latter possibly
  * removed if they become inconsistent after reconnect
  *
  * @generated
  */
 @SuppressWarnings("unchecked")
 public Command getCommand(Request request) {
   if (request instanceof ReconnectRequest) {
     Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
     if (view instanceof View) {
       Integer id = new Integer(UMLVisualIDRegistry.getVisualID((View) view));
       request.getExtendedData().put(VISUAL_ID_KEY, id);
       request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, (View) view);
     }
   }
   return super.getCommand(request);
 }
 /**
  * Extended request data key to hold editpart visual id. Add visual id of edited editpart to
  * extended data of the request so command switch can decide what kind of diagram element is being
  * edited. It is done in those cases when it's not possible to deduce diagram element kind from
  * domain element.
  *
  * @generated
  */
 public Command getCommand(Request request) {
   if (request instanceof ReconnectRequest) {
     Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel();
     if (view instanceof View) {
       Integer id =
           new Integer(
               edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part
                   .ClassDiagram_MAVOVisualIDRegistry.getVisualID((View) view));
       request.getExtendedData().put(VISUAL_ID_KEY, id);
     }
   }
   return super.getCommand(request);
 }
 public static Rectangle fixMessageBounds(
     Rectangle newBounds, Request cvr, LifelineEditPart host) {
   Object oc1 =
       getFirstElement(
           cvr.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION));
   Object oc2 =
       getFirstElement(
           cvr.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2));
   if (oc1 != null
       && oc2 != null
       && (oc1 instanceof MessageOccurrenceSpecification
           || oc2 instanceof MessageOccurrenceSpecification)) {
     Point start = null, end = null;
     Rectangle bounds = null;
     if (oc1 instanceof InteractionFragment) {
       start = SequenceUtil.findLocationOfEvent(host, (InteractionFragment) oc1, true);
     }
     if (oc2 instanceof InteractionFragment) {
       end = SequenceUtil.findLocationOfEvent(host, (InteractionFragment) oc2, true);
     }
     if (start != null && end != null) {
       bounds = (start.y < end.y) ? new Rectangle(start, end) : new Rectangle(end, start);
     }
     if (bounds != null) {
       IFigure parentFigure = host.getFigure();
       Point parentFigDelta = parentFigure.getBounds().getLocation().getCopy().negate();
       parentFigure.translateToRelative(bounds);
       bounds.translate(parentFigDelta);
       if (bounds.y != newBounds.y || newBounds.height != bounds.height) {
         newBounds.y = bounds.y;
         newBounds.height = bounds.height;
       }
     }
   }
   return newBounds;
 }
  protected Command chainGuideDetachmentCommand(
      Request request, LogicSubpart part, Command cmd, boolean horizontal) {
    Command result = cmd;

    // Detach from guide, if none is given
    Integer guidePos =
        (Integer)
            request
                .getExtendedData()
                .get(
                    horizontal
                        ? SnapToGuides.KEY_HORIZONTAL_GUIDE
                        : SnapToGuides.KEY_VERTICAL_GUIDE);
    if (guidePos == null) result = result.chain(new ChangeGuideCommand(part, horizontal));

    return result;
  }