1 11 package org.eclipse.ltk.core.refactoring; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.OperationCanceledException; 16 import org.eclipse.core.runtime.PlatformObject; 17 import org.eclipse.core.runtime.SubProgressMonitor; 18 19 66 public abstract class Refactoring extends PlatformObject { 67 68 private Object fValidationContext; 69 70 79 public final void setValidationContext(Object context) { 80 fValidationContext= context; 81 } 82 83 89 public final Object getValidationContext() { 90 return fValidationContext; 91 } 92 93 99 public abstract String getName(); 100 101 103 111 public final RefactoringTickProvider getRefactoringTickProvider() { 112 RefactoringTickProvider result= doGetRefactoringTickProvider(); 113 if (result == null) { 114 result= RefactoringTickProvider.DEFAULT; 115 } 116 return result; 117 } 118 119 128 protected RefactoringTickProvider doGetRefactoringTickProvider() { 129 return RefactoringTickProvider.DEFAULT; 130 } 131 132 152 public RefactoringStatus checkAllConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { 153 RefactoringTickProvider refactoringTickProvider= getRefactoringTickProvider(); 154 pm.beginTask("", refactoringTickProvider.getCheckAllConditionsTicks()); RefactoringStatus result= new RefactoringStatus(); 156 result.merge(checkInitialConditions(new SubProgressMonitor(pm, refactoringTickProvider.getCheckInitialConditionsTicks()))); 157 if (!result.hasFatalError()) { 158 if (pm.isCanceled()) 159 throw new OperationCanceledException(); 160 result.merge(checkFinalConditions(new SubProgressMonitor(pm, refactoringTickProvider.getCheckFinalConditionsTicks()))); 161 } 162 pm.done(); 163 return result; 164 } 165 166 194 public abstract RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException; 195 196 221 public abstract RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException; 222 223 225 238 public abstract Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException; 239 240 243 public Object getAdapter(Class adapter) { 244 if (adapter.isInstance(this)) 245 return this; 246 return super.getAdapter(adapter); 247 } 248 249 252 public String toString() { 253 return getName(); 254 } 255 } 256 | Popular Tags |