private HashMap<?, ?> createCurrentExportPackageMap() {
   // Dummy hash map created in order to return a defined but empty map
   HashMap<?, ?> packageFragments = new HashMap<>(0);
   // Get the model
   IPluginModelBase model = getModel();
   // Ensure model is defined
   if (model == null) {
     return packageFragments;
   }
   // Get the underlying resource
   IResource resource = model.getUnderlyingResource();
   // Ensure resource is defined
   if (resource == null) {
     return packageFragments;
   }
   // Get the project
   IProject project = resource.getProject();
   // Ensure the project is defined
   if (project == null) {
     return packageFragments;
   }
   // Ensure the project is a Java project
   try {
     if (project.hasNature(JavaCore.NATURE_ID) == false) {
       return packageFragments;
     }
   } catch (CoreException e) {
     return packageFragments;
   }
   // Get the Java project
   IJavaProject javaProject = JavaCore.create(project);
   // Ensure the Java project is defined
   if (javaProject == null) {
     return packageFragments;
   }
   // Get the current packages associated with the export package header
   Vector<?> currentExportPackages = null;
   if (fHeader == null) {
     currentExportPackages = new Vector<>();
   } else {
     currentExportPackages = fHeader.getPackageNames();
   }
   // Get a hashtable of all the package fragments that are allowed to
   // be added to the current export package header
   // Generally, all package fragments contained in the same Java project
   // as the plugin manifest file
   // No duplicates are allowed and all current packages are excluded
   return PDEJavaHelper.getPackageFragmentsHash(
       javaProject, currentExportPackages, allowJavaPackages());
 }
  private IPackageFragment getPackageFragment(ISelection sel) {
    if (sel instanceof IStructuredSelection) {
      IStructuredSelection selection = (IStructuredSelection) sel;
      if (selection.size() != 1) return null;

      IBaseModel model = getPage().getModel();
      if (!(model instanceof IPluginModelBase)) return null;

      return PDEJavaHelper.getPackageFragment(
          ((PackageObject) selection.getFirstElement()).getName(),
          ((IPluginModelBase) model).getPluginBase().getId(),
          getPage().getPDEEditor().getCommonProject());
    }
    return null;
  }