01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.Report;
04: import jimm.datavision.Section;
05: import jimm.util.I18N;
06: import jimm.datavision.gui.Designer;
07: import jimm.datavision.gui.SectionWidget;
08:
09: public class NewSectionCommand extends CommandAdapter {
10:
11: protected Designer designer;
12: protected Report report;
13: protected Section sectionAbove;
14: protected Section section;
15: protected SectionWidget swAbove;
16:
17: public NewSectionCommand(Designer designer, Report report,
18: Section putBelow) {
19: super (I18N.get("NewSectionCommand.name"));
20:
21: this .designer = designer;
22: this .report = report;
23: sectionAbove = putBelow; // New section goes below "sectionAbove"
24: swAbove = designer.findSectionWidgetFor(sectionAbove);
25: }
26:
27: public void perform() {
28: section = report.insertSectionBelow(sectionAbove);
29: SectionWidget sw = new SectionWidget(designer, section, "");
30: designer.insertSectionWidgetAfter(sw, swAbove);
31: }
32:
33: public void undo() {
34: // Removes section as observer and calls renameSectionWidgets
35: designer.doDeleteSection(section);
36: }
37:
38: }
|