/**
   * Override to : -> Put in "Movin state" this edit part and all its children which are Group
   * Framework concern
   */
  @Override
  public Command getCommand(Request request) {
    if (request instanceof ChangeBoundsRequest) {
      final ChangeBoundsRequest req = (ChangeBoundsRequest) request;
      CompositeCommand cc = new CompositeCommand("GroupNotifyingEditPolicy ");
      for (final EditPart part : Utils.getTargetedEditPart(req)) {
        ICommand cmd =
            getGroupRequestAdvisor()
                .notifyGroupFramework(
                    new AbstractGroupRequest(
                        (IGraphicalEditPart) getHost(),
                        Utils.getChangeBoundsRequestCopy(req, part),
                        part,
                        getTargetGroupDescriptor(part)) {

                      public GroupRequestType getGroupRequestType() {
                        return GroupRequestType.MOVE;
                      }
                    });
        if (cmd != null && cmd.canExecute()) {
          cc.compose(cmd);
        }
      }
      stopMovingPartState(req);
      if (cc != null && cc.canExecute()) {
        return new ICommandProxy(cc);
      }
    }
    return null;
  }
 @Override
 protected Command getCommand() {
   final EditPart targetEditPart = getTargetEditPart();
   final CompositeCommand compositeCommand =
       new CompositeCommand(
           Messages.OccurrenceSpecificationCreationTool_CreateOccurrenceSpecification);
   EditPart timeline;
   if (targetEditPart instanceof FullStateInvariantEditPartCN) {
     final FullStateInvariantEditPartCN fullStateInvariantEditPartCN =
         (FullStateInvariantEditPartCN) targetEditPart;
     timeline =
         EditPartUtils.findParentEditPartWithId(
             targetEditPart, FullLifelineTimelineCompartmentEditPartCN.VISUAL_ID);
     compositeCommand.add(
         new CutAndInsertOccurrenceSpecificationCommand(
             fullStateInvariantEditPartCN, getLocation(), false));
   } else if (targetEditPart instanceof CompactStateInvariantEditPartCN) {
     final CompactStateInvariantEditPartCN compactStateInvariantEditPartCN =
         (CompactStateInvariantEditPartCN) targetEditPart;
     timeline =
         EditPartUtils.findParentEditPartWithId(
             targetEditPart, CompactLifelineCompartmentEditPartCN.VISUAL_ID);
     compositeCommand.add(
         new AddOccurrenceSpecificationInCompactLifelineCommand(
             compactStateInvariantEditPartCN, getLocation()));
   } else {
     return UnexecutableCommand.INSTANCE;
   }
   final Command updateLayoutCommand =
       timeline.getCommand(AbstractTimelineLayoutPolicy.UPDATE_LAYOUT_REQUEST);
   compositeCommand.add(new CommandProxy(updateLayoutCommand));
   return new ICommandProxy(compositeCommand);
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.papyrus.commands.ICreationCommand#createDiagram(org.eclipse.emf.ecore.resource.Resource, org.eclipse.emf.ecore.EObject,
   * org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype, java.lang.String)
   */
  @Override
  public final Diagram createDiagram(
      ModelSet modelSet, EObject owner, EObject element, ViewPrototype prototype, String name) {
    ICommand createCmd = getCreateDiagramCommand(modelSet, owner, element, prototype, name);
    TransactionalEditingDomain dom = modelSet.getTransactionalEditingDomain();
    CompositeCommand cmd = new CompositeCommand("Create diagram");
    cmd.add(createCmd);
    cmd.add(new OpenDiagramCommand(dom, createCmd));

    try {

      IStatus status =
          CheckedOperationHistory.getInstance().execute(cmd, new NullProgressMonitor(), null);
      if (status.isOK()) {
        CommandResult result = cmd.getCommandResult();
        Object returnValue = result.getReturnValue();

        // CompositeCommands should always return a collection
        if (returnValue instanceof Collection<?>) {
          for (Object returnElement : (Collection<?>) returnValue) {
            if (returnElement instanceof Diagram) {
              return (Diagram) returnElement;
            }
          }
        }
      } else if (status.getSeverity() != IStatus.CANCEL) {
        StatusManager.getManager().handle(status, StatusManager.SHOW);
      }
    } catch (ExecutionException ex) {
      Activator.log.error(ex);
    }

    return null;
  }
  public static void removeMessageFlow(
      TransactionalEditingDomain editingDomain,
      Message event,
      AbstractCatchMessageEvent target,
      DiagramEditPart dep) {

    EditPart ep = findEditPart(dep, target);
    CompositeCommand command = new CompositeCommand("Remove MessageFlows");

    for (Object connection : ((AbstractGraphicalEditPart) ep).getTargetConnections()) {
      if (connection instanceof MessageFlowEditPart) {
        MessageFlowEditPart connectionPart = (MessageFlowEditPart) connection;
        MessageFlow flow = (MessageFlow) connectionPart.resolveSemanticElement();
        SetCommand c =
            new SetCommand(
                editingDomain,
                flow.getTarget(),
                ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT,
                null);
        editingDomain.getCommandStack().execute(c);
        command.add(new DeleteCommand(editingDomain, connectionPart.getPrimaryView()));
        DestroyElementRequest req =
            new DestroyElementRequest(
                editingDomain, connectionPart.resolveSemanticElement(), false);
        DestroyElementCommand rmComd = new DestroyElementCommand(req);
        command.add(rmComd);
      }
    }

    dep.getDiagramEditDomain()
        .getDiagramCommandStack()
        .execute(new ICommandProxy(command.reduce()));
    dep.getDiagramEditDomain().getDiagramCommandStack().flush();
    dep.refresh();
  }
  /** {@inheritDoc} */
  @Override
  public ICommand create(ConfigureRequest request) {

    ICommand configureCommand = null;

    Shell shell = Display.getDefault().getActiveShell();
    // Start dialog to identify the new part type
    Property part = (Property) request.getElementToConfigure();
    Package partPkg = part.getNearestPackage();

    CreateOrSelectBlockPropertyTypeDialog dialog =
        new CreateOrSelectBlockPropertyTypeDialog(shell, partPkg);
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {

      final ICommand typeCreationCommand = dialog.getNewTypeCreateCommand();
      final Type partType = (Type) dialog.getExistingType();

      // Abort if type creation command exists but is not executable
      if ((typeCreationCommand != null) && (!typeCreationCommand.canExecute())) {
        return cancelCommand(request);
      } else {
        configureCommand = CompositeCommand.compose(configureCommand, typeCreationCommand);
      }

      // Create the configure command that will set the part type
      ICommand setTypeCommand =
          new ConfigureElementCommand(request) {

            @Override
            protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
                throws ExecutionException {

              Property part = (Property) getElementToEdit();
              if (partType != null) {
                part.setType(partType);
              } else {
                Type newType = (Type) GMFCommandUtils.getCommandEObjectResult(typeCreationCommand);
                part.setType(newType);
              }
              return CommandResult.newOKCommandResult(part);
            }
          };

      configureCommand = CompositeCommand.compose(configureCommand, setTypeCommand);
      return configureCommand;
    }

    return cancelCommand(request);
  }
Exemple #6
0
 /** @generated */
 protected ICommand getInsteadCommand(IEditCommandRequest req) {
   ICommand epCommand = (ICommand) req.getParameter(EDIT_POLICY_COMMAND);
   req.setParameter(EDIT_POLICY_COMMAND, null);
   ICommand ehCommand = super.getInsteadCommand(req);
   if (epCommand == null) {
     return ehCommand;
   }
   if (ehCommand == null) {
     return epCommand;
   }
   CompositeCommand command = new CompositeCommand(null);
   command.add(epCommand);
   command.add(ehCommand);
   return command;
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.papyrus.layout.LayouttoolInterface#execute(java.util.Map)
  */
 public void execute(Map<EditPart, Rectangle> map) {
   TransactionalEditingDomain ted = getTransactionalEditingDomain();
   if (ted != null) {
     CommandStack cs = null;
     // Add a command to apply new bounds of all nodes
     for (Entry<EditPart, Rectangle> s : map.entrySet()) {
       SetBoundsCommand boundsCommand =
           new SetBoundsCommand(
               ted,
               "apply layout",
               new EObjectAdapter((View) s.getKey().getModel()),
               s.getValue());
       command.add(boundsCommand);
       GraphicalEditPart gep = (GraphicalEditPart) s.getKey();
       if (cs == null) {
         cs = gep.getViewer().getEditDomain().getCommandStack();
       }
     }
     try {
       // Execute layout commands with animation
       Animation.markBegin();
       cs.execute(new ICommandProxy(command));
       Animation.run(1000);
     } catch (Exception e) {
       Activator.getDefault().log(e.getMessage() + " : Cannot apply new bounds of all nodes", e);
     }
   }
 }
 /**
  * Removes the bend points.
  *
  * @param edge the edge
  */
 public void removeBendPoints(Edge edge) {
   SetConnectionBendpointsCommand scbc =
       new SetConnectionBendpointsCommand(getTransactionalEditingDomain());
   scbc.setEdgeAdapter(new EObjectAdapter((View) edge));
   scbc.setNewPointList(new PointList(), new Point(), new Point());
   command.add(scbc);
 }
 @Override
 protected ICommand getInsteadCommand(final IEditCommandRequest req) {
   final ICommand epCommand =
       (ICommand) req.getParameter(PartitioningBaseEditHelper.EDIT_POLICY_COMMAND);
   req.setParameter(PartitioningBaseEditHelper.EDIT_POLICY_COMMAND, null);
   final ICommand ehCommand = super.getInsteadCommand(req);
   if (epCommand == null) {
     return ehCommand;
   }
   if (ehCommand == null) {
     return epCommand;
   }
   final CompositeCommand command = new CompositeCommand(null);
   command.add(epCommand);
   command.add(ehCommand);
   return command;
 }
 public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
   CollaborationUse cu = doAdapt(element);
   if (cu == null) {
     return UnexecutableCommand.INSTANCE;
   }
   if (newString == null) {
     return UnexecutableCommand.INSTANCE;
   }
   Collaboration oldType = cu.getType();
   String oldName = cu.getName() == null ? "" : cu.getName(); // $NON-NLS-1$
   List<Type> types = getTypeProposals(cu);
   try {
     Object[] parsed = COLLABORATION_USE_FORMAT.parse(newString);
     String newName = (String) parsed[0];
     CompositeCommand cc =
         new CompositeCommand(
             CustomMessages.CollaborationUseParser_collaboration_use_name_parser_command);
     if (!oldName.equals(newName)) {
       cc.add(
           new SetValueCommand(
               new SetRequest(cu, UMLPackage.eINSTANCE.getNamedElement_Name(), newName)));
     }
     if (parsed.length < 2) {
       return cc;
     }
     String newType = (String) parsed[1];
     for (Type next : types) {
       if (newType.equals(next.getName()) && !newType.equals(oldType)) {
         cc.add(
             new SetValueCommand(
                 new SetRequest(cu, UMLPackage.eINSTANCE.getCollaborationUse_Type(), next)));
         break;
       }
     }
     return cc;
   } catch (ParseException e) {
   }
   return UnexecutableCommand.INSTANCE;
 }
  @Override
  protected ICommand getBeforeSetCommand(SetRequest request) {

    ICommand setCommand = super.getBeforeSetCommand(request);

    Set<View> viewsToDestroy = new HashSet<View>();

    // Get modified object and retrieve inconsistent view
    EObject modifiedObject = request.getElementToEdit();
    if ((modifiedObject != null)
        && (modifiedObject instanceof Property)
        && (request.getFeature() == UMLPackage.eINSTANCE.getProperty_Aggregation())
        && (request.getValue() != AggregationKind.COMPOSITE_LITERAL)) {

      viewsToDestroy.addAll(getViewsToDestroy(modifiedObject));
    }

    if ((modifiedObject != null)
        && (modifiedObject instanceof Property)
        && (request.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type())
        && (request.getValue() instanceof Type)
        && !((ISpecializationType) SysMLElementTypes.BLOCK)
            .getMatcher()
            .matches((Type) request.getValue())) {

      viewsToDestroy.addAll(getViewsToDestroy(modifiedObject));
    }

    if (!viewsToDestroy.isEmpty()) {
      DestroyDependentsRequest ddr =
          new DestroyDependentsRequest(
              request.getEditingDomain(), request.getElementToEdit(), false);
      ddr.setClientContext(request.getClientContext());
      ddr.addParameters(request.getParameters());
      ICommand destroyViewsCommand = ddr.getDestroyDependentsCommand(viewsToDestroy);
      setCommand = CompositeCommand.compose(setCommand, destroyViewsCommand);
    }

    return setCommand;
  }
  public static void removeMessageFlow(
      TransactionalEditingDomain editingDomain,
      Message event,
      ThrowMessageEvent source,
      DiagramEditPart dep) {
    EditPart ep = findEditPart(dep, source);
    CompositeCommand command = new CompositeCommand("Remove MessageFlows");

    for (Object connection : ((AbstractGraphicalEditPart) ep).getSourceConnections()) {
      if (connection instanceof MessageFlowEditPart) {
        MessageFlowEditPart connectionPart = (MessageFlowEditPart) connection;
        MessageFlow flow = (MessageFlow) connectionPart.resolveSemanticElement();
        if (flow.getTarget().getEvent() == null
            || flow.getTarget().getEvent().equals(event.getName())) {
          List<Message> events = new ArrayList<Message>();
          ModelHelper.findAllEvents(source, events);
          for (Message ev : events) {
            if (ev.eContainer().equals(source) && !ev.equals(event)) {
              if (ev.getTargetProcessExpression() != null
                  && event.getTargetProcessExpression() != null
                  && ev.getTargetProcessExpression()
                      .getContent()
                      .equals(event.getTargetProcessExpression().getContent())
                  && ev.getTargetElementExpression() != null
                  && ev.getTargetElementExpression().getContent() != null
                  && event.getTargetElementExpression() != null
                  && ev.getTargetElementExpression()
                      .getContent()
                      .equals(event.getTargetElementExpression().getContent())) {
                SetCommand setCommand =
                    new SetCommand(
                        editingDomain,
                        ev,
                        ProcessPackage.Literals.MESSAGE__TARGET_PROCESS_EXPRESSION,
                        null);
                editingDomain.getCommandStack().execute(setCommand);
                setCommand =
                    new SetCommand(
                        editingDomain,
                        ev,
                        ProcessPackage.Literals.MESSAGE__TARGET_ELEMENT_EXPRESSION,
                        null);
                editingDomain.getCommandStack().execute(setCommand);
              }
            }
          }
          SetCommand c =
              new SetCommand(
                  editingDomain,
                  flow.getTarget(),
                  ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT,
                  null);
          editingDomain.getCommandStack().execute(c);
          command.add(new DeleteCommand(editingDomain, connectionPart.getPrimaryView()));
          DestroyElementRequest req =
              new DestroyElementRequest(
                  editingDomain, connectionPart.resolveSemanticElement(), false);
          DestroyElementCommand rmComd = new DestroyElementCommand(req);
          command.add(rmComd);
        }
      }
    }
    dep.getDiagramEditDomain()
        .getDiagramCommandStack()
        .execute(new ICommandProxy(command.reduce()));
    dep.getDiagramEditDomain().getDiagramCommandStack().flush();
    dep.refresh();
  }
  /**
   * Given the proper references, it displays the dialog pre-filled with data from the current
   * provider.
   *
   * @param currentNattableModelManager
   * @param axisProvider
   * @param axisProvidersHistory
   * @param axisProvidersHistoryEReference
   * @return
   */
  public Object saveAxisProviderConfig(
      final INattableModelManager currentNattableModelManager,
      final AbstractAxisProvider axisProvider,
      EList<AbstractAxisProvider> axisProvidersHistory,
      EReference axisProvidersHistoryEReference) {
    final AbstractAxisProvider copy = EcoreUtil.copy(axisProvider);

    // We ask the user for a name and description
    String name = axisProvider.getName();
    String description = axisProvider.getDescription();

    final List<String> existingProviderNames = new ArrayList<String>();
    for (AbstractAxisProvider abstractAxisProvider : axisProvidersHistory) {
      existingProviderNames.add(abstractAxisProvider.getName());
    }
    TwoInputDialog dialog =
        new TwoInputDialog(
            Display.getCurrent().getActiveShell(),
            Messages.AbstractSaveCurrentAxisProvidersHandler_0,
            Messages.AbstractSaveCurrentAxisProvidersHandler_1,
            Messages.AbstractSaveCurrentAxisProvidersHandler_2,
            name,
            description,
            new IInputValidator() {

              @Override
              public String isValid(String newText) {
                if (newText == null || newText.equals("")) { // $NON-NLS-1$
                  return Messages.AbstractSaveCurrentAxisProvidersHandler_4;
                } else if (existingProviderNames.contains(newText)) {
                  return Messages.AbstractSaveCurrentAxisProvidersHandler_5;
                }
                return null;
              }
            });
    if (dialog.open() == Dialog.OK) {
      // get the name and the description for the table
      name = dialog.getValue();
      description = dialog.getValue_2();

      copy.setName(name);
      copy.setDescription(description);

      final List<AbstractAxisProvider> historyCopy =
          new ArrayList<AbstractAxisProvider>(axisProvidersHistory);
      historyCopy.add(copy);

      // Create the transactional command
      final CompositeCommand cmd =
          new CompositeCommand("SaveCurrentAxisProvidersHandler"); // $NON-NLS-1$
      final IEditCommandRequest request =
          new SetRequest(
              (TransactionalEditingDomain) getTableEditingDomain(),
              currentNattableModelManager.getTable(),
              axisProvidersHistoryEReference,
              historyCopy);
      final IElementEditService provider =
          ElementEditServiceUtils.getCommandProvider(currentNattableModelManager.getTable());
      cmd.add(provider.getEditCommand(request));
      getTableEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));

      return copy;
    }
    return null;
  }
  /** {@inheritDoc} */
  @Override
  protected ICommand getBeforeDuplicateCommand(DuplicateElementsRequest request) {
    Object additional =
        request.getParameter(IPapyrusDuplicateCommandConstants.ADDITIONAL_DUPLICATED_ELEMENTS);
    // additional element should be a set of elements that will be duplicated. If this is null, the
    // request will be ignored.
    if (!(additional instanceof Set<?>)) {
      return super.getBeforeDuplicateCommand(request);
    }

    Set<Object> duplicatedObjects = ((Set<Object>) additional);
    EObject object = getDuplicatedEObject(request);
    if (object == null || object.eResource() == null) {
      return super.getBeforeDuplicateCommand(request);
    }

    // retrieve the Tables linked to the object
    List<Table> tablesToDuplicate = new ArrayList<Table>();

    ResourceSet resourceSet = object.eResource().getResourceSet();
    ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(resourceSet);
    if (adapter == null) {
      adapter = new ECrossReferenceAdapter();
      resourceSet.eAdapters().add(adapter);
    }

    // do not proceed for graphical elements, which will have evident relationships to Diagrams
    // (owner, etc.)
    // not required for Table
    //		if(object instanceof View) {
    //			return super.getBeforeDuplicateCommand(request);
    //		}

    // check for the element itself
    Collection<Setting> settings = adapter.getInverseReferences(object, false);
    for (Setting setting : settings) {
      EObject value = setting.getEObject();
      if (value instanceof Table) {
        tablesToDuplicate.add((Table) value);
      }
    }

    // check for sub-elements
    for (Iterator<EObject> it = object.eAllContents(); it.hasNext(); ) {
      EObject child = it.next();
      settings = adapter.getInverseReferences(child, false);

      for (Setting setting : settings) {
        EObject value = setting.getEObject();
        if (value instanceof Table) {
          tablesToDuplicate.add((Table) value);
        }
      }
    }

    if (!tablesToDuplicate.isEmpty()) {
      CompositeCommand command = null;
      // create the command for all the Tables that have no command ready
      for (Table TableToDuplicate : tablesToDuplicate) {
        if (!duplicatedObjects.contains(TableToDuplicate)) {
          if (command == null) {
            command =
                new CompositeCommand(
                    "",
                    Arrays.asList(
                        new DuplicateTableCommand(
                            request.getEditingDomain(),
                            "Duplicate Table",
                            TableToDuplicate,
                            request.getAllDuplicatedElementsMap()))); // $NON-NLS-1$ //$NON-NLS-2$
          } else {
            command.add(
                new DuplicateTableCommand(
                    request.getEditingDomain(),
                    "Duplicate Table",
                    TableToDuplicate,
                    request.getAllDuplicatedElementsMap())); // $NON-NLS-1$
          }
          duplicatedObjects.add(TableToDuplicate);
        }
      }

      if (command != null) {
        if (super.getBeforeDuplicateCommand(request) != null) {
          command.add(super.getBeforeDuplicateCommand(request));
          return command.reduce();
        } else {
          return command.reduce();
        }
      }
    }

    return super.getBeforeDuplicateCommand(request);
  }
  /**
   * Gets the show link command from updater link descriptor.
   *
   * @param linkToShow the link to show
   * @param domain2NotationMap the domain2 notation map
   * @param descriptor the descriptor
   * @return the show link command from updater link descriptor
   */
  private ICommand getShowLinkCommandFromUpdaterLinkDescriptor(
      final EObject linkToShow,
      final Domain2Notation domain2NotationMap,
      UpdaterLinkDescriptor descriptor) {
    ConnectorUtils connectorUtils = new ConnectorUtils();

    if (descriptor != null) {

      Set<View> sourceViewList = domain2NotationMap.get(descriptor.getSource());
      Set<View> targetViewList = domain2NotationMap.get(descriptor.getDestination());

      final Set<View> linkSet = domain2NotationMap.get(linkToShow);

      CompositeCommand compositeCommand = new CompositeCommand("Restore All Related Links");
      for (View sourceView : sourceViewList) {
        for (View targetView : targetViewList) {
          if (canDisplayExistingLinkBetweenViews(linkToShow, sourceView, targetView)) {

            if (ConnectorUtils.canDisplayExistingConnectorBetweenViewsAccordingToNestedPaths(
                (Connector) linkToShow, sourceView, targetView)) {
              boolean alreadyDisplayed = false;
              if (linkSet != null) {
                for (View viewLink : linkSet) {
                  boolean linkForViews =
                      isLinkForViews(
                          (org.eclipse.gmf.runtime.notation.Connector) viewLink,
                          sourceView,
                          targetView);
                  alreadyDisplayed = alreadyDisplayed || linkForViews;
                }
              }

              if (!alreadyDisplayed) {
                EditPart sourceEditPart = getEditPartFromView(sourceView);
                EditPart targetEditPart = getEditPartFromView(targetView);

                // If the parts are still null...
                if (sourceEditPart == null || targetEditPart == null) {
                  return null;
                }
                String semanticHint = getSemanticHint(linkToShow);
                CreateConnectionViewRequest.ConnectionViewDescriptor viewDescriptor =
                    new CreateConnectionViewRequest.ConnectionViewDescriptor(
                        descriptor.getSemanticAdapter(),
                        semanticHint,
                        ViewUtil.APPEND,
                        false,
                        ((GraphicalEditPart) getHost()).getDiagramPreferencesHint());
                CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(viewDescriptor);
                ccr.setType(org.eclipse.gef.RequestConstants.REQ_CONNECTION_START);
                ccr.setSourceEditPart(sourceEditPart);
                sourceEditPart.getCommand(ccr);
                ccr.setTargetEditPart(targetEditPart);
                ccr.setType(org.eclipse.gef.RequestConstants.REQ_CONNECTION_END);
                CommandProxy commandProxy = new CommandProxy(targetEditPart.getCommand(ccr));
                compositeCommand.add(commandProxy);
              }
            }
          }
        }
      }
      return compositeCommand;
    }
    return null;
  }
  @Override
  protected ICommand getAfterReorientRelationshipCommand(ReorientRelationshipRequest request) {
    ICommand defaultCommand = super.getAfterReorientRelationshipCommand(request);

    int reorientDirection = request.getDirection();
    Edge reorientedEdgeView = RequestParameterUtils.getReconnectedEdge(request);
    View newEndView = RequestParameterUtils.getReconnectedEndView(request);
    View oppositeEndView =
        (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE)
            ? reorientedEdgeView.getTarget()
            : reorientedEdgeView.getSource();

    // Restrict this advice action to the end of Connector creation gesture (before clicking on
    // target)
    // in order to add SysML specific constraint
    Connector connector = (Connector) request.getRelationship();

    // Restrict action to SysML Connector (meaning owned by Block)
    if (((ISpecializationType) SysMLElementTypes.BLOCK)
        .getMatcher()
        .matches(connector.eContainer())) {

      // If the source or target view is enclosed in a structure encapsulated view, forbid creation.
      if (utils.isCrossingEncapsulation(newEndView, oppositeEndView)
          || utils.isCrossingEncapsulation(oppositeEndView, newEndView)) {
        return UnexecutableCommand.INSTANCE;
      }

      int tmpNestedPathDirection = -1;
      List<Property> tmpNestedPath = Collections.emptyList();

      // Check if new end view is nested
      tmpNestedPathDirection =
          (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE)
              ? SetNestedPathCommand.NESTED_SOURCE
              : SetNestedPathCommand.NESTED_TARGET;
      tmpNestedPath = utils.getNestedPropertyPath(newEndView, oppositeEndView);
      defaultCommand =
          CompositeCommand.compose(
              defaultCommand,
              new SetNestedPathCommand(
                  "Set connector nested source path",
                  request.getRelationship(),
                  request,
                  tmpNestedPath,
                  tmpNestedPathDirection)); //$NON-NLS-0$

      // Check if opposite end view is nested
      tmpNestedPathDirection =
          (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE)
              ? SetNestedPathCommand.NESTED_TARGET
              : SetNestedPathCommand.NESTED_SOURCE;
      tmpNestedPath = utils.getNestedPropertyPath(oppositeEndView, newEndView);
      defaultCommand =
          CompositeCommand.compose(
              defaultCommand,
              new SetNestedPathCommand(
                  "Set connector nested target path",
                  request.getRelationship(),
                  request,
                  tmpNestedPath,
                  tmpNestedPathDirection)); //$NON-NLS-0$
    }

    return defaultCommand;
  }