/**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {

    final List<EObject> exportModelElements = getSelfContainedModelElementTree(event);

    if (exportModelElements.size() > 0) {

      String filePath =
          getFilePathByFileDialog(UiUtil.getNameForModelElement(exportModelElements.get(0)));

      if (filePath == null) {
        return null;
      }

      PreferenceHelper.setPreference(EXPORT_MODEL_PATH, new File(filePath).getParent());

      runCommand(exportModelElements, filePath);
    }

    return null;
  }
  private String getFilePathByFileDialog(String modelElementName) {
    FileDialog dialog =
        new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
    dialog.setFilterNames(FILTER_NAMES);
    dialog.setFilterExtensions(FILTER_EXTS);
    String initialPath =
        PreferenceHelper.getPreference(EXPORT_MODEL_PATH, System.getProperty("user.home"));
    dialog.setFilterPath(initialPath);
    dialog.setOverwrite(true);

    try {
      // String initialFileName = projectSpace.getProjectName() + "@"
      // + projectSpace.getBaseVersion().getIdentifier() + ".ucp";
      String initialFileName = "ModelElement_" + modelElementName + "." + FILE_EXTENSION;
      dialog.setFileName(initialFileName);

    } catch (NullPointerException e) {
      // do nothing
    }

    String filePath = dialog.open();

    return filePath;
  }