1 package org.catacomb.druid.blocks;
2
3 import org.catacomb.druid.build.Context;
4 import org.catacomb.druid.build.GUIPath;
5 import org.catacomb.druid.gui.base.DruPanel;
6 import org.catacomb.druid.gui.edit.DruToggleButton;
7
8
9 public class ToggleButton extends AbstractButton {
10
11 public String group;
12 public String store;
13 public String value;
14
15 public boolean initial;
16
17 public String offImage;
18 public String onImage;
19
20 public String groupAction;
21
22 public ToggleButton() {
23 super();
24 }
25
26
27 public ToggleButton(String slab) {
28 super(slab);
29 }
30
31
32
33
34
35 public DruPanel instantiatePanel() {
36 return new DruToggleButton(label, action);
37 }
38
39 public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) {
40
41
42 DruToggleButton drup = (DruToggleButton)dp;
43
44 if (image != null) {
45 drup.setOffImage(image);
46
47 } else if (offImage != null) {
48 drup.setOffImage(offImage);
49 }
50
51 if (onImage != null) {
52 drup.setOnImage(onImage);
53 }
54
55 applyPadding(drup);
56
57
58
59
60
61 if (group != null) {
62 drup.setToggle(group, value);
63
64 drup.setContingencyGroup(ctx.getContingencyGroup(group));
65 if (initial) {
66 drup.setInitialValue(true);
67 }
68 }
69
70
71 if (groupAction != null) {
72 drup.setGroupAction(groupAction);
73 }
74
75 drup.setEffects(realizeEffects(effects, ctx, gpath));
76
77 if (title == null || title.length() == 0) {
78 drup.setTitle(label + " Button");
79 }
80
81 drup.setInitialValue(initial);
82 }
83 }
84
85