/**
   * Run as transaction.
   *
   * @param diResourceSet the di resource set
   */
  protected void runAsTransaction(final DiResourceSet diResourceSet) {
    // Get the uml element to which the newly created diagram will be attached.
    // Create the diagram
    final Resource modelResource = diResourceSet.getModelResource();
    TransactionalEditingDomain editingDomain = diResourceSet.getTransactionalEditingDomain();

    AbstractTransactionalCommand command =
        new AbstractTransactionalCommand(
            editingDomain, "Initialize model", Collections.EMPTY_LIST) {

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

            CommandResult commandResult =
                CommandResult.newErrorCommandResult("Error during diagram creation");
            EObject model = getRootElement(modelResource);
            attachModelToResource(model, modelResource);

            initializeModel(model);
            return CommandResult.newOKCommandResult();
          }
        };
    try {
      OperationHistoryFactory.getOperationHistory()
          .execute(command, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
      e.printStackTrace();
    }
  }
  /**
   * @see
   *     org.eclipse.papyrus.core.extension.commands.IModelCreationCommand#createModel(org.eclipse.papyrus.core.utils.DiResourceSet)
   * @param diResourceSet
   */
  public void createModel(final DiResourceSet diResourceSet) {
    TransactionalEditingDomain transactionalEditingDomain =
        diResourceSet.getTransactionalEditingDomain();
    RecordingCommand command =
        new RecordingCommand(transactionalEditingDomain) {

          @Override
          protected void doExecute() {
            runAsTransaction(diResourceSet);
          }
        };
    transactionalEditingDomain.getCommandStack().execute(command);
  }