svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / PluginsLocator.java @ 44831
History | View | Annotate | Download (4.49 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 | 44831 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
27 | 40435 | jjdelcerro | import org.gvsig.andami.actioninfo.ActionInfoManager; |
28 | 41307 | jjdelcerro | import org.gvsig.andami.ui.mdiFrame.MainFrame; |
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 | 40435 | jjdelcerro | |
45 | private static final String PLUGINS_MANAGER_DESCRIPTION = "PluginsManager of Andami framework"; |
||
46 | private static final String PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION = "PluginsActionInfoManager"; |
||
47 | 41390 | jjdelcerro | private static final String PLUGINS_LOCALE_MANAGER_DESCRIPTION = "LocaleManager"; |
48 | 40435 | jjdelcerro | |
49 | /**
|
||
50 | * Unique instance.
|
||
51 | */
|
||
52 | 44505 | jjdelcerro | private static final PluginsLocator INSTANCE = new PluginsLocator(); |
53 | 40435 | jjdelcerro | |
54 | /**
|
||
55 | * Return the singleton instance.
|
||
56 | *
|
||
57 | * @return the singleton instance
|
||
58 | */
|
||
59 | public static PluginsLocator getInstance() { |
||
60 | 44505 | jjdelcerro | return INSTANCE;
|
61 | 40435 | jjdelcerro | } |
62 | |||
63 | /**
|
||
64 | * Returns the Locator name.
|
||
65 | *
|
||
66 | * @return String containing the locator name.
|
||
67 | */
|
||
68 | 44505 | jjdelcerro | @Override
|
69 | 40435 | jjdelcerro | public String getLocatorName() { |
70 | return LOCATOR_NAME;
|
||
71 | } |
||
72 | |||
73 | /**
|
||
74 | 44505 | jjdelcerro | * Return a reference to PluginsManager.
|
75 | 40435 | jjdelcerro | *
|
76 | 44505 | jjdelcerro | * @return a reference to PluginsManager
|
77 | 40435 | jjdelcerro | * @throws LocatorException
|
78 | * if there is no access to the class or the class cannot be
|
||
79 | * instantiated
|
||
80 | * @see Locator#get(String)
|
||
81 | */
|
||
82 | public static PluginsManager getManager() throws LocatorException { |
||
83 | return (PluginsManager) getInstance().get(PLUGINS_MANAGER_NAME);
|
||
84 | } |
||
85 | |||
86 | 44505 | jjdelcerro | public static PluginsManager getPluginsManager() throws LocatorException { |
87 | return (PluginsManager) getInstance().get(PLUGINS_MANAGER_NAME);
|
||
88 | } |
||
89 | |||
90 | 40435 | jjdelcerro | /**
|
91 | 44505 | jjdelcerro | * Registers the Class implementing the PluginsManager interface.
|
92 | 40435 | jjdelcerro | *
|
93 | * @param clazz
|
||
94 | 44505 | jjdelcerro | * implementing the PluginsManager interface
|
95 | 40435 | jjdelcerro | */
|
96 | public static void registerManager(Class clazz) { |
||
97 | getInstance().register(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
||
98 | clazz); |
||
99 | } |
||
100 | |||
101 | /**
|
||
102 | 44505 | jjdelcerro | * Registers a class as the default PluginsManager.
|
103 | 40435 | jjdelcerro | *
|
104 | * @param clazz
|
||
105 | * implementing the DataManager interface
|
||
106 | */
|
||
107 | public static void registerDefaultManager(Class clazz) { |
||
108 | getInstance().registerDefault(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
||
109 | clazz); |
||
110 | } |
||
111 | |||
112 | |||
113 | public static ActionInfoManager getActionInfoManager() throws LocatorException { |
||
114 | return (ActionInfoManager) getInstance().get(PLUGINS_ACTIONINFO_MANAGER_NAME);
|
||
115 | } |
||
116 | |||
117 | public static void registerActionInfoManager(Class clazz) { |
||
118 | getInstance().register(PLUGINS_ACTIONINFO_MANAGER_NAME, PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION, |
||
119 | clazz); |
||
120 | } |
||
121 | |||
122 | 41307 | jjdelcerro | public static MainFrame getMainFrame() { |
123 | return Launcher.getFrame();
|
||
124 | } |
||
125 | 41390 | jjdelcerro | |
126 | public static LocaleManager getLocaleManager() throws LocatorException { |
||
127 | return (LocaleManager) getInstance().get(PLUGINS_LOCALE_MANAGER_NAME);
|
||
128 | } |
||
129 | |||
130 | public static void registerLocaleManager(Class clazz) { |
||
131 | getInstance().register(PLUGINS_LOCALE_MANAGER_NAME, PLUGINS_LOCALE_MANAGER_DESCRIPTION, |
||
132 | clazz); |
||
133 | } |
||
134 | 43256 | jjdelcerro | } |