01: package jimm.datavision.gui;
02:
03: import jimm.datavision.*;
04: import jimm.datavision.gui.cmd.ReportStartupScriptEditCommand;
05: import jimm.util.I18N;
06:
07: /**
08: * This dialog is for editing {@link Formula} code.
09: *
10: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
11: * @see FormulaWidget
12: * @see jimm.datavision.gui.cmd.FormulaEditCommand
13: */
14: public class StartupScriptEditor extends ScriptEditorWin {
15:
16: protected Report report;
17:
18: /**
19: * Constructor.
20: *
21: * @param designer the window to which this dialog belongs
22: * @param report the report
23: */
24: public StartupScriptEditor(Designer designer, Report report) {
25: super (designer, report, report.getStartFormula() == null ? ""
26: : report.getStartFormula().getEditableExpression(),
27: I18N.get("StartupScriptEditor.title_prefix"),
28: "StartupScriptEditor.error_unchanged",
29: "StartupScriptEditor.error_title");
30: this .report = report;
31:
32: if (report.getStartFormula() != null)
33: setLanguage(report.getStartFormula().getLanguage());
34: else
35: setLanguage(report.getScripting().getDefaultLanguage());
36:
37: // (We don't need to observe this formula)
38: }
39:
40: /**
41: * Creates and executes a command that changes the formula's eval string.
42: * If there is an error, the command is cancelled (never sent to the
43: * design window).
44: *
45: * @param text the new eval string
46: */
47: public void save(String text) {
48: command = new ReportStartupScriptEditCommand(report, text,
49: getLanguage());
50: }
51:
52: }
|