395ee761b482d971bdaf55939cffcb4f3829a980
[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 =
18                 "net.sourceforge.phpdt.internal.ui.";
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. Otherwise low color
39         // images are used
40         static {
41                 fgIconBaseURL= PHPeclipsePlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$
42         }
43         private static ImageRegistry fgImageRegistry= null;
44         private static HashMap fgAvoidSWTErrorMap= null;
45         
46         protected static final String OBJ_PREFIX = "obj16";
47         protected static final String OVR_PREFIX = "ovr16";
48         protected static final String CTOOL_PREFIX = "ctool16";
49
50         public static final String IMG_CLASS = NAME_PREFIX + "class_default_obj.gif";
51         public static final String IMG_DEFINE = NAME_PREFIX + "define_obj.gif";
52         public static final String IMG_BUILTIN = NAME_PREFIX + "builtin_obj.gif";
53         public static final String IMG_FUN = NAME_PREFIX + "fun_obj.gif";
54         public static final String IMG_INC = NAME_PREFIX + "impc_obj.gif";
55         public static final String IMG_VAR = NAME_PREFIX + "var_obj.gif";
56         
57         public static final String IMG_TABLE = NAME_PREFIX + "table_obj.gif";
58         public static final String IMG_COLUMN = NAME_PREFIX + "column_obj.gif";
59         
60         public static final String IMG_OBJS_WARNING =
61                 NAME_PREFIX + "warning_obj.gif";
62         public static final String IMG_OBJS_INFO = NAME_PREFIX + "info_obj.gif";
63         public static final String IMG_CTOOLS_PHP_PAGE =
64                 NAME_PREFIX + "php_page.gif";
65         public static final String IMG_CTOOLS_PHP = NAME_PREFIX + "php.gif";
66
67         public static final String IMG_CLEAR = NAME_PREFIX + "clear.gif"; 
68                 
69         public static final ImageDescriptor DESC_CLASS =
70                 createManaged(OBJ_PREFIX, IMG_CLASS);
71         public static final ImageDescriptor DESC_DEFINE =
72                 createManaged(OBJ_PREFIX, IMG_DEFINE);
73         public static final ImageDescriptor DESC_BUILTIN =
74                 createManaged(OBJ_PREFIX, IMG_BUILTIN);
75         public static final ImageDescriptor DESC_FUN =
76                 createManaged(OBJ_PREFIX, IMG_FUN);
77         public static final ImageDescriptor DESC_INC =
78                 createManaged(OBJ_PREFIX, IMG_INC);
79         public static final ImageDescriptor DESC_VAR =
80                 createManaged(OBJ_PREFIX, IMG_VAR);
81         
82         public static final ImageDescriptor DESC_TABLE =
83                 createManaged(OBJ_PREFIX, IMG_TABLE);
84         public static final ImageDescriptor DESC_COLUMN =
85                 createManaged(OBJ_PREFIX, IMG_COLUMN);
86         
87         public static final ImageDescriptor DESC_OBJS_WARNING =
88                 createManaged(OBJ_PREFIX, IMG_OBJS_WARNING);
89         public static final ImageDescriptor DESC_OBJS_INFO =
90                 createManaged(OBJ_PREFIX, IMG_OBJS_INFO);
91         public static final ImageDescriptor DESC_CTOOL_PHP_PAGE =
92                 createManaged(CTOOL_PREFIX, IMG_CTOOLS_PHP_PAGE);
93         public static final ImageDescriptor DESC_CTOOL_PHP =
94                 createManaged(CTOOL_PREFIX, IMG_CTOOLS_PHP);
95
96                 
97         public static final ImageDescriptor DESC_CLEAR =
98                         createManaged(OBJ_PREFIX, IMG_CLEAR);
99         
100         /*
101                  * Set of predefined Image Descriptors.
102                  */
103                 private static final String T_OBJ= "obj16";             //$NON-NLS-1$
104                 private static final String T_OVR= "ovr16";             //$NON-NLS-1$
105                 private static final String T_WIZBAN= "wizban";         //$NON-NLS-1$
106                 private static final String T_CLCL= "clcl16";   //$NON-NLS-1$
107                 private static final String T_DLCL= "dlcl16";   //$NON-NLS-1$
108                 private static final String T_ELCL= "elcl16";   //$NON-NLS-1$
109                 private static final String T_CTOOL= "ctool16";         //$NON-NLS-1$
110                 private static final String T_CVIEW= "cview16"; //$NON-NLS-1$
111         
112         public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= create(T_WIZBAN, "newclass_wiz.gif");                         //$NON-NLS-1$
113                 
114         public static final ImageDescriptor DESC_ELCL_FILTER= create(T_ELCL, "filter_ps.gif"); //$NON-NLS-1$
115         public static final ImageDescriptor DESC_DLCL_FILTER= create(T_DLCL, "filter_ps.gif"); //$NON-NLS-1$
116
117         /*
118          * Available cached Images in the Java plugin image registry.
119          */
120         public static final String IMG_MISC_PUBLIC= NAME_PREFIX + "methpub_obj.gif";                    //$NON-NLS-1$
121         public static final String IMG_MISC_PROTECTED= NAME_PREFIX + "methpro_obj.gif";                 //$NON-NLS-1$
122         public static final String IMG_MISC_PRIVATE= NAME_PREFIX + "methpri_obj.gif";           //$NON-NLS-1$
123         public static final String IMG_MISC_DEFAULT= NAME_PREFIX + "methdef_obj.gif";           //$NON-NLS-1$
124
125         public static final String IMG_FIELD_PUBLIC= NAME_PREFIX + "field_public_obj.gif";                      //$NON-NLS-1$
126         public static final String IMG_FIELD_PROTECTED= NAME_PREFIX + "field_protected_obj.gif";                //$NON-NLS-1$
127         public static final String IMG_FIELD_PRIVATE= NAME_PREFIX + "field_private_obj.gif";            //$NON-NLS-1$
128         public static final String IMG_FIELD_DEFAULT= NAME_PREFIX + "field_default_obj.gif";            //$NON-NLS-1$
129
130         
131         public static final String IMG_OBJS_GHOST= NAME_PREFIX + "ghost.gif";                           //$NON-NLS-1$
132         public static final String IMG_OBJS_SEARCH_TSK= NAME_PREFIX + "search_tsk.gif";                 //$NON-NLS-1$
133         public static final String IMG_OBJS_PACKDECL= NAME_PREFIX + "packd_obj.gif";                    //$NON-NLS-1$
134         public static final String IMG_OBJS_IMPDECL= NAME_PREFIX + "imp_obj.gif";                       //$NON-NLS-1$
135         public static final String IMG_OBJS_IMPCONT= NAME_PREFIX + "impc_obj.gif";                      //$NON-NLS-1$
136         public static final String IMG_OBJS_JSEARCH= NAME_PREFIX + "jsearch_obj.gif";           //$NON-NLS-1$
137         public static final String IMG_OBJS_SEARCH_DECL= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
138         public static final String IMG_OBJS_SEARCH_REF= NAME_PREFIX + "search_ref_obj.gif";     //$NON-NLS-1$
139         public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif";                       //$NON-NLS-1$
140         public static final String IMG_OBJS_CLASSALT= NAME_PREFIX + "classfo_obj.gif";                  //$NON-NLS-1$   
141         public static final String IMG_OBJS_CLASS_DEFAULT= NAME_PREFIX + "class_default_obj.gif";                       //$NON-NLS-1$
142         public static final String IMG_OBJS_INTERFACE= NAME_PREFIX + "int_obj.gif";                     //$NON-NLS-1$
143         public static final String IMG_OBJS_INTERFACEALT= NAME_PREFIX + "intf_obj.gif";                         //$NON-NLS-1$   
144         public static final String IMG_OBJS_INTERFACE_DEFAULT= NAME_PREFIX + "int_default_obj.gif";             //$NON-NLS-1$
145         public static final String IMG_OBJS_CUNIT= NAME_PREFIX + "phpedit.gif";                                 //$NON-NLS-1$
146         public static final String IMG_OBJS_CUNIT_RESOURCE= NAME_PREFIX + "jcu_resource_obj.gif";                               //$NON-NLS-1$
147         public static final String IMG_OBJS_CFILE= NAME_PREFIX + "classf_obj.gif";                      //$NON-NLS-1$
148         public static final String IMG_OBJS_CFILECLASS= NAME_PREFIX + "class_obj.gif";                  //$NON-NLS-1$
149         public static final String IMG_OBJS_CFILEINT= NAME_PREFIX + "int_obj.gif";                      //$NON-NLS-1$
150         public static final String IMG_OBJS_LOGICAL_PACKAGE= NAME_PREFIX + "logical_package_obj.gif";//$NON-NLS-1$
151         public static final String IMG_OJS_EMPTY_LOGICAL_PACKAGE= NAME_PREFIX + "empty_logical_package_obj.gif";//$NON-NLS-1$
152         public static final String IMG_OBJS_PACKAGE= NAME_PREFIX + "package_obj.gif";           //$NON-NLS-1$
153         public static final String IMG_OBJS_EMPTY_PACK_RESOURCE= NAME_PREFIX + "empty_pack_fldr_obj.gif"; //$NON-NLS-1$
154         public static final String IMG_OBJS_EMPTY_PACKAGE= NAME_PREFIX + "empty_pack_obj.gif"; //$NON-NLS-1$
155         public static final String IMG_OBJS_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_obj.gif"; //$NON-NLS-1$
156         public static final String IMG_OBJS_MISSING_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_nonexist_obj.gif"; //$NON-NLS-1$
157         public static final String IMG_OBJS_MISSING_JAR= NAME_PREFIX + "jar_nonexist_obj.gif"; //$NON-NLS-1$
158         public static final String IMG_OBJS_JAR= NAME_PREFIX + "jar_obj.gif";                           //$NON-NLS-1$
159         public static final String IMG_OBJS_EXTJAR= NAME_PREFIX + "jar_l_obj.gif";                      //$NON-NLS-1$
160         public static final String IMG_OBJS_JAR_WSRC= NAME_PREFIX + "jar_src_obj.gif";          //$NON-NLS-1$
161         public static final String IMG_OBJS_EXTJAR_WSRC= NAME_PREFIX + "jar_lsrc_obj.gif";      //$NON-NLS-1$
162         public static final String IMG_OBJS_ENV_VAR= NAME_PREFIX + "envvar_obj.gif";                    //$NON-NLS-1$
163         public static final String IMG_OBJS_MISSING_ENV_VAR= NAME_PREFIX + "envvar_nonexist_obj.gif"; //$NON-NLS-1$
164         public static final String IMG_OBJS_JAVA_MODEL= NAME_PREFIX + "java_model_obj.gif"; //$NON-NLS-1$
165         public static final String IMG_OBJS_UNKNOWN= NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
166         
167         public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "library_obj.gif";           //$NON-NLS-1$
168         
169         public static final String IMG_OBJS_JAVADOCTAG= NAME_PREFIX + "jdoc_tag_obj.gif";       //$NON-NLS-1$
170         public static final String IMG_OBJS_HTMLTAG= NAME_PREFIX + "html_tag_obj.gif";          //$NON-NLS-1$
171         
172         public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif";                 //$NON-NLS-1$
173
174         public static final String IMG_OBJS_EXCEPTION= NAME_PREFIX + "jexception_obj.gif";      //$NON-NLS-1$
175         public static final String IMG_OBJS_ERROR= NAME_PREFIX + "jrtexception_obj.gif";                //$NON-NLS-1$
176         
177         public static final String IMG_OBJS_BREAKPOINT_INSTALLED= NAME_PREFIX + "brkpi_obj.gif"; //$NON-NLS-1$
178         public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
179         public static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
180
181         public static final String IMG_OBJS_SNIPPET_EVALUATING= NAME_PREFIX + "jsbook_run_obj.gif"; //$NON-NLS-1$
182
183         public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$
184         public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
185         public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
186         public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif";     //$NON-NLS-1$
187
188         public static final String IMG_OBJS_NLS_TRANSLATE= NAME_PREFIX + "translate.gif"; //$NON-NLS-1$
189         public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
190         public static final String IMG_OBJS_NLS_SKIP= NAME_PREFIX + "skip.gif"; //$NON-NLS-1$
191
192         public static final String IMG_OBJS_SEARCH_READACCESS= NAME_PREFIX + "occ_read.gif"; //$NON-NLS-1$
193         public static final String IMG_OBJS_SEARCH_WRITEACCESS= NAME_PREFIX + "occ_write.gif"; //$NON-NLS-1$
194         public static final String IMG_OBJS_SEARCH_OCCURRENCE= NAME_PREFIX + "occ_match.gif"; //$NON-NLS-1$
195         
196         public static final ImageDescriptor DESC_VIEW_ERRORWARNING_TAB= create(T_CVIEW, "errorwarning_tab.gif"); //$NON-NLS-1$
197         public static final ImageDescriptor DESC_VIEW_CLASSFILEGENERATION_TAB= create(T_CVIEW, "classfilegeneration_tab.gif"); //$NON-NLS-1$
198         public static final ImageDescriptor DESC_VIEW_JDKCOMPLIANCE_TAB= create(T_CVIEW, "jdkcompliance_tab.gif"); //$NON-NLS-1$
199         
200         public static final ImageDescriptor DESC_CLCL_FILTER= create(T_CLCL, "filter_ps.gif"); //$NON-NLS-1$
201
202         public static final ImageDescriptor DESC_CLCL_CODE_ASSIST= create(T_CLCL, "metharg_obj.gif"); //$NON-NLS-1$
203         public static final ImageDescriptor DESC_DLCL_CODE_ASSIST= create(T_DLCL, "metharg_obj.gif"); //$NON-NLS-1$
204
205         public static final ImageDescriptor DESC_MISC_PUBLIC= createManaged(T_OBJ, IMG_MISC_PUBLIC);
206         public static final ImageDescriptor DESC_MISC_PROTECTED= createManaged(T_OBJ, IMG_MISC_PROTECTED);
207         public static final ImageDescriptor DESC_MISC_PRIVATE= createManaged(T_OBJ, IMG_MISC_PRIVATE);
208         public static final ImageDescriptor DESC_MISC_DEFAULT= createManaged(T_OBJ, IMG_MISC_DEFAULT);
209
210         public static final ImageDescriptor DESC_FIELD_PUBLIC= createManaged(T_OBJ, IMG_FIELD_PUBLIC); //$NON-NLS-1$
211         public static final ImageDescriptor DESC_FIELD_PROTECTED= createManaged(T_OBJ, IMG_FIELD_PROTECTED); //$NON-NLS-1$
212         public static final ImageDescriptor DESC_FIELD_PRIVATE= createManaged(T_OBJ, IMG_FIELD_PRIVATE); //$NON-NLS-1$
213         public static final ImageDescriptor DESC_FIELD_DEFAULT= createManaged(T_OBJ, IMG_FIELD_DEFAULT); //$NON-NLS-1$
214         
215         public static final ImageDescriptor DESC_MENU_SHIFT_RIGHT= create(T_CTOOL, "shift_r_edit.gif");         //$NON-NLS-1$
216         public static final ImageDescriptor DESC_MENU_SHIFT_LEFT= create(T_CTOOL, "shift_l_edit.gif");  //$NON-NLS-1$
217
218         public static final ImageDescriptor DESC_OBJS_GHOST= createManaged(T_OBJ, IMG_OBJS_GHOST);
219         public static final ImageDescriptor DESC_OBJS_PACKDECL= createManaged(T_OBJ, IMG_OBJS_PACKDECL);
220         public static final ImageDescriptor DESC_OBJS_IMPDECL= createManaged(T_OBJ, IMG_OBJS_IMPDECL);
221         public static final ImageDescriptor DESC_OBJS_IMPCONT= createManaged(T_OBJ, IMG_OBJS_IMPCONT);
222         public static final ImageDescriptor DESC_OBJS_JSEARCH= createManaged(T_OBJ, IMG_OBJS_JSEARCH);
223         public static final ImageDescriptor DESC_OBJS_SEARCH_DECL= createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
224         public static final ImageDescriptor DESC_OBJS_SEARCH_REF= createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
225         public static final ImageDescriptor DESC_OBJS_CUNIT= createManaged(T_OBJ, IMG_OBJS_CUNIT);
226         public static final ImageDescriptor DESC_OBJS_CUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_CUNIT_RESOURCE);
227         public static final ImageDescriptor DESC_OBJS_CFILE= createManaged(T_OBJ, IMG_OBJS_CFILE); 
228         public static final ImageDescriptor DESC_OBJS_CFILECLASS= createManaged(T_OBJ, IMG_OBJS_CFILECLASS); 
229         public static final ImageDescriptor DESC_OBJS_CFILEINT= createManaged(T_OBJ, IMG_OBJS_CFILEINT); 
230         public static final ImageDescriptor DESC_OBJS_PACKAGE= createManaged(T_OBJ, IMG_OBJS_PACKAGE);
231         public static final ImageDescriptor DESC_OBJS_EMPTY_LOGICAL_PACKAGE= createManaged(T_OBJ, IMG_OJS_EMPTY_LOGICAL_PACKAGE);
232         public static final ImageDescriptor DESC_OBJS_LOGICAL_PACKAGE= createManaged(T_OBJ, IMG_OBJS_LOGICAL_PACKAGE);
233         public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE_RESOURCES= createManaged(T_OBJ, IMG_OBJS_EMPTY_PACK_RESOURCE);
234         public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE= createManaged(T_OBJ, IMG_OBJS_EMPTY_PACKAGE);      
235         public static final ImageDescriptor DESC_OBJS_PACKFRAG_ROOT= createManaged(T_OBJ, IMG_OBJS_PACKFRAG_ROOT);
236         public static final ImageDescriptor DESC_OBJS_MISSING_PACKFRAG_ROOT= createManaged(T_OBJ, IMG_OBJS_MISSING_PACKFRAG_ROOT);
237         public static final ImageDescriptor DESC_OBJS_JAVA_MODEL= createManaged(T_OBJ, IMG_OBJS_JAVA_MODEL);
238
239         public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS);
240         public static final ImageDescriptor DESC_OBJS_CLASS_DEFAULT= createManaged(T_OBJ, IMG_OBJS_CLASS_DEFAULT);
241         
242         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PUBLIC= create(T_OBJ, "innerclass_public_obj.gif"); //$NON-NLS-1$
243         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_DEFAULT= create(T_OBJ, "innerclass_default_obj.gif"); //$NON-NLS-1$
244         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PROTECTED= create(T_OBJ, "innerclass_protected_obj.gif"); //$NON-NLS-1$
245         public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PRIVATE= create(T_OBJ, "innerclass_private_obj.gif"); //$NON-NLS-1$
246         
247         public static final ImageDescriptor DESC_OBJS_CLASSALT= createManaged(T_OBJ, IMG_OBJS_CLASSALT);
248
249         public static final ImageDescriptor DESC_OBJS_INTERFACE= createManaged(T_OBJ, IMG_OBJS_INTERFACE);
250         public static final ImageDescriptor DESC_OBJS_INTERFACE_DEFAULT= createManaged(T_OBJ, IMG_OBJS_INTERFACE_DEFAULT);
251         
252         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PUBLIC= create(T_OBJ, "innerinterface_public_obj.gif"); //$NON-NLS-1$
253         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_DEFAULT= create(T_OBJ, "innerinterface_default_obj.gif"); //$NON-NLS-1$
254         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PROTECTED= create(T_OBJ, "innerinterface_protected_obj.gif"); //$NON-NLS-1$
255         public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PRIVATE= create(T_OBJ, "innerinterface_private_obj.gif"); //$NON-NLS-1$
256         
257         public static final ImageDescriptor DESC_OBJS_INTERFACEALT= createManaged(T_OBJ, IMG_OBJS_INTERFACEALT);
258         
259         public static final ImageDescriptor DESC_OBJS_JAR= createManaged(T_OBJ, IMG_OBJS_JAR);
260         public static final ImageDescriptor DESC_OBJS_MISSING_JAR= createManaged(T_OBJ, IMG_OBJS_MISSING_JAR);
261         public static final ImageDescriptor DESC_OBJS_EXTJAR= createManaged(T_OBJ, IMG_OBJS_EXTJAR);
262         public static final ImageDescriptor DESC_OBJS_JAR_WSRC= createManaged(T_OBJ, IMG_OBJS_JAR_WSRC);
263         public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManaged(T_OBJ, IMG_OBJS_EXTJAR_WSRC);
264         public static final ImageDescriptor DESC_OBJS_ENV_VAR= createManaged(T_OBJ, IMG_OBJS_ENV_VAR);
265         public static final ImageDescriptor DESC_OBJS_MISSING_ENV_VAR= createManaged(T_OBJ, IMG_OBJS_MISSING_ENV_VAR);
266         
267         public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
268         
269         public static final ImageDescriptor DESC_OBJS_JAVADOCTAG= createManaged(T_OBJ, IMG_OBJS_JAVADOCTAG);
270         public static final ImageDescriptor DESC_OBJS_HTMLTAG= createManaged(T_OBJ, IMG_OBJS_HTMLTAG);
271
272         public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
273         
274         public static final ImageDescriptor DESC_OBJS_EXCEPTION= createManaged(T_OBJ, IMG_OBJS_EXCEPTION);
275         public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED= createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_INSTALLED);
276         public static final ImageDescriptor DESC_OBJS_ERROR= createManaged(T_OBJ, IMG_OBJS_ERROR);
277         public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
278         public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
279         
280         public static final ImageDescriptor DESC_OBJS_SNIPPET_EVALUATING= createManaged(T_OBJ, IMG_OBJS_SNIPPET_EVALUATING);
281         
282         public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE= create(T_OBJ, "change.gif"); //$NON-NLS-1$
283         public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE= create(T_OBJ, "composite_change.gif"); //$NON-NLS-1$
284         public static final ImageDescriptor DESC_OBJS_CU_CHANGE= create(T_OBJ, "cu_change.gif"); //$NON-NLS-1$
285         public static final ImageDescriptor DESC_OBJS_FILE_CHANGE= create(T_OBJ, "file_change.gif"); //$NON-NLS-1$
286         public static final ImageDescriptor DESC_OBJS_TEXT_EDIT= create(T_OBJ, "text_edit.gif"); //$NON-NLS-1$
287
288         public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB= create(T_OBJ, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
289         public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER_ATTRIB= create(T_OBJ, "output_folder_attrib.gif"); //$NON-NLS-1$
290         public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= create(T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$
291         public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB= create(T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$
292
293         public static final ImageDescriptor DESC_OBJS_REFACTORING_FATAL= createManaged(T_OBJ, IMG_OBJS_REFACTORING_FATAL);
294         public static final ImageDescriptor DESC_OBJS_REFACTORING_ERROR= createManaged(T_OBJ, IMG_OBJS_REFACTORING_ERROR);
295         public static final ImageDescriptor DESC_OBJS_REFACTORING_WARNING= createManaged(T_OBJ, IMG_OBJS_REFACTORING_WARNING);
296         public static final ImageDescriptor DESC_OBJS_REFACTORING_INFO= createManaged(T_OBJ, IMG_OBJS_REFACTORING_INFO);
297         
298         public static final ImageDescriptor DESC_OBJS_NLS_TRANSLATE= createManaged(T_OBJ, IMG_OBJS_NLS_TRANSLATE);
299         public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE= createManaged(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
300         public static final ImageDescriptor DESC_OBJS_NLS_SKIP= createManaged(T_OBJ, IMG_OBJS_NLS_SKIP);
301         
302         public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
303
304         public static final ImageDescriptor DESC_OBJS_SEARCH_READACCESS= createManaged(T_OBJ, IMG_OBJS_SEARCH_READACCESS);
305         public static final ImageDescriptor DESC_OBJS_SEARCH_WRITEACCESS= createManaged(T_OBJ, IMG_OBJS_SEARCH_WRITEACCESS);
306         public static final ImageDescriptor DESC_OBJS_SEARCH_OCCURRENCE= createManaged(T_OBJ, IMG_OBJS_SEARCH_OCCURRENCE);
307
308         public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= create(T_OBJ, "localvariable_obj.gif"); //$NON-NLS-1$
309         
310         public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif");                                            //$NON-NLS-1$
311         public static final ImageDescriptor DESC_OVR_FINAL= create(T_OVR, "final_co.gif");                                              //$NON-NLS-1$
312         public static final ImageDescriptor DESC_OVR_ABSTRACT= create(T_OVR, "abstract_co.gif");                                        //$NON-NLS-1$
313         public static final ImageDescriptor DESC_OVR_SYNCH= create(T_OVR, "synch_co.gif");                                              //$NON-NLS-1$
314         public static final ImageDescriptor DESC_OVR_RUN= create(T_OVR, "run_co.gif");                                                  //$NON-NLS-1$
315         public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif");                                  //$NON-NLS-1$
316         public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif");                                              //$NON-NLS-1$
317         public static final ImageDescriptor DESC_OVR_OVERRIDES= create(T_OVR, "over_co.gif");                                   //$NON-NLS-1$
318         public static final ImageDescriptor DESC_OVR_IMPLEMENTS= create(T_OVR, "implm_co.gif");                                 //$NON-NLS-1$
319         public static final ImageDescriptor DESC_OVR_CONSTRUCTOR= create(T_OVR, "constr_ovr.gif");                      //$NON-NLS-1$
320         public static final ImageDescriptor DESC_OVR_FOCUS= create(T_OVR, "focus_ovr.gif"); //$NON-NLS-1$
321                 
322         public static final ImageDescriptor DESC_WIZBAN_NEWFIELD= create(T_WIZBAN, "newfield_wiz.gif");                         //$NON-NLS-1$
323         public static final ImageDescriptor DESC_WIZBAN_NEWINT= create(T_WIZBAN, "newint_wiz.gif");                             //$NON-NLS-1$
324         public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ= create(T_WIZBAN, "newjprj_wiz.gif");                   //$NON-NLS-1$
325         public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= create(T_WIZBAN, "newsrcfldr_wiz.gif");    //$NON-NLS-1$
326         public static final ImageDescriptor DESC_WIZBAN_NEWMETH= create(T_WIZBAN, "newmeth_wiz.gif");                   //$NON-NLS-1$
327         public static final ImageDescriptor DESC_WIZBAN_NEWPACK= create(T_WIZBAN, "newpack_wiz.gif");                   //$NON-NLS-1$
328         public static final ImageDescriptor DESC_WIZBAN_NEWSCRAPPAGE= create(T_WIZBAN, "newsbook_wiz.gif");             //$NON-NLS-1$
329         public static final ImageDescriptor DESC_WIZBAN_JAVA_LAUNCH= create(T_WIZBAN, "java_app_wiz.gif");              //$NON-NLS-1$
330         public static final ImageDescriptor DESC_WIZBAN_JAVA_ATTACH= create(T_WIZBAN, "java_attach_wiz.gif");   //$NON-NLS-1$
331         public static final ImageDescriptor DESC_WIZBAN_REFACTOR= create(T_WIZBAN, "refactor_wiz.gif");                         //$NON-NLS-1$
332         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= create(T_WIZBAN, "fieldrefact_wiz.gif");        //$NON-NLS-1$
333         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= create(T_WIZBAN, "methrefact_wiz.gif");        //$NON-NLS-1$
334         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE= create(T_WIZBAN, "typerefact_wiz.gif");  //$NON-NLS-1$
335         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PACKAGE= create(T_WIZBAN, "packrefact_wiz.gif"); //$NON-NLS-1$
336         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CODE= create(T_WIZBAN, "coderefact_wiz.gif");  //$NON-NLS-1$
337         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CU= create(T_WIZBAN, "compunitrefact_wiz.gif");        //$NON-NLS-1$
338         public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PULL_UP= create(T_WIZBAN, "pullup_wiz.gif");   //$NON-NLS-1$
339         public static final ImageDescriptor DESC_WIZBAN_JAR_PACKAGER= create(T_WIZBAN, "jar_pack_wiz.gif");             //$NON-NLS-1$
340         public static final ImageDescriptor DESC_WIZBAN_JAVA_WORKINGSET= create(T_WIZBAN, "java_workingset_wiz.gif");//$NON-NLS-1$
341         public static final ImageDescriptor DESC_WIZBAN_EXPORT_JAVADOC= create(T_WIZBAN, "export_javadoc_wiz.gif");//$NON-NLS-1$
342         public static final ImageDescriptor DESC_WIZBAN_EXTERNALIZE_STRINGS= create(T_WIZBAN, "extstr_wiz.gif");//$NON-NLS-1$
343         public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY= create(T_WIZBAN, "addlibrary_wiz.gif");//$NON-NLS-1$
344
345                 
346         public static final ImageDescriptor DESC_TOOL_DISPLAYSNIPPET= create(T_CTOOL, "disp_sbook.gif");                        //$NON-NLS-1$
347         public static final ImageDescriptor DESC_TOOL_RUNSNIPPET= create(T_CTOOL, "run_sbook.gif");                             //$NON-NLS-1$
348         public static final ImageDescriptor DESC_TOOL_INSPSNIPPET= create(T_CTOOL, "insp_sbook.gif");                   //$NON-NLS-1$
349         public static final ImageDescriptor DESC_TOOL_PACKSNIPPET= create(T_CTOOL, "pack_sbook.gif");                   //$NON-NLS-1$
350         public static final ImageDescriptor DESC_TOOL_TERMSNIPPET= create(T_CTOOL, "term_sbook.gif");                   //$NON-NLS-1$
351         public static final ImageDescriptor DESC_TOOL_SHOW_EMPTY_PKG= create(T_CTOOL, "show_empty_pkg.gif");            //$NON-NLS-1$
352         public static final ImageDescriptor DESC_TOOL_SHOW_SEGMENTS= create(T_CTOOL, "segment_edit.gif");               //$NON-NLS-1$
353         public static final ImageDescriptor DESC_TOOL_GOTO_NEXT_ERROR= create(T_CTOOL, "next_error_nav.gif");   //$NON-NLS-1$
354         public static final ImageDescriptor DESC_TOOL_GOTO_PREV_ERROR= create(T_CTOOL, "prev_error_nav.gif");   //$NON-NLS-1$
355
356         public static final ImageDescriptor DESC_TOOL_OPENTYPE= create(T_CTOOL, "opentype.gif");                                        //$NON-NLS-1$
357         public static final ImageDescriptor DESC_TOOL_NEWPROJECT= create(T_CTOOL, "newjprj_wiz.gif");                   //$NON-NLS-1$
358         public static final ImageDescriptor DESC_TOOL_NEWPACKAGE= create(T_CTOOL, "newpack_wiz.gif");                   //$NON-NLS-1$
359         public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_CTOOL, "newclass_wiz.gif");                            //$NON-NLS-1$
360         public static final ImageDescriptor DESC_TOOL_NEWINTERFACE= create(T_CTOOL, "newint_wiz.gif");                  //$NON-NLS-1$
361         public static final ImageDescriptor DESC_TOOL_NEWSNIPPET= create(T_CTOOL, "newsbook_wiz.gif");                  //$NON-NLS-1$
362         public static final ImageDescriptor DESC_TOOL_NEWPACKROOT= create(T_CTOOL, "newpackfolder_wiz.gif");            //$NON-NLS-1$
363
364         public static final ImageDescriptor DESC_TOOL_CLASSPATH_ORDER= create(T_OBJ, "cp_order_obj.gif");               //$NON-NLS-1$
365
366         // Keys for correction proposal. We have to put the image into the registry since "code assist" doesn't
367         // have a life cycle. So no change to dispose icons.
368         
369         public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
370         public static final String IMG_CORRECTION_MOVE= NAME_PREFIX + "correction_move.gif"; //$NON-NLS-1$
371         public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
372         public static final String IMG_CORRECTION_DELETE_IMPORT= NAME_PREFIX + "correction_delete_import.gif"; //$NON-NLS-1$
373         public static final String IMG_CORRECTION_LOCAL= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$
374         public static final String IMG_CORRECTION_REMOVE= NAME_PREFIX + "remove_correction.gif"; //$NON-NLS-1$
375         public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "add_correction.gif"; //$NON-NLS-1$
376
377         static {
378                 createManaged(T_OBJ, IMG_CORRECTION_CHANGE);
379                 createManaged(T_OBJ, IMG_CORRECTION_MOVE);
380                 createManaged(T_OBJ, IMG_CORRECTION_RENAME);
381                 createManaged(T_OBJ, IMG_CORRECTION_DELETE_IMPORT);
382                 createManaged(T_OBJ, IMG_CORRECTION_LOCAL);
383                 createManaged(T_OBJ, IMG_CORRECTION_REMOVE);
384                 createManaged(T_OBJ, IMG_CORRECTION_ADD);
385         }
386         
387         /**
388          * Returns the image managed under the given key in this registry.
389          * 
390          * @param key the image's key
391          * @return the image managed under the given key
392          */ 
393         public static Image get(String key) {
394                 return getImageRegistry().get(key);
395         }
396         
397         /**
398          * Returns the image descriptor for the given key in this registry. Might be called in a non-UI thread.
399          * 
400          * @param key the image's key
401          * @return the image descriptor for the given key
402          */ 
403         public static ImageDescriptor getDescriptor(String key) {
404                 if (fgImageRegistry == null) {
405                         return (ImageDescriptor) fgAvoidSWTErrorMap.get(key);
406                 }
407                 return getImageRegistry().getDescriptor(key);
408         }
409
410         /**
411          * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
412          * are retrieved from the *tool16 folders.
413          */
414         public static void setToolImageDescriptors(
415                 IAction action,
416                 String iconName) {
417                 setImageDescriptors(action, "tool16", iconName);
418         }
419
420         /**
421          * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
422          * are retrieved from the *lcl16 folders.
423          */
424         public static void setLocalImageDescriptors(
425                 IAction action,
426                 String iconName) {
427                 setImageDescriptors(action, "lcl16", iconName);
428         }
429
430         /*
431          * Helper method to access the image registry from the JavaPlugin class.
432          */
433         /* package */ static ImageRegistry getImageRegistry() {
434                 if (fgImageRegistry == null) {
435                         fgImageRegistry= new ImageRegistry();
436                         for (Iterator iter= fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext();) {
437                                 String key= (String) iter.next();
438                                 fgImageRegistry.put(key, (ImageDescriptor) fgAvoidSWTErrorMap.get(key));
439                         }
440                         fgAvoidSWTErrorMap= null;
441                 }
442                 return fgImageRegistry;
443         }
444
445         //---- Helper methods to access icons on the file system --------------------------------------
446
447         protected static void setImageDescriptors(
448                 IAction action,
449                 String type,
450                 String relPath) {
451
452                 try {
453                         ImageDescriptor id =
454                                 ImageDescriptor.createFromURL(
455                                         makeIconFileURL("d" + type, relPath));
456                         if (id != null)
457                                 action.setDisabledImageDescriptor(id);
458                 } catch (MalformedURLException e) {
459                 }
460
461                 try {
462                         ImageDescriptor id =
463                                 ImageDescriptor.createFromURL(
464                                         makeIconFileURL("c" + type, relPath));
465                         if (id != null)
466                                 action.setHoverImageDescriptor(id);
467                 } catch (MalformedURLException e) {
468                 }
469
470                 action.setImageDescriptor(create("e" + type, relPath));
471         }
472
473         private static ImageDescriptor createManaged(String prefix, String name) {
474                 try {
475                         ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
476                         if (fgAvoidSWTErrorMap == null) {
477                                 fgAvoidSWTErrorMap= new HashMap();
478                         }
479                         fgAvoidSWTErrorMap.put(name, result);
480                         if (fgImageRegistry != null) {
481                                 PHPeclipsePlugin.logErrorMessage("Image registry already defined"); //$NON-NLS-1$
482                         }
483                         return result;
484                 } catch (MalformedURLException e) {
485                         return ImageDescriptor.getMissingImageDescriptor();
486                 }
487         }
488         
489         private static ImageDescriptor createManaged(String prefix, String name, String key) {
490                 try {
491                         ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
492                         if (fgAvoidSWTErrorMap == null) {
493                                 fgAvoidSWTErrorMap= new HashMap();
494                         }
495                         fgAvoidSWTErrorMap.put(key, result);
496                         if (fgImageRegistry != null) {
497                                 PHPeclipsePlugin.logErrorMessage("Image registry already defined"); //$NON-NLS-1$
498                         }
499                         return result;
500                 } catch (MalformedURLException e) {
501                         return ImageDescriptor.getMissingImageDescriptor();
502                 }
503         }
504
505         protected static ImageDescriptor create(String prefix, String name) {
506                 try {
507                         return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
508                 } catch (MalformedURLException e) {
509                         return ImageDescriptor.getMissingImageDescriptor();
510                 }
511         }
512
513         protected static URL makeIconFileURL(String prefix, String name)
514                 throws MalformedURLException {
515                 if (fgIconBaseURL == null)
516                         throw new MalformedURLException();
517
518                 StringBuffer buffer = new StringBuffer(prefix);
519                 buffer.append('/');
520                 buffer.append(name);
521                 return new URL(fgIconBaseURL, buffer.toString());
522         }
523 }