コード例 #1
0
  /** {@inheritDoc} */
  @Override
  protected void doExecute() {
    // ResetClipboard (in case of multi-paste)
    domain.setClipboard(clipboard);

    paste.execute();
  }
コード例 #2
0
 /** Add the created invoked object to its selected parent */
 protected void addParameter(Parameter createdParameter) {
   TransactionalEditingDomain editingdomain = EditorUtils.getTransactionalEditingDomain();
   // Let the command find the relation on its own.
   Command addCmd =
       AddCommand.create(
           editingdomain, parameterOwner, null, Collections.singleton(createdParameter));
   addCmd.execute();
 }
コード例 #3
0
 /** Execute a command within the editing domain. */
 public void executeViaUndoManager(String label, Command command) {
   if (command.canExecute()) {
     if (undoManager != null) {
       undoManager.beginRecording(this, label);
       command.execute();
       undoManager.endRecording(this);
     } else executeViaStack(command);
   }
 }
コード例 #4
0
  public void execute() {
    // FIXME: Related to CompoundCommand vs StrictCompoundCommand.
    // Sometimes, canExecute() is not called, and the command is not prepared
    if (!isPrepared) {
      prepare();
      isPrepared = true;
    }

    if (needsCreate) {
      view.getStyles().add(style);
    }
    command.execute();
  }
コード例 #5
0
  /**
   * Drop a semantic element and create the corresponding view in the given container
   *
   * @param newContainer Semantic container
   * @param semanticElement Element to drop
   * @param containerView Container view
   * @param moveSemanticElement True to move the dropped semantic element or false to just show the
   *     element on a diagram
   */
  private void drop(
      final Element newContainer,
      final Element semanticElement,
      final DSemanticDecorator containerView,
      boolean moveSemanticElement) {
    final Session session = SessionManager.INSTANCE.getSession(newContainer);
    final Element oldContainer = semanticElement.getOwner();
    if (moveSemanticElement && oldContainer != newContainer) {
      // Manage stereotypes and profiles
      final List<Stereotype> stereotypesToApply = Lists.newArrayList();
      for (final Stereotype stereotype : semanticElement.getAppliedStereotypes()) {
        stereotypesToApply.add(stereotype);
      }

      // Move the semantic element to the selected container
      final TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
      // The feature is set to null because the domain will deduce it
      Command cmd = AddCommand.create(domain, newContainer, null, semanticElement);
      if (cmd.canExecute()) {
        cmd.execute();
      }
      cmd = RemoveCommand.create(domain, oldContainer, null, semanticElement);
      if (cmd.canExecute()) {
        cmd.execute();
      }

      if (semanticElement instanceof UseCase) {
        // Reset the current element as subject
        cmd =
            SetCommand.create(
                domain,
                semanticElement,
                UMLPackage.Literals.USE_CASE__SUBJECT,
                SetCommand.UNSET_VALUE);
        if (cmd.canExecute()) {
          cmd.execute();
        }
        final List<Element> subjects = new ArrayList<Element>();
        subjects.add(newContainer);
        cmd =
            SetCommand.create(
                domain, semanticElement, UMLPackage.Literals.USE_CASE__SUBJECT, subjects);
        if (cmd.canExecute()) {
          cmd.execute();
        }
      }
      // Apply stereotypes on dropped element and apply the necessary
      // profiles automatically
      StereotypeServices.INSTANCE.applyAllStereotypes(semanticElement, stereotypesToApply);

      // Check if profile should be unapplied
      for (final Stereotype stereotype : stereotypesToApply) {
        StereotypeServices.INSTANCE.unapplyProfile(oldContainer, stereotype);
      }
    }

    // Show the semantic element on the diagram
    showView(
        semanticElement,
        containerView,
        session,
        "[self.getContainerView(newContainerView)/]"); //$NON-NLS-1$
  }