View Javadoc

1   
2   package org.catacomb.druid.blocks;
3   
4   import org.catacomb.datalish.SColor;
5   import org.catacomb.druid.build.Context;
6   import org.catacomb.druid.build.GUIPath;
7   import org.catacomb.druid.build.Realizer;
8   import org.catacomb.druid.gui.base.DruDialog;
9   import org.catacomb.druid.gui.base.DruFrame;
10  import org.catacomb.druid.gui.base.DruPanel;
11  import org.catacomb.interlish.structure.AddableTo;
12  import org.catacomb.report.E;
13  
14  
15  
16  public class Dialog implements AddableTo, Realizer {
17  
18  
19      public String title;
20      public Panel panel;
21  
22      public String id;
23  
24      public boolean modal;
25  
26      public SColor backgroundColor;
27  
28  
29      public Dialog() {
30          modal = false;
31      }
32  
33  
34      public void add(Object obj) {
35          if (obj instanceof Panel) {
36              panel = (Panel)obj;
37          } else {
38              E.error("cant add " + obj);
39          }
40      }
41  
42  
43      public Object realize(Context ctx, GUIPath gpath) {
44          return realize(null, ctx, gpath);
45      }
46  
47      public Object realize(DruFrame dfin, Context ctx, GUIPath gpathin) {
48          DruFrame druFrame = dfin;
49          GUIPath gpath = gpathin;
50          gpath = gpath.extend(id);
51  
52          if (druFrame == null) {
53              druFrame = new DruFrame("dummy frame");
54          }
55  
56          if (backgroundColor != null) {
57              ctx.setBg(backgroundColor.getColor());
58          }
59  
60  
61  
62  
63          DruDialog drud = new DruDialog(druFrame, (title != null ? title : ""));
64          drud.setID(id);
65  
66  
67  
68          if (panel != null) {
69              DruPanel drup = (DruPanel)(panel.realize(ctx, gpath));
70              drud.setDruPanel(drup);
71          }
72  
73          drud.setModal(modal);
74  
75          ctx.addComponent(drud, gpath);
76  
77          return drud;
78      }
79  
80  
81  
82  }