/** @generated */
 protected void doConfigure(Assign newElement, IProgressMonitor monitor, IAdaptable info)
     throws ExecutionException {
   IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
   ConfigureRequest configureRequest =
       new ConfigureRequest(getEditingDomain(), newElement, elementType);
   configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
   configureRequest.addParameters(getRequest().getParameters());
   ICommand configureCommand = elementType.getEditCommand(configureRequest);
   if (configureCommand != null && configureCommand.canExecute()) {
     configureCommand.execute(monitor, info);
   }
 }
 /** @generated */
 protected void doConfigure(
     ScopeToCompositeActionMapping newElement, IProgressMonitor monitor, IAdaptable info)
     throws ExecutionException {
   IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
   ConfigureRequest configureRequest =
       new ConfigureRequest(getEditingDomain(), newElement, elementType);
   configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
   configureRequest.addParameters(getRequest().getParameters());
   configureRequest.setParameter(CreateRelationshipRequest.SOURCE, getSource());
   configureRequest.setParameter(CreateRelationshipRequest.TARGET, getTarget());
   ICommand configureCommand = elementType.getEditCommand(configureRequest);
   if (configureCommand != null && configureCommand.canExecute()) {
     configureCommand.execute(monitor, info);
   }
 }
 private EObject create(EObject origin, EReference reference, String typeID) {
   IElementType itype = ElementTypeRegistry.getInstance().getType(typeID);
   CreateElementRequest request = new CreateElementRequest(origin, itype, reference);
   ICommand command = service.getEditCommand(request);
   IStatus status = null;
   try {
     status = command.execute(null, null);
   } catch (ExecutionException e) {
     return null;
   }
   if (!status.isOK()) {
     return null;
   }
   CommandResult result = command.getCommandResult();
   if (result == null) {
     return null;
   }
   return (EObject) result.getReturnValue();
 }
  /**
   * Performs a <code>DropObjectsRequest</code> in a modal context thread. Verifies that the diagram
   * refreshes on the UI thread.
   *
   * @throws Exception if an unexpected exception occurs
   */
  public void test_drop_modalContextThread() throws Exception {

    // Open the test fixture diagram
    getTestFixture().openDiagram();
    final DiagramEditPart diagramEditPart = getDiagramEditPart();

    // Create an AND gate in the semantic model
    ICommand andCommand =
        new AbstractTransactionalCommand(
            getTestFixture().getEditingDomain(), "Create AND Gate", null) { // $NON-NLS-1$

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

            AndGate newElement =
                (AndGate)
                    SemanticPackage.eINSTANCE
                        .getEFactoryInstance()
                        .create(SemanticPackage.eINSTANCE.getAndGate());

            ContainerElement semanticElement =
                (ContainerElement) diagramEditPart.resolveSemanticElement();

            semanticElement.getChildren().add(newElement);
            return CommandResult.newOKCommandResult(newElement);
          }
        };

    andCommand.execute(new NullProgressMonitor(), null);
    AndGate andGate = (AndGate) andCommand.getCommandResult().getReturnValue();

    // Get the initial number of edit parts on the diagram
    List primaryEditParts = diagramEditPart.getPrimaryEditParts();
    int initialEditPartCount = primaryEditParts.size();

    // Get the command to drop the AND gate onto the diagram
    Point dropLocation = ICanonicalShapeCompartmentLayout.UNDEFINED.getLocation();
    DropObjectsRequest request = new DropObjectsRequest();
    request.setObjects(Collections.singletonList(andGate));
    request.setAllowedDetail(DND.DROP_COPY);
    request.setLocation(dropLocation);

    Command command = diagramEditPart.getCommand(request);
    final CommandProxy proxy = new CommandProxy(command);

    // Execute the command in a forking progress monitor dialog
    IRunnableWithProgress runnable =
        new IRunnableWithProgress() {

          public void run(IProgressMonitor monitor)
              throws InvocationTargetException, InterruptedException {

            try {
              OperationHistoryFactory.getOperationHistory().execute(proxy, monitor, null);

            } catch (ExecutionException e) {
              throw new InvocationTargetException(e);
            }
          }
        };

    new ProgressMonitorDialog(null).run(true, true, runnable);

    // Verify that a new edit part has been added to the diagram for the AND gate
    primaryEditParts = getDiagramEditPart().getPrimaryEditParts();

    assertTrue(
        "Size of primary edit parts should have increased.",
        primaryEditParts.size() > initialEditPartCount); // $NON-NLS-1$

    IGraphicalEditPart andGateEditPart = null;
    for (Iterator i = primaryEditParts.iterator(); i.hasNext(); ) {
      IGraphicalEditPart nextEditPart = (IGraphicalEditPart) i.next();

      if (andGate.equals(nextEditPart.resolveSemanticElement())) {
        andGateEditPart = nextEditPart;
        break;
      }
    }
    assertNotNull("Expected a new edit part for the AND gate", andGateEditPart); // $NON-NLS-1$
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.emf.common.command.Command#execute()
  */
 public void execute() {
   try {
     gmfCommand.execute(new NullProgressMonitor(), null);
   } catch (ExecutionException e) {
   }
 }