1 package no.uio.ifi.refaktor.refactorings;
3 import org.eclipse.core.resources.IProject;
4 import org.eclipse.core.resources.ResourcesPlugin;
5 import org.eclipse.core.runtime.CoreException;
6 import org.eclipse.core.runtime.IProgressMonitor;
7 import org.eclipse.core.runtime.OperationCanceledException;
8 import org.eclipse.jdt.core.IJavaProject;
9 import org.eclipse.jdt.core.IType;
10 import org.eclipse.jdt.core.JavaCore;
11 import org.eclipse.jdt.core.JavaModelException;
12 import org.eclipse.ltk.core.refactoring.Refactoring;
13 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
15 public abstract class RefaktorRefactoring extends Refactoring {
17 protected Refactoring refactoring;
18 protected String projectName;
20 public RefaktorRefactoring() {
21 this.refactoring = null;
24 protected abstract void setRefactoring() throws CoreException;
27 public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException,
28 OperationCanceledException {
29 System.err.println(getName() + ".checkInitialConditions");
30 return getRefactoring().checkInitialConditions(monitor);
34 public RefactoringStatus checkFinalConditions(IProgressMonitor monitor) throws CoreException,
35 OperationCanceledException {
36 System.err.println(getName() + ".checkFinalConditions");
37 return getRefactoring().checkFinalConditions(monitor);
40 protected Refactoring getRefactoring() throws JavaModelException, CoreException {
41 if (this.refactoring == null)
43 assert this.refactoring != null;
44 return this.refactoring;
47 protected IType getIType(String typeName, String projectName) throws CoreException {
48 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
51 IJavaProject javaProject = JavaCore.create(project);
52 return javaProject.findType(typeName);
56 public String getName() {
57 return this.getClass().getSimpleName();
60 protected String getProjectName() {
61 return this.projectName;
64 protected void setProjectName(String projectName) {
65 this.projectName = projectName;