@Override
  protected IProgressMonitor executeCommand(final RefactorCommand command) {
    IProgressMonitor monitor = super.executeCommand(command);

    try {
      // Save refactored resource
      final ModelEditor editor = ModelerCore.getModelEditor();

      // defect 16527 - check that a resource is a file before casting
      IResource res = this.dest.findMember(MoveRefactorAction.this.resSelectedResource.getName());
      if (res instanceof IFile) {
        final IFile file = (IFile) res;
        ModelResource model = editor.findModelResource(file);
        if (model != null) {
          if (model.getEmfResource().isModified()) {
            // If an editor is open, call doSave on it, else tell the model to save
            org.teiid.designer.ui.editors.ModelEditor openEditor =
                ModelEditorManager.getModelEditorForFile(file, false);
            if (openEditor != null) {
              openEditor.doSave(monitor);
            } else {
              model.save(monitor, true);
            }
          }
        }
      } // endif -- move was on a file

      // Save modified dependent resources
      for (final Iterator iter = ((ResourceMoveCommand) command).getDependentResources().iterator();
          iter.hasNext(); ) {
        IFile file = (IFile) iter.next();
        ModelResource model = editor.findModelResource(file);
        if (model != null) {
          if (model.getEmfResource().isModified() && !model.isReadOnly()) {
            // If an editor is open, call doSave on it, else tell the model to save
            org.teiid.designer.ui.editors.ModelEditor openEditor =
                ModelEditorManager.getModelEditorForFile(file, false);
            if (openEditor != null) {
              openEditor.doSave(monitor);
            } else {
              model.save(monitor, true);
            }
          }
        }
      }
    } catch (final ModelWorkspaceException err) {
      ModelerCore.Util.log(err);
    }

    return monitor;
  }
  private ModelTableEditor getTableEditor() {
    ModelTableEditor result = null;
    IEditorPart editor = getActiveEditor();

    if (editor instanceof ModelEditor) {
      ModelEditor modelEditor = (ModelEditor) editor;
      IEditorPart subEditor = modelEditor.getActiveEditor();

      if (subEditor instanceof ModelTableEditor) {
        result = (ModelTableEditor) subEditor;
      }
    }

    return result;
  }
  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;
  }