001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.gui;
019:
020: import java.util.Collection;
021: import java.util.Map;
022: import java.util.TreeMap;
023:
024: import de.finix.contelligent.client.base.AbstractRegistry;
025:
026: /**
027: * Singleton that allows guis to register a mapping from a symbolic to an
028: * implementation name.
029: */
030: public class GUIRegistry extends AbstractRegistry {
031:
032: public final static String TEMPLATE_GUI_IMPL = "de.finix.contelligent.client.gui.category.TemplateGUI";
033:
034: public final static String TRANSFORMER_GUI_IMPL = "de.finix.contelligent.client.gui.category.TransformerGUI";
035:
036: public final static String DEFAULT_TEMPLATE_GUI_IMPL = TEMPLATE_GUI_IMPL;
037:
038: // XXX make this accessible from outside, as ContelligentEditorKit needs it
039: public final static String DATA_GUI_NAME = "Subcomponent (Data)";
040:
041: public final static String ACCESS_GUI_NAME = "Access";
042:
043: private final static String DEFAULT_GUI_IMPL = "de.finix.contelligent.client.gui.property.PropertyGUI";
044:
045: protected static GUIRegistry registry = null;
046:
047: protected Map<String, String> componentGuiEntries;
048:
049: protected Map<String, String> viewGuiEntries;
050:
051: protected Map<String, String> templateGuiEntries;
052:
053: private GUIRegistry() {
054: super ();
055: componentGuiEntries = new TreeMap<String, String>();
056: viewGuiEntries = new TreeMap<String, String>();
057: templateGuiEntries = new TreeMap<String, String>();
058:
059: // Aliases for previous names are needed because old versions stored
060: // GUI mappings by their symbolic name
061: registerAlias("Default / Properties", "Properties (All)");
062: registerAlias("Edit properties", "Properties (Edit)");
063: registerAlias("View", "Subcomponent (View)");
064: registerAlias("Data", "Subcomponent (Data)");
065: registerAlias("Content", "Subcomponent (Content)");
066: registerAlias("Subcomponents", "Subcomponent (First)");
067:
068: registerAlias("Directory", "RestrictedTree");
069: registerAlias("PreviewTree", "BasicTree");
070:
071: // add values that should be retrieved from server in future
072: registerComponentGui("Properties (All)", DEFAULT_GUI_IMPL);
073:
074: registerComponentGui(ACCESS_GUI_NAME,
075: "de.finix.contelligent.client.gui.access.AccessGUI");
076: registerComponentGui("Boolean",
077: "de.finix.contelligent.client.gui.text.BooleanGUI");
078:
079: registerComponentGui("Image",
080: "de.finix.contelligent.client.gui.image.ImageGUI");
081: registerComponentGui("File",
082: "de.finix.contelligent.client.gui.file.FileGUI");
083: registerComponentGui("Properties (Edit)",
084: "de.finix.contelligent.client.gui.property.EditPropertyGUI");
085: registerComponentGui("Properties (Develop)",
086: "de.finix.contelligent.client.gui.property.DevelopPropertyGUI");
087:
088: registerComponentGui("String",
089: "de.finix.contelligent.client.gui.text.StringGUI");
090: registerComponentGui("Number",
091: "de.finix.contelligent.client.gui.text.NumberGUI");
092: registerComponentGui("Text",
093: "de.finix.contelligent.client.gui.text.TextGUI");
094: registerComponentGui("StyledText",
095: "de.finix.contelligent.client.gui.text.StyledTextGUI");
096: registerComponentGui("Password",
097: "de.finix.contelligent.client.gui.text.PasswordGUI");
098: registerComponentGui("Date",
099: "de.finix.contelligent.client.gui.text.DateGUI");
100:
101: registerComponentGui("Color",
102: "de.finix.contelligent.client.gui.color.ColorGUI");
103:
104: registerComponentGui("Link",
105: "de.finix.contelligent.client.gui.link.LinkGUI");
106:
107: registerComponentGui("Folder",
108: "de.finix.contelligent.client.gui.directory.FolderGUI");
109:
110: registerComponentGui("Description",
111: "de.finix.contelligent.client.gui.property.DescriptionGUI");
112:
113: registerViewGui("Library",
114: "de.finix.contelligent.client.gui.directory.LibraryGUI");
115: registerViewGui("Container",
116: "de.finix.contelligent.client.gui.directory.ContainerGUI");
117: registerHidden("Pages",
118: "de.finix.contelligent.client.gui.directory.PagesGUI");
119: registerViewGui("RestrictedTree",
120: "de.finix.contelligent.client.gui.directory.DirectoryGUI");
121: registerViewGui("BasicTree",
122: "de.finix.contelligent.client.gui.directory.PreviewGUI");
123: registerViewGui("ExpertTree",
124: "de.finix.contelligent.client.gui.directory.ExpertTreeGUI");
125:
126: registerComponentGui("Action",
127: "de.finix.contelligent.client.gui.action.FActionGUI");
128: registerComponentGui("ActionParameter",
129: "de.finix.contelligent.client.gui.property.ActionParameterGUI");
130: registerComponentGui("Routing",
131: "de.finix.contelligent.client.gui.action.RoutingGUI");
132:
133: registerComponentGui("Subcomponent (View)",
134: "de.finix.contelligent.client.gui.delegate.ViewGUI");
135: registerComponentGui(DATA_GUI_NAME,
136: "de.finix.contelligent.client.gui.delegate.DataGUI");
137: registerComponentGui("Subcomponent (Content)",
138: "de.finix.contelligent.client.gui.delegate.ContentGUI");
139: registerComponentGui("Subcomponent (First)",
140: "de.finix.contelligent.client.gui.delegate.SubcomponentGUI");
141:
142: registerComponentGui("ComposedTabbed",
143: "de.finix.contelligent.client.gui.composed.TabbedGUI");
144: registerComponentGui("ComposedTable",
145: "de.finix.contelligent.client.gui.composed.TableGUI");
146: registerComponentGui("ComposedForm",
147: "de.finix.contelligent.client.gui.composed.FormGUI");
148:
149: registerComponentGui("Metadata",
150: "de.finix.contelligent.client.gui.metadata.MetadataGUI");
151:
152: registerComponentGui("HTML (Block)",
153: "de.finix.contelligent.client.gui.text.EkitBlockGUI");
154: registerComponentGui("HTML (Page)",
155: "de.finix.contelligent.client.gui.text.EkitPageGUI");
156:
157: registerTemplateGui("Template (Normal)", TEMPLATE_GUI_IMPL);
158: registerTemplateGui("Template (XSL)", TRANSFORMER_GUI_IMPL);
159:
160: }
161:
162: public void register(String symbolicName, String impl) {
163: super .register(symbolicName, impl);
164: componentGuiEntries.put(symbolicName, impl);
165: templateGuiEntries.put(symbolicName, impl);
166: viewGuiEntries.put(symbolicName, impl);
167: }
168:
169: public void registerComponentGui(String symbolicName, String impl) {
170: super .register(symbolicName, impl);
171: componentGuiEntries.put(symbolicName, impl);
172: }
173:
174: public void registerViewGui(String symbolicName, String impl) {
175: super .register(symbolicName, impl);
176: viewGuiEntries.put(symbolicName, impl);
177: }
178:
179: public void registerTemplateGui(String symbolicName, String impl) {
180: super .register(symbolicName, impl);
181: templateGuiEntries.put(symbolicName, impl);
182: }
183:
184: public void registerHidden(String symbolicName, String impl) {
185: super .register(symbolicName, impl);
186: }
187:
188: public Collection getComponentGuiSymbolicNames() {
189: return componentGuiEntries.keySet();
190: }
191:
192: public Collection getComponentGuiImpls() {
193: return componentGuiEntries.values();
194: }
195:
196: public Collection getViewGuiSymbolicNames() {
197: return viewGuiEntries.keySet();
198: }
199:
200: public Collection getViewGuiImpls() {
201: return viewGuiEntries.values();
202: }
203:
204: public Collection getTemplateGuiSymbolicNames() {
205: return templateGuiEntries.keySet();
206: }
207:
208: public Collection getTemplateGuiImpls() {
209: return templateGuiEntries.values();
210: }
211:
212: public static GUIRegistry getInstance() {
213: if (registry == null) {
214: registry = new GUIRegistry();
215: }
216: return registry;
217: }
218:
219: public String getDefaultImpl() {
220: return DEFAULT_GUI_IMPL;
221: }
222:
223: public String getDefaultViewGuiImpl() {
224: return "de.finix.contelligent.client.gui.directory.ExpertTreeGUI";
225: }
226:
227: }
|