01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.gui.Designer;
04: import jimm.datavision.gui.FieldWidget;
05: import jimm.datavision.gui.SectionWidget;
06: import jimm.datavision.gui.Clipboard;
07: import jimm.util.I18N;
08: import java.util.*;
09:
10: public class PasteCommand extends CommandAdapter {
11:
12: // ================================================================
13: static class PasteInfo {
14: HashSet fieldWidgets;
15: SectionResizeCommand sectionResizeCommand;
16:
17: PasteInfo(SectionWidget sw) {
18: fieldWidgets = new HashSet();
19: sectionResizeCommand = new SectionResizeCommand(sw);
20: }
21:
22: void add(FieldWidget fw) {
23: fieldWidgets.add(fw);
24: }
25:
26: Iterator fieldWidgets() {
27: return fieldWidgets.iterator();
28: }
29: }
30:
31: // ================================================================
32:
33: protected Designer designer;
34: /** Maps section widgets to sets of field widgets contained within them. */
35: protected HashMap sectionFields;
36:
37: /**
38: * Constructor.
39: */
40: public PasteCommand(Designer designer) {
41: super (I18N.get("PasteCommand.name"));
42:
43: this .designer = designer;
44: }
45:
46: public void perform() {
47: Iterator iter = ((List) Clipboard.instance().getContents())
48: .iterator();
49: while (iter.hasNext())
50: ((Pasteable) iter.next()).paste(designer);
51: }
52:
53: public void undo() {
54: Iterator iter = ((List) Clipboard.instance().getContents())
55: .iterator();
56: while (iter.hasNext())
57: ((Pasteable) iter.next()).undo(designer);
58: }
59:
60: }
|