Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / PluginsLocator.java @ 44093

History | View | Annotate | Download (4.26 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
    public String getLocatorName() {
68
        return LOCATOR_NAME;
69
    }
70

    
71
    /**
72
     * Return a reference to DataManager.
73
     *
74
     * @return a reference to DataManager
75
     * @throws LocatorException
76
     *             if there is no access to the class or the class cannot be
77
     *             instantiated
78
     * @see Locator#get(String)
79
     */
80
    public static PluginsManager getManager() throws LocatorException {
81
        return (PluginsManager) getInstance().get(PLUGINS_MANAGER_NAME);
82
    }
83
    
84
    /**
85
     * Registers the Class implementing the DataManager interface.
86
     *
87
     * @param clazz
88
     *            implementing the DataManager interface
89
     */
90
    public static void registerManager(Class clazz) {
91
        getInstance().register(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION,
92
                clazz);
93
    }
94

    
95
    /**
96
     * Registers a class as the default DataManager.
97
     *
98
     * @param clazz
99
     *            implementing the DataManager interface
100
     */
101
    public static void registerDefaultManager(Class clazz) {
102
        getInstance().registerDefault(PLUGINS_MANAGER_NAME, PLUGINS_MANAGER_DESCRIPTION,
103
                clazz);
104
    }
105

    
106

    
107
    public static ActionInfoManager getActionInfoManager() throws LocatorException {
108
        return (ActionInfoManager) getInstance().get(PLUGINS_ACTIONINFO_MANAGER_NAME);
109
    }
110

    
111
    public static void registerActionInfoManager(Class clazz) {
112
        getInstance().register(PLUGINS_ACTIONINFO_MANAGER_NAME, PLUGINS_ACTIONINFO_MANAGER_DESCRIPTION,
113
                clazz);
114
    }
115

    
116
    public static MainFrame getMainFrame() {
117
        return Launcher.getFrame();
118
    }
119
    
120
    public static LocaleManager getLocaleManager() throws LocatorException {
121
        return (LocaleManager) getInstance().get(PLUGINS_LOCALE_MANAGER_NAME);
122
    }
123

    
124
    public static void registerLocaleManager(Class clazz) {
125
        getInstance().register(PLUGINS_LOCALE_MANAGER_NAME, PLUGINS_LOCALE_MANAGER_DESCRIPTION,
126
                clazz);
127
    }
128
}