KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > refactoring > DeleteMethodParticipant


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.refactoring;
5
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.core.runtime.OperationCanceledException;
9 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   {
27     return new RefactoringStatus();
28   }
29
30   public Change createChange(IProgressMonitor pm)
31     throws OperationCanceledException
32   {
33     return createChangesForMethodDelete(fMethod);
34   }
35
36   public String JavaDoc getName() {
37     return "TCDeleteMethodChange";
38   }
39
40   protected boolean initialize(Object JavaDoc element) {
41     TcPlugin plugin = TcPlugin.getDefault();
42     IMethod method = (IMethod)element;
43     IProject project = method.getJavaProject().getProject();
44     ConfigurationHelper configHelper = plugin.getConfigurationHelper(project);
45
46     if(configHelper.isLocked(method)) {
47       fMethod = method;
48       return true;
49     }
50
51     return false;
52   }
53
54   public static Change createChangesForMethodDelete(IMethod method) {
55     MethodInfo methodInfo = PatternHelper.getHelper().getMethodInfo(method);
56     return new DeleteMethodChange(method, methodInfo);
57   }
58 }
59
Popular Tags