]> git.uio.no Git - ifi-stolz-refaktor.git/blame - software/no.uio.ifi.refaktor/src/no/uio/ifi/refaktor/refactorings/RefaktorRefactoring.java
fixed block bug
[ifi-stolz-refaktor.git] / software / no.uio.ifi.refaktor / src / no / uio / ifi / refaktor / refactorings / RefaktorRefactoring.java
CommitLineData
535ff0e4 1package no.uio.ifi.refaktor.refactorings;
79bfcf2d
EK
2
3import org.eclipse.core.resources.IProject;
4import org.eclipse.core.resources.ResourcesPlugin;
79bfcf2d
EK
5import org.eclipse.core.runtime.CoreException;
6import org.eclipse.core.runtime.IProgressMonitor;
7import org.eclipse.core.runtime.OperationCanceledException;
79bfcf2d
EK
8import org.eclipse.jdt.core.IJavaProject;
9import org.eclipse.jdt.core.IType;
10import org.eclipse.jdt.core.JavaCore;
11import org.eclipse.jdt.core.JavaModelException;
79bfcf2d
EK
12import org.eclipse.ltk.core.refactoring.Refactoring;
13import org.eclipse.ltk.core.refactoring.RefactoringStatus;
14
15public abstract class RefaktorRefactoring extends Refactoring {
16
17 protected Refactoring refactoring;
79bfcf2d
EK
18 protected String projectName;
19
20 public RefaktorRefactoring() {
ed2d5290 21 this.refactoring = null;
79bfcf2d
EK
22 }
23
24 protected abstract void setRefactoring() throws CoreException;
25
79bfcf2d
EK
26 @Override
27 public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException,
28 OperationCanceledException {
29 System.err.println(getName() + ".checkInitialConditions");
30 return getRefactoring().checkInitialConditions(monitor);
31 }
32
33 @Override
34 public RefactoringStatus checkFinalConditions(IProgressMonitor monitor) throws CoreException,
35 OperationCanceledException {
36 System.err.println(getName() + ".checkFinalConditions");
37 return getRefactoring().checkFinalConditions(monitor);
38 }
39
40 protected Refactoring getRefactoring() throws JavaModelException, CoreException {
41 if (this.refactoring == null)
42 setRefactoring();
3cb3a16b 43 assert this.refactoring != null;
79bfcf2d
EK
44 return this.refactoring;
45 }
46
651584c9
EK
47 protected IType getIType(String typeName, String projectName) throws CoreException {
48 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
79bfcf2d
EK
49 project.open(null);
50
51 IJavaProject javaProject = JavaCore.create(project);
52 return javaProject.findType(typeName);
53 }
54
55 @Override
56 public String getName() {
57 return this.getClass().getSimpleName();
58 }
59
79bfcf2d
EK
60 protected String getProjectName() {
61 return this.projectName;
62 }
63
64 protected void setProjectName(String projectName) {
65 this.projectName = projectName;
66 }
67
68}