Update MANIFEST.MF, replaced deprecated Provide-Package with Export-Package.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / internal / ui / PHPUiImages.java
1 package net.sourceforge.phpdt.internal.ui;
2
3 import java.net.MalformedURLException;
4 import java.net.URL;
5 import java.util.HashMap;
6 import java.util.Iterator;
7
8 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
9 import net.sourceforge.phpeclipse.ui.WebUI;
10
11 import org.eclipse.jface.action.IAction;
12 import org.eclipse.jface.resource.ImageDescriptor;
13 import org.eclipse.jface.resource.ImageRegistry;
14 import org.eclipse.swt.graphics.Image;
15
16 public class PHPUiImages {
17
18         protected static final String NAME_PREFIX = "net.sourceforge.phpdt.internal.ui.";
19
20         protected static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
21
22         protected static URL fgIconBaseURL = null;
23
24         // static {
25         // String pathSuffix = "icons/";
26         // try {
27         // fgIconBaseURL =
28         // new URL(
29         // PHPeclipsePlugin
30         // .getDefault()
31         // .getDescriptor()
32         // .getInstallURL(),
33         // pathSuffix);
34         // } catch (MalformedURLException e) {
35         // PHPeclipsePlugin.log(e);
36         // }
37         // }
38
39         // Determine display depth. If depth > 4 then we use high color images.
40         // Otherwise low color
41         // images are used
42         static {
43                 fgIconBaseURL = WebUI.getDefault().getBundle().getEntry(
44                                 "/icons/"); //$NON-NLS-1$
45         }
46
47         private static ImageRegistry fgImageRegistry = null;
48
49         private static HashMap fgAvoidSWTErrorMap = null;
50
51         protected static final String OBJ_PREFIX = "obj16";
52
53         protected static final String OVR_PREFIX = "ovr16";
54
55         protected static final String CTOOL_PREFIX = "ctool16";
56
57         public static final String IMG_CLASS = NAME_PREFIX
58                         + "class_default_obj.gif";
59
60         public static final String IMG_DEFINE = NAME_PREFIX + "define_obj.gif";
61
62         public static final String IMG_BUILTIN = NAME_PREFIX + "builtin_obj.gif";
63
64         public static final String IMG_FUN = NAME_PREFIX + "fun_obj.gif";
65
66         public static final String IMG_INC = NAME_PREFIX + "impc_obj.gif";
67
68         public static final String IMG_VAR = NAME_PREFIX + "var_obj.gif";
69
70         public static final String IMG_TABLE = NAME_PREFIX + "table_obj.gif";
71
72         public static final String IMG_COLUMN = NAME_PREFIX + "column_obj.gif";
73
74         public static final String IMG_OBJS_WARNING = NAME_PREFIX
75                         + "warning_obj.gif";
76
77         public static final String IMG_OBJS_INFO = NAME_PREFIX + "info_obj.gif";
78
79         public static final String IMG_CTOOLS_PHP_PAGE = NAME_PREFIX
80                         + "php_page.gif";
81
82         public static final String IMG_CTOOLS_PHP = NAME_PREFIX + "php.gif";
83
84         public static final String IMG_CLEAR = NAME_PREFIX + "clear.gif";
85
86         public static final ImageDescriptor DESC_CLASS = createManaged(OBJ_PREFIX,
87                         IMG_CLASS);
88
89         public static final ImageDescriptor DESC_DEFINE = createManaged(OBJ_PREFIX,
90                         IMG_DEFINE);
91
92         public static final ImageDescriptor DESC_BUILTIN = createManaged(
93                         OBJ_PREFIX, IMG_BUILTIN);
94
95         public static final ImageDescriptor DESC_FUN = createManaged(OBJ_PREFIX,
96                         IMG_FUN);
97
98         public static final ImageDescriptor DESC_INC = createManaged(OBJ_PREFIX,
99                         IMG_INC);
100
101         public static final ImageDescriptor DESC_VAR = createManaged(OBJ_PREFIX,
102                         IMG_VAR);
103
104         public static final ImageDescriptor DESC_TABLE = createManaged(OBJ_PREFIX,
105                         IMG_TABLE);
106
107         public static final ImageDescriptor DESC_COLUMN = createManaged(OBJ_PREFIX,
108                         IMG_COLUMN);
109
110         public static final ImageDescriptor DESC_OBJS_WARNING = createManaged(
111                         OBJ_PREFIX, IMG_OBJS_WARNING);
112
113         public static final ImageDescriptor DESC_OBJS_INFO = createManaged(
114                         OBJ_PREFIX, IMG_OBJS_INFO);
115
116         public static final ImageDescriptor DESC_CTOOL_PHP_PAGE = createManaged(
117                         CTOOL_PREFIX, IMG_CTOOLS_PHP_PAGE);
118
119         public static final ImageDescriptor DESC_CTOOL_PHP = createManaged(
120                         CTOOL_PREFIX, IMG_CTOOLS_PHP);
121
122         public static final ImageDescriptor DESC_CLEAR = createManaged(OBJ_PREFIX,
123                         IMG_CLEAR);
124
125         /*
126          * Set of predefined Image Descriptors.
127          */
128         private static final String T_OBJ = "obj16"; //$NON-NLS-1$
129
130         private static final String T_OVR = "ovr16"; //$NON-NLS-1$
131
132         private static final String T_WIZBAN = "wizban"; //$NON-NLS-1$
133
134         private static final String T_CLCL = "clcl16"; //$NON-NLS-1$
135
136         private static final String T_DLCL = "dlcl16"; //$NON-NLS-1$
137
138         private static final String T_ELCL = "elcl16"; //$NON-NLS-1$
139
140         private static final String T_CTOOL = "ctool16"; //$NON-NLS-1$
141
142         private static final String T_CVIEW = "cview16"; //$NON-NLS-1$
143
144         public static final ImageDescriptor DESC_WIZBAN_NEWCLASS = create(T_WIZBAN,
145                         "newclass_wiz.gif"); //$NON-NLS-1$
146
147         public static final ImageDescriptor DESC_ELCL_FILTER = create(T_ELCL,
148                         "filter_ps.gif"); //$NON-NLS-1$
149
150         public static final ImageDescriptor DESC_DLCL_FILTER = create(T_DLCL,
151                         "filter_ps.gif"); //$NON-NLS-1$
152
153         /*
154          * Available cached Images in the Java plugin image registry.
155          */
156         public static final String IMG_MISC_PUBLIC = NAME_PREFIX
157                         + "methpub_obj.gif"; //$NON-NLS-1$
158
159         public static final String IMG_MISC_PROTECTED = NAME_PREFIX
160                         + "methpro_obj.gif"; //$NON-NLS-1$
161
162         public static final String IMG_MISC_PRIVATE = NAME_PREFIX
163                         + "methpri_obj.gif"; //$NON-NLS-1$
164
165         public static final String IMG_MISC_DEFAULT = NAME_PREFIX
166                         + "methdef_obj.gif"; //$NON-NLS-1$
167
168         public static final String IMG_FIELD_PUBLIC = NAME_PREFIX
169                         + "field_public_obj.gif"; //$NON-NLS-1$
170
171         public static final String IMG_FIELD_PROTECTED = NAME_PREFIX
172                         + "field_protected_obj.gif"; //$NON-NLS-1$
173
174         public static final String IMG_FIELD_PRIVATE = NAME_PREFIX
175                         + "field_private_obj.gif"; //$NON-NLS-1$
176
177         public static final String IMG_FIELD_DEFAULT = NAME_PREFIX
178                         + "field_default_obj.gif"; //$NON-NLS-1$
179
180         public static final String IMG_OBJS_GHOST = NAME_PREFIX + "ghost.gif"; //$NON-NLS-1$
181
182         public static final String IMG_OBJS_SEARCH_TSK = NAME_PREFIX
183                         + "search_tsk.gif"; //$NON-NLS-1$
184
185         public static final String IMG_OBJS_PACKDECL = NAME_PREFIX
186                         + "packd_obj.gif"; //$NON-NLS-1$
187
188         public static final String IMG_OBJS_IMPDECL = NAME_PREFIX + "imp_obj.gif"; //$NON-NLS-1$
189
190         public static final String IMG_OBJS_IMPCONT = NAME_PREFIX + "impc_obj.gif"; //$NON-NLS-1$
191
192         public static final String IMG_OBJS_JSEARCH = NAME_PREFIX
193                         + "jsearch_obj.gif"; //$NON-NLS-1$
194
195         public static final String IMG_OBJS_SEARCH_DECL = NAME_PREFIX
196                         + "search_decl_obj.gif"; //$NON-NLS-1$
197
198         public static final String IMG_OBJS_SEARCH_REF = NAME_PREFIX
199                         + "search_ref_obj.gif"; //$NON-NLS-1$
200
201         public static final String IMG_OBJS_CLASS = NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
202
203         public static final String IMG_OBJS_CLASSALT = NAME_PREFIX
204                         + "classfo_obj.gif"; //$NON-NLS-1$
205
206         public static final String IMG_OBJS_CLASS_DEFAULT = NAME_PREFIX
207                         + "class_default_obj.gif"; //$NON-NLS-1$
208
209         public static final String IMG_OBJS_INTERFACE = NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$
210
211         public static final String IMG_OBJS_INTERFACEALT = NAME_PREFIX
212                         + "intf_obj.gif"; //$NON-NLS-1$
213
214         public static final String IMG_OBJS_INTERFACE_DEFAULT = NAME_PREFIX
215                         + "int_default_obj.gif"; //$NON-NLS-1$
216
217         public static final String IMG_OBJS_CUNIT = NAME_PREFIX + "phpedit.png"; //$NON-NLS-1$
218
219         public static final String IMG_OBJS_CUNIT_RESOURCE = NAME_PREFIX
220                         + "jcu_resource_obj.gif"; //$NON-NLS-1$
221
222         public static final String IMG_OBJS_CFILE = NAME_PREFIX + "classf_obj.gif"; //$NON-NLS-1$
223
224         public static final String IMG_OBJS_CFILECLASS = NAME_PREFIX
225                         + "class_obj.gif"; //$NON-NLS-1$
226
227         public static final String IMG_OBJS_CFILEINT = NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$
228
229         public static final String IMG_OBJS_LOGICAL_PACKAGE = NAME_PREFIX
230                         + "logical_package_obj.gif";//$NON-NLS-1$
231
232         public static final String IMG_OJS_EMPTY_LOGICAL_PACKAGE = NAME_PREFIX
233                         + "empty_logical_package_obj.gif";//$NON-NLS-1$
234
235         public static final String IMG_OBJS_PACKAGE = NAME_PREFIX
236                         + "package_obj.gif"; //$NON-NLS-1$
237
238         public static final String IMG_OBJS_EMPTY_PACK_RESOURCE = NAME_PREFIX
239                         + "empty_pack_fldr_obj.gif"; //$NON-NLS-1$
240
241         public static final String IMG_OBJS_EMPTY_PACKAGE = NAME_PREFIX
242                         + "empty_pack_obj.gif"; //$NON-NLS-1$
243
244         public static final String IMG_OBJS_PACKFRAG_ROOT = NAME_PREFIX
245                         + "packagefolder_obj.gif"; //$NON-NLS-1$
246
247         public static final String IMG_OBJS_MISSING_PACKFRAG_ROOT = NAME_PREFIX
248                         + "packagefolder_nonexist_obj.gif"; //$NON-NLS-1$
249
250         public static final String IMG_OBJS_MISSING_JAR = NAME_PREFIX
251                         + "jar_nonexist_obj.gif"; //$NON-NLS-1$
252
253         public static final String IMG_OBJS_JAR = NAME_PREFIX + "jar_obj.gif"; //$NON-NLS-1$
254
255         public static final String IMG_OBJS_EXTJAR = NAME_PREFIX + "jar_l_obj.gif"; //$NON-NLS-1$
256
257         public static final String IMG_OBJS_JAR_WSRC = NAME_PREFIX
258                         + "jar_src_obj.gif"; //$NON-NLS-1$
259
260         public static final String IMG_OBJS_EXTJAR_WSRC = NAME_PREFIX
261                         + "jar_lsrc_obj.gif"; //$NON-NLS-1$
262
263         public static final String IMG_OBJS_ENV_VAR = NAME_PREFIX
264                         + "envvar_obj.gif"; //$NON-NLS-1$
265
266         public static final String IMG_OBJS_MISSING_ENV_VAR = NAME_PREFIX
267                         + "envvar_nonexist_obj.gif"; //$NON-NLS-1$
268
269         public static final String IMG_OBJS_JAVA_MODEL = NAME_PREFIX
270                         + "java_model_obj.gif"; //$NON-NLS-1$
271
272         public static final String IMG_OBJS_UNKNOWN = NAME_PREFIX
273                         + "unknown_obj.gif"; //$NON-NLS-1$
274
275         public static final String IMG_OBJS_LIBRARY = NAME_PREFIX
276                         + "library_obj.gif"; //$NON-NLS-1$
277
278         public static final String IMG_OBJS_JAVADOCTAG = NAME_PREFIX
279                         + "jdoc_tag_obj.gif"; //$NON-NLS-1$
280
281         public static final String IMG_OBJS_HTMLTAG = NAME_PREFIX
282                         + "html_tag_obj.gif"; //$NON-NLS-1$
283
284         public static final String IMG_OBJS_TEMPLATE = NAME_PREFIX
285                         + "template_obj.gif"; //$NON-NLS-1$
286
287         public static final String IMG_OBJS_EXCEPTION = NAME_PREFIX
288                         + "jexception_obj.gif"; //$NON-NLS-1$
289
290         public static final String IMG_OBJS_ERROR = NAME_PREFIX
291                         + "jrtexception_obj.gif"; //$NON-NLS-1$
292
293         public static final String IMG_OBJS_BREAKPOINT_INSTALLED = NAME_PREFIX
294                         + "brkpi_obj.gif"; //$NON-NLS-1$
295
296         public static final String IMG_OBJS_FIXABLE_PROBLEM = NAME_PREFIX
297                         + "quickfix_warning_obj.gif"; //$NON-NLS-1$
298
299         public static final String IMG_OBJS_FIXABLE_ERROR = NAME_PREFIX
300                         + "quickfix_error_obj.gif"; //$NON-NLS-1$
301
302         public static final String IMG_OBJS_SNIPPET_EVALUATING = NAME_PREFIX
303                         + "jsbook_run_obj.gif"; //$NON-NLS-1$
304
305         public static final String IMG_OBJS_REFACTORING_FATAL = NAME_PREFIX
306                         + "fatalerror_obj.gif"; //$NON-NLS-1$
307
308         public static final String IMG_OBJS_REFACTORING_ERROR = NAME_PREFIX
309                         + "error_obj.gif"; //$NON-NLS-1$
310
311         public static final String IMG_OBJS_REFACTORING_WARNING = NAME_PREFIX
312                         + "warning_obj.gif"; //$NON-NLS-1$
313
314         public static final String IMG_OBJS_REFACTORING_INFO = NAME_PREFIX
315                         + "info_obj.gif"; //$NON-NLS-1$
316
317         public static final String IMG_OBJS_NLS_TRANSLATE = NAME_PREFIX
318                         + "translate.gif"; //$NON-NLS-1$
319
320         public static final String IMG_OBJS_NLS_NEVER_TRANSLATE = NAME_PREFIX
321                         + "never_translate.gif"; //$NON-NLS-1$
322
323         public static final String IMG_OBJS_NLS_SKIP = NAME_PREFIX + "skip.gif"; //$NON-NLS-1$
324
325         public static final String IMG_OBJS_SEARCH_READACCESS = NAME_PREFIX
326                         + "occ_read.gif"; //$NON-NLS-1$
327
328         public static final String IMG_OBJS_SEARCH_WRITEACCESS = NAME_PREFIX
329                         + "occ_write.gif"; //$NON-NLS-1$
330
331         public static final String IMG_OBJS_SEARCH_OCCURRENCE = NAME_PREFIX
332                         + "occ_match.gif"; //$NON-NLS-1$
333
334         public static final ImageDescriptor DESC_VIEW_ERRORWARNING_TAB = create(
335                         T_CVIEW, "errorwarning_tab.gif"); //$NON-NLS-1$
336
337         public static final ImageDescriptor DESC_VIEW_CLASSFILEGENERATION_TAB = create(
338                         T_CVIEW, "classfilegeneration_tab.gif"); //$NON-NLS-1$
339
340         public static final ImageDescriptor DESC_VIEW_JDKCOMPLIANCE_TAB = create(
341                         T_CVIEW, "jdkcompliance_tab.gif"); //$NON-NLS-1$
342
343         public static final ImageDescriptor DESC_CLCL_FILTER = create(T_CLCL,
344                         "filter_ps.gif"); //$NON-NLS-1$
345
346         public static final ImageDescriptor DESC_CLCL_CODE_ASSIST = create(T_CLCL,
347                         "metharg_obj.gif"); //$NON-NLS-1$
348
349         public static final ImageDescriptor DESC_DLCL_CODE_ASSIST = create(T_DLCL,
350                         "metharg_obj.gif"); //$NON-NLS-1$
351
352         public static final ImageDescriptor DESC_MISC_PUBLIC = createManaged(T_OBJ,
353                         IMG_MISC_PUBLIC);
354
355         public static final ImageDescriptor DESC_MISC_PROTECTED = createManaged(
356                         T_OBJ, IMG_MISC_PROTECTED);
357
358         public static final ImageDescriptor DESC_MISC_PRIVATE = createManaged(
359                         T_OBJ, IMG_MISC_PRIVATE);
360
361         public static final ImageDescriptor DESC_MISC_DEFAULT = createManaged(
362                         T_OBJ, IMG_MISC_DEFAULT);
363
364         public static final ImageDescriptor DESC_FIELD_PUBLIC = createManaged(
365                         T_OBJ, IMG_FIELD_PUBLIC); //$NON-NLS-1$
366
367         public static final ImageDescriptor DESC_FIELD_PROTECTED = createManaged(
368                         T_OBJ, IMG_FIELD_PROTECTED); //$NON-NLS-1$
369
370         public static final ImageDescriptor DESC_FIELD_PRIVATE = createManaged(
371                         T_OBJ, IMG_FIELD_PRIVATE); //$NON-NLS-1$
372
373         public static final ImageDescriptor DESC_FIELD_DEFAULT = createManaged(
374                         T_OBJ, IMG_FIELD_DEFAULT); //$NON-NLS-1$
375
376         public static final ImageDescriptor DESC_MENU_SHIFT_RIGHT = create(T_CTOOL,
377                         "shift_r_edit.gif"); //$NON-NLS-1$
378
379         public static final ImageDescriptor DESC_MENU_SHIFT_LEFT = create(T_CTOOL,
380                         "shift_l_edit.gif"); //$NON-NLS-1$
381
382         public static final ImageDescriptor DESC_OBJS_GHOST = createManaged(T_OBJ,
383                         IMG_OBJS_GHOST);
384
385         public static final ImageDescriptor DESC_OBJS_PACKDECL = createManaged(
386                         T_OBJ, IMG_OBJS_PACKDECL);
387
388         public static final ImageDescriptor DESC_OBJS_IMPDECL = createManaged(
389                         T_OBJ, IMG_OBJS_IMPDECL);
390
391         public static final ImageDescriptor DESC_OBJS_IMPCONT = createManaged(
392                         T_OBJ, IMG_OBJS_IMPCONT);
393
394         public static final ImageDescriptor DESC_OBJS_JSEARCH = createManaged(
395                         T_OBJ, IMG_OBJS_JSEARCH);
396
397         public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(
398                         T_OBJ, IMG_OBJS_SEARCH_DECL);
399
400         public static final ImageDescriptor DESC_OBJS_SEARCH_REF = createManaged(
401                         T_OBJ, IMG_OBJS_SEARCH_REF);
402
403         public static final ImageDescriptor DESC_OBJS_CUNIT = createManaged(T_OBJ,
404                         IMG_OBJS_CUNIT);
405
406         public static final ImageDescriptor DESC_OBJS_CUNIT_RESOURCE = createManaged(
407                         T_OBJ, IMG_OBJS_CUNIT_RESOURCE);
408
409         public static final ImageDescriptor DESC_OBJS_CFILE = createManaged(T_OBJ,
410                         IMG_OBJS_CFILE);
411
412         public static final ImageDescriptor DESC_OBJS_CFILECLASS = createManaged(
413                         T_OBJ, IMG_OBJS_CFILECLASS);
414
415         public static final ImageDescriptor DESC_OBJS_CFILEINT = createManaged(
416                         T_OBJ, IMG_OBJS_CFILEINT);
417
418         public static final ImageDescriptor DESC_OBJS_PACKAGE = createManaged(
419                         T_OBJ, IMG_OBJS_PACKAGE);
420
421         public static final ImageDescriptor DESC_OBJS_EMPTY_LOGICAL_PACKAGE = createManaged(
422                         T_OBJ, IMG_OJS_EMPTY_LOGICAL_PACKAGE);
423
424         public static final ImageDescriptor DESC_OBJS_LOGICAL_PACKAGE = createManaged(
425                         T_OBJ, IMG_OBJS_LOGICAL_PACKAGE);
426
427         public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE_RESOURCES = createManaged(
428                         T_OBJ, IMG_OBJS_EMPTY_PACK_RESOURCE);
429
430         public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE = createManaged(
431                         T_OBJ, IMG_OBJS_EMPTY_PACKAGE);
432
433         public static final ImageDescriptor DESC_OBJS_PACKFRAG_ROOT = createManaged(
434                         T_OBJ, IMG_OBJS_PACKFRAG_ROOT);
435
436         public static final ImageDescriptor DESC_OBJS_MISSING_PACKFRAG_ROOT = createManaged(
437                         T_OBJ, IMG_OBJS_MISSING_PACKFRAG_ROOT);
438
439         public static final ImageDescriptor DESC_OBJS_JAVA_MODEL = createManaged(
440                         T_OBJ, IMG_OBJS_JAVA_MODEL);
441
442         public static final ImageDescriptor DESC_OBJS_CLASS = createManaged(T_OBJ,
443                         IMG_OBJS_CLASS);
444
445         public static final ImageDescriptor DESC_OBJS_CLASS_DEFAULT = createManaged(
446                         T_OBJ, IMG_OBJS_CLASS_DEFAULT);
447
448         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PUBLIC = create(
449                         T_OBJ, "innerclass_public_obj.gif"); //$NON-NLS-1$
450
451         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_DEFAULT = create(
452                         T_OBJ, "innerclass_default_obj.gif"); //$NON-NLS-1$
453
454         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PROTECTED = create(
455                         T_OBJ, "innerclass_protected_obj.gif"); //$NON-NLS-1$
456
457         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PRIVATE = create(
458                         T_OBJ, "innerclass_private_obj.gif"); //$NON-NLS-1$
459
460         public static final ImageDescriptor DESC_OBJS_CLASSALT = createManaged(
461                         T_OBJ, IMG_OBJS_CLASSALT);
462
463         public static final ImageDescriptor DESC_OBJS_INTERFACE = createManaged(
464                         T_OBJ, IMG_OBJS_INTERFACE);
465
466         public static final ImageDescriptor DESC_OBJS_INTERFACE_DEFAULT = createManaged(
467                         T_OBJ, IMG_OBJS_INTERFACE_DEFAULT);
468
469         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PUBLIC = create(
470                         T_OBJ, "innerinterface_public_obj.gif"); //$NON-NLS-1$
471
472         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_DEFAULT = create(
473                         T_OBJ, "innerinterface_default_obj.gif"); //$NON-NLS-1$
474
475         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PROTECTED = create(
476                         T_OBJ, "innerinterface_protected_obj.gif"); //$NON-NLS-1$
477
478         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PRIVATE = create(
479                         T_OBJ, "innerinterface_private_obj.gif"); //$NON-NLS-1$
480
481         public static final ImageDescriptor DESC_OBJS_INTERFACEALT = createManaged(
482                         T_OBJ, IMG_OBJS_INTERFACEALT);
483
484         public static final ImageDescriptor DESC_OBJS_JAR = createManaged(T_OBJ,
485                         IMG_OBJS_JAR);
486
487         public static final ImageDescriptor DESC_OBJS_MISSING_JAR = createManaged(
488                         T_OBJ, IMG_OBJS_MISSING_JAR);
489
490         public static final ImageDescriptor DESC_OBJS_EXTJAR = createManaged(T_OBJ,
491                         IMG_OBJS_EXTJAR);
492
493         public static final ImageDescriptor DESC_OBJS_JAR_WSRC = createManaged(
494                         T_OBJ, IMG_OBJS_JAR_WSRC);
495
496         public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC = createManaged(
497                         T_OBJ, IMG_OBJS_EXTJAR_WSRC);
498
499         public static final ImageDescriptor DESC_OBJS_ENV_VAR = createManaged(
500                         T_OBJ, IMG_OBJS_ENV_VAR);
501
502         public static final ImageDescriptor DESC_OBJS_MISSING_ENV_VAR = createManaged(
503                         T_OBJ, IMG_OBJS_MISSING_ENV_VAR);
504
505         public static final ImageDescriptor DESC_OBJS_LIBRARY = createManaged(
506                         T_OBJ, IMG_OBJS_LIBRARY);
507
508         public static final ImageDescriptor DESC_OBJS_JAVADOCTAG = createManaged(
509                         T_OBJ, IMG_OBJS_JAVADOCTAG);
510
511         public static final ImageDescriptor DESC_OBJS_HTMLTAG = createManaged(
512                         T_OBJ, IMG_OBJS_HTMLTAG);
513
514         public static final ImageDescriptor DESC_OBJS_TEMPLATE = createManaged(
515                         T_OBJ, IMG_OBJS_TEMPLATE);
516
517         public static final ImageDescriptor DESC_OBJS_EXCEPTION = createManaged(
518                         T_OBJ, IMG_OBJS_EXCEPTION);
519
520         public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED = createManaged(
521                         T_OBJ, IMG_OBJS_BREAKPOINT_INSTALLED);
522
523         public static final ImageDescriptor DESC_OBJS_ERROR = createManaged(T_OBJ,
524                         IMG_OBJS_ERROR);
525
526         public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM = createManaged(
527                         T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
528
529         public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR = createManaged(
530                         T_OBJ, IMG_OBJS_FIXABLE_ERROR);
531
532         public static final ImageDescriptor DESC_OBJS_SNIPPET_EVALUATING = createManaged(
533                         T_OBJ, IMG_OBJS_SNIPPET_EVALUATING);
534
535         public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE = create(
536                         T_OBJ, "change.gif"); //$NON-NLS-1$
537
538         public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE = create(
539                         T_OBJ, "composite_change.gif"); //$NON-NLS-1$
540
541         public static final ImageDescriptor DESC_OBJS_CU_CHANGE = create(T_OBJ,
542                         "cu_change.gif"); //$NON-NLS-1$
543
544         public static final ImageDescriptor DESC_OBJS_FILE_CHANGE = create(T_OBJ,
545                         "file_change.gif"); //$NON-NLS-1$
546
547         public static final ImageDescriptor DESC_OBJS_TEXT_EDIT = create(T_OBJ,
548                         "text_edit.gif"); //$NON-NLS-1$
549
550         public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = create(
551                         T_OBJ, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
552
553         public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER_ATTRIB = create(
554                         T_OBJ, "output_folder_attrib.gif"); //$NON-NLS-1$
555
556         public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB = create(
557                         T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$
558
559         public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB = create(
560                         T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$
561
562         public static final ImageDescriptor DESC_OBJS_REFACTORING_FATAL = createManaged(
563                         T_OBJ, IMG_OBJS_REFACTORING_FATAL);
564
565         public static final ImageDescriptor DESC_OBJS_REFACTORING_ERROR = createManaged(
566                         T_OBJ, IMG_OBJS_REFACTORING_ERROR);
567
568         public static final ImageDescriptor DESC_OBJS_REFACTORING_WARNING = createManaged(
569                         T_OBJ, IMG_OBJS_REFACTORING_WARNING);
570
571         public static final ImageDescriptor DESC_OBJS_REFACTORING_INFO = createManaged(
572                         T_OBJ, IMG_OBJS_REFACTORING_INFO);
573
574         public static final ImageDescriptor DESC_OBJS_NLS_TRANSLATE = createManaged(
575                         T_OBJ, IMG_OBJS_NLS_TRANSLATE);
576
577         public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE = createManaged(
578                         T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
579
580         public static final ImageDescriptor DESC_OBJS_NLS_SKIP = createManaged(
581                         T_OBJ, IMG_OBJS_NLS_SKIP);
582
583         public static final ImageDescriptor DESC_OBJS_UNKNOWN = createManaged(
584                         T_OBJ, IMG_OBJS_UNKNOWN);
585
586         public static final ImageDescriptor DESC_OBJS_SEARCH_READACCESS = createManaged(
587                         T_OBJ, IMG_OBJS_SEARCH_READACCESS);
588
589         public static final ImageDescriptor DESC_OBJS_SEARCH_WRITEACCESS = createManaged(
590                         T_OBJ, IMG_OBJS_SEARCH_WRITEACCESS);
591
592         public static final ImageDescriptor DESC_OBJS_SEARCH_OCCURRENCE = createManaged(
593                         T_OBJ, IMG_OBJS_SEARCH_OCCURRENCE);
594
595         public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE = create(
596                         T_OBJ, "localvariable_obj.gif"); //$NON-NLS-1$
597
598         public static final ImageDescriptor DESC_OVR_STATIC = create(T_OVR,
599                         "static_co.gif"); //$NON-NLS-1$
600
601         public static final ImageDescriptor DESC_OVR_FINAL = create(T_OVR,
602                         "final_co.gif"); //$NON-NLS-1$
603
604         public static final ImageDescriptor DESC_OVR_ABSTRACT = create(T_OVR,
605                         "abstract_co.gif"); //$NON-NLS-1$
606
607         public static final ImageDescriptor DESC_OVR_SYNCH = create(T_OVR,
608                         "synch_co.gif"); //$NON-NLS-1$
609
610         public static final ImageDescriptor DESC_OVR_RUN = create(T_OVR,
611                         "run_co.gif"); //$NON-NLS-1$
612
613         public static final ImageDescriptor DESC_OVR_WARNING = create(T_OVR,
614                         "warning_co.gif"); //$NON-NLS-1$
615
616         public static final ImageDescriptor DESC_OVR_ERROR = create(T_OVR,
617                         "error_co.gif"); //$NON-NLS-1$
618
619         public static final ImageDescriptor DESC_OVR_OVERRIDES = create(T_OVR,
620                         "over_co.gif"); //$NON-NLS-1$
621
622         public static final ImageDescriptor DESC_OVR_IMPLEMENTS = create(T_OVR,
623                         "implm_co.gif"); //$NON-NLS-1$
624
625         public static final ImageDescriptor DESC_OVR_CONSTRUCTOR = create(T_OVR,
626                         "constr_ovr.gif"); //$NON-NLS-1$
627
628         public static final ImageDescriptor DESC_OVR_FOCUS = create(T_OVR,
629                         "focus_ovr.gif"); //$NON-NLS-1$
630
631         public static final ImageDescriptor DESC_WIZBAN_NEWFIELD = create(T_WIZBAN,
632                         "newfield_wiz.gif"); //$NON-NLS-1$
633
634         public static final ImageDescriptor DESC_WIZBAN_NEWINT = create(T_WIZBAN,
635                         "newint_wiz.gif"); //$NON-NLS-1$
636
637         public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ = create(T_WIZBAN,
638                         "newjprj_wiz.gif"); //$NON-NLS-1$
639
640         public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR = create(
641                         T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$
642
643         public static final ImageDescriptor DESC_WIZBAN_NEWMETH = create(T_WIZBAN,
644                         "newmeth_wiz.gif"); //$NON-NLS-1$
645
646         public static final ImageDescriptor DESC_WIZBAN_NEWPACK = create(T_WIZBAN,
647                         "newpack_wiz.gif"); //$NON-NLS-1$
648
649         public static final ImageDescriptor DESC_WIZBAN_NEWSCRAPPAGE = create(
650                         T_WIZBAN, "newsbook_wiz.gif"); //$NON-NLS-1$
651
652         public static final ImageDescriptor DESC_WIZBAN_JAVA_LAUNCH = create(
653                         T_WIZBAN, "java_app_wiz.gif"); //$NON-NLS-1$
654
655         public static final ImageDescriptor DESC_WIZBAN_JAVA_ATTACH = create(
656                         T_WIZBAN, "java_attach_wiz.gif"); //$NON-NLS-1$
657
658         public static final ImageDescriptor DESC_WIZBAN_REFACTOR = create(T_WIZBAN,
659                         "refactor_wiz.gif"); //$NON-NLS-1$
660
661         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD = create(
662                         T_WIZBAN, "fieldrefact_wiz.gif"); //$NON-NLS-1$
663
664         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD = create(
665                         T_WIZBAN, "methrefact_wiz.gif"); //$NON-NLS-1$
666
667         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE = create(
668                         T_WIZBAN, "typerefact_wiz.gif"); //$NON-NLS-1$
669
670         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PACKAGE = create(
671                         T_WIZBAN, "packrefact_wiz.gif"); //$NON-NLS-1$
672
673         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CODE = create(
674                         T_WIZBAN, "coderefact_wiz.gif"); //$NON-NLS-1$
675
676         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CU = create(
677                         T_WIZBAN, "compunitrefact_wiz.gif"); //$NON-NLS-1$
678
679         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PULL_UP = create(
680                         T_WIZBAN, "pullup_wiz.gif"); //$NON-NLS-1$
681
682         public static final ImageDescriptor DESC_WIZBAN_JAR_PACKAGER = create(
683                         T_WIZBAN, "jar_pack_wiz.gif"); //$NON-NLS-1$
684
685         public static final ImageDescriptor DESC_WIZBAN_JAVA_WORKINGSET = create(
686                         T_WIZBAN, "java_workingset_wiz.gif");//$NON-NLS-1$
687
688         public static final ImageDescriptor DESC_WIZBAN_EXPORT_JAVADOC = create(
689                         T_WIZBAN, "export_javadoc_wiz.gif");//$NON-NLS-1$
690
691         public static final ImageDescriptor DESC_WIZBAN_EXTERNALIZE_STRINGS = create(
692                         T_WIZBAN, "extstr_wiz.gif");//$NON-NLS-1$
693
694         public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY = create(
695                         T_WIZBAN, "addlibrary_wiz.gif");//$NON-NLS-1$
696
697         public static final ImageDescriptor DESC_TOOL_DISPLAYSNIPPET = create(
698                         T_CTOOL, "disp_sbook.gif"); //$NON-NLS-1$
699
700         public static final ImageDescriptor DESC_TOOL_RUNSNIPPET = create(T_CTOOL,
701                         "run_sbook.gif"); //$NON-NLS-1$
702
703         public static final ImageDescriptor DESC_TOOL_INSPSNIPPET = create(T_CTOOL,
704                         "insp_sbook.gif"); //$NON-NLS-1$
705
706         public static final ImageDescriptor DESC_TOOL_PACKSNIPPET = create(T_CTOOL,
707                         "pack_sbook.gif"); //$NON-NLS-1$
708
709         public static final ImageDescriptor DESC_TOOL_TERMSNIPPET = create(T_CTOOL,
710                         "term_sbook.gif"); //$NON-NLS-1$
711
712         public static final ImageDescriptor DESC_TOOL_SHOW_EMPTY_PKG = create(
713                         T_CTOOL, "show_empty_pkg.gif"); //$NON-NLS-1$
714
715         public static final ImageDescriptor DESC_TOOL_SHOW_SEGMENTS = create(
716                         T_CTOOL, "segment_edit.gif"); //$NON-NLS-1$
717
718         public static final ImageDescriptor DESC_TOOL_GOTO_NEXT_ERROR = create(
719                         T_CTOOL, "next_error_nav.gif"); //$NON-NLS-1$
720
721         public static final ImageDescriptor DESC_TOOL_GOTO_PREV_ERROR = create(
722                         T_CTOOL, "prev_error_nav.gif"); //$NON-NLS-1$
723
724         public static final ImageDescriptor DESC_TOOL_OPENTYPE = create(T_CTOOL,
725                         "opentype.gif"); //$NON-NLS-1$
726
727         public static final ImageDescriptor DESC_TOOL_NEWPROJECT = create(T_CTOOL,
728                         "newjprj_wiz.gif"); //$NON-NLS-1$
729
730         public static final ImageDescriptor DESC_TOOL_NEWPACKAGE = create(T_CTOOL,
731                         "newpack_wiz.gif"); //$NON-NLS-1$
732
733         public static final ImageDescriptor DESC_TOOL_NEWCLASS = create(T_CTOOL,
734                         "newclass_wiz.gif"); //$NON-NLS-1$
735
736         public static final ImageDescriptor DESC_TOOL_NEWINTERFACE = create(
737                         T_CTOOL, "newint_wiz.gif"); //$NON-NLS-1$
738
739         public static final ImageDescriptor DESC_TOOL_NEWSNIPPET = create(T_CTOOL,
740                         "newsbook_wiz.gif"); //$NON-NLS-1$
741
742         public static final ImageDescriptor DESC_TOOL_NEWPACKROOT = create(T_CTOOL,
743                         "newpackfolder_wiz.gif"); //$NON-NLS-1$
744
745         public static final ImageDescriptor DESC_TOOL_CLASSPATH_ORDER = create(
746                         T_OBJ, "cp_order_obj.gif"); //$NON-NLS-1$
747
748         // Keys for correction proposal. We have to put the image into the registry
749         // since "code assist" doesn't
750         // have a life cycle. So no change to dispose icons.
751
752         public static final String IMG_CORRECTION_CHANGE = NAME_PREFIX
753                         + "correction_change.gif"; //$NON-NLS-1$
754
755         public static final String IMG_CORRECTION_MOVE = NAME_PREFIX
756                         + "correction_move.gif"; //$NON-NLS-1$
757
758         public static final String IMG_CORRECTION_RENAME = NAME_PREFIX
759                         + "correction_rename.gif"; //$NON-NLS-1$
760
761         public static final String IMG_CORRECTION_DELETE_IMPORT = NAME_PREFIX
762                         + "correction_delete_import.gif"; //$NON-NLS-1$
763
764         public static final String IMG_CORRECTION_LOCAL = NAME_PREFIX
765                         + "localvariable_obj.gif"; //$NON-NLS-1$
766
767         public static final String IMG_CORRECTION_REMOVE = NAME_PREFIX
768                         + "remove_correction.gif"; //$NON-NLS-1$
769
770         public static final String IMG_CORRECTION_ADD = NAME_PREFIX
771                         + "add_correction.gif"; //$NON-NLS-1$
772
773         static {
774                 createManaged(T_OBJ, IMG_CORRECTION_CHANGE);
775                 createManaged(T_OBJ, IMG_CORRECTION_MOVE);
776                 createManaged(T_OBJ, IMG_CORRECTION_RENAME);
777                 createManaged(T_OBJ, IMG_CORRECTION_DELETE_IMPORT);
778                 createManaged(T_OBJ, IMG_CORRECTION_LOCAL);
779                 createManaged(T_OBJ, IMG_CORRECTION_REMOVE);
780                 createManaged(T_OBJ, IMG_CORRECTION_ADD);
781         }
782
783         /**
784          * Returns the image managed under the given key in this registry.
785          * 
786          * @param key
787          *            the image's key
788          * @return the image managed under the given key
789          */
790         public static Image get(String key) {
791                 return getImageRegistry().get(key);
792         }
793
794         /**
795          * Returns the image descriptor for the given key in this registry. Might be
796          * called in a non-UI thread.
797          * 
798          * @param key
799          *            the image's key
800          * @return the image descriptor for the given key
801          */
802         public static ImageDescriptor getDescriptor(String key) {
803                 if (fgImageRegistry == null) {
804                         return (ImageDescriptor) fgAvoidSWTErrorMap.get(key);
805                 }
806                 return getImageRegistry().getDescriptor(key);
807         }
808
809         /**
810          * Sets the three image descriptors for enabled, disabled, and hovered to an
811          * action. The actions are retrieved from the *tool16 folders.
812          */
813         public static void setToolImageDescriptors(IAction action, String iconName) {
814                 setImageDescriptors(action, "tool16", iconName);
815         }
816
817         /**
818          * Sets the three image descriptors for enabled, disabled, and hovered to an
819          * action. The actions are retrieved from the *lcl16 folders.
820          */
821         public static void setLocalImageDescriptors(IAction action, String iconName) {
822                 setImageDescriptors(action, "lcl16", iconName);
823         }
824
825         /*
826          * Helper method to access the image registry from the JavaPlugin class.
827          */
828         /* package */static ImageRegistry getImageRegistry() {
829                 if (fgImageRegistry == null) {
830                         fgImageRegistry = new ImageRegistry();
831                         for (Iterator iter = fgAvoidSWTErrorMap.keySet().iterator(); iter
832                                         .hasNext();) {
833                                 String key = (String) iter.next();
834                                 fgImageRegistry.put(key, (ImageDescriptor) fgAvoidSWTErrorMap
835                                                 .get(key));
836                         }
837                         fgAvoidSWTErrorMap = null;
838                 }
839                 return fgImageRegistry;
840         }
841
842         // ---- Helper methods to access icons on the file system
843         // --------------------------------------
844
845         protected static void setImageDescriptors(IAction action, String type,
846                         String relPath) {
847
848                 try {
849                         ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL(
850                                         "d" + type, relPath));
851                         if (id != null)
852                                 action.setDisabledImageDescriptor(id);
853                 } catch (MalformedURLException e) {
854                 }
855
856                 try {
857                         ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL(
858                                         "c" + type, relPath));
859                         if (id != null)
860                                 action.setHoverImageDescriptor(id);
861                 } catch (MalformedURLException e) {
862                 }
863
864                 action.setImageDescriptor(create("e" + type, relPath));
865         }
866
867         private static ImageDescriptor createManaged(String prefix, String name) {
868                 try {
869                         ImageDescriptor result = ImageDescriptor
870                                         .createFromURL(makeIconFileURL(prefix, name
871                                                         .substring(NAME_PREFIX_LENGTH)));
872                         if (fgAvoidSWTErrorMap == null) {
873                                 fgAvoidSWTErrorMap = new HashMap();
874                         }
875                         fgAvoidSWTErrorMap.put(name, result);
876                         if (fgImageRegistry != null) {
877                                 WebUI
878                                                 .logErrorMessage("Image registry already defined"); //$NON-NLS-1$
879                         }
880                         return result;
881                 } catch (MalformedURLException e) {
882                         return ImageDescriptor.getMissingImageDescriptor();
883                 }
884         }
885
886         private static ImageDescriptor createManaged(String prefix, String name,
887                         String key) {
888                 try {
889                         ImageDescriptor result = ImageDescriptor
890                                         .createFromURL(makeIconFileURL(prefix, name
891                                                         .substring(NAME_PREFIX_LENGTH)));
892                         if (fgAvoidSWTErrorMap == null) {
893                                 fgAvoidSWTErrorMap = new HashMap();
894                         }
895                         fgAvoidSWTErrorMap.put(key, result);
896                         if (fgImageRegistry != null) {
897                                 WebUI
898                                                 .logErrorMessage("Image registry already defined"); //$NON-NLS-1$
899                         }
900                         return result;
901                 } catch (MalformedURLException e) {
902                         return ImageDescriptor.getMissingImageDescriptor();
903                 }
904         }
905
906         protected static ImageDescriptor create(String prefix, String name) {
907                 try {
908                         return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
909                 } catch (MalformedURLException e) {
910                         return ImageDescriptor.getMissingImageDescriptor();
911                 }
912         }
913
914         protected static URL makeIconFileURL(String prefix, String name)
915                         throws MalformedURLException {
916                 if (fgIconBaseURL == null)
917                         throw new MalformedURLException();
918
919                 StringBuffer buffer = new StringBuffer(prefix);
920                 buffer.append('/');
921                 buffer.append(name);
922                 return new URL(fgIconBaseURL, buffer.toString());
923         }
924 }