Beispiel #1
0
  /**
   * Create a MessageOccurenceSpecification and the call event when a message is created
   *
   * @generated NOT
   */
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {
    if (!canExecute()) {
      throw new ExecutionException("Invalid arguments in create link command"); // $NON-NLS-1$
    }
    InteractionFragment sourceContainer =
        (InteractionFragment)
            getRequest().getParameters().get(SequenceRequestConstant.SOURCE_MODEL_CONTAINER);
    InteractionFragment targetContainer =
        (InteractionFragment)
            getRequest().getParameters().get(SequenceRequestConstant.TARGET_MODEL_CONTAINER);

    Message message =
        CommandHelper.doCreateMessage(
            container,
            MessageSort.SYNCH_CALL_LITERAL,
            getSource(),
            getTarget(),
            sourceContainer,
            targetContainer);
    if (message != null) {
      doConfigure(message, monitor, info);
      ((CreateElementRequest) getRequest()).setNewElement(message);
      return CommandResult.newOKCommandResult(message);
    }

    return CommandResult.newErrorCommandResult(
        "There is now valid container for events"); //$NON-NLS-1$
  }
Beispiel #2
0
  /**
   * Add a condition on the MOS container
   *
   * @generated NOT
   */
  @Override
  public boolean canExecute() {
    if (source == null && target == null) {
      return false;
    }
    if (source != null && false == source instanceof Element) {
      return false;
    }
    if (target != null && false == target instanceof Element) {
      return false;
    }
    if (getSource() == null) {
      return true; // link creation is in progress; source is not defined yet
    }
    // target may be null here but it's possible to check constraint
    if (getContainer() == null) {
      return false;
    }

    if (getSource() != null && getTarget() != null) {
      if (!CommandHelper.hasValidContainer(getRequest())) {
        return false;
      }
    }

    return UMLBaseItemSemanticEditPolicy.getLinkConstraints()
        .canCreateMessage_4003(getContainer(), getSource(), getTarget());
  }