01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.dso.refactoring;
05:
06: import org.eclipse.core.resources.IProject;
07: import org.eclipse.core.runtime.IProgressMonitor;
08: import org.eclipse.core.runtime.OperationCanceledException;
09: import org.eclipse.jdt.core.IMethod;
10: import org.eclipse.ltk.core.refactoring.Change;
11: import org.eclipse.ltk.core.refactoring.RefactoringStatus;
12: import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
13: import org.eclipse.ltk.core.refactoring.participants.DeleteParticipant;
14:
15: import org.terracotta.dso.ConfigurationHelper;
16: import org.terracotta.dso.PatternHelper;
17: import org.terracotta.dso.TcPlugin;
18: import com.tc.aspectwerkz.reflect.MethodInfo;
19:
20: public class DeleteMethodParticipant extends DeleteParticipant {
21: private IMethod fMethod;
22:
23: public RefactoringStatus checkConditions(IProgressMonitor pm,
24: CheckConditionsContext context)
25: throws OperationCanceledException {
26: return new RefactoringStatus();
27: }
28:
29: public Change createChange(IProgressMonitor pm)
30: throws OperationCanceledException {
31: return createChangesForMethodDelete(fMethod);
32: }
33:
34: public String getName() {
35: return "TCDeleteMethodChange";
36: }
37:
38: protected boolean initialize(Object element) {
39: TcPlugin plugin = TcPlugin.getDefault();
40: IMethod method = (IMethod) element;
41: IProject project = method.getJavaProject().getProject();
42: ConfigurationHelper configHelper = plugin
43: .getConfigurationHelper(project);
44:
45: if (configHelper.isLocked(method)) {
46: fMethod = method;
47: return true;
48: }
49:
50: return false;
51: }
52:
53: public static Change createChangesForMethodDelete(IMethod method) {
54: MethodInfo methodInfo = PatternHelper.getHelper()
55: .getMethodInfo(method);
56: return new DeleteMethodChange(method, methodInfo);
57: }
58: }
|