1 11 package org.eclipse.jdt.internal.ui.packageview; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.IAdaptable; 17 18 import org.eclipse.jface.resource.ImageDescriptor; 19 20 import org.eclipse.jdt.core.IClasspathEntry; 21 import org.eclipse.jdt.core.IJavaProject; 22 import org.eclipse.jdt.core.IPackageFragmentRoot; 23 import org.eclipse.jdt.core.JavaModelException; 24 25 import org.eclipse.jdt.internal.ui.JavaPluginImages; 26 27 public class LibraryContainer extends PackageFragmentRootContainer { 28 29 public LibraryContainer(IJavaProject project) { 30 super(project); 31 } 32 33 public boolean equals(Object obj) { 34 if (obj instanceof LibraryContainer) { 35 LibraryContainer other = (LibraryContainer)obj; 36 return getJavaProject().equals(other.getJavaProject()); 37 } 38 return false; 39 } 40 41 public int hashCode() { 42 return getJavaProject().hashCode(); 43 } 44 45 public IAdaptable[] getChildren() { 46 return getPackageFragmentRoots(); 47 } 48 49 50 public ImageDescriptor getImageDescriptor() { 51 return JavaPluginImages.DESC_OBJS_LIBRARY; 52 } 53 54 public String getLabel() { 55 return PackagesMessages.LibraryContainer_name; 56 } 57 58 61 public IPackageFragmentRoot[] getPackageFragmentRoots() { 62 List list= new ArrayList (); 63 try { 64 IPackageFragmentRoot[] roots= getJavaProject().getPackageFragmentRoots(); 65 for (int i= 0; i < roots.length; i++) { 66 IPackageFragmentRoot root= roots[i]; 67 int classpathEntryKind= root.getRawClasspathEntry().getEntryKind(); 68 if (classpathEntryKind == IClasspathEntry.CPE_LIBRARY || classpathEntryKind == IClasspathEntry.CPE_VARIABLE) { 69 list.add(root); 70 } 71 } 72 } catch (JavaModelException e) { 73 } 75 return (IPackageFragmentRoot[]) list.toArray(new IPackageFragmentRoot[list.size()]); 76 } 77 } 78 | Popular Tags |