01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.Formula;
04: import jimm.util.I18N;
05:
06: /**
07: * A command for changing a {@link Formula}'s code text.
08: *
09: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
10: */
11: public class FormulaEditCommand extends CommandAdapter {
12:
13: protected Formula formula;
14: protected String newExpression;
15: protected String oldExpression;
16: protected String newLanguage;
17: protected String oldLanguage;
18:
19: public FormulaEditCommand(Formula formula, String expression,
20: String language) {
21: super (I18N.get("FormulaEditCommand.name"));
22: this .formula = formula;
23: newExpression = expression;
24: oldExpression = formula.getExpression();
25: newLanguage = language;
26: oldLanguage = formula.getLanguage();
27: }
28:
29: public void perform() {
30: formula.setLanguage(newLanguage);
31: formula.setEditableExpression(newExpression);
32: }
33:
34: public void undo() {
35: formula.setLanguage(oldLanguage);
36: formula.setEditableExpression(oldExpression);
37: }
38:
39: }
|