KickJava   Java API By Example, From Geeks To Geeks.

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


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.RenameParticipant;
14
15 import org.terracotta.dso.ConfigurationHelper;
16 import org.terracotta.dso.TcPlugin;
17
18 public class RenameMethodParticipant extends RenameParticipant {
19   private IMethod fMethod;
20   private String JavaDoc fDestination;
21
22   public RefactoringStatus checkConditions(IProgressMonitor pm,
23                                            CheckConditionsContext context)
24     throws OperationCanceledException
25   {
26     return new RefactoringStatus();
27   }
28
29   public Change createChange(IProgressMonitor pm)
30     throws OperationCanceledException
31   {
32     return createChangesForMethodRename(fMethod, fDestination);
33   }
34
35   public String JavaDoc getName() {
36     return "TCRenameMethodChange";
37   }
38
39   protected boolean initialize(Object JavaDoc element) {
40     TcPlugin plugin = TcPlugin.getDefault();
41     IMethod method = (IMethod)element;
42     IProject project = method.getJavaProject().getProject();
43     ConfigurationHelper configHelper = plugin.getConfigurationHelper(project);
44
45     if(configHelper.isLocked(method) ||
46        configHelper.isDistributedMethod(method))
47     {
48       fMethod = method;
49       fDestination = getArguments().getNewName();
50       
51       return true;
52     }
53
54     return false;
55   }
56
57   public static Change createChangesForMethodRename(IMethod method, String JavaDoc destination) {
58     return new RenameMethodChange(method, destination);
59   }
60 }
61
Popular Tags