1 11 12 package org.eclipse.jdt.internal.corext.refactoring.changes; 13 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.core.runtime.SubProgressMonitor; 19 20 import org.eclipse.core.resources.IResource; 21 22 import org.eclipse.ui.ide.undo.ResourceDescription; 23 24 import org.eclipse.ltk.core.refactoring.Change; 25 26 public class UndoablePackageDeleteChange extends DynamicValidationStateChange { 27 28 private final List fPackageDeletes; 29 30 public UndoablePackageDeleteChange(String name, List packageDeletes) { 31 super(name); 32 fPackageDeletes= packageDeletes; 33 } 34 35 public Change perform(IProgressMonitor pm) throws CoreException { 36 int count= fPackageDeletes.size(); 37 pm.beginTask("", count * 3); ResourceDescription[] packageDeleteDescriptions= new ResourceDescription[fPackageDeletes.size()]; 39 for (int i= 0; i < fPackageDeletes.size(); i++) { 40 IResource resource= (IResource) fPackageDeletes.get(i); 41 packageDeleteDescriptions[i]= ResourceDescription.fromResource(resource); 42 pm.worked(1); 43 } 44 45 DynamicValidationStateChange result= (DynamicValidationStateChange) super.perform(new SubProgressMonitor(pm, count)); 46 47 for (int i= 0; i < fPackageDeletes.size(); i++) { 48 IResource resource= (IResource) fPackageDeletes.get(i); 49 ResourceDescription resourceDescription= packageDeleteDescriptions[i]; 50 resourceDescription.recordStateFromHistory(resource, new SubProgressMonitor(pm, 1)); 51 result.add(new UndoDeleteResourceChange(resourceDescription)); 52 } 53 return result; 54 } 55 } 56
| Popular Tags
|