View Javadoc

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