1 package org.catacomb.druid.gui.edit;
2
3 import org.catacomb.druid.event.LabelActor;
4 import org.catacomb.druid.swing.DCheckboxMenuItem;
5 import org.catacomb.interlish.structure.Ablable;
6 import org.catacomb.interlish.structure.ActionRelay;
7 import org.catacomb.interlish.structure.ActionSource;
8 import org.catacomb.interlish.structure.InfoReceiver;
9 import org.catacomb.interlish.structure.SelectionListener;
10 import org.catacomb.interlish.structure.SelectionSource;
11 import org.catacomb.interlish.structure.Syncable;
12
13
14
15 public class DruCheckboxMenuItem implements ActionSource, LabelActor,
16 Ablable, SelectionListener, Syncable {
17
18 static final long serialVersionUID = 1001;
19
20 String label;
21 String methodName;
22 ActionRelay actionRelay;
23
24 String enableOn;
25 SelectionSource selectionSource;
26
27 String info;
28
29 InfoReceiver infoReceiver;
30
31 DCheckboxMenuItem dItem;
32
33 public DruCheckboxMenuItem(String lab, String mnm) {
34 dItem = new DCheckboxMenuItem(lab);
35 label = lab;
36 methodName = mnm;
37 dItem.setLabelActor(this);
38 }
39
40
41 public DCheckboxMenuItem getGUIPeer() {
42 return dItem;
43 }
44
45 public String getID() {
46 return "";
47 }
48
49
50 public void able(boolean b) {
51 dItem.setEnabled(b);
52 }
53
54
55
56
57 public void setActionRelay(ActionRelay ar) {
58 actionRelay = ar;
59 }
60
61
62
63 public void labelAction(String s, boolean b) {
64 if (info != null) {
65 infoReceiver.receiveInfo(label, info);
66 }
67 if (actionRelay != null) {
68 actionRelay.actionB(methodName, b);
69 }
70
71 }
72
73
74 public void setState(boolean b) {
75 dItem.setSelected(b);
76 }
77
78
79 public void setEnableOnSelection(String depends) {
80 enableOn = depends;
81 }
82
83
84 public void setSelectionSource(SelectionSource source) {
85 selectionSource = source;
86 }
87
88
89 public void sync() {
90
91 if (selectionSource != null && enableOn != null) {
92 String s = selectionSource.getSelectionType();
93 if (enableOn.indexOf(s) >= 0) {
94 dItem.setEnabled(true);
95 } else {
96 dItem.setEnabled(false);
97 }
98
99 }
100 }
101
102
103 public void setInfo(String s) {
104 info = s;
105 }
106
107
108 public void setInfoReceiver(InfoReceiver irec) {
109 infoReceiver = irec;
110 }
111
112
113 }