KickJava   Java API By Example, From Geeks To Geeks.

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


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