/** {@inheritDoc} */
    @Override
    protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info)
        throws ExecutionException {
      // Remove elements whose container is getting copied.
      // ClipboardSupportUtil.getCopyElements(getObjectsToBeDuplicated());

      // Perform the copy and update the references.
      EcoreUtil.Copier copier = new TableCopier(getAllDuplicatedObjectsMap());
      copier.copy(TableToDuplicate);
      copier.copyReferences();

      EObject duplicateTable = copier.get(TableToDuplicate);
      Resource targetResource =
          getNotationResourceForTable(((Table) duplicateTable).getContext(), getEditingDomain());
      Resource diTargetResource =
          getDiResourceForTable(((Table) duplicateTable).getContext(), getEditingDomain());

      if (targetResource != null) {
        targetResource.getContents().add(duplicateTable);

        if (diTargetResource != null) {
          try {
            IPageManager pageManager =
                ServiceUtilsForResource.getInstance().getIPageManager(diTargetResource);
            pageManager.addPage(duplicateTable);
          } catch (ServiceException e) {
            Activator.log.error(e);
          }
        } else {
          Activator.log.error(
              "It was not possible to find the di resource where to add the Table page",
              null); //$NON-NLS-1$
        }
      } else {
        Activator.log.warn(
            "It was not possible to find the Resource with the target EObject"); //$NON-NLS-1$
        targetResource = TableToDuplicate.eResource();
        if (targetResource != null) {
          Activator.log.error(
              "It was not possible to find the Resource with the source Table",
              null); //$NON-NLS-1$
          targetResource.getContents().add(duplicateTable);
          if (diTargetResource != null) {
            try {
              IPageManager pageManager =
                  ServiceUtilsForResource.getInstance().getIPageManager(diTargetResource);
              pageManager.addPage(duplicateTable);
            } catch (ServiceException e) {
              Activator.log.error(e);
            }
          } else {
            Activator.log.error(
                "It was not possible to find the di resource where to add the Table page",
                null); //$NON-NLS-1$
          }
        }
      }
      return CommandResult.newOKCommandResult(getAllDuplicatedObjectsMap());
    }
    private CommandResult createDiagram() throws ServiceException {
      Resource modelResource = UmlUtils.getUmlResource(modelSet);
      Resource notationResource = getNotationResource(modelSet, owner, element);
      if (notationResource == null) {
        return CommandResult.newErrorCommandResult(
            "Cannot create a diagram on the selected element (ReadOnly?)");
      }
      Resource diResource = DiModelUtils.getDiResource(modelSet);

      if (owner == null) {
        owner = getRootElement(modelResource);
        attachModelToResource(owner, modelResource);
      }

      service = ElementEditServiceUtils.getCommandProvider(owner);
      if (service == null) {
        // Something isn't right ...
        return null;
      }

      try {
        clientContext = TypeContext.getContext();
      } catch (ServiceException e) {
        Activator.log.error(e);
      }
      if (clientContext == null) {
        // Something isn't right ...
        return null;
      }

      rule = PolicyChecker.getCurrent().getOwningRuleFor(prototype, owner);
      if (rule == null) {
        // Something isn't right ...
        return null;
      }

      element = owner;
      if (rule.getNewModelPath() != null) {
        // We have a path for the root auto-creation
        for (ModelAutoCreate auto : rule.getNewModelPath()) {
          EReference ref = auto.getFeature();
          String type = auto.getCreationType();
          if (ref.isMany()) {
            element = create(element, ref, type);
          } else {
            EObject temp = (EObject) element.eGet(ref);
            if (temp != null) {
              element = temp;
            } else {
              element = create(element, ref, type);
            }
          }
        }
      }

      if (rule.getSelectDiagramRoot() != null) {
        // We have a path for the root auto-selection
        for (RootAutoSelect auto : rule.getSelectDiagramRoot()) {
          EReference ref = auto.getFeature();
          element = (EObject) element.eGet(ref);
        }
      }

      if (name == null) {
        name =
            openDiagramNameDialog(
                prototype.isNatural()
                    ? getDefaultDiagramName()
                    : "New" + prototype.getLabel().replace(" ", ""));
      }
      // canceled
      if (name == null) {
        return CommandResult.newCancelledCommandResult();
      }

      Diagram diagram = doCreateDiagram(notationResource, owner, element, prototype, name);

      if (diagram != null) {
        IPageManager pageManager =
            ServiceUtilsForResource.getInstance().getIPageManager(diResource);
        pageManager.addPage(diagram);
        return CommandResult.newOKCommandResult(diagram);
      }

      return CommandResult.newCancelledCommandResult();
    }