KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > JavaDebugImages


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui;
12
13 import java.net.URL JavaDoc;
14
15 import org.eclipse.core.runtime.FileLocator;
16 import org.eclipse.core.runtime.Path;
17 import org.eclipse.core.runtime.Platform;
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.eclipse.jface.resource.ImageRegistry;
20 import org.eclipse.swt.graphics.Image;
21 import org.osgi.framework.Bundle;
22
23 /**
24  * Bundle of most images used by the Java debug plug-in.
25  */

26 public class JavaDebugImages {
27
28     private static String JavaDoc ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$
29

30     // The plugin registry
31
private static ImageRegistry fgImageRegistry = null;
32
33     /*
34      * Available cached Images in the Java debug plug-in image registry.
35      */

36     public static final String JavaDoc IMG_OBJS_EXCEPTION= "IMG_OBJS_EXCEPTION"; //$NON-NLS-1$
37
public static final String JavaDoc IMG_OBJS_EXCEPTION_DISABLED= "IMG_OBJS_EXCEPTION_DISABLED"; //$NON-NLS-1$
38
public static final String JavaDoc IMG_OBJS_ERROR= "IMG_OBJS_ERROR"; //$NON-NLS-1$
39

40     public static final String JavaDoc IMG_OVR_BREAKPOINT_INSTALLED= "IMG_OBJS_BREAKPOINT_INSTALLED"; //$NON-NLS-1$
41
public static final String JavaDoc IMG_OVR_BREAKPOINT_INSTALLED_DISABLED= "IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED"; //$NON-NLS-1$
42

43     public static final String JavaDoc IMG_OBJS_LOCAL_VARIABLE = "IMG_OBJS_LOCAL_VARIABLE"; //$NON-NLS-1$
44

45     public static final String JavaDoc IMG_OVR_METHOD_BREAKPOINT_ENTRY= "IMG_OBJS_METHOD_BREAKPOINT_ENTRY"; //$NON-NLS-1$
46
public static final String JavaDoc IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED= "IMG_OBJS_METHOD_BREAKPOINT_ENTRY_DISABLED"; //$NON-NLS-1$
47
public static final String JavaDoc IMG_OVR_METHOD_BREAKPOINT_EXIT= "IMG_OBJS_METHOD_BREAKPOINT_EXIT"; //$NON-NLS-1$
48
public static final String JavaDoc IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED= "IMG_OBJS_METHOD_BREAKPOINT_EXIT_DISABLED"; //$NON-NLS-1$
49

50     public static final String JavaDoc IMG_OVR_CONDITIONAL_BREAKPOINT= "IMG_OBJS_CONDITIONAL_BREAKPOINT"; //$NON-NLS-1$
51
public static final String JavaDoc IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED= "IMG_OBJS_CONDITIONAL_BREAKPOINT_DISABLED"; //$NON-NLS-1$
52

53     public static final String JavaDoc IMG_OVR_SCOPED_BREAKPOINT= "IMG_OBJS_SCOPED_BREAKPOINT"; //$NON-NLS-1$
54
public static final String JavaDoc IMG_OVR_SCOPED_BREAKPOINT_DISABLED= "IMG_OBJS_SCOPED_BREAKPOINT_DISABLED"; //$NON-NLS-1$
55

56     public static final String JavaDoc IMG_OVR_UNCAUGHT_BREAKPOINT= "IMG_OBJS_UNCAUGHT_BREAKPOINT"; //$NON-NLS-1$
57
public static final String JavaDoc IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED= "IMG_OBJS_UNCAUGHT_BREAKPOINT_DISABLED"; //$NON-NLS-1$
58

59     public static final String JavaDoc IMG_OVR_CAUGHT_BREAKPOINT= "IMG_OBJS_CAUGHT_BREAKPOINT"; //$NON-NLS-1$
60
public static final String JavaDoc IMG_OVR_CAUGHT_BREAKPOINT_DISABLED= "IMG_OBJS_CAUGHT_BREAKPOINT_DISABLED"; //$NON-NLS-1$
61

62     public static final String JavaDoc IMG_OBJS_SNIPPET_EVALUATING= "IMG_OBJS_SNIPPET_EVALUATING"; //$NON-NLS-1$
63

64     public static final String JavaDoc IMG_VIEW_ARGUMENTS_TAB= "IMG_VIEW_ARGUMENTS_TAB"; //$NON-NLS-1$
65

66     public static final String JavaDoc IMG_OBJS_MONITOR = "IMG_OBJS_MONITOR"; //$NON-NLS-1$
67
public static final String JavaDoc IMG_OBJS_CONTENDED_MONITOR = "IMG_OBJS_CONTENDED_MONITOR"; //$NON-NLS-1$
68
public static final String JavaDoc IMG_OBJS_OWNED_MONITOR = "IMG_OBJS_OWNED_MONITOR"; //$NON-NLS-1$
69

70     public static final String JavaDoc IMG_OBJS_REFERENCE = "IMG_OBJS_REFERENCE"; //$NON-NLS-1$
71

72     public static final String JavaDoc IMG_OVR_OWNED = "IMG_OVR_OWNED"; //$NON-NLS-1$
73
public static final String JavaDoc IMG_OVR_OWNS_MONITOR = "IMG_OVR_OWNS_MONITOR"; //$NON-NLS-1$
74
public static final String JavaDoc IMG_OVR_IN_CONTENTION = "IMG_OVR_IN_CONTENTION"; //$NON-NLS-1$
75
public static final String JavaDoc IMG_OVR_IN_CONTENTION_FOR_MONITOR = "IMG_OVR_IN_CONTENTION_FOR_MONITOR"; //$NON-NLS-1$
76
public static final String JavaDoc IMG_OVR_IN_DEADLOCK = "IMG_OVR_IN_DEADLOCK"; //$NON-NLS-1$
77

78     public static final String JavaDoc IMG_OBJS_EXCEPTION_BRKPT_TYPE = "IMG_OBJS_EXCEPTION_BRKPT_TYPE"; //$NON-NLS-1$
79
public static final String JavaDoc IMG_OBJS_LINE_BRKPT_TYPE = "IMG_OBJS_LINE_BRKPT_TYPE"; //$NON-NLS-1$
80
public static final String JavaDoc IMG_OBJS_CLASSLOAD_BRKPT_TYPE = "IMG_OBJS_CLASSLOAD_BRKPT_TYPE"; //$NON-NLS-1$
81
public static final String JavaDoc IMG_OBJS_WATCHPOINT_TYPE = "IMG_OBJS_WATCHPOINT_TYPE"; //$NON-NLS-1$
82
public static final String JavaDoc IMG_OBJS_JSP_BRKPT_TYPE = "IMG_OBJS_JSP_BRKPT_TYPE"; //$NON-NLS-1$
83
public static final String JavaDoc IMG_OBJS_METHOD_BRKPT_TYPE = "IMG_OBJS_METHOD_BRKPT_TYPE"; //$NON-NLS-1$
84
public static final String JavaDoc IMG_OBJS_THREAD_GROUP = "IMG_OBJS_THREAD_GROUP"; //$NON-NLS-1$
85

86     public static final String JavaDoc IMG_OBJS_CLASSPATH = "IMG_OBJS_CLASSPATH"; //$NON-NLS-1$
87

88     public static final String JavaDoc IMG_OVR_OUT_OF_SYNCH = "IMG_OVR_OUT_OF_SYNCH"; //$NON-NLS-1$
89
public static final String JavaDoc IMG_OVR_MAY_BE_OUT_OF_SYNCH = "IMG_OVR_MAY_BE_OUT_OF_SYNCH"; //$NON-NLS-1$
90
public static final String JavaDoc IMG_OVR_SYNCHRONIZED = "IMG_OVR_SYNCHRONIZED"; //$NON-NLS-1$
91

92     public static final String JavaDoc IMG_WIZBAN_NEWSCRAPPAGE = "IMG_WIZBAN_NEWSCRAPPAGE"; //$NON-NLS-1$
93
public static final String JavaDoc IMG_WIZBAN_LIBRARY = "IMG_WIZBAN_LIBRARY"; //$NON-NLS-1$
94
public static final String JavaDoc IMG_TOOL_TERMSNIPPET = "IMG_TOOL_TERMSNIPPET"; //$NON-NLS-1$
95
public static final String JavaDoc IMG_TOOL_TERMSNIPPET_HOVER = "IMG_TOOL_TERMSNIPPET_HOVER"; //$NON-NLS-1$
96
public static final String JavaDoc IMG_TOOL_TERMSNIPPET_DISABLED = "IMG_TOOL_TERMSNIPPET_DISABLED"; //$NON-NLS-1$
97
public static final String JavaDoc IMG_OBJ_JAVA_INSPECT_EXPRESSION = "IMG_OBJ_JAVA_INSPECT_EXPRESSION"; //$NON-NLS-1$
98

99     public static final String JavaDoc IMG_ELCL_AUTO_FORMAT = "IMG_ELCL_AUTO_FORMAT"; //$NON-NLS-1$
100

101     public static final String JavaDoc IMG_ELCL_ALL_REFERENCES = "IMG_ELCL_ALL_REFERENCES"; //$NON-NLS-1$
102

103     /*
104      * Set of predefined Image Descriptors.
105      */

106     private static final String JavaDoc T_OBJ= ICONS_PATH + "obj16/"; //$NON-NLS-1$
107
private static final String JavaDoc T_OVR= ICONS_PATH + "ovr16/"; //$NON-NLS-1$
108
private static final String JavaDoc T_WIZBAN= ICONS_PATH + "wizban/"; //$NON-NLS-1$
109
private static final String JavaDoc T_EVIEW= ICONS_PATH + "eview16/"; //$NON-NLS-1$
110
private static final String JavaDoc T_DLCL= ICONS_PATH + "dtool16/"; //$NON-NLS-1$
111
private static final String JavaDoc T_ELCL= ICONS_PATH + "etool16/"; //$NON-NLS-1$
112
private static final String JavaDoc E_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$
113

114     /**
115      * Returns the image managed under the given key in this registry.
116      *
117      * @param key the image's key
118      * @return the image managed under the given key
119      */

120     public static Image get(String JavaDoc key) {
121         return getImageRegistry().get(key);
122     }
123     
124     /**
125      * Returns the <code>ImageDescriptor</code> identified by the given key,
126      * or <code>null</code> if it does not exist.
127      */

128     public static ImageDescriptor getImageDescriptor(String JavaDoc key) {
129         return getImageRegistry().getDescriptor(key);
130     }
131     
132     /*
133      * Helper method to access the image registry from the JDIDebugUIPlugin class.
134      */

135     /* package */ static ImageRegistry getImageRegistry() {
136         if (fgImageRegistry == null) {
137             initializeImageRegistry();
138         }
139         return fgImageRegistry;
140     }
141     
142     private static void initializeImageRegistry() {
143         fgImageRegistry= new ImageRegistry(JDIDebugUIPlugin.getStandardDisplay());
144         declareImages();
145     }
146     
147     private static void declareImages() {
148         declareRegistryImage(IMG_OBJS_EXCEPTION, T_OBJ + "jexception_obj.gif"); //$NON-NLS-1$
149
declareRegistryImage(IMG_OBJS_EXCEPTION_DISABLED, T_OBJ + "jexceptiond_obj.gif"); //$NON-NLS-1$
150
declareRegistryImage(IMG_OVR_BREAKPOINT_INSTALLED, T_OVR + "installed_ovr.gif"); //$NON-NLS-1$
151
declareRegistryImage(IMG_OVR_BREAKPOINT_INSTALLED_DISABLED, T_OVR + "installed_ovr_disabled.gif"); //$NON-NLS-1$
152
declareRegistryImage(IMG_OBJS_REFERENCE, T_OBJ + "reference_obj.gif"); //$NON-NLS-1$
153

154         declareRegistryImage(IMG_OBJS_LOCAL_VARIABLE, T_OBJ + "localvariable_obj.gif"); //$NON-NLS-1$
155

156         declareRegistryImage(IMG_OVR_METHOD_BREAKPOINT_ENTRY, T_OVR + "entry_ovr.gif"); //$NON-NLS-1$
157
declareRegistryImage(IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED, T_OVR + "entry_ovr_disabled.gif"); //$NON-NLS-1$
158
declareRegistryImage(IMG_OVR_METHOD_BREAKPOINT_EXIT, T_OVR + "exit_ovr.gif"); //$NON-NLS-1$
159
declareRegistryImage(IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED, T_OVR + "exit_ovr_disabled.gif"); //$NON-NLS-1$
160

161         declareRegistryImage(IMG_OVR_CONDITIONAL_BREAKPOINT, T_OVR + "conditional_ovr.gif"); //$NON-NLS-1$
162
declareRegistryImage(IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED, T_OVR + "conditional_ovr_disabled.gif"); //$NON-NLS-1$
163

164         declareRegistryImage(IMG_OVR_SCOPED_BREAKPOINT, T_OVR + "scoped_ovr.gif"); //$NON-NLS-1$
165
declareRegistryImage(IMG_OVR_SCOPED_BREAKPOINT_DISABLED, T_OVR + "scoped_ovr_disabled.gif"); //$NON-NLS-1$
166

167         declareRegistryImage(IMG_OVR_UNCAUGHT_BREAKPOINT, T_OVR + "uncaught_ovr.gif"); //$NON-NLS-1$
168
declareRegistryImage(IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED, T_OVR + "uncaught_ovr_disabled.gif"); //$NON-NLS-1$
169

170         declareRegistryImage(IMG_OVR_CAUGHT_BREAKPOINT, T_OVR + "caught_ovr.gif"); //$NON-NLS-1$
171
declareRegistryImage(IMG_OVR_CAUGHT_BREAKPOINT_DISABLED, T_OVR + "caught_ovr_disabled.gif"); //$NON-NLS-1$
172

173         declareRegistryImage(IMG_OBJS_ERROR, T_OBJ + "jrtexception_obj.gif"); //$NON-NLS-1$
174

175         declareRegistryImage(IMG_OBJS_SNIPPET_EVALUATING, T_OBJ + "jsbook_run_obj.gif"); //$NON-NLS-1$
176

177         declareRegistryImage(IMG_VIEW_ARGUMENTS_TAB, T_EVIEW + "variable_tab.gif"); //$NON-NLS-1$
178

179         declareRegistryImage(IMG_OVR_OUT_OF_SYNCH, T_OVR + "error_co.gif"); //$NON-NLS-1$
180
declareRegistryImage(IMG_OVR_MAY_BE_OUT_OF_SYNCH, T_OVR + "warning_co.gif"); //$NON-NLS-1$
181
declareRegistryImage(IMG_OVR_SYNCHRONIZED, T_OVR + "sync_ovr.gif"); //$NON-NLS-1$
182

183         declareRegistryImage(IMG_OBJS_MONITOR, T_OBJ + "monitor_obj.gif"); //$NON-NLS-1$
184
declareRegistryImage(IMG_OVR_OWNED, T_OVR + "owned_ovr.gif"); //$NON-NLS-1$
185
declareRegistryImage(IMG_OVR_OWNS_MONITOR, T_OVR + "ownsmonitor_ovr.gif"); //$NON-NLS-1$
186
declareRegistryImage(IMG_OVR_IN_CONTENTION, T_OVR + "contention_ovr.gif"); //$NON-NLS-1$
187
declareRegistryImage(IMG_OVR_IN_CONTENTION_FOR_MONITOR, T_OVR + "contentionformonitor_ovr.gif"); //$NON-NLS-1$
188
declareRegistryImage(IMG_OVR_IN_DEADLOCK, T_OVR + "deadlock_ovr.gif"); //$NON-NLS-1$
189
declareRegistryImage(IMG_OBJS_CONTENDED_MONITOR, T_OBJ + "contended_monitor_obj.gif"); //$NON-NLS-1$
190
declareRegistryImage(IMG_OBJS_OWNED_MONITOR, T_OBJ + "owned_monitor_obj.gif"); //$NON-NLS-1$
191
declareRegistryImage(IMG_OBJS_THREAD_GROUP, T_OBJ + "threadgroup_obj.gif"); //$NON-NLS-1$
192

193         declareRegistryImage(IMG_WIZBAN_NEWSCRAPPAGE, T_WIZBAN + "newsbook_wiz.png"); //$NON-NLS-1$
194
declareRegistryImage(IMG_WIZBAN_LIBRARY, T_WIZBAN + "library_wiz.png"); //$NON-NLS-1$
195

196         declareRegistryImage(IMG_TOOL_TERMSNIPPET, T_ELCL + "term_sbook.gif"); //$NON-NLS-1$
197
declareRegistryImage(IMG_TOOL_TERMSNIPPET_HOVER, T_ELCL + "term_sbook.gif"); //$NON-NLS-1$
198
declareRegistryImage(IMG_TOOL_TERMSNIPPET_DISABLED, T_DLCL + "term_sbook.gif"); //$NON-NLS-1$
199

200         declareRegistryImage(IMG_OBJ_JAVA_INSPECT_EXPRESSION, T_OBJ + "insp_sbook.gif"); //$NON-NLS-1$
201
declareRegistryImage(IMG_OBJS_CLASSPATH, T_OBJ + "classpath_obj.gif"); //$NON-NLS-1$
202

203         declareRegistryImage(IMG_OBJS_EXCEPTION_BRKPT_TYPE, T_OBJ + "jexcept_obj.gif"); //$NON-NLS-1$
204
declareRegistryImage(IMG_OBJS_LINE_BRKPT_TYPE, T_OBJ + "jline_obj.gif"); //$NON-NLS-1$
205
declareRegistryImage(IMG_OBJS_CLASSLOAD_BRKPT_TYPE, T_OBJ + "jload_obj.gif"); //$NON-NLS-1$
206
declareRegistryImage(IMG_OBJS_METHOD_BRKPT_TYPE, T_OBJ + "jmeth_obj.gif"); //$NON-NLS-1$
207
declareRegistryImage(IMG_OBJS_JSP_BRKPT_TYPE, T_OBJ + "jspbrkpt_obj.gif"); //$NON-NLS-1$
208
declareRegistryImage(IMG_OBJS_WATCHPOINT_TYPE, T_OBJ + "jwatch_obj.gif"); //$NON-NLS-1$
209

210         declareRegistryImage(IMG_ELCL_AUTO_FORMAT, E_LCL + "autoform_menu.gif"); //$NON-NLS-1$
211

212         declareRegistryImage(IMG_ELCL_ALL_REFERENCES, E_LCL + "all_references.gif"); //$NON-NLS-1$
213
}
214
215     /**
216      * Declare an Image in the registry table.
217      * @param key The key to use when registering the image
218      * @param path The path where the image can be found. This path is relative to where
219      * this plugin class is found (i.e. typically the packages directory)
220      */

221     private final static void declareRegistryImage(String JavaDoc key, String JavaDoc path) {
222         ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
223         Bundle bundle = Platform.getBundle(JDIDebugUIPlugin.getUniqueIdentifier());
224         URL JavaDoc url = null;
225         if (bundle != null){
226             url = FileLocator.find(bundle, new Path(path), null);
227             desc = ImageDescriptor.createFromURL(url);
228         }
229         fgImageRegistry.put(key, desc);
230     }
231 }
232
Popular Tags