1 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 53 public class MasterScreen { 54 55 protected static final Logger logger = Logger.getLogger(MasterScreen.class.getName()); 57 public static final String 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 public MasterScreen(EventGateway iegRoot, Locale ilocale) { 76 if (logger.isDebugEnabled()) logger.debug("Creating new ConfigScreen object"); 77 78 egRoot = iegRoot; 80 locale = ilocale; 81 82 try {dom = DefaultDOMLoader.getGlobalInstance().getDOM(ConfigHTML.class, locale);} 84 catch (IOException e) {logger.fatal ("Fatal Error loading DOM template:", e);} 85 86 bcRoot = new BComponent(); 88 89 BTemplate btTabs = new BTemplate(); 91 bcRoot.addChild(btTabs); 92 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 MasterConfig masterConfig = (MasterConfig) SimpleServiceFinder.findInstance(MasterConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 105 if (masterConfig!=null) { 106 masterModel = masterConfig.getModel(); 107 btTabs.addModel(masterModel); 108 } 109 tabsModel = new TabsModel(btTabs); 111 btTabs.addModel(tabsModel); 112 CompConfig compConfig = (CompConfig) SimpleServiceFinder.findInstance(CompConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 114 if (compConfig!=null) { 115 compModel = compConfig.getModel(); 116 btTabs.addModel(compModel); 117 } 118 DataConfig dataConfig = (DataConfig) SimpleServiceFinder.findInstance(DataConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 120 if (dataConfig!=null) { 121 dataModel = dataConfig.getModel(); 122 btTabs.addModel(dataModel); 123 } 124 DomConfig domConfig = (DomConfig) SimpleServiceFinder.findInstance(DomConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 126 if (domConfig!=null) { 127 domModel = domConfig.getModel(); 128 btTabs.addModel(domModel); 129 } 130 EventConfig eventConfig = (EventConfig) SimpleServiceFinder.findInstance(EventConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 132 if (eventConfig!=null) { 133 eventModel = eventConfig.getModel(); 134 btTabs.addModel(eventModel); 135 } 136 FormsConfig formsConfig = (FormsConfig) SimpleServiceFinder.findInstance(FormsConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 138 if (formsConfig!=null) { 139 formsModel = formsConfig.getModel(); 140 btTabs.addModel(formsModel); 141 } 142 UtilConfig utilConfig = (UtilConfig) SimpleServiceFinder.findInstance(UtilConfig.class, egRoot, SimpleServiceFinder.DOWNSTREAM); 144 if (utilConfig!=null) { 145 utilModel = utilConfig.getModel(); 146 btTabs.addModel(utilModel); 147 } 148 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 |