01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui;
19:
20: import java.util.Collection;
21: import java.util.Map;
22: import java.util.TreeMap;
23:
24: import de.finix.contelligent.client.base.AbstractRegistry;
25:
26: /**
27: * Singleton that allows views to register a mapping from a symbolic to an
28: * implementation name.
29: */
30: public class ViewRegistry extends AbstractRegistry {
31:
32: private static ViewRegistry viewRegistry = null;
33:
34: protected Map<String, String> visibleEntries;
35:
36: private final static String DEFAULT_VIEW_IMPL = "de.finix.contelligent.client.gui.DefaultView";
37:
38: private ViewRegistry() {
39: super ();
40: visibleEntries = new TreeMap<String, String>();
41: // add values that should be retrieved from server in future
42: register("Default", DEFAULT_VIEW_IMPL);
43: registerHidden("Dialog",
44: "de.finix.contelligent.client.gui.DialogView");
45: register("Library",
46: "de.finix.contelligent.client.gui.LibraryView");
47: registerHidden("Administration",
48: "de.finix.contelligent.client.gui.AdministrationView");
49: }
50:
51: public void register(String symbolicName, String impl) {
52: super .register(symbolicName, impl);
53: visibleEntries.put(symbolicName, impl);
54: }
55:
56: public void registerHidden(String symbolicName, String impl) {
57: super .register(symbolicName, impl);
58: }
59:
60: public Collection getVisibleSymbolicNames() {
61: return visibleEntries.keySet();
62: }
63:
64: public Collection getVisibleImpls() {
65: return visibleEntries.values();
66: }
67:
68: public static ViewRegistry getInstance() {
69: if (viewRegistry == null) {
70: viewRegistry = new ViewRegistry();
71: }
72: return viewRegistry;
73: }
74:
75: public String getDefaultImpl() {
76: return DEFAULT_VIEW_IMPL;
77: }
78: }
|