01: package jimm.datavision.gui.sql;
02:
03: import jimm.datavision.*;
04: import jimm.datavision.gui.Designer;
05: import jimm.datavision.source.*;
06: import jimm.datavision.gui.cmd.NewSubreportCommand;
07: import jimm.util.I18N;
08: import java.util.*;
09: import javax.swing.*;
10:
11: /**
12: * Starts the process of importing a sub-report.
13: *
14: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
15: */
16: public class SubreportWin extends VisTableWin {
17:
18: JLabel this ReportLabel, subreportLabel;
19:
20: /**
21: * Constructor.
22: *
23: * @param designer the window to which this dialog belongs
24: * @param report the...um...I forgot
25: */
26: public SubreportWin(Designer designer, Report report) {
27: super (designer, report, new Query(report));
28: }
29:
30: protected void fillJoinsPanel() {
31: delCheckBoxPanel.add(new JLabel(" "));
32:
33: this ReportLabel = new JLabel(I18N
34: .get("SubreportWin.this_report"));
35: fromPanel.add(this ReportLabel);
36: this ReportLabel.setVisible(false);
37:
38: relationPanel.add(new JLabel(" "));
39:
40: subreportLabel = new JLabel(I18N.get("SubreportWin.subreport"));
41: toPanel.add(subreportLabel);
42: subreportLabel.setVisible(false);
43:
44: super .fillJoinsPanel();
45: }
46:
47: protected void addNewJoin() {
48: super .addNewJoin();
49: this ReportLabel.setVisible(true);
50: subreportLabel.setVisible(true);
51: }
52:
53: protected void deleteSelectedJoins() {
54: super .deleteSelectedJoins();
55: this ReportLabel.setVisible(!joinFieldsList.isEmpty());
56: subreportLabel.setVisible(!joinFieldsList.isEmpty());
57: }
58:
59: protected void doSave() {
60: JFileChooser chooser = Designer.getChooser();
61: Designer.setPrefsDir(chooser, null);
62: int returnVal = chooser.showOpenDialog(designer.getFrame());
63: if (returnVal == JFileChooser.APPROVE_OPTION) {
64: Designer.savePrefsDir(chooser, null); // save report directory
65: ArrayList newJoins = new ArrayList();
66: for (Iterator iter = joinFieldsList.iterator(); iter
67: .hasNext();) {
68: JoinFields jf = (JoinFields) iter.next();
69: Column from = columnFromDropdown(jf.from);
70: String relation = (String) jf.relation
71: .getSelectedItem();
72: Column to = columnFromDropdown(jf.to);
73:
74: newJoins.add(new Join(from, relation, to));
75: }
76:
77: try {
78: NewSubreportCommand cmd = new NewSubreportCommand(
79: designer, report, chooser.getSelectedFile(),
80: newJoins);
81: cmd.perform();
82: commands.add(cmd);
83: } catch (Exception e) {
84: ErrorHandler.error(e);
85: }
86: }
87: }
88:
89: }
|