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.IField;
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 RenameFieldParticipant extends RenameParticipant {
19: private IField fField;
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 createChangesForFieldRename(fField, fDestination);
31: }
32:
33: public String getName() {
34: return "TCRenameFieldChange";
35: }
36:
37: protected boolean initialize(Object element) {
38: TcPlugin plugin = TcPlugin.getDefault();
39: IField field = (IField) element;
40: IProject project = field.getJavaProject().getProject();
41: ConfigurationHelper configHelper = plugin
42: .getConfigurationHelper(project);
43:
44: if (configHelper.isRoot(field)) {
45: fField = field;
46: fDestination = getArguments().getNewName();
47:
48: return true;
49: }
50:
51: return false;
52: }
53:
54: public static Change createChangesForFieldRename(IField field,
55: String destination) {
56: return new RenameFieldChange(field, destination);
57: }
58: }
|