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.DruApplication;
7   import org.catacomb.druid.gui.base.DruFrame;
8   import org.catacomb.druid.gui.base.DruTooltips;
9   import org.catacomb.druid.guimodel.Log;
10  import org.catacomb.interlish.structure.AddableTo;
11  import org.catacomb.interlish.version.BuildInfo;
12  import org.catacomb.report.E;
13  
14  
15  
16  
17  import java.util.ArrayList;
18  
19  
20  
21  public class Application implements AddableTo, Realizer {
22  
23      public String name;
24      public String versionNumber;
25      public String id;
26      public String controllerClass;
27  
28      public int background;
29  
30      // not used here - pull this out before parsing;
31      public SplashScreen splashScreen;
32  
33      public boolean logging;
34      public boolean stateExposure;
35  
36      public HTMLContent doc;
37  
38      public Frame frame;
39  
40  
41      public ArrayList<Requisite> requisites;
42  
43      public ArrayList<Dialog> dialogs;
44  
45      public ArrayList<Wizard> wizards;
46  
47  
48      public Application() {
49          requisites = new ArrayList<Requisite>();
50          wizards = new ArrayList<Wizard>();
51          dialogs = new ArrayList<Dialog>();
52      }
53  
54  
55  
56      public Object realize(Context ctx, GUIPath gpathin) {
57          GUIPath gpath = gpathin;
58  
59          DruTooltips.init();
60  
61          gpath = gpath.extend(id);
62  
63          DruFrame druFrame = (DruFrame)(frame.realize(ctx, gpath));
64  
65          druFrame.setTitle(name + " " + BuildInfo.getInfo().getTitleDate());
66  
67          DruApplication druapp = new DruApplication();
68  
69          druapp.setControllerPath(controllerClass);
70          druapp.setName(name);
71  
72          druapp.setMainFrame(druFrame);
73  
74          if (doc != null) {
75              druapp.setDoc(doc.getContent());
76          }
77  
78          if (dialogs != null) {
79              for (Dialog dlg : dialogs) {
80                  dlg.realize(druFrame, ctx, gpath);
81              }
82          }
83  
84  
85          ctx.addComponent(druapp, gpath);
86  
87  
88          BuildInfo bi = BuildInfo.getInfo();
89          bi.setName(name);
90          bi.setNum(versionNumber);
91  
92          bi.printIntro();
93  
94  
95  
96          //  druFrame.setTitle(BuildInfo.getInfo().getFrameTitle());
97  
98  
99          Log log = new Log("default");
100         Log.setSystemLog(log);
101         ctx.getMarketplace().global().addReceiver("LogMessage", log, "default");
102 
103         if (logging) {
104             ctx.getMarketplace().global().addProducer("Log", log, "default");
105         }
106 
107         if (stateExposure) {
108             E.missing("cant do state exposure");
109 //      ctx.getHookupBoard().addProducer("Page", new StatePageSupplier(doc.getContent()), "state");
110         }
111 
112 
113         if (requisites != null) {
114             for (Requisite requ : requisites) {
115                 requ.realize(ctx, gpath);
116             }
117         }
118 
119         ctx.getMarketplace().logUnresolved();
120         ctx.getMarketplace().global().logUnresolved();
121 
122         Log.infoMsg("startup" , BuildInfo.getInfo().getIntro());
123 
124         return druapp;
125     }
126 
127 
128 
129     public void add(Object obj) {
130         if (obj instanceof TableTree) {
131             E.missing();
132 
133         } else if (obj instanceof Requisite) {
134             requisites.add((Requisite)obj);
135 
136         } else if (obj instanceof Dialog) {
137             dialogs.add((Dialog)obj);
138 
139         } else if (obj instanceof Wizard) {
140             wizards.add((Wizard)obj);
141 
142         } else if (obj instanceof Frame) {
143             frame = (Frame)obj;
144 
145         } else {
146             E.error("cant add " + obj);
147         }
148 
149 
150 
151     }
152 
153 
154 
155 }