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