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.build.Realizer;
6 import org.catacomb.druid.gui.base.*;
7 import org.catacomb.druid.gui.edit.DruMenu;
8 import org.catacomb.interlish.structure.AddableTo;
9 import org.catacomb.report.E;
10
11
12 import java.util.ArrayList;
13
14
15 public abstract class MultiPanel extends Panel implements AddableTo {
16
17 public ArrayList<Realizer> realizers;
18
19 public int xspace;
20 public int yspace;
21
22
23 public MultiPanel() {
24 xspace = 0;
25 yspace = 0;
26 }
27
28
29 public void add(Object obj) {
30 if (realizers == null) {
31 realizers = new ArrayList<Realizer>();
32 }
33 if (obj instanceof Realizer) {
34 realizers.add((Realizer)obj);
35 } else {
36 E.error("cant add non-realizer " + obj + " to " + this);
37 }
38 }
39
40
41 public void checkPanelCount(int np) {
42 if (getPanelCount() != np) {
43 E.warning("wrong number of panels - got " + getPanelCount() + " but need " + np);
44 }
45 }
46
47 public int getPanelCount() {
48 int npan = 0;
49 if (realizers != null) {
50 npan = realizers.size();
51 }
52 return npan;
53 }
54
55
56
57
58
59 public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) {
60
61
62
63 if (realizers != null) {
64 for (Realizer rlz : realizers) {
65
66 Object panobj = rlz.realize(ctx, gpath);
67
68 if (panobj instanceof DruPanel) {
69 dp.addPanel((DruPanel)panobj);
70
71 } else if (panobj instanceof PanelWrapper) {
72 DruPanel dpw = ((PanelWrapper)panobj).getPanel();
73 dp.addPanel(dpw);
74
75 } else if (panobj instanceof DruMenu) {
76 dp.addMenu((DruMenu)panobj);
77
78 } else if (panobj instanceof DruSplitterBar) {
79 dp.addDComponent(((DruSplitterBar)panobj).getGUIPeer());
80
81
82
83
84 } else {
85 E.error(" (Druid build) - non-panel object in MultiPanel " + panobj + " "
86 + panobj.getClass().getName());
87 }
88 }
89 }
90 }
91
92
93 }