KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jimm > datavision > gui > cmd > NewSectionCommand


1 package jimm.datavision.gui.cmd;
2 import jimm.datavision.Report;
3 import jimm.datavision.Section;
4 import jimm.util.I18N;
5 import jimm.datavision.gui.Designer;
6 import jimm.datavision.gui.SectionWidget;
7
8 public class NewSectionCommand extends CommandAdapter {
9
10 protected Designer designer;
11 protected Report report;
12 protected Section sectionAbove;
13 protected Section section;
14 protected SectionWidget swAbove;
15
16 public NewSectionCommand(Designer designer, Report report, Section putBelow)
17 {
18     super(I18N.get("NewSectionCommand.name"));
19
20     this.designer = designer;
21     this.report = report;
22     sectionAbove = putBelow; // New section goes below "sectionAbove"
23
swAbove = designer.findSectionWidgetFor(sectionAbove);
24 }
25
26 public void perform() {
27     section = report.insertSectionBelow(sectionAbove);
28     SectionWidget sw = new SectionWidget(designer, section, "");
29     designer.insertSectionWidgetAfter(sw, swAbove);
30 }
31
32 public void undo() {
33     // Removes section as observer and calls renameSectionWidgets
34
designer.doDeleteSection(section);
35 }
36
37 }
38
Popular Tags