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

History | View | Annotate | Download (11 KB)

1 802 cordinyana
/**
2
 * gvSIG. Desktop Geographic Information System.
3 93 cordinyana
 *
4 802 cordinyana
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6 93 cordinyana
 * 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 802 cordinyana
 *
11 93 cordinyana
 * 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 802 cordinyana
 *
16 93 cordinyana
 * 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 802 cordinyana
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 93 cordinyana
 * MA  02110-1301, USA.
20 802 cordinyana
 *
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 93 cordinyana
 */
24
package org.gvsig.tools.swing.api;
25
26
import org.gvsig.tools.locator.BaseLocator;
27 272 cmartin
import org.gvsig.tools.locator.Locator;
28 1593 jjdelcerro
import org.gvsig.tools.locator.LocatorException;
29 806 jldominguez
import org.gvsig.tools.swing.api.evaluator.ComponentSwingManager;
30 1593 jjdelcerro
import org.gvsig.tools.swing.api.reminder.DialogReminderManager;
31 1754 jjdelcerro
import org.gvsig.tools.swing.api.script.ScriptSwingManager;
32 447 jjdelcerro
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager;
33 1173 jjdelcerro
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
34 100 cordinyana
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
35 449 jjdelcerro
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
36 698 jjdelcerro
import org.gvsig.tools.swing.icontheme.IconThemeManager;
37 93 cordinyana
38
/**
39 272 cmartin
 * {@link Locator} for the tools swing Library. It returns a reference to the
40
 * library's main
41 93 cordinyana
 * utilities.
42
 *
43
 * @author 2010- C?sar Ordi?ana - gvSIG team
44
 */
45
public class ToolsSwingLocator extends BaseLocator {
46
47 270 cmartin
    private static final String LOCATOR_NAME = "Tools.swing.locator";
48 1124 jjdelcerro
49 270 cmartin
    public static final String USABILITY_SWING_MANAGER_NAME =
50
        "Tools.usability.swing.manager";
51 100 cordinyana
52 270 cmartin
    public static final String USABILITY_SWING_MANAGER_DESCRIPTION =
53
        "Tools Usability Swing Manager";
54 100 cordinyana
55 1173 jjdelcerro
    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 447 jjdelcerro
58 1173 jjdelcerro
    private static final String WINDOW_MANAGER_NAME = "Tools.swing.windowmanager";
59 449 jjdelcerro
60 1173 jjdelcerro
    private static final String WINDOW_MANAGER_DESCRIPTION = "Tools Window Manager";
61 449 jjdelcerro
62 1173 jjdelcerro
    private static final String ICONTHEME_MANAGER_NAME = "Tools.swing.iconthememanager";
63 698 jjdelcerro
64 1173 jjdelcerro
    private static final String ICONTHEME_MANAGER_DESCRIPTION = "Tools Icon Theme Manager";
65 698 jjdelcerro
66 806 jldominguez
    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 1173 jjdelcerro
    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 1251 jjdelcerro
    private static final String SWING_MANAGER_NAME = "Tools.swing.manager";
75
76
    private static final String SWING_MANAGER_DESCRIPTION = "Tools Swing Manager";
77
78 1593 jjdelcerro
    public static final String PLUGINS_DIALOGREMINDER_MANAGER_NAME = "DialogReminderManager";
79
    private static final String PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION = "DialogReminderManager";
80
81 1754 jjdelcerro
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 1173 jjdelcerro
    /**
86 270 cmartin
     * Unique instance.
87
     */
88
    private static final ToolsSwingLocator instance = new ToolsSwingLocator();
89 93 cordinyana
90 270 cmartin
    /**
91 272 cmartin
     * Return the {@link Singleton} instance.
92 270 cmartin
     *
93 272 cmartin
     * @return the {@link Singleton} instance
94 270 cmartin
     */
95
    public static ToolsSwingLocator getInstance() {
96
        return instance;
97
    }
98 170 cmartin
99 270 cmartin
    /**
100 447 jjdelcerro
     * Return the {@link Locator}'s name
101 270 cmartin
     *
102 447 jjdelcerro
     * @return a String with the {@link Locator}'s name
103 270 cmartin
     */
104 447 jjdelcerro
    @Override
105
    public String getLocatorName() {
106
        return LOCATOR_NAME;
107 270 cmartin
    }
108 93 cordinyana
109 270 cmartin
    /**
110 447 jjdelcerro
     * 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 272 cmartin
     * Registers the Class implementing the {@link UsabilitySwingManager}
121
     * interface.
122 270 cmartin
     *
123
     * @param clazz
124 272 cmartin
     *            implementing the {@link UsabilitySwingManager} interface
125 270 cmartin
     */
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 93 cordinyana
132 270 cmartin
    /**
133 447 jjdelcerro
     * Gets the instance of the {@link TaskStatusSwingManager} registered.
134 270 cmartin
     *
135 447 jjdelcerro
     * @return {@link TaskStatusSwingManager}
136 270 cmartin
     */
137 447 jjdelcerro
    public static TaskStatusSwingManager getTaskStatusSwingManager() {
138
        return (TaskStatusSwingManager) getInstance().get(
139
                        TASKSTATUS_SWING_MANAGER_NAME);
140 270 cmartin
    }
141 100 cordinyana
142 447 jjdelcerro
    /**
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 449 jjdelcerro
    /**
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 447 jjdelcerro
165 449 jjdelcerro
    /**
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 1741 jjdelcerro
    public static void registerDefaultWindowManager(Class clazz) {
179
            getInstance().registerDefault(WINDOW_MANAGER_NAME,
180
                WINDOW_MANAGER_DESCRIPTION,
181
                clazz);
182
    }
183
184 698 jjdelcerro
    /**
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 449 jjdelcerro
194 698 jjdelcerro
    /**
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 1741 jjdelcerro
207
    public static void registerDefaultIconThemeManager(Class clazz) {
208
            getInstance().registerDefault(ICONTHEME_MANAGER_NAME,
209
                ICONTHEME_MANAGER_DESCRIPTION,
210
                clazz);
211
    }
212 806 jldominguez
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 698 jjdelcerro
223 806 jldominguez
    /**
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 1173 jjdelcerro
    /**
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 1741 jjdelcerro
    public static void registerDefaultThreadSafeDialogsManager(Class clazz) {
262
            getInstance().registerDefault(THREADSAFEDIALOGS_MANAGER_NAME,
263
                THREADSAFEDIALOGS_MANAGER_DESCRIPTION,
264
                clazz);
265
    }
266
267 1251 jjdelcerro
    /**
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 1173 jjdelcerro
277 1251 jjdelcerro
    /**
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 1593 jjdelcerro
290
        //Dialog reminder
291
    public static DialogReminderManager getDialogReminderManager() throws LocatorException {
292
        return (DialogReminderManager) getInstance().get(PLUGINS_DIALOGREMINDER_MANAGER_NAME);
293
    }
294 1251 jjdelcerro
295 1593 jjdelcerro
    public static void registerDialogReminderManager(Class clazz) {
296
        getInstance().register(PLUGINS_DIALOGREMINDER_MANAGER_NAME, PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION,
297
                clazz);
298
    }
299
300 1741 jjdelcerro
    public static void registerDefaultDialogReminderManager(Class clazz) {
301
            getInstance().registerDefault(PLUGINS_DIALOGREMINDER_MANAGER_NAME, PLUGINS_DIALOGREMINDER_MANAGER_DESCRIPTION,
302
        clazz);
303
    }
304 1754 jjdelcerro
305
    public static ScriptSwingManager getScriptSwingManager() throws LocatorException {
306 1774 jjdelcerro
        return (ScriptSwingManager) getInstance().get(SCRIPT_SWING_MANAGER_NAME);
307 1754 jjdelcerro
    }
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 270 cmartin
}