private void executeInTransaction(final Resource resource, final Shell shell) {
    boolean requiredStart =
        ModelerCore.startTxn(true, true, "Update Cost Statistics", this); // $NON-NLS-1$
    boolean succeeded = false;
    try {
      internalExecute(resource, shell);

      succeeded = true;
    } finally {
      // if we started the txn, commit it.
      if (requiredStart) {
        if (succeeded) {
          ModelerCore.commitTxn();
        } else {
          ModelerCore.rollbackTxn();
        }
      }
    }
  }
  /* (non-Javadoc)
   * @See org.teiid.designer.ui.wizards.INewModelWizardContributor#doFinish(org.teiid.designer.core.workspace.ModelResource, org.eclipse.core.runtime.IProgressMonitor)
   */
  @Override
  public void doFinish(ModelResource modelResource, IProgressMonitor monitor) {
    String transactionName =
        Util.getString("TransformationLinkContributor.transactionName"); // $NON-NLS-1$
    boolean started = ModelerCore.startTxn(transactionName, this);
    boolean succeeded = false;
    try {
      IStructuralCopyTreePopulator populator = transformationLinkPage.getTreePopulator();
      TreeViewer viewer = transformationLinkPage.getViewer();
      Map extraProperties =
          transformationLinkPage.isClearSupportsUpdate()
              ? MAP_CLEAR_SUPPORTS_UPDATES
              : MAP_KEEP_SUPPORTS_UPDATES;
      if ((populator != null) && (viewer != null)) {

        // all nodes selected, copy all:
        populator.copyModel(
            (ModelResource) viewer.getInput(),
            modelResource,
            extraProperties,
            transformationLinkPage.isCopyAllDescriptions(),
            monitor);
      }
      succeeded = true;
    } catch (Exception ex) {
      String message =
          UiConstants.Util.getString(
              "TransformationLinkContributor.doFinishError", //$NON-NLS-1$
              modelResource.getItemName());
      UiConstants.Util.log(IStatus.ERROR, ex, message);
    } finally {
      if (started) {
        if (succeeded) {
          ModelerCore.commitTxn();
        } else {
          ModelerCore.rollbackTxn();
        }
      }
    }
  }
  private void executeCommand(
      final ObjectDeleteCommand odcDeleteCommand,
      final EObject[] eObjects,
      TransactionSettings ts) {

    if (odcDeleteCommand == null) {
      createObjectDeleteCommand();
    }

    String tempString = UiConstants.Util.getString(DELETE_ONE_TITLE_KEY);
    if (eObjects.length > 1) {
      tempString = UiConstants.Util.getString(DELETE_MANY_TITLE_KEY, eObjects.length);
    }
    final String deleteTitle = tempString;

    WorkspaceModifyOperation operation =
        new WorkspaceModifyOperation() {
          @Override
          public void execute(final IProgressMonitor monitor) {

            if (monitor instanceof SubProgressMonitor) {
              ((SubProgressMonitor) monitor).getWrappedProgressMonitor().setTaskName(deleteTitle);
            }

            monitor.beginTask(CoreStringUtil.Constants.EMPTY_STRING, 100);
            monitor.worked(5);
            // execute the command
            IStatus status = odcDeleteCommand.execute(monitor);

            setResult(status);
          }
        };

    // start the txn
    ts.setSource(this);
    boolean started =
        ModelerCore.startTxn(
            ts.isSignificant(), ts.isUndoable(), ts.getDescription(), ts.getSource());

    boolean succeeded = false;

    try {
      ProgressMonitorDialog progressDialog =
          new ProgressMonitorDialog(Display.getDefault().getActiveShell());

      // run the operation
      progressDialog.run(true, true, operation);
      if (!progressDialog.getProgressMonitor().isCanceled()) {
        succeeded = true;
      }

      if (!getStatus().isOK()) {
        UiConstants.Util.log(getStatus());
      }
    } catch (Exception e) {
      UiConstants.Util.log(IStatus.ERROR, e, e.getMessage());
    } finally {
      if (started) {
        if (succeeded) {
          ModelerCore.commitTxn();
        } else {
          ModelerCore.rollbackTxn();
        }
      }
    }
  }
  @Override
  protected void doRun() {
    if (descriptor != null) {

      Shell shell = super.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell();
      ModelResource modelResource = null;
      boolean continuing = true;
      try {
        modelResource = ModelerCore.getModelEditor().findModelResource(sibling);
      } catch (Exception ex) {
        String msg = getPluginUtils().getString(PROBLEM, new Object[] {descriptor});
        getPluginUtils().log(IStatus.ERROR, ex, msg);
        continuing = false;
      }

      // BML 9/16/04  ----------------------------
      // ModelObjectAction caches a selection, however, this instance does not.
      // Need to create a temporary selection to pass into the wizards, either an EObject
      // or a model resource.
      ISelection tempSelection = null;
      if (sibling.eContainer() != null) {
        tempSelection = new StructuredSelection(sibling.eContainer());
      } else {
        ModelResource mr = ModelUtilities.getModelResourceForModelObject(sibling);
        if (mr != null) tempSelection = new StructuredSelection(mr);
      }
      // --------------------------------------------

      if (continuing) {
        // We need to insure that all containers (especially Transformation & MappingClassSet
        // containers) are loaded/created
        // prior to new child transaction.  This insures undo works.
        ModelUtilities.initializeModelContainers(
            modelResource, "New Sibling Added", this); // $NON-NLS-1$

        if (NewModelObjectWizardManager.isObjectDescriptorValid(
            shell, descriptor, modelResource, tempSelection)) {

          //                   System.out.println("[NewSiblingAction.doRun] will run the
          // wizard");//$NON-NLS-1$

          // Defect 18433 - The XMLDocumentWizard was changed to insure that all work was done one a
          // single thread
          // and that wizard managed a single transaction to insure UNDO capability
          // (i.e. started, committed, canceled/rolledBack)
          // if there is a wizard, use it:
          NewModelObjectWizardManager.processObjectDescriptor(
              shell, descriptor, modelResource, tempSelection);

        } else {

          // if no wizard, create the new objects here
          //                   System.out.println("[NewSiblingAction.doRun] will do create txn");
          // //$NON-NLS-1$
          boolean started =
              ModelerCore.startTxn(
                  true,
                  UiConstants.Util.getString("NewSiblingAction.undoLabel", descriptor.getLabel()),
                  this); //$NON-NLS-1$
          boolean succeeded = false;
          EObject newObj = null;
          try {
            boolean undoable = true;

            newObj = ModelerCore.getModelEditor().createNewSiblingFromCommand(sibling, descriptor);

            // Defect 18433 - BML 8/31/05 - Added this manager and INewModelObjectHelper interface
            // to give arbitary
            // plugins the change to contribute more work following the creation of a new object
            // In the case of a Virtual Group, we needed to create the transformation for that table
            // so it didn't
            // get lazily created as another "Undo" event. (i.e. TransformationNotificationListener,
            // EditAction,, etc.)
            // If Helper exists, ask for helpCreate(newObj)
            // The helper also has the opportunity to change/override the "Undo" state of the
            // transaction

            undoable = NewModelObjectHelperManager.helpCreate(newObj, null);
            if (!undoable) ModelerCore.getCurrentUoW().setUndoable(false);

            succeeded = true;
          } catch (ModelerCoreException theException) {
            String msg = getPluginUtils().getString(PROBLEM, new Object[] {descriptor});
            getPluginUtils().log(IStatus.ERROR, theException, msg);
            setEnabled(false);
          } finally {
            if (started) {
              if (succeeded) {
                String newObjName = ModelerCore.getModelEditor().getName(newObj);
                if (newObjName != null) {
                  ModelerCore.getCurrentUoW()
                      .setDescription(
                          UiConstants.Util.getString(
                              "NewSiblingAction.undoLabel", newObjName)); // $NON-NLS-1$
                }
                ModelerCore.commitTxn();
              } else {
                ModelerCore.rollbackTxn();
              }
            }
          }
        }
      }
    }
  }
  private EObject createViewProcedureInTxn(
      ModelResource modelResource, RelationalViewProcedure viewProcedure) {
    EObject newTable = null;

    boolean requiredStart =
        ModelerCore.startTxn(true, true, Messages.createRelationalViewProcedureTitle, this);
    boolean succeeded = false;
    try {
      ModelEditor editor =
          ModelEditorManager.getModelEditorForFile(
              (IFile) modelResource.getCorrespondingResource(), true);
      if (editor != null) {
        boolean isDirty = editor.isDirty();

        RelationalViewModelFactory factory = new RelationalViewModelFactory();

        RelationalModel relModel = new RelationalModel("dummy"); // $NON-NLS-1$
        relModel.addChild(viewProcedure);

        factory.build(modelResource, relModel, new NullProgressMonitor());

        if (!isDirty && editor.isDirty()) {
          editor.doSave(new NullProgressMonitor());
        }
        succeeded = true;

        for (Object child : modelResource.getEObjects()) {
          EObject eObj = (EObject) child;
          if (ModelerCore.getModelEditor()
              .getName(eObj)
              .equalsIgnoreCase(this.relationalViewProcedure.getName())) {
            newTable = eObj;
            break;
          }
        }
      }
    } catch (Exception e) {
      MessageDialog.openError(
          Display.getCurrent().getActiveShell(),
          Messages.createRelationalViewProcedureExceptionMessage,
          e.getMessage());
      IStatus status =
          new Status(
              IStatus.ERROR,
              UiConstants.PLUGIN_ID,
              Messages.createRelationalViewProcedureExceptionMessage,
              e);
      UiConstants.Util.log(status);

      return null;
    } finally {
      // if we started the txn, commit it.
      if (requiredStart) {
        if (succeeded) {
          ModelerCore.commitTxn();
        } else {
          ModelerCore.rollbackTxn();
        }
      }
    }

    return newTable;
  }