Examples of CompositeTransactionalCommand


Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

    TransactionalEditingDomain editingDomain = TransactionUtil
        .getEditingDomain(element);
    if (editingDomain == null) {
      return UnexecutableCommand.INSTANCE;
    }
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
        editingDomain, "Set Values"); //$NON-NLS-1$
    for (int i = 0; i < values.length; i++) {
      command.compose(getModificationCommand(element, features[i],
          values[i]));
    }
    return command;
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

      ICommand command = elementType.getEditCommand(completedRequest);
      if (command != null) {
        if (!(command instanceof CompositeTransactionalCommand)) {
          TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
              .getEditingDomain();
          command = new CompositeTransactionalCommand(editingDomain,
              command.getLabel()).compose(command);
        }
        semanticCommand = new ICommandProxy(command);
      }
    }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

    List operationSet = getOperationSet();
    if (operationSet.isEmpty()) {
      return UnexecutableCommand.INSTANCE;
    }
    Iterator editParts = operationSet.iterator();
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
        getEditingDomain(), getCommandLabel());
    while (editParts.hasNext()) {
      EditPart editPart = (EditPart) editParts.next();
      Command curCommand = editPart.getCommand(request);
      if (curCommand != null) {
        command.compose(new CommandProxy(curCommand));
      }
    }
    if (command.isEmpty() || command.size() != operationSet.size()) {
      return UnexecutableCommand.INSTANCE;
    }
    return new ICommandProxy(command);
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

  /**
   * @generated
   */
  protected Command getDestroyElementCommand(DestroyElementRequest req) {
    View view = (View) getHost().getModel();
    CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
        getEditingDomain(), null);
    cmd.setTransactionNestingEnabled(false);
    EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
    if (annotation == null) {
      // there are indirectly referenced children, need extra commands: false
      addDestroyChildNodesCommand(cmd);
      addDestroyShortcutsCommand(cmd, view);
      // delete host element
      cmd.add(new DestroyElementCommand(req));
    } else {
      cmd.add(new DeleteCommand(getEditingDomain(), view));
    }
    return getGEFWrapper(cmd.reduce());
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

  /**
   * @generated
   */
  protected Command getDestroyElementCommand(DestroyElementRequest req) {
    View view = (View) getHost().getModel();
    CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
        getEditingDomain(), null);
    cmd.setTransactionNestingEnabled(false);
    EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
    if (annotation == null) {
      // there are indirectly referenced children, need extra commands: false
      addDestroyChildNodesCommand(cmd);
      addDestroyShortcutsCommand(cmd, view);
      // delete host element
      cmd.add(new DestroyElementCommand(req));
    } else {
      cmd.add(new DeleteCommand(getEditingDomain(), view));
    }
    return getGEFWrapper(cmd.reduce());
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

  /**
   * @generated
   */
  protected Command getDestroyElementCommand(DestroyElementRequest req) {
    View view = (View) getHost().getModel();
    CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
        getEditingDomain(), null);
    cmd.setTransactionNestingEnabled(false);
    EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
    if (annotation == null) {
      // there are indirectly referenced children, need extra commands: true
      addDestroyChildNodesCommand(cmd);
      addDestroyShortcutsCommand(cmd, view);
      // delete host element
      cmd.add(new DestroyElementCommand(req));
    } else {
      cmd.add(new DeleteCommand(getEditingDomain(), view));
    }
    return getGEFWrapper(cmd.reduce());
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

  /**
   * @generated
   */
  protected Command getDestroyElementCommand(DestroyElementRequest req) {
    View view = (View) getHost().getModel();
    CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
        getEditingDomain(), null);
    cmd.setTransactionNestingEnabled(false);
    for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
      Edge incomingLink = (Edge) it.next();
      if (DispelVisualIDRegistry.getVisualID(incomingLink) == ConnectionExpressionEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(
            incomingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
        continue;
      }
    }
    for (Iterator<?> it = view.getSourceEdges().iterator(); it.hasNext();) {
      Edge outgoingLink = (Edge) it.next();
      if (DispelVisualIDRegistry.getVisualID(outgoingLink) == ConnectionExpressionEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(
            outgoingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
        continue;
      }
    }
    EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
    if (annotation == null) {
      // there are indirectly referenced children, need extra commands: true
      addDestroyChildNodesCommand(cmd);
      addDestroyShortcutsCommand(cmd, view);
      // delete host element
      cmd.add(new DestroyElementCommand(req));
    } else {
      cmd.add(new DeleteCommand(getEditingDomain(), view));
    }
    return getGEFWrapper(cmd.reduce());
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

    }
    // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to,
    // or those we have potential matches to, and thus need to be recreated, preserving size/location information.
    orphaned.addAll(knownViewChildren);
    //
    CompositeTransactionalCommand boundsCommand = new CompositeTransactionalCommand(
        host().getEditingDomain(),
        DiagramUIMessages.SetLocationCommand_Label_Resize);
    ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(
        childDescriptors.size());
    for (DispelNodeDescriptor next : childDescriptors) {
      String hint = DispelVisualIDRegistry.getType(next.getVisualID());
      IAdaptable elementAdapter = new CanonicalElementAdapter(
          next.getModelElement(), hint);
      CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(
          elementAdapter, Node.class, hint, ViewUtil.APPEND, false,
          host().getDiagramPreferencesHint());
      viewDescriptors.add(descriptor);

      LinkedList<View> possibleMatches = potentialViews.get(next);
      if (possibleMatches != null) {
        // from potential matches, leave those that were not eventually used for some other NodeDescriptor (i.e. those left as orphaned)
        possibleMatches.retainAll(knownViewChildren);
      }
      if (possibleMatches != null && !possibleMatches.isEmpty()) {
        View originalView = possibleMatches.getFirst();
        knownViewChildren.remove(originalView); // remove not to copy properties of the same view again and again
        // add command to copy properties
        if (originalView instanceof Node) {
          if (((Node) originalView).getLayoutConstraint() instanceof Bounds) {
            Bounds b = (Bounds) ((Node) originalView)
                .getLayoutConstraint();
            boundsCommand.add(new SetBoundsCommand(boundsCommand
                .getEditingDomain(), boundsCommand.getLabel(),
                descriptor, new Rectangle(b.getX(), b.getY(), b
                    .getWidth(), b.getHeight())));
          } else if (((Node) originalView).getLayoutConstraint() instanceof Location) {
            Location l = (Location) ((Node) originalView)
                .getLayoutConstraint();
            boundsCommand.add(new SetBoundsCommand(boundsCommand
                .getEditingDomain(), boundsCommand.getLabel(),
                descriptor, new Point(l.getX(), l.getY())));
          } else if (((Node) originalView).getLayoutConstraint() instanceof Size) {
            Size s = (Size) ((Node) originalView)
                .getLayoutConstraint();
            boundsCommand.add(new SetBoundsCommand(boundsCommand
                .getEditingDomain(), boundsCommand.getLabel(),
                descriptor, new Dimension(s.getWidth(), s
                    .getHeight())));
          }
        }
      }
    }

    boolean changed = deleteViews(orphaned.iterator());
    //
    CreateViewRequest request = getCreateViewRequest(viewDescriptors);
    Command cmd = getCreateViewCommand(request);
    if (cmd != null && cmd.canExecute()) {
      SetViewMutabilityCommand.makeMutable(
          new EObjectAdapter(host().getNotationView())).execute();
      executeCommand(cmd);
      if (boundsCommand.canExecute()) {
        executeCommand(new ICommandProxy(boundsCommand.reduce()));
      }
      @SuppressWarnings("unchecked")
      List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject();
      createdViews.addAll(nl);
    }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

    TransactionalEditingDomain editingDomain = TransactionUtil
        .getEditingDomain(element);
    if (editingDomain == null) {
      return UnexecutableCommand.INSTANCE;
    }
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
        editingDomain, "Set Values"); //$NON-NLS-1$
    for (int i = 0; i < values.length; i++) {
      command.compose(getModificationCommand(element,
          editableFeatures[i], values[i]));
    }
    return command;
  }
View Full Code Here

Examples of org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand

  /**
   * @generated
   */
  protected Command getDestroyElementCommand(DestroyElementRequest req) {
    View view = (View) getHost().getModel();
    CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
        getEditingDomain(), null);
    cmd.setTransactionNestingEnabled(false);
    EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
    if (annotation == null) {
      // there are indirectly referenced children, need extra commands: false
      addDestroyShortcutsCommand(cmd, view);
      // delete host element
      cmd.add(new DestroyElementCommand(req));
    } else {
      cmd.add(new DeleteCommand(getEditingDomain(), view));
    }
    return getGEFWrapper(cmd.reduce());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.