01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.Report;
04: import jimm.datavision.Formula;
05: import jimm.util.I18N;
06:
07: /**
08: * A command for changing the {@link Report}'s startup {@link Formula}'s code
09: * text.
10: *
11: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
12: */
13: public class ReportStartupScriptEditCommand extends CommandAdapter {
14:
15: protected Report report;
16: protected String newExpression;
17: protected String oldExpression;
18: protected String oldLanguage;
19: protected String newLanguage;
20:
21: public ReportStartupScriptEditCommand(Report report,
22: String expression, String language) {
23: super (I18N.get("ReportStartupScriptEditCommand.name"));
24: this .report = report;
25:
26: Formula f = report.getStartFormula();
27:
28: newExpression = expression;
29: oldExpression = f == null ? null : f.getExpression();
30:
31: newLanguage = language;
32: oldLanguage = f == null ? null : f.getLanguage();
33: }
34:
35: public void perform() {
36: Formula f = null;
37: if (oldExpression == null) {
38: f = new Formula(null, report, "", "");
39: report.setStartFormula(f);
40: } else
41: f = report.getStartFormula();
42:
43: f.setEditableExpression(newExpression);
44: f.setLanguage(newLanguage);
45: }
46:
47: public void undo() {
48: if (oldExpression == null)
49: report.setStartFormula(null);
50: else {
51: Formula f = report.getStartFormula();
52: f.setEditableExpression(oldExpression);
53: f.setLanguage(oldLanguage);
54: }
55: }
56:
57: }
|