KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > config > MasterScreen


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site (http://www.enhydra.org/).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: MasterScreen.java,v 1.1 2004/05/28 19:39:27 slobodan Exp $
22  */

23 package org.enhydra.barracuda.config;
24
25 import java.io.*;
26 import java.util.*;
27 import java.lang.ref.*;
28 import java.net.*;
29 import javax.servlet.*;
30 import javax.servlet.http.*;
31
32 import org.apache.log4j.*;
33 import org.w3c.dom.*;
34 import org.w3c.dom.html.*;
35
36 import org.enhydra.barracuda.config.events.*;
37 import org.enhydra.barracuda.config.xmlc.*;
38 import org.enhydra.barracuda.core.comp.*;
39 import org.enhydra.barracuda.core.event.*;
40 import org.enhydra.barracuda.core.event.helper.*;
41 import org.enhydra.barracuda.core.forms.*;
42 import org.enhydra.barracuda.core.util.dom.*;
43 import org.enhydra.barracuda.core.util.srv.*;
44 import org.enhydra.barracuda.core.view.*;
45 import org.enhydra.barracuda.plankton.data.*;
46 import org.enhydra.barracuda.plankton.http.*;
47
48 /**
49  * This class represents the master Barracuda config screen. It is stored
50  * in the users session on a per-locale basis, and is used kind of as a
51  * master repository for objects that make up the system.
52  */

53 public class MasterScreen {
54
55     //public constants
56
protected static final Logger logger = Logger.getLogger(MasterScreen.class.getName());
57     public static final String JavaDoc KEY = MasterScreen.class.getName()+".Key";
58
59     public Document dom = null;
60     public EventGateway egRoot = null;
61     public BComponent bcRoot = null;
62     public TabsModel tabsModel = null;
63     public TemplateModel masterModel = null;
64     public TemplateModel compModel = null;
65     public TemplateModel dataModel = null;
66     public TemplateModel domModel = null;
67     public TemplateModel eventModel = null;
68     public TemplateModel formsModel = null;
69     public TemplateModel utilModel = null;
70     public TemplateModel viewModel = null;
71     public Locale locale = null;
72     
73
74     //------------------- MasterScreen ---------------------------
75
public MasterScreen(EventGateway iegRoot, Locale ilocale) {
76         if (logger.isDebugEnabled()) logger.debug("Creating new ConfigScreen object");
77         
78         //save a copy of the locale
79
egRoot = iegRoot;
80         locale = ilocale;
81         
82         //load the localized DOM template
83
try {dom = DefaultDOMLoader.getGlobalInstance().getDOM(ConfigHTML.class, locale);}
84         catch (IOException e) {logger.fatal ("Fatal Error loading DOM template:", e);}
85
86         //create the root component
87
bcRoot = new BComponent();
88
89         //create the tab template
90
BTemplate btTabs = new BTemplate();
91         bcRoot.addChild(btTabs);
92         //...create the views (we're storing directives in separate file)
93
try {
94             Properties props = new Properties();
95             props.load(this.getClass().getResourceAsStream("Config.directives"));
96             Node node = dom.getElementById("ConfigTabs");
97             TemplateView tv = new DefaultTemplateView(node, "id", new MapStateMap(props));
98             btTabs.addView(tv);
99         } catch (IOException e) {
100             logger.fatal("Fatal err loading properties file:", e);
101         }
102         //...create the models
103
//......Master model
104
MasterConfig masterConfig = (MasterConfig) SimpleServiceFinder.findInstance(MasterConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
105         if (masterConfig!=null) {
106             masterModel = masterConfig.getModel();
107             btTabs.addModel(masterModel);
108         }
109         //......Tabs model
110
tabsModel = new TabsModel(btTabs);
111         btTabs.addModel(tabsModel);
112         //......Comp screen model
113
CompConfig compConfig = (CompConfig) SimpleServiceFinder.findInstance(CompConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
114         if (compConfig!=null) {
115             compModel = compConfig.getModel();
116             btTabs.addModel(compModel);
117         }
118         //......Data screen model
119
DataConfig dataConfig = (DataConfig) SimpleServiceFinder.findInstance(DataConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
120         if (dataConfig!=null) {
121             dataModel = dataConfig.getModel();
122             btTabs.addModel(dataModel);
123         }
124         //......Dom screen model
125
DomConfig domConfig = (DomConfig) SimpleServiceFinder.findInstance(DomConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
126         if (domConfig!=null) {
127             domModel = domConfig.getModel();
128             btTabs.addModel(domModel);
129         }
130         //......Event screen model
131
EventConfig eventConfig = (EventConfig) SimpleServiceFinder.findInstance(EventConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
132         if (eventConfig!=null) {
133             eventModel = eventConfig.getModel();
134             btTabs.addModel(eventModel);
135         }
136         //......Forms screen model
137
FormsConfig formsConfig = (FormsConfig) SimpleServiceFinder.findInstance(FormsConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
138         if (formsConfig!=null) {
139             formsModel = formsConfig.getModel();
140             btTabs.addModel(formsModel);
141         }
142         //......Util screen model
143
UtilConfig utilConfig = (UtilConfig) SimpleServiceFinder.findInstance(UtilConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
144         if (utilConfig!=null) {
145             utilModel = utilConfig.getModel();
146             btTabs.addModel(utilModel);
147         }
148         //......View screen model
149
ViewConfig viewConfig = (ViewConfig) SimpleServiceFinder.findInstance(ViewConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM);
150         if (viewConfig!=null) {
151             viewModel = viewConfig.getModel();
152             btTabs.addModel(viewModel);
153         }
154     }
155 }
156
157
158
159
160
161
162
Popular Tags