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:
13: import org.terracotta.dso.TcPlugin;
14: import com.terracottatech.config.TcConfigDocument.TcConfig;
15:
16: public class DeleteFieldChange extends Change {
17: private IField fField;
18:
19: public DeleteFieldChange(IField field) {
20: super ();
21: fField = field;
22: }
23:
24: public Object getModifiedElement() {
25: return null;
26: }
27:
28: public String getName() {
29: return "TCDeleteFieldConfigUpdate";
30: }
31:
32: public void initializeValidationData(IProgressMonitor pm) {/**/
33: }
34:
35: public RefactoringStatus isValid(IProgressMonitor pm)
36: throws OperationCanceledException {
37: return new RefactoringStatus();
38: }
39:
40: public Change perform(IProgressMonitor pm) {
41: TcPlugin plugin = TcPlugin.getDefault();
42: IProject project = fField.getJavaProject().getProject();
43: TcConfig config = (TcConfig) plugin.getConfiguration(project)
44: .copy();
45:
46: plugin.getConfigurationHelper(project).ensureNotRoot(fField);
47:
48: // create the undo change
49: return new ConfigUndoneChange(project, config);
50: }
51: }
|