예제 #1
0
  /** @generated */
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {

    Port newElement = UMLFactory.eINSTANCE.createPort();

    EObject target = getElementToEdit();
    ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
    if (data.isPermitted()) {
      if (data.isPathDefined()) {
        if (!data.execute(target, newElement)) {
          return CommandResult.newErrorCommandResult(
              "Failed to follow the policy-specified for the insertion of the new element");
        }
      } else {

        StructuredClassifier qualifiedTarget = (StructuredClassifier) target;
        qualifiedTarget.getOwnedAttributes().add(newElement);
      }
    } else {
      return CommandResult.newErrorCommandResult(
          "The active policy restricts the addition of this element");
    }

    ElementInitializers.getInstance().init_Port_3069(newElement);

    doConfigure(newElement, monitor, info);

    ((CreateElementRequest) getRequest()).setNewElement(newElement);
    return CommandResult.newOKCommandResult(newElement);
  }
예제 #2
0
  /** @generated */
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {

    Package newElement = UMLFactory.eINSTANCE.createPackage();

    Package owner = (Package) getElementToEdit();
    owner.getPackagedElements().add(newElement);

    ElementInitializers.getInstance().init_Package_3200(newElement);

    doConfigure(newElement, monitor, info);

    ((CreateElementRequest) getRequest()).setNewElement(newElement);
    return CommandResult.newOKCommandResult(newElement);
  }
  /** @generated */
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {
    if (!canExecute()) {
      throw new ExecutionException("Invalid arguments in create link command"); // $NON-NLS-1$
    }

    InterfaceRealization newElement = UMLFactory.eINSTANCE.createInterfaceRealization();
    getContainer().getPackagedElements().add(newElement);
    newElement.getClients().add(getSource());
    newElement.setContract(getTarget());
    ElementInitializers.getInstance().init_InterfaceRealization_4006(newElement);
    doConfigure(newElement, monitor, info);
    ((CreateElementRequest) getRequest()).setNewElement(newElement);
    return CommandResult.newOKCommandResult(newElement);
  }