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 @ 1741

History | View | Annotate | Download (10.2 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 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
 * 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.tools.swing.api;
25

    
26
import org.gvsig.tools.locator.BaseLocator;
27
import org.gvsig.tools.locator.Locator;
28
import org.gvsig.tools.locator.LocatorException;
29
import org.gvsig.tools.swing.api.evaluator.ComponentSwingManager;
30
import org.gvsig.tools.swing.api.reminder.DialogReminderManager;
31
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager;
32
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
33
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
34
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
35
import org.gvsig.tools.swing.icontheme.IconThemeManager;
36

    
37
/**
38
 * {@link Locator} for the tools swing Library. It returns a reference to the
39
 * library's main
40
 * utilities.
41
 * 
42
 * @author 2010- C?sar Ordi?ana - gvSIG team
43
 */
44
public class ToolsSwingLocator extends BaseLocator {
45

    
46
    private static final String LOCATOR_NAME = "Tools.swing.locator";
47
    
48
    public static final String USABILITY_SWING_MANAGER_NAME =
49
        "Tools.usability.swing.manager";
50

    
51
    public static final String USABILITY_SWING_MANAGER_DESCRIPTION =
52
        "Tools Usability Swing Manager";
53

    
54
    private static final String TASKSTATUS_SWING_MANAGER_NAME = "Tools.task.swing.manager";
55

    
56
    private static final String TASKSTATUS_SWING_MANAGER_DESCRIPTION = "Tools Task Swing Manager";
57

    
58
    private static final String WINDOW_MANAGER_NAME = "Tools.swing.windowmanager";
59

    
60
    private static final String WINDOW_MANAGER_DESCRIPTION = "Tools Window Manager";
61

    
62
    private static final String ICONTHEME_MANAGER_NAME = "Tools.swing.iconthememanager";
63

    
64
    private static final String ICONTHEME_MANAGER_DESCRIPTION = "Tools Icon Theme Manager";
65

    
66
    private static final String COMPONENT_SWING_MANAGER_NAME = "Tools.swing.componentmanager";
67

    
68
    private static final String COMPONENT_SWING_MANAGER_DESCRIPTION = "Tools Swing Component Manager";
69

    
70
    private static final String THREADSAFEDIALOGS_MANAGER_NAME = "Tools.swing.threadsafedialogs";
71

    
72
    private static final String THREADSAFEDIALOGS_MANAGER_DESCRIPTION = "Thread safe dialogs Manager";
73
    
74
    private static final String SWING_MANAGER_NAME = "Tools.swing.manager";
75

    
76
    private static final String SWING_MANAGER_DESCRIPTION = "Tools Swing Manager";
77

    
78
    public static final String PLUGINS_DIALOGREMINDER_MANAGER_NAME = "DialogReminderManager";
79
    private static final String PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION = "DialogReminderManager";
80

    
81
    /**
82
     * Unique instance.
83
     */
84
    private static final ToolsSwingLocator instance = new ToolsSwingLocator();
85

    
86
    /**
87
     * Return the {@link Singleton} instance.
88
     * 
89
     * @return the {@link Singleton} instance
90
     */
91
    public static ToolsSwingLocator getInstance() {
92
        return instance;
93
    }
94

    
95
    /**
96
     * Return the {@link Locator}'s name
97
     * 
98
     * @return a String with the {@link Locator}'s name
99
     */
100
    @Override
101
    public String getLocatorName() {
102
        return LOCATOR_NAME;
103
    }
104

    
105
    /**
106
     * Gets the instance of the {@link UsabilitySwingManager} registered.
107
     * 
108
     * @return {@link UsabilitySwingManager}
109
     */
110
    public static UsabilitySwingManager getUsabilitySwingManager() {
111
        return (UsabilitySwingManager) getInstance().get(
112
            USABILITY_SWING_MANAGER_NAME);
113
    }
114

    
115
    /**
116
     * Registers the Class implementing the {@link UsabilitySwingManager}
117
     * interface.
118
     * 
119
     * @param clazz
120
     *            implementing the {@link UsabilitySwingManager} interface
121
     */
122
    public static void registerUsabilitySwingManager(
123
        Class<? extends UsabilitySwingManager> clazz) {
124
        getInstance().register(USABILITY_SWING_MANAGER_NAME,
125
            USABILITY_SWING_MANAGER_DESCRIPTION, clazz);
126
    }
127

    
128
    /**
129
     * Gets the instance of the {@link TaskStatusSwingManager} registered.
130
     * 
131
     * @return {@link TaskStatusSwingManager}
132
     */
133
    public static TaskStatusSwingManager getTaskStatusSwingManager() {
134
        return (TaskStatusSwingManager) getInstance().get(
135
                        TASKSTATUS_SWING_MANAGER_NAME);
136
    }
137

    
138
    /**
139
     * Registers the Class implementing the {@link TaskStatusSwingManager}
140
     * interface.
141
     * 
142
     * @param clazz
143
     *            implementing the {@link TaskStatusSwingManager} interface
144
     */
145
    public static void registerTaskStatusSwingManager(
146
        Class<? extends TaskStatusSwingManager> clazz) {
147
        getInstance().register(TASKSTATUS_SWING_MANAGER_NAME,
148
                        TASKSTATUS_SWING_MANAGER_DESCRIPTION, clazz);
149
    }
150

    
151
    /**
152
     * Gets the instance of the {@link WindowManager} registered.
153
     * 
154
     * @return {@link WindowManager}
155
     */
156
    public static WindowManager getWindowManager() {
157
        return (WindowManager) getInstance().get(
158
                        WINDOW_MANAGER_NAME);
159
    }
160

    
161
    /**
162
     * Registers the Class implementing the {@link WindowManager}
163
     * interface.
164
     * 
165
     * @param clazz
166
     *            implementing the {@link WindowManager} interface
167
     */
168
    public static void registerWindowManager(
169
        Class<? extends WindowManager> clazz) {
170
        getInstance().register(WINDOW_MANAGER_NAME,
171
                        WINDOW_MANAGER_DESCRIPTION, clazz);
172
    }
173

    
174
    public static void registerDefaultWindowManager(Class clazz) {
175
            getInstance().registerDefault(WINDOW_MANAGER_NAME, 
176
                WINDOW_MANAGER_DESCRIPTION,
177
                clazz);
178
    }
179
    
180
    /**
181
     * Gets the instance of the {@link IconThemeManager} registered.
182
     * 
183
     * @return {@link IconThemeManager}
184
     */
185
    public static IconThemeManager getIconThemeManager() {
186
        return (IconThemeManager) getInstance().get(
187
                        ICONTHEME_MANAGER_NAME);
188
    }
189

    
190
    /**
191
     * Registers the Class implementing the {@link IconThemeManager}
192
     * interface.
193
     * 
194
     * @param clazz
195
     *            implementing the {@link IconThemeManager} interface
196
     */
197
    public static void registerIconThemeManager(
198
        Class<? extends IconThemeManager> clazz) {
199
        getInstance().register(ICONTHEME_MANAGER_NAME,
200
                        ICONTHEME_MANAGER_DESCRIPTION, clazz);
201
    }
202

    
203
    public static void registerDefaultIconThemeManager(Class clazz) {
204
            getInstance().registerDefault(ICONTHEME_MANAGER_NAME, 
205
                ICONTHEME_MANAGER_DESCRIPTION,
206
                clazz);
207
    }
208
    
209
    /**
210
     * Gets the instance of the {@link ComponentSwingManager} registered.
211
     * 
212
     * @return {@link ComponentSwingManager}
213
     */
214
    public static ComponentSwingManager getComponentSwingManager() {
215
        return (ComponentSwingManager) getInstance().get(
216
            COMPONENT_SWING_MANAGER_NAME);
217
    }
218

    
219
    /**
220
     * Registers the Class implementing the {@link ComponentSwingManager}
221
     * interface.
222
     * 
223
     * @param clazz
224
     *            implementing the {@link ComponentSwingManager} interface
225
     */
226
    public static void registerComponentSwingManager(
227
        Class<? extends ComponentSwingManager> clazz) {
228
        getInstance().register(
229
            COMPONENT_SWING_MANAGER_NAME,
230
            COMPONENT_SWING_MANAGER_DESCRIPTION, clazz);
231
    }
232

    
233

    
234
    /**
235
     * Gets the instance of the {@link ThreadSafeDialogsManager} registered.
236
     * 
237
     * @return {@link ThreadSafeDialogsManager}
238
     */
239
    public static ThreadSafeDialogsManager getThreadSafeDialogsManager() {
240
        return (ThreadSafeDialogsManager) getInstance().get(
241
                        THREADSAFEDIALOGS_MANAGER_NAME);
242
    }
243

    
244
    /**
245
     * Registers the Class implementing the {@link ThreadSafeDialogsManager}
246
     * interface.
247
     * 
248
     * @param clazz
249
     *            implementing the {@link ThreadSafeDialogsManager} interface
250
     */
251
    public static void registerThreadSafeDialogsManager(
252
        Class<? extends ThreadSafeDialogsManager> clazz) {
253
        getInstance().register(THREADSAFEDIALOGS_MANAGER_NAME,
254
                        THREADSAFEDIALOGS_MANAGER_DESCRIPTION, clazz);
255
    }
256

    
257
    public static void registerDefaultThreadSafeDialogsManager(Class clazz) {
258
            getInstance().registerDefault(THREADSAFEDIALOGS_MANAGER_NAME, 
259
                THREADSAFEDIALOGS_MANAGER_DESCRIPTION,
260
                clazz);
261
    }
262

    
263
    /**
264
     * Gets the instance of the {@link ToolsSwingManager} registered.
265
     * 
266
     * @return {@link ToolsSwingManager}
267
     */
268
    public static ToolsSwingManager getToolsSwingManager() {
269
        return (ToolsSwingManager) getInstance().get(
270
                        SWING_MANAGER_NAME);
271
    }
272

    
273
    /**
274
     * Registers the Class implementing the {@link ToolsSwingManager}
275
     * interface.
276
     * 
277
     * @param clazz
278
     *            implementing the {@link ToolsSwingManager} interface
279
     */
280
    public static void registerToolsSwingManager(
281
        Class<? extends ToolsSwingManager> clazz) {
282
        getInstance().register(SWING_MANAGER_NAME,
283
                        SWING_MANAGER_DESCRIPTION, clazz);
284
    }
285
    
286
        //Dialog reminder
287
    public static DialogReminderManager getDialogReminderManager() throws LocatorException {
288
        return (DialogReminderManager) getInstance().get(PLUGINS_DIALOGREMINDER_MANAGER_NAME);
289
    }
290

    
291
    public static void registerDialogReminderManager(Class clazz) {
292
        getInstance().register(PLUGINS_DIALOGREMINDER_MANAGER_NAME, PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION,
293
                clazz);
294
    }
295

    
296
    public static void registerDefaultDialogReminderManager(Class clazz) {
297
            getInstance().registerDefault(PLUGINS_DIALOGREMINDER_MANAGER_NAME, PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION,
298
        clazz);
299
    }
300
}