01: /**
02: *
03: */package core;
04:
05: import model.ModelModifier;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09: import org.eclipse.jdt.core.IJavaElement;
10:
11: /**
12: * This class is responsible for execute the type
13: * refactoring in the model.
14: *
15: * @author sh
16: */
17: public class RenameModelField extends AbstractAST implements
18: IModelRefactoring {
19:
20: // the Info Object containing all nesessary refactor info
21: private RefactorInfo info = null;
22:
23: private Log log = LogFactory.getLog(getClass());
24:
25: /**
26: * Performs the model modifications.
27: *
28: * @param modelElement the field to refactor
29: */
30: public void updateModel(IJavaElement modelElement) {
31: // get the implementation of the compilation unit
32: // in which the field is declared
33: String implementation = Util.getImplementation(this .info
34: .getUnit());
35:
36: // get the environment entry name
37: String fieldName = info.getOldVarName();
38:
39: // start the model update
40: // first update the entries type
41: new ModelModifier().doEnvEntryTypeModification(implementation,
42: info.getOldName(), info.getNewName(), fieldName);
43: log.info("Model: Environment Entry type change performed");
44:
45: // second update the entries variable name
46: new ModelModifier().doEnvEntryNameModification(implementation,
47: info.getOldVarName(), info.getNewVarName());
48: log.info("Model: Environment Entry name change performed");
49: }
50:
51: @Override
52: public void modification(IJavaElement sourceElement) {
53: }
54:
55: /**
56: * Start the refactoring process.
57: *
58: * @param info the info object
59: */
60: public void process(RefactorInfo info) {
61: this.info = info;
62: updateModel(null);
63: }
64: }
|