1 package org.catacomb.druid.gui.edit;
2
3 import org.catacomb.interlish.structure.TargetStore;
4 import org.catacomb.interlish.structure.TargetStoreUser;
5 import org.catacomb.interlish.structure.Viewer;
6 import org.catacomb.report.E;
7
8
9
10
11 public class DruMenuButton extends DruButton implements Viewer, TargetStoreUser {
12 private static final long serialVersionUID = 1L;
13
14
15 String popupID;
16 TargetStore targetStore;
17
18 DruMenu menu;
19
20 public DruMenuButton(String lab) {
21 super(lab);
22 }
23
24
25
26 public String toString() {
27 return ("DruMenuButton id=" + getID());
28 }
29
30
31 public void labelAction(String s, boolean b) {
32 if (menu == null) {
33 if (popupID != null && targetStore != null) {
34 menu = (DruMenu)(targetStore.get(popupID));
35 } else {
36 E.error("missing data in menu button " + popupID + " " + targetStore);
37 }
38 }
39
40 if (menu != null) {
41 menu.showPopup(this, 0, 18);
42
43 }
44 }
45
46
47 public void setOptions(String[] sa) {
48 if (menu == null) {
49 menu = new DruMenu("");
50 menu.setItems(sa);
51 menu.setActionRelay(getActionRelay());
52 menu.setAction(getAction());
53 }
54 }
55
56 public void setPopupToShow(String show) {
57 popupID = show;
58 }
59
60
61
62
63 public void setTargetStore(TargetStore ts) {
64 targetStore = ts;
65 }
66
67 }