01: package jimm.datavision.gui;
02:
03: import jimm.datavision.field.Field;
04: import jimm.datavision.field.FormulaField;
05: import jimm.util.I18N;
06: import javax.swing.JDialog;
07:
08: /**
09: *
10: * A formula widget must be able to edit its formula's code and perform
11: * a few other formula-specific actions.
12: *
13: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
14: */
15: public class FormulaWidget extends EditWinWidget {
16:
17: /**
18: * Constructor.
19: *
20: * @param sw section widget in which the field's new widget will reside
21: * @param field a report field
22: */
23: public FormulaWidget(SectionWidget sw, Field field) {
24: super (sw, field);
25: }
26:
27: protected JDialog createEditor() {
28: return new FormulaWin(sectionWidget.designer, getField()
29: .getReport(), ((FormulaField) getField()).getFormula());
30: }
31:
32: protected void updateEditor() {
33: ((FormulaWin) editor).update(null, null); // Re-read code
34: }
35:
36: protected String getWidgetName() {
37: return ((FormulaField) getField()).getFormula().getName();
38: }
39:
40: protected String getEditorTitle() {
41: return I18N.get("FormulaWidget.editor_title");
42: }
43:
44: protected String getEditorLabel() {
45: return I18N.get("FormulaWidget.editor_label");
46: }
47:
48: public void setWidgetName(String newName) {
49: if (newName.length() == 0)
50: newName = I18N.get("FieldPickerWin.unnamed_formula");
51: ((FormulaField) getField()).getFormula().setName(newName);
52: }
53:
54: }
|