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.DruCheckbox;
7 import org.catacomb.interlish.structure.AddableTo;
8 import org.catacomb.report.E;
9
10
11 import java.util.ArrayList;
12
13
14 public class Checkbox extends Panel implements AddableTo {
15
16
17 public String label;
18 public String store;
19 public String action;
20 public boolean initial;
21
22 public ArrayList<BaseEffect> effects;
23
24
25 public Checkbox() {
26 initial = false;
27 }
28
29
30 public Checkbox(String slab) {
31 label = slab;
32 action = label;
33 }
34
35
36
37 public void add(Object obj) {
38 if (effects == null) {
39 effects = new ArrayList<BaseEffect>();
40 }
41 if (obj instanceof BaseEffect) {
42 effects.add((BaseEffect)obj);
43 } else {
44 E.error("cant add non effect " + obj);
45 }
46 }
47
48
49 public DruPanel instantiatePanel() {
50 if (title == null) {
51 title = label;
52 }
53 return new DruCheckbox(label, action);
54 }
55
56
57 public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) {
58
59 DruCheckbox drup = (DruCheckbox)dp;
60 drup.setInitialValue(initial);
61
62 if (effects != null) {
63 drup.setEffects(realizeEffects(effects, ctx, gpath));
64 }
65
66 if (title == null) {
67 title = label;
68 }
69
70
71 }
72
73 }