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

History | View | Annotate | Download (11.1 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.script.ScriptSwingManager;
32
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager;
33
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
34
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
35
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
36
import org.gvsig.tools.swing.icontheme.IconThemeManager;
37

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

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

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

    
55
    private static final String TASKSTATUS_SWING_MANAGER_NAME = "Tools.task.swing.manager";
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
    private static final String SCRIPT_SWING_MANAGER_NAME = "Tools.script.swing.manager";
83
    private static final String SCRIPT_SWING_MANAGER_DESCRIPTION = "Tools Script Swing Manager";
84

    
85
    /**
86
     * Unique instance.
87
     */
88
    private static final ToolsSwingLocator instance = new ToolsSwingLocator();
89

    
90
    /**
91
     * Return the {@link Singleton} instance.
92
     * 
93
     * @return the {@link Singleton} instance
94
     */
95
    public static ToolsSwingLocator getInstance() {
96
        return instance;
97
    }
98

    
99
    /**
100
     * Return the {@link Locator}'s name
101
     * 
102
     * @return a String with the {@link Locator}'s name
103
     */
104
    @Override
105
    public String getLocatorName() {
106
        return LOCATOR_NAME;
107
    }
108

    
109
    /**
110
     * Gets the instance of the {@link UsabilitySwingManager} registered.
111
     * 
112
     * @return {@link UsabilitySwingManager}
113
     */
114
    public static UsabilitySwingManager getUsabilitySwingManager() {
115
        return (UsabilitySwingManager) getInstance().get(
116
            USABILITY_SWING_MANAGER_NAME);
117
    }
118

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

    
132
    /**
133
     * Gets the instance of the {@link TaskStatusSwingManager} registered.
134
     * 
135
     * @return {@link TaskStatusSwingManager}
136
     */
137
    public static TaskStatusSwingManager getTaskStatusSwingManager() {
138
        return (TaskStatusSwingManager) getInstance().get(
139
                        TASKSTATUS_SWING_MANAGER_NAME);
140
    }
141

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

    
155
    /**
156
     * Gets the instance of the {@link WindowManager} registered.
157
     * 
158
     * @return {@link WindowManager}
159
     */
160
    public static WindowManager getWindowManager() {
161
        return (WindowManager) getInstance().get(
162
                        WINDOW_MANAGER_NAME);
163
    }
164

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

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

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

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

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

    
237

    
238
    /**
239
     * Gets the instance of the {@link ThreadSafeDialogsManager} registered.
240
     * 
241
     * @return {@link ThreadSafeDialogsManager}
242
     */
243
    public static ThreadSafeDialogsManager getThreadSafeDialogsManager() {
244
        return (ThreadSafeDialogsManager) getInstance().get(
245
                        THREADSAFEDIALOGS_MANAGER_NAME);
246
    }
247

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

    
261
    public static void registerDefaultThreadSafeDialogsManager(Class clazz) {
262
            getInstance().registerDefault(THREADSAFEDIALOGS_MANAGER_NAME, 
263
                THREADSAFEDIALOGS_MANAGER_DESCRIPTION,
264
                clazz);
265
    }
266

    
267
    /**
268
     * Gets the instance of the {@link ToolsSwingManager} registered.
269
     * 
270
     * @return {@link ToolsSwingManager}
271
     */
272
    public static ToolsSwingManager getToolsSwingManager() {
273
        return (ToolsSwingManager) getInstance().get(
274
                        SWING_MANAGER_NAME);
275
    }
276

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

    
295
    public static void registerDialogReminderManager(Class clazz) {
296
        getInstance().register(PLUGINS_DIALOGREMINDER_MANAGER_NAME, PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION,
297
                clazz);
298
    }
299

    
300
    public static void registerDefaultDialogReminderManager(Class clazz) {
301
            getInstance().registerDefault(PLUGINS_DIALOGREMINDER_MANAGER_NAME, PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION,
302
        clazz);
303
    }
304

    
305
    public static ScriptSwingManager getScriptSwingManager() throws LocatorException {
306
        return (ScriptSwingManager) (DialogReminderManager) getInstance().get(SCRIPT_SWING_MANAGER_NAME);
307
    }
308

    
309
    public static void registerScriptSwingManager(Class clazz) {
310
        getInstance().register(SCRIPT_SWING_MANAGER_NAME, SCRIPT_SWING_MANAGER_DESCRIPTION,
311
                clazz);
312
    }
313

    
314
    public static void registerDefaultScriptSwingManager(Class clazz) {
315
            getInstance().registerDefault(
316
                    SCRIPT_SWING_MANAGER_NAME, 
317
                    SCRIPT_SWING_MANAGER_DESCRIPTION,
318
                    clazz
319
            );
320
    }
321

    
322
}