KickJava   Java API By Example, From Geeks To Geeks.

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


1 package jimm.datavision.gui.cmd;
2 import jimm.datavision.gui.Designer;
3 import jimm.datavision.gui.FieldWidget;
4 import jimm.datavision.gui.SectionWidget;
5 import jimm.datavision.gui.Clipboard;
6 import jimm.util.I18N;
7 import java.util.*;
8
9 public class PasteCommand extends CommandAdapter {
10
11 // ================================================================
12
static class PasteInfo {
13 HashSet fieldWidgets;
14 SectionResizeCommand sectionResizeCommand;
15
16 PasteInfo(SectionWidget sw) {
17     fieldWidgets = new HashSet();
18     sectionResizeCommand = new SectionResizeCommand(sw);
19 }
20 void add(FieldWidget fw) { fieldWidgets.add(fw); }
21 Iterator fieldWidgets() { return fieldWidgets.iterator(); }
22 }
23 // ================================================================
24

25 protected Designer designer;
26 /** Maps section widgets to sets of field widgets contained within them. */
27 protected HashMap sectionFields;
28
29 /**
30  * Constructor.
31  */

32 public PasteCommand(Designer designer) {
33     super(I18N.get("PasteCommand.name"));
34
35     this.designer = designer;
36 }
37
38 public void perform() {
39     Iterator iter = ((List)Clipboard.instance().getContents()).iterator();
40     while (iter.hasNext())
41     ((Pasteable)iter.next()).paste(designer);
42 }
43
44 public void undo() {
45     Iterator iter = ((List)Clipboard.instance().getContents()).iterator();
46     while (iter.hasNext())
47     ((Pasteable)iter.next()).undo(designer);
48 }
49
50 }
51
Popular Tags