01: package jimm.datavision.gui;
02:
03: import jimm.datavision.Report;
04: import jimm.datavision.gui.cmd.SummaryCommand;
05: import jimm.util.I18N;
06: import java.awt.BorderLayout;
07: import javax.swing.*;
08:
09: /**
10: * A report description (name, title, author, etc.) editing dialog box.
11: *
12: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
13: */
14: public class DescripWin extends EditWin {
15:
16: protected static final int TEXT_FIELD_COLS = 32;
17: protected static final int TEXT_AREA_ROWS = 6;
18: protected static final int TEXT_AREA_COLS = 32;
19:
20: protected Report report;
21: protected JTextField nameField;
22: protected JTextField titleField;
23: protected JTextField authorField;
24: protected JTextArea descriptionField;
25:
26: /**
27: * Constructor.
28: *
29: * @param designer the window to which this dialog belongs
30: * @param report report (I love useful, thoughtful comments)
31: */
32: public DescripWin(Designer designer, Report report) {
33: super (designer, I18N.get("DescripWin.title"),
34: "SummaryCommand.name");
35:
36: this .report = report;
37:
38: buildWindow();
39: pack();
40: setVisible(true);
41: }
42:
43: /**
44: * Builds the window contents.
45: */
46: protected void buildWindow() {
47: // All edit fields
48: JPanel editorPanel = buildEditor();
49:
50: // OK, Apply, Revert, and Cancel Buttons
51: JPanel buttonPanel = closeButtonPanel();
52:
53: // Add values and buttons to window
54: getContentPane().add(editorPanel, BorderLayout.CENTER);
55: getContentPane().add(buttonPanel, BorderLayout.SOUTH);
56: }
57:
58: protected JPanel buildEditor() {
59: EditFieldLayout efl = new EditFieldLayout();
60:
61: nameField = efl.addTextField(
62: I18N.get("DescripWin.report_name"), report.getName(),
63: TEXT_FIELD_COLS);
64: titleField = efl.addTextField(I18N
65: .get("DescripWin.report_title"), report.getTitle(),
66: TEXT_FIELD_COLS);
67: authorField = efl.addTextField(I18N
68: .get("DescripWin.author_name"), report.getAuthor(),
69: TEXT_FIELD_COLS);
70: descriptionField = efl
71: .addTextArea(I18N.get("DescripWin.description"), report
72: .getDescription(), TEXT_AREA_ROWS,
73: TEXT_AREA_COLS);
74:
75: return efl.getPanel();
76: }
77:
78: protected void fillEditFields() {
79: nameField.setText(report.getName());
80: titleField.setText(report.getTitle());
81: authorField.setText(report.getAuthor());
82: descriptionField.setText(report.getDescription());
83: }
84:
85: protected void doSave() {
86: SummaryCommand cmd = new SummaryCommand(report, nameField
87: .getText(), titleField.getText(),
88: authorField.getText(), descriptionField.getText());
89: cmd.perform();
90: commands.add(cmd);
91: }
92:
93: protected void doRevert() {
94: fillEditFields();
95: }
96:
97: }
|