View Javadoc

1   package org.catacomb.druid.blocks;
2   
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.DruEditorWindow;
9   import org.catacomb.druid.gui.base.DruFrame;
10  import org.catacomb.interlish.resource.Role;
11  import org.catacomb.interlish.structure.AddableTo;
12  import org.catacomb.report.E;
13  
14  
15  
16  import java.util.ArrayList;
17  
18  
19  
20  public class EditorWindow implements Realizer, AddableTo {
21  
22      public String name;
23      public String title;
24      public String id;
25      public String controllerClass;
26  
27      public int background;
28  
29      public SColor backgroundColor;
30  
31      public String closeAction;
32  
33      public Frame frame;
34  
35      public ArrayList<Dialog> dialogs;
36  
37  
38  
39  
40      public EditorWindow() {
41      }
42  
43  
44      public void add(Object obj) {
45          if (obj instanceof Frame) {
46              frame = (Frame)obj;
47  
48  
49          } else if (obj instanceof Dialog) {
50              if (dialogs == null) {
51                  dialogs = new ArrayList<Dialog>();
52              }
53              dialogs.add((Dialog)obj);
54  
55          } else if (obj instanceof Role) {
56  
57          } else {
58              E.error("cant add " + obj);
59          }
60      }
61  
62  
63      public Object realize(Context ctx, GUIPath gpathin) {
64          GUIPath gpath = gpathin;
65          gpath = gpath.extend(id);
66  
67  
68          DruFrame druFrame = (DruFrame)(frame.realize(ctx, gpath));
69  
70          if (closeAction != null) {
71              if (closeAction.equals("hide")) {
72                  druFrame.setCloseActionHide();
73              } else {
74                  E.warning("unrecognized close action : " + closeAction);
75              }
76          }
77  
78          if (name == null) {
79              name = title;
80          }
81  
82          druFrame.setTitle(name);
83  
84          DruEditorWindow druew = new DruEditorWindow();
85  
86          if (backgroundColor != null) {
87              E.info("need to use bg color");
88          }
89  
90          druew.setControllerPath(controllerClass);
91          druew.setName(name);
92  
93          druew.setMainFrame(druFrame);
94  
95  
96  
97          ctx.addComponent(druew, gpath);
98  
99  
100         if (dialogs != null) {
101             for (Dialog d : dialogs) {
102                 d.realize(ctx, new GUIPath());
103             }
104         }
105 
106 
107 
108         return druew;
109     }
110 
111 
112 
113 }