Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.api / src / main / java / org / gvsig / tools / swing / api / ToolsSwingLocator.java @ 298

History | View | Annotate | Download (3.86 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22
package org.gvsig.tools.swing.api;
23

    
24
import org.gvsig.tools.locator.BaseLocator;
25
import org.gvsig.tools.locator.Locator;
26
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
27
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
28

    
29
/**
30
 * {@link Locator} for the tools swing Library. It returns a reference to the
31
 * library's main
32
 * utilities.
33
 * 
34
 * @author 2010- C?sar Ordi?ana - gvSIG team
35
 */
36
public class ToolsSwingLocator extends BaseLocator {
37

    
38
    private static final String LOCATOR_NAME = "Tools.swing.locator";
39

    
40
    public static final String DYNOBJECT_SWING_MANAGER_NAME =
41
        "Tools.dynobject.swing.manager";
42

    
43
    public static final String DYNOBJECT_SWING_MANAGER_DESCRIPTION =
44
        "Tools DynObject Swing Manager";
45

    
46
    public static final String USABILITY_SWING_MANAGER_NAME =
47
        "Tools.usability.swing.manager";
48

    
49
    public static final String USABILITY_SWING_MANAGER_DESCRIPTION =
50
        "Tools Usability Swing Manager";
51

    
52
    /**
53
     * Unique instance.
54
     */
55
    private static final ToolsSwingLocator instance = new ToolsSwingLocator();
56

    
57
    /**
58
     * Gets the instance of the {@link DynObjectSwingManager} registered.
59
     * 
60
     * @return {@link DynObjectSwingManager}
61
     */
62
    public static DynObjectSwingManager getDynObjectSwingManager() {
63
        return (DynObjectSwingManager) getInstance().get(
64
            DYNOBJECT_SWING_MANAGER_NAME);
65
    }
66

    
67
    /**
68
     * Return the {@link Singleton} instance.
69
     * 
70
     * @return the {@link Singleton} instance
71
     */
72
    public static ToolsSwingLocator getInstance() {
73
        return instance;
74
    }
75

    
76
    /**
77
     * Gets the instance of the {@link UsabilitySwingManager} registered.
78
     * 
79
     * @return {@link UsabilitySwingManager}
80
     */
81
    public static UsabilitySwingManager getUsabilitySwingManager() {
82
        return (UsabilitySwingManager) getInstance().get(
83
            USABILITY_SWING_MANAGER_NAME);
84
    }
85

    
86
    /**
87
     * Registers the Class implementing the {@link DynObjectSwingManager}
88
     * interface.
89
     * 
90
     * @param clazz
91
     *            implementing the {@link DynObjectSwingManager} interface
92
     */
93
    public static void registerDynObjectSwingManager(
94
        Class<? extends DynObjectSwingManager> clazz) {
95
        getInstance().register(DYNOBJECT_SWING_MANAGER_NAME,
96
            DYNOBJECT_SWING_MANAGER_DESCRIPTION, clazz);
97
    }
98

    
99
    /**
100
     * Registers the Class implementing the {@link UsabilitySwingManager}
101
     * interface.
102
     * 
103
     * @param clazz
104
     *            implementing the {@link UsabilitySwingManager} interface
105
     */
106
    public static void registerUsabilitySwingManager(
107
        Class<? extends UsabilitySwingManager> clazz) {
108
        getInstance().register(USABILITY_SWING_MANAGER_NAME,
109
            USABILITY_SWING_MANAGER_DESCRIPTION, clazz);
110
    }
111

    
112
    /**
113
     * Return the {@link Locator}'s name
114
     * 
115
     * @return a String with the {@link Locator}'s name
116
     */
117
    @Override
118
    public String getLocatorName() {
119
        return LOCATOR_NAME;
120
    }
121

    
122
}