1
2 package org.catacomb.druid.blocks;
3
4 import org.catacomb.druid.build.Context;
5 import org.catacomb.druid.build.GUIPath;
6 import org.catacomb.druid.build.Realizer;
7 import org.catacomb.druid.gui.base.DruKitPanel;
8 import org.catacomb.druid.gui.base.DruPanel;
9 import org.catacomb.interlish.structure.AddableTo;
10 import org.catacomb.interlish.structure.AdderTo;
11 import org.catacomb.report.E;
12
13
14 import java.util.ArrayList;
15
16 public class KitPanel extends Panel implements AddableTo {
17
18 public ArrayList<Realizer> realizers;
19
20 public KitPanel() {
21 }
22
23 public void add(Object obj) {
24 if (realizers == null) {
25 realizers = new ArrayList<Realizer>();
26 }
27 if (obj instanceof Realizer) {
28 realizers.add((Realizer)obj);
29
30 } else if (obj instanceof AdderTo) {
31 ((AdderTo)obj).addTo(this);
32
33 } else {
34 E.error("cant add non-realizer " + obj + " to " + this);
35 }
36 }
37
38
39 public DruPanel instantiatePanel() {
40 return new DruKitPanel();
41 }
42
43
44 public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) {
45
46 DruKitPanel dkp = (DruKitPanel)dp;
47
48
49 dkp.setRealizationContext(ctx.simpleCopy());
50
51 for (Realizer rlz : realizers) {
52 dkp.addRealizer(rlz);
53 }
54
55 }
56
57
58
59
60 }