1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.jdt.core.*; 14 import org.eclipse.jdt.core.IJavaElement; 15 import org.eclipse.jdt.core.JavaModelException; 16 17 21 public class BecomeWorkingCopyOperation extends JavaModelOperation { 22 23 IProblemRequestor problemRequestor; 24 25 29 public BecomeWorkingCopyOperation(CompilationUnit workingCopy, IProblemRequestor problemRequestor) { 30 super(new IJavaElement[] {workingCopy}); 31 this.problemRequestor = problemRequestor; 32 } 33 protected void executeOperation() throws JavaModelException { 34 35 CompilationUnit workingCopy = getWorkingCopy(); 37 JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(workingCopy, true, true, this.problemRequestor); 38 workingCopy.openWhenClosed(workingCopy.createElementInfo(), this.progressMonitor); 39 40 if (!workingCopy.isPrimary()) { 41 JavaElementDelta delta = new JavaElementDelta(getJavaModel()); 43 delta.added(workingCopy); 44 addDelta(delta); 45 } else { 46 if (workingCopy.getResource().isAccessible()) { 47 JavaElementDelta delta = new JavaElementDelta(getJavaModel()); 49 delta.changed(workingCopy, IJavaElementDelta.F_PRIMARY_WORKING_COPY); 50 addDelta(delta); 51 } else { 52 JavaElementDelta delta = new JavaElementDelta(this.getJavaModel()); 54 delta.added(workingCopy, IJavaElementDelta.F_PRIMARY_WORKING_COPY); 55 addDelta(delta); 56 } 57 } 58 59 this.resultElements = new IJavaElement[] {workingCopy}; 60 } 61 64 protected CompilationUnit getWorkingCopy() { 65 return (CompilationUnit)getElementToProcess(); 66 } 67 70 public boolean isReadOnly() { 71 return true; 72 } 73 74 } 75 | Popular Tags |