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