svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / PluginsLocator.java @ 43167
History | View | Annotate | Download (4.92 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 3
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.andami; |
25 | |||
26 | import org.gvsig.andami.actioninfo.ActionInfoManager; |
||
27 | 41307 | jjdelcerro | import org.gvsig.andami.ui.mdiFrame.MainFrame; |
28 | 43167 | jjdelcerro | import org.gvsig.dialogremember.DialogRememberManager; |
29 | 40435 | jjdelcerro | import org.gvsig.tools.locator.AbstractLocator; |
30 | import org.gvsig.tools.locator.Locator; |
||
31 | import org.gvsig.tools.locator.LocatorException; |
||
32 | |||
33 | |||
34 | public class PluginsLocator extends AbstractLocator { |
||
35 | |||
36 | private static final String LOCATOR_NAME = "PluginsLocator"; |
||
37 | |||
38 | /**
|
||
39 | * PluginsManager name used by the locator to access the instance
|
||
40 | */
|
||
41 | public static final String PLUGINS_MANAGER_NAME = "PluginsManager"; |
||
42 | public static final String PLUGINS_ACTIONINFO_MANAGER_NAME = "PluginsActionInfoManager"; |
||
43 | 41390 | jjdelcerro | public static final String PLUGINS_LOCALE_MANAGER_NAME = "LocaleManager"; |
44 | 43167 | jjdelcerro | public static final String PLUGINS_DIALOGREMEMBERDER_MANAGER_NAME = "DialogReminderManager"; |
45 | 40435 | jjdelcerro | |
46 | private static final String PLUGINS_MANAGER_DESCRIPTION = "PluginsManager of Andami framework"; |
||
47 | private static final String PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION = "PluginsActionInfoManager"; |
||
48 | 41390 | jjdelcerro | private static final String PLUGINS_LOCALE_MANAGER_DESCRIPTION = "LocaleManager"; |
49 | 43167 | jjdelcerro | private static final String PLUGINS_DIALOGREMEMBER_MANAGER_DESCRIPTION = "DialogReminderManager"; |
50 | 40435 | jjdelcerro | |
51 | /**
|
||
52 | * Unique instance.
|
||
53 | */
|
||
54 | private static final PluginsLocator instance = new PluginsLocator(); |
||
55 | |||
56 | /**
|
||
57 | * Return the singleton instance.
|
||
58 | *
|
||
59 | * @return the singleton instance
|
||
60 | */
|
||
61 | public static PluginsLocator getInstance() { |
||
62 | return instance;
|
||
63 | } |
||
64 | |||
65 | /**
|
||
66 | * Returns the Locator name.
|
||
67 | *
|
||
68 | * @return String containing the locator name.
|
||
69 | */
|
||
70 | public String getLocatorName() { |
||
71 | return LOCATOR_NAME;
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * Return a reference to DataManager.
|
||
76 | *
|
||
77 | * @return a reference to DataManager
|
||
78 | * @throws LocatorException
|
||
79 | * if there is no access to the class or the class cannot be
|
||
80 | * instantiated
|
||
81 | * @see Locator#get(String)
|
||
82 | */
|
||
83 | public static PluginsManager getManager() throws LocatorException { |
||
84 | return (PluginsManager) getInstance().get(PLUGINS_MANAGER_NAME);
|
||
85 | } |
||
86 | |||
87 | /**
|
||
88 | * Registers the Class implementing the DataManager interface.
|
||
89 | *
|
||
90 | * @param clazz
|
||
91 | * implementing the DataManager interface
|
||
92 | */
|
||
93 | public static void registerManager(Class clazz) { |
||
94 | getInstance().register(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
||
95 | clazz); |
||
96 | } |
||
97 | |||
98 | /**
|
||
99 | * Registers a class as the default DataManager.
|
||
100 | *
|
||
101 | * @param clazz
|
||
102 | * implementing the DataManager interface
|
||
103 | */
|
||
104 | public static void registerDefaultManager(Class clazz) { |
||
105 | getInstance().registerDefault(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
||
106 | clazz); |
||
107 | } |
||
108 | |||
109 | |||
110 | public static ActionInfoManager getActionInfoManager() throws LocatorException { |
||
111 | return (ActionInfoManager) getInstance().get(PLUGINS_ACTIONINFO_MANAGER_NAME);
|
||
112 | } |
||
113 | |||
114 | public static void registerActionInfoManager(Class clazz) { |
||
115 | getInstance().register(PLUGINS_ACTIONINFO_MANAGER_NAME, PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION, |
||
116 | clazz); |
||
117 | } |
||
118 | |||
119 | 41307 | jjdelcerro | public static MainFrame getMainFrame() { |
120 | return Launcher.getFrame();
|
||
121 | } |
||
122 | 41390 | jjdelcerro | |
123 | public static LocaleManager getLocaleManager() throws LocatorException { |
||
124 | return (LocaleManager) getInstance().get(PLUGINS_LOCALE_MANAGER_NAME);
|
||
125 | } |
||
126 | |||
127 | public static void registerLocaleManager(Class clazz) { |
||
128 | getInstance().register(PLUGINS_LOCALE_MANAGER_NAME, PLUGINS_LOCALE_MANAGER_DESCRIPTION, |
||
129 | clazz); |
||
130 | } |
||
131 | |||
132 | 43167 | jjdelcerro | public static DialogRememberManager getDialogRemembereManager() throws LocatorException { |
133 | return (DialogRememberManager) getInstance().get(PLUGINS_DIALOGREMEMBERDER_MANAGER_NAME);
|
||
134 | } |
||
135 | |||
136 | public static void registerDialogRememberManager(Class clazz) { |
||
137 | getInstance().register(PLUGINS_DIALOGREMEMBERDER_MANAGER_NAME, PLUGINS_DIALOGREMEMBER_MANAGER_DESCRIPTION, |
||
138 | clazz); |
||
139 | } |
||
140 | 40435 | jjdelcerro | } |