View Javadoc

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.DruPanel;
7   import org.catacomb.druid.gui.base.PanelWrapper;
8   import org.catacomb.interlish.structure.AddableTo;
9   import org.catacomb.report.E;
10  
11  
12  
13  public class SinglePanelContainer implements AddableTo {
14  
15      public Realizer realizer;
16  
17  
18  
19      public DruPanel realizePanel(Context ctx, GUIPath gpath) {
20          DruPanel ret = null;
21          if (realizer != null) {
22              Object obj = realizer.realize(ctx, gpath);
23              if (obj instanceof DruPanel) {
24                  ret = (DruPanel)obj;
25              } else if (obj instanceof PanelWrapper) {
26                  ret = ((PanelWrapper)obj).getPanel();
27              } else {
28                  E.error("cant get panel from " + obj);
29              }
30          }
31  
32          return ret;
33  
34      }
35  
36  
37      public void add(Object obj) {
38          if (obj instanceof Realizer) {
39              if (realizer == null) {
40                  realizer = (Realizer)obj;
41              } else {
42                  E.error("too many panels (>1) " + getClass().getName());
43              }
44  
45          } else {
46              E.error("cant add  non-panel to " + this);
47              E.info("tried to add " + obj + " (" + obj.getClass().getName() + ")");
48          }
49  
50      }
51  
52  }