01: package jimm.datavision.gui;
02:
03: import jimm.datavision.Report;
04: import jimm.util.I18N;
05: import javax.swing.JComboBox;
06: import javax.swing.JComponent;
07: import java.awt.BorderLayout;
08:
09: /**
10: * This is the abstract superclass of windows used for editing paragraphs of
11: * scripting code such as formulas
12: *
13: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
14: */
15: public abstract class ScriptEditorWin extends CodeEditorWin {
16:
17: protected JComboBox languageMenu;
18:
19: /**
20: * Constructor.
21: *
22: * @param designer the design window to which this dialog belongs
23: * @param report the report
24: * @param initialText the initial text to edit
25: * @param title the window title
26: * @param errorSuffixKey I18N lookup key for error text suffix; may be
27: * <code>null</code>
28: * @param errorTitleKey I18N lookup key for error window title; may be
29: * <code>null</code>
30: */
31: public ScriptEditorWin(Designer designer, Report report,
32: String initialText, String title, String errorSuffixKey,
33: String errorTitleKey) {
34: super (designer, report, initialText, title, errorSuffixKey,
35: errorTitleKey);
36: }
37:
38: /** Returns language name selected in drop-down menu. */
39: protected String getLanguage() {
40: return (String) languageMenu.getSelectedItem();
41: }
42:
43: /**
44: * Sets dropdown menu's language.
45: *
46: * @param lang a scripting language name
47: */
48: protected void setLanguage(String lang) {
49: languageMenu.setSelectedItem(lang);
50: }
51:
52: /**
53: * Adds a scripting language dropdown.
54: */
55: protected void buildWindow(Report report, String initialText) {
56: getContentPane().add(northPanel(report), BorderLayout.NORTH);
57:
58: super .buildWindow(report, initialText);
59: }
60:
61: protected JComponent northPanel(Report report) {
62: EditFieldLayout efl = new EditFieldLayout();
63: Object[] langs = report.getScripting().getLanguages().keySet()
64: .toArray();
65: languageMenu = efl.addComboBox(I18N
66: .get("ScriptEditorWin.scripting_lang"), langs);
67: return efl.getPanel();
68: }
69:
70: }
|