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 |
/**
|
---|---|
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 |
package org.gvsig.andami; |
25 |
|
26 |
import org.apache.commons.lang3.StringUtils; |
27 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
28 |
import org.gvsig.andami.ui.mdiFrame.MainFrame; |
29 |
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 |
public static final String PLUGINS_LOCALE_MANAGER_NAME = "LocaleManager"; |
44 |
|
45 |
private static final String PLUGINS_MANAGER_DESCRIPTION = "PluginsManager of Andami framework"; |
46 |
private static final String PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION = "PluginsActionInfoManager"; |
47 |
private static final String PLUGINS_LOCALE_MANAGER_DESCRIPTION = "LocaleManager"; |
48 |
|
49 |
/**
|
50 |
* Unique instance.
|
51 |
*/
|
52 |
private static final PluginsLocator INSTANCE = new PluginsLocator(); |
53 |
|
54 |
/**
|
55 |
* Return the singleton instance.
|
56 |
*
|
57 |
* @return the singleton instance
|
58 |
*/
|
59 |
public static PluginsLocator getInstance() { |
60 |
return INSTANCE;
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* Returns the Locator name.
|
65 |
*
|
66 |
* @return String containing the locator name.
|
67 |
*/
|
68 |
@Override
|
69 |
public String getLocatorName() { |
70 |
return LOCATOR_NAME;
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* Return a reference to PluginsManager.
|
75 |
*
|
76 |
* @return a reference to PluginsManager
|
77 |
* @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 |
public static PluginsManager getPluginsManager() throws LocatorException { |
87 |
return (PluginsManager) getInstance().get(PLUGINS_MANAGER_NAME);
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* Registers the Class implementing the PluginsManager interface.
|
92 |
*
|
93 |
* @param clazz
|
94 |
* implementing the PluginsManager interface
|
95 |
*/
|
96 |
public static void registerManager(Class clazz) { |
97 |
getInstance().register(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION, |
98 |
clazz); |
99 |
} |
100 |
|
101 |
/**
|
102 |
* Registers a class as the default PluginsManager.
|
103 |
*
|
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 |
public static MainFrame getMainFrame() { |
123 |
return Launcher.getFrame();
|
124 |
} |
125 |
|
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 |
} |