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.DeleteParticipant;
14:
15: import org.terracotta.dso.ConfigurationHelper;
16: import org.terracotta.dso.TcPlugin;
17:
18: public class DeleteFieldParticipant extends DeleteParticipant {
19: private IField fField;
20:
21: public RefactoringStatus checkConditions(IProgressMonitor pm,
22: CheckConditionsContext context)
23: throws OperationCanceledException {
24: return new RefactoringStatus();
25: }
26:
27: public Change createChange(IProgressMonitor pm)
28: throws OperationCanceledException {
29: return createChangesForFieldDelete(fField);
30: }
31:
32: public String getName() {
33: return "TCDeleteFieldChange";
34: }
35:
36: protected boolean initialize(Object element) {
37: TcPlugin plugin = TcPlugin.getDefault();
38: IField field = (IField) element;
39: IProject project = field.getJavaProject().getProject();
40: ConfigurationHelper configHelper = plugin
41: .getConfigurationHelper(project);
42:
43: if (configHelper.isRoot(field)) {
44: fField = field;
45: return true;
46: }
47:
48: return false;
49: }
50:
51: public static Change createChangesForFieldDelete(IField field) {
52: return new DeleteFieldChange(field);
53: }
54: }
|