01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.Report;
04: import jimm.datavision.SectionArea;
05: import jimm.datavision.Subreport;
06: import jimm.datavision.Point;
07: import jimm.datavision.field.Field;
08: import jimm.datavision.field.Rectangle;
09: import jimm.datavision.source.sql.Database;
10: import jimm.datavision.source.sql.SubreportDatabase;
11: import jimm.datavision.gui.Designer;
12: import jimm.datavision.gui.FieldWidget;
13: import java.io.File;
14: import java.util.Collection;
15:
16: public class NewSubreportCommand extends InsertFieldCommand {
17:
18: protected Designer designer;
19: protected Report report;
20: protected Subreport subreport;
21:
22: public NewSubreportCommand(Designer designer, Report report,
23: File f, Collection newJoins) throws Exception {
24: super (designer.findSectionWidgetFor(report
25: .getFirstSectionByArea(SectionArea.DETAIL)),
26: "subreport", new Point(0, report.getFirstSectionByArea(
27: SectionArea.DETAIL).getMinHeight()));
28:
29: this .designer = designer;
30: this .report = report;
31:
32: subreport = new Subreport(report, null);
33: Database db = (Database) report.getDataSource();
34: subreport.setDataSource(new SubreportDatabase(db
35: .getConnection(), subreport));
36: subreport.read(f);
37: subreport.addAllJoins(newJoins);
38: }
39:
40: protected Rectangle initialFieldBounds() {
41: return new Rectangle(insertLoc.getX(), insertLoc.getY()
42: - (int) (Field.DEFAULT_HEIGHT / 2),
43: (double) (Field.DEFAULT_WIDTH * 4),
44: (double) Field.DEFAULT_HEIGHT);
45: }
46:
47: protected Object initialFieldValue() {
48: return subreport.getId();
49: }
50:
51: protected FieldWidget createFieldWidget(Field f) {
52: return new FieldWidget(null, f);
53: }
54:
55: }
|