1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.core.runtime.IPath; 14 import org.eclipse.jdt.core.IClasspathEntry; 15 import org.eclipse.jdt.core.IJavaElement; 16 import org.eclipse.jdt.core.IJavaModelStatus; 17 import org.eclipse.jdt.core.IJavaProject; 18 import org.eclipse.jdt.core.JavaModelException; 19 20 25 public class SetClasspathOperation extends ChangeClasspathOperation { 26 27 IClasspathEntry[] newRawClasspath; 28 IPath newOutputLocation; 29 JavaProject project; 30 31 34 public SetClasspathOperation( 35 JavaProject project, 36 IClasspathEntry[] newRawClasspath, 37 IPath newOutputLocation, 38 boolean canChangeResource) { 39 40 super(new IJavaElement[] { project }, canChangeResource); 41 this.project = project; 42 this.newRawClasspath = newRawClasspath; 43 this.newOutputLocation = newOutputLocation; 44 } 45 46 49 protected void executeOperation() throws JavaModelException { 50 checkCanceled(); 51 try { 52 this.project.getPerProjectInfo().setClasspath(this.newRawClasspath, this.newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null); 54 55 classpathChanged(this.project); 57 58 if (this.canChangeResources && this.project.saveClasspath(this.newRawClasspath, this.newOutputLocation)) 60 setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE); 61 } finally { 62 done(); 63 } 64 } 65 66 public String toString(){ 67 StringBuffer buffer = new StringBuffer (20); 68 buffer.append("SetClasspathOperation\n"); buffer.append(" - classpath : "); buffer.append("{"); for (int i = 0; i < this.newRawClasspath.length; i++) { 72 if (i > 0) buffer.append(","); IClasspathEntry element = this.newRawClasspath[i]; 74 buffer.append(" ").append(element.toString()); } 76 buffer.append("\n - output location : "); buffer.append(this.newOutputLocation.toString()); 78 return buffer.toString(); 79 } 80 81 public IJavaModelStatus verify() { 82 IJavaModelStatus status = super.verify(); 83 if (!status.isOK()) 84 return status; 85 return ClasspathEntry.validateClasspath( this.project, this.newRawClasspath, this.newOutputLocation); 86 } 87 88 } 89 | Popular Tags |