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