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.DruCollapsiblePanel; 7 import org.catacomb.druid.gui.base.DruPanel; 8 import org.catacomb.druid.gui.base.PanelWrapper; 9 import org.catacomb.interlish.structure.AddableTo; 10 import org.catacomb.report.E; 11 12 13 public class CollapsiblePanel extends Panel implements AddableTo { 14 15 public Realizer realizer; 16 17 18 public CollapsiblePanel() { 19 20 } 21 22 23 public void add(Object obj) { 24 if (obj instanceof Realizer) { 25 realizer = (Realizer)obj; 26 } else { 27 E.error("cant add non-realizer " + obj + " to " + this); 28 } 29 } 30 31 32 public DruPanel instantiatePanel() { 33 DruCollapsiblePanel dcp = new DruCollapsiblePanel(); 34 dcp.setSingle(); 35 return dcp; 36 } 37 38 39 public void populatePanel(DruPanel dp, Context ctx, GUIPath gpath) { 40 DruCollapsiblePanel dcp = (DruCollapsiblePanel)dp; 41 if (realizer != null) { 42 Object panobj = realizer.realize(ctx, gpath); 43 44 if (panobj instanceof DruPanel) { 45 dcp.addContentPanel((DruPanel)panobj); 46 47 } else if (panobj instanceof PanelWrapper) { 48 DruPanel dpw = ((PanelWrapper)panobj).getPanel(); 49 dcp.addContentPanel(dpw); 50 51 } else { 52 E.error(" (Druid build) - non-panel object in MultiPanel " + panobj + " " 53 + panobj.getClass().getName()); 54 } 55 } 56 } 57 58 59 }