private IRuntimeClasspathEntry convertClasspathEntry(IClasspathEntry entry) {
    if (entry == null) return null;

    IPath srcPath = entry.getSourceAttachmentPath();
    if (srcPath != null && srcPath.segmentCount() > 0) {
      IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath());
      rte.setSourceAttachmentPath(srcPath);
      rte.setSourceAttachmentRootPath(entry.getSourceAttachmentRootPath());
      return rte;
    }
    return null;
  }
  private void addProjectSourceContainers(IProject project, ArrayList result) throws CoreException {
    if (project == null || !project.hasNature(JavaCore.NATURE_ID)) return;

    IJavaProject jProject = JavaCore.create(project);
    result.add(JavaRuntime.newProjectRuntimeClasspathEntry(jProject));

    IClasspathEntry[] entries = jProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++) {
      IClasspathEntry entry = entries[i];
      if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        IRuntimeClasspathEntry rte = convertClasspathEntry(entry);
        if (rte != null) result.add(rte);
      }
    }
  }