1 11 package org.eclipse.jdt.internal.corext.buildpath; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IPath; 19 20 import org.eclipse.jdt.core.IClasspathEntry; 21 import org.eclipse.jdt.core.IJavaProject; 22 23 import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; 24 25 public class CPJavaProject { 26 27 public static CPJavaProject createFromExisting(IJavaProject javaProject) throws CoreException { 28 List classpathEntries= ClasspathModifier.getExistingEntries(javaProject); 29 return new CPJavaProject(classpathEntries, javaProject.getOutputLocation()); 30 } 31 32 private final List fCPListElements; 33 private IPath fDefaultOutputLocation; 34 35 public CPJavaProject(List cpListElements, IPath defaultOutputLocation) { 36 fCPListElements= cpListElements; 37 fDefaultOutputLocation= defaultOutputLocation; 38 } 39 40 public CPJavaProject createWorkingCopy() { 41 List newList= new ArrayList (fCPListElements.size()); 42 for (Iterator iterator= fCPListElements.iterator(); iterator.hasNext();) { 43 CPListElement element= (CPListElement)iterator.next(); 44 newList.add(element.copy()); 45 } 46 return new CPJavaProject(newList, fDefaultOutputLocation); 47 } 48 49 public CPListElement get(int index) { 50 return (CPListElement)fCPListElements.get(index); 51 } 52 53 public IClasspathEntry[] getClasspathEntries() { 54 IClasspathEntry[] result= new IClasspathEntry[fCPListElements.size()]; 55 int i= 0; 56 for (Iterator iterator= fCPListElements.iterator(); iterator.hasNext();) { 57 CPListElement element= (CPListElement)iterator.next(); 58 result[i]= element.getClasspathEntry(); 59 i++; 60 } 61 return result; 62 } 63 64 public CPListElement getCPElement(CPListElement element) { 65 return ClasspathModifier.getClasspathEntry(fCPListElements, element); 66 } 67 68 public List getCPListElements() { 69 return fCPListElements; 70 } 71 72 public IPath getDefaultOutputLocation() { 73 return fDefaultOutputLocation; 74 } 75 76 public IJavaProject getJavaProject() { 77 return ((CPListElement)fCPListElements.get(0)).getJavaProject(); 78 } 79 80 public int indexOf(CPListElement element) { 81 return fCPListElements.indexOf(element); 82 } 83 84 public void setDefaultOutputLocation(IPath path) { 85 fDefaultOutputLocation= path; 86 } 87 } 88 | Popular Tags |