KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.ArrayList JavaDoc;
14 import java.util.HashMap JavaDoc;
15 import java.util.Iterator JavaDoc;
16 import java.util.List JavaDoc;
17 import java.util.StringTokenizer JavaDoc;
18
19 import org.eclipse.core.resources.IMarker;
20 import org.eclipse.core.resources.IResource;
21 import org.eclipse.core.runtime.CoreException;
22 import org.eclipse.core.runtime.IAdaptable;
23 import org.eclipse.debug.core.DebugException;
24 import org.eclipse.debug.core.DebugPlugin;
25 import org.eclipse.debug.core.model.IBreakpoint;
26 import org.eclipse.debug.core.model.IDisconnect;
27 import org.eclipse.debug.core.model.IExpression;
28 import org.eclipse.debug.core.model.IStackFrame;
29 import org.eclipse.debug.core.model.ITerminate;
30 import org.eclipse.debug.core.model.IThread;
31 import org.eclipse.debug.core.model.IValue;
32 import org.eclipse.debug.core.model.IWatchExpression;
33 import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
34 import org.eclipse.debug.core.sourcelookup.containers.ZipEntryStorage;
35 import org.eclipse.debug.ui.DebugUITools;
36 import org.eclipse.debug.ui.IDebugModelPresentation;
37 import org.eclipse.debug.ui.IDebugUIConstants;
38 import org.eclipse.debug.ui.IValueDetailListener;
39 import org.eclipse.jdt.core.IMember;
40 import org.eclipse.jdt.core.IType;
41 import org.eclipse.jdt.core.Signature;
42 import org.eclipse.jdt.debug.core.IJavaArray;
43 import org.eclipse.jdt.debug.core.IJavaBreakpoint;
44 import org.eclipse.jdt.debug.core.IJavaClassPrepareBreakpoint;
45 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
46 import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
47 import org.eclipse.jdt.debug.core.IJavaFieldVariable;
48 import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
49 import org.eclipse.jdt.debug.core.IJavaMethodBreakpoint;
50 import org.eclipse.jdt.debug.core.IJavaMethodEntryBreakpoint;
51 import org.eclipse.jdt.debug.core.IJavaModifiers;
52 import org.eclipse.jdt.debug.core.IJavaObject;
53 import org.eclipse.jdt.debug.core.IJavaPatternBreakpoint;
54 import org.eclipse.jdt.debug.core.IJavaReferenceType;
55 import org.eclipse.jdt.debug.core.IJavaStackFrame;
56 import org.eclipse.jdt.debug.core.IJavaStratumLineBreakpoint;
57 import org.eclipse.jdt.debug.core.IJavaTargetPatternBreakpoint;
58 import org.eclipse.jdt.debug.core.IJavaThread;
59 import org.eclipse.jdt.debug.core.IJavaType;
60 import org.eclipse.jdt.debug.core.IJavaValue;
61 import org.eclipse.jdt.debug.core.IJavaVariable;
62 import org.eclipse.jdt.debug.core.IJavaWatchpoint;
63 import org.eclipse.jdt.internal.debug.core.breakpoints.JavaExceptionBreakpoint;
64 import org.eclipse.jdt.internal.debug.core.logicalstructures.JDIAllInstancesValue;
65 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListEntryVariable;
66 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListValue;
67 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListVariable;
68 import org.eclipse.jdt.internal.debug.core.model.JDIThread;
69 import org.eclipse.jdt.internal.debug.ui.display.JavaInspectExpression;
70 import org.eclipse.jdt.internal.debug.ui.monitors.JavaContendedMonitor;
71 import org.eclipse.jdt.internal.debug.ui.monitors.JavaOwnedMonitor;
72 import org.eclipse.jdt.internal.debug.ui.monitors.JavaOwningThread;
73 import org.eclipse.jdt.internal.debug.ui.monitors.JavaWaitingThread;
74 import org.eclipse.jdt.internal.debug.ui.monitors.NoMonitorInformationElement;
75 import org.eclipse.jdt.internal.debug.ui.monitors.ThreadMonitorManager;
76 import org.eclipse.jdt.internal.ui.JavaPlugin;
77 import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
78 import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
79 import org.eclipse.jdt.ui.ISharedImages;
80 import org.eclipse.jdt.ui.JavaElementImageDescriptor;
81 import org.eclipse.jdt.ui.JavaElementLabelProvider;
82 import org.eclipse.jdt.ui.JavaUI;
83 import org.eclipse.jface.resource.ImageDescriptor;
84 import org.eclipse.jface.viewers.IColorProvider;
85 import org.eclipse.jface.viewers.LabelProvider;
86 import org.eclipse.swt.graphics.Color;
87 import org.eclipse.swt.graphics.Image;
88 import org.eclipse.swt.graphics.Point;
89 import org.eclipse.ui.IEditorDescriptor;
90 import org.eclipse.ui.IEditorInput;
91 import org.eclipse.ui.IWorkbenchWindow;
92 import org.eclipse.ui.PartInitException;
93 import org.eclipse.ui.PlatformUI;
94 import org.eclipse.ui.ide.IDE;
95
96 import com.ibm.icu.text.MessageFormat;
97 import com.sun.jdi.ObjectCollectedException;
98
99 /**
100  * Determines how to display java elements, including labels, images and editors.
101  * @see IDebugModelPresentation
102  */

103 public class JDIModelPresentation extends LabelProvider implements IDebugModelPresentation, IColorProvider {
104
105     /**
106      * Qualified names presentation property (value <code>"DISPLAY_QUALIFIED_NAMES"</code>).
107      * When <code>DISPLAY_QUALIFIED_NAMES</code> is set to <code>True</code>,
108      * this label provider should use fully qualified type names when rendering elements.
109      * When set to <code>False</code>, this label provider should use simple
110      * names when rendering elements.
111      * @see #setAttribute(String, Object)
112      */

113     public final static String JavaDoc DISPLAY_QUALIFIED_NAMES= "DISPLAY_QUALIFIED_NAMES"; //$NON-NLS-1$
114

115     protected HashMap JavaDoc fAttributes= new HashMap JavaDoc(3);
116     
117     static final Point BIG_SIZE= new Point(16, 16);
118     
119     private static ImageDescriptorRegistry fgJavaElementImageRegistry;
120     private static org.eclipse.jdt.internal.debug.ui.ImageDescriptorRegistry fgDebugImageRegistry;
121     
122     /**
123      * Flag to indicate if image registry's referenced by this model presentation is initialized
124      */

125     private static boolean fInitialized = false;
126
127     protected static final String JavaDoc fgStringName= "java.lang.String"; //$NON-NLS-1$
128

129     private JavaElementLabelProvider fJavaLabelProvider;
130     
131     public JDIModelPresentation() {
132         super();
133     }
134     
135     /* (non-Javadoc)
136      * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
137      */

138     public void dispose() {
139         super.dispose();
140         if (fJavaLabelProvider != null) {
141             fJavaLabelProvider.dispose();
142         }
143         fAttributes.clear();
144     }
145
146     /**
147      * @see IDebugModelPresentation#computeDetail(IValue, IValueDetailListener)
148      */

149     public void computeDetail(IValue value, IValueDetailListener listener) {
150         IJavaThread thread = getEvaluationThread((IJavaDebugTarget)value.getDebugTarget());
151         if (thread == null) {
152             listener.detailComputed(value, DebugUIMessages.JDIModelPresentation_no_suspended_threads);
153         } else {
154             JavaDetailFormattersManager.getDefault().computeValueDetail((IJavaValue)value, thread, listener);
155         }
156     }
157     
158     /**
159      * Returns a thread from the specified VM that can be
160      * used for an evaluation or <code>null</code> if
161      * none.
162      *
163      * @param debug target the target in which a thread is
164      * required
165      * @return thread or <code>null</code>
166      */

167     public static IJavaThread getEvaluationThread(IJavaDebugTarget target) {
168         IJavaStackFrame frame = EvaluationContextManager.getEvaluationContext((IWorkbenchWindow)null);
169         IJavaThread thread = null;
170         if (frame != null) {
171             thread = (IJavaThread) frame.getThread();
172         }
173         if (thread != null && (!thread.getDebugTarget().equals(target) || (!thread.isSuspended() && !thread.isPerformingEvaluation()))) {
174             // can only use suspended threads in the same target
175
thread = null;
176         }
177         if (thread == null) {
178             try {
179                 IThread[] threads = target.getThreads();
180                 for (int i = 0; i < threads.length; i++) {
181                     if (threads[i].isSuspended()) {
182                         thread = (IJavaThread)threads[i];
183                         break;
184                     }
185                 }
186             } catch (DebugException e) {
187                 JDIDebugUIPlugin.log(e);
188             }
189         }
190         return thread;
191     }
192             
193     /**
194      * @see IDebugModelPresentation#getText(Object)
195      */

196     public String JavaDoc getText(Object JavaDoc item) {
197         try {
198             boolean showQualified= isShowQualifiedNames();
199             if (item instanceof IJavaVariable) {
200                 return getVariableText((IJavaVariable) item);
201             } else if (item instanceof IStackFrame) {
202                 StringBuffer JavaDoc label= new StringBuffer JavaDoc(getStackFrameText((IStackFrame) item));
203                 if (item instanceof IJavaStackFrame) {
204                     if (((IJavaStackFrame)item).isOutOfSynch()) {
205                         label.append(DebugUIMessages.JDIModelPresentation___out_of_synch__1);
206                     }
207                 }
208                 return label.toString();
209             } else if (item instanceof IMarker) {
210                 IBreakpoint breakpoint = getBreakpoint((IMarker)item);
211                 if (breakpoint != null) {
212                     return getBreakpointText(breakpoint);
213                 }
214                 return null;
215             } else if (item instanceof IBreakpoint) {
216                 return getBreakpointText((IBreakpoint)item);
217             } else if (item instanceof IWatchExpression) {
218                 return getWatchExpressionText((IWatchExpression)item);
219             } else if (item instanceof IExpression) {
220                 return getExpressionText((IExpression)item);
221             } else if (item instanceof JavaOwnedMonitor) {
222                 return getJavaOwnedMonitorText((JavaOwnedMonitor)item);
223             } else if (item instanceof JavaContendedMonitor) {
224                 return getJavaContendedMonitorText((JavaContendedMonitor)item);
225             } else if (item instanceof JavaOwningThread) {
226                 return getJavaOwningTreadText((JavaOwningThread)item);
227             } else if (item instanceof JavaWaitingThread) {
228                 return getJavaWaitingTreadText((JavaWaitingThread)item);
229             } else if (item instanceof NoMonitorInformationElement) {
230                 return DebugUIMessages.JDIModelPresentation_5;
231             } else {
232                 StringBuffer JavaDoc label= new StringBuffer JavaDoc();
233                 if (item instanceof IJavaThread) {
234                     label.append(getThreadText((IJavaThread) item, showQualified));
235                     if (((IJavaThread)item).isOutOfSynch()) {
236                         label.append(DebugUIMessages.JDIModelPresentation___out_of_synch__1);
237                     } else if (((IJavaThread)item).mayBeOutOfSynch()) {
238                         label.append(DebugUIMessages.JDIModelPresentation___may_be_out_of_synch__2);
239                     }
240                 } else if (item instanceof IJavaDebugTarget) {
241                     label.append(getDebugTargetText((IJavaDebugTarget) item));
242                     if (((IJavaDebugTarget)item).isOutOfSynch()) {
243                         label.append(DebugUIMessages.JDIModelPresentation___out_of_synch__1);
244                     } else if (((IJavaDebugTarget)item).mayBeOutOfSynch()) {
245                         label.append(DebugUIMessages.JDIModelPresentation___may_be_out_of_synch__2);
246                     }
247                 } else if (item instanceof IJavaValue) {
248                     label.append(getValueText((IJavaValue) item));
249                 }
250                 if (item instanceof ITerminate) {
251                     if (((ITerminate) item).isTerminated()) {
252                         label.insert(0, DebugUIMessages.JDIModelPresentation__terminated__2);
253                         return label.toString();
254                     }
255                 }
256                 if (item instanceof IDisconnect) {
257                     if (((IDisconnect) item).isDisconnected()) {
258                         label.insert(0, DebugUIMessages.JDIModelPresentation__disconnected__4);
259                         return label.toString();
260                     }
261                 }
262                 if (label.length() > 0) {
263                     return label.toString();
264                 }
265             }
266         } catch (CoreException e) {
267             return DebugUIMessages.JDIModelPresentation__not_responding__6;
268         }
269         return null;
270     }
271
272     private String JavaDoc getJavaOwningTreadText(JavaOwningThread thread) throws CoreException {
273         return getFormattedString(DebugUIMessages.JDIModelPresentation_0, getThreadText(thread.getThread().getThread(), isShowQualifiedNames()));
274     }
275
276     private String JavaDoc getJavaWaitingTreadText(JavaWaitingThread thread) throws CoreException {
277         return getFormattedString(DebugUIMessages.JDIModelPresentation_1, getThreadText(thread.getThread().getThread(), isShowQualifiedNames()));
278     }
279
280     private String JavaDoc getJavaContendedMonitorText(JavaContendedMonitor monitor) throws DebugException {
281         return getFormattedString(DebugUIMessages.JDIModelPresentation_2, getValueText(monitor.getMonitor().getMonitor()));
282     }
283
284     private String JavaDoc getJavaOwnedMonitorText(JavaOwnedMonitor monitor) throws DebugException {
285         return getFormattedString(DebugUIMessages.JDIModelPresentation_3, getValueText(monitor.getMonitor().getMonitor()));
286     }
287
288     protected IBreakpoint getBreakpoint(IMarker marker) {
289         return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
290         }
291     
292     /**
293      * Build the text for an IJavaThread.
294      */

295     protected String JavaDoc getThreadText(IJavaThread thread, boolean qualified) throws CoreException {
296         StringBuffer JavaDoc key = new StringBuffer JavaDoc("thread_"); //$NON-NLS-1$
297
String JavaDoc[] args = null;
298         IBreakpoint[] breakpoints= thread.getBreakpoints();
299         if (thread.isDaemon()) {
300             key.append("daemon_"); //$NON-NLS-1$
301
}
302         if (thread.isSystemThread()) {
303             key.append("system_"); //$NON-NLS-1$
304
}
305         if (thread.isTerminated()) {
306             key.append("terminated"); //$NON-NLS-1$
307
args = new String JavaDoc[] {thread.getName()};
308         } else if (thread.isStepping()) {
309             key.append("stepping"); //$NON-NLS-1$
310
args = new String JavaDoc[] {thread.getName()};
311         } else if (thread.isPerformingEvaluation() && breakpoints.length == 0) {
312             key.append("evaluating"); //$NON-NLS-1$
313
args = new String JavaDoc[] {thread.getName()};
314         } else if (!thread.isSuspended() || (thread instanceof JDIThread && ((JDIThread)thread).isSuspendedQuiet())) {
315             key.append("running"); //$NON-NLS-1$
316
args = new String JavaDoc[] {thread.getName()};
317         } else {
318             key.append("suspended"); //$NON-NLS-1$
319
if (breakpoints.length > 0) {
320                 IJavaBreakpoint breakpoint= (IJavaBreakpoint)breakpoints[0];
321                 for (int i= 0, numBreakpoints= breakpoints.length; i < numBreakpoints; i++) {
322                     if (BreakpointUtils.isProblemBreakpoint(breakpoints[i])) {
323                         // If a compilation error breakpoint exists, display it instead of the first breakpoint
324
breakpoint= (IJavaBreakpoint)breakpoints[i];
325                         break;
326                     }
327                 }
328                 String JavaDoc typeName= getMarkerTypeName(breakpoint, qualified);
329                 if (BreakpointUtils.isProblemBreakpoint(breakpoint)) {
330                     IJavaStackFrame frame = (IJavaStackFrame)thread.getTopStackFrame();
331                     IMarker problem = null;
332                     if (frame != null) {
333                         problem = JavaDebugOptionsManager.getDefault().getProblem(frame);
334                     }
335                     if (problem != null) {
336                         key.append("_problem"); //$NON-NLS-1$
337
String JavaDoc message = problem.getAttribute(IMarker.MESSAGE, DebugUIMessages.JDIModelPresentation_Compilation_error_1);
338                         args = new String JavaDoc[] {thread.getName(), message};
339                     }
340                 }
341                 // check args == null in case the exception is a compilation error
342
if (breakpoint instanceof IJavaExceptionBreakpoint && args == null) {
343                     key.append("_exception"); //$NON-NLS-1$
344
String JavaDoc exName = ((IJavaExceptionBreakpoint)breakpoint).getExceptionTypeName();
345                     if (exName == null) {
346                         exName = typeName;
347                     } else if (!qualified) {
348                         int index = exName.lastIndexOf('.');
349                         exName = exName.substring(index + 1);
350                     }
351                     args = new String JavaDoc[] {thread.getName(), exName};
352                 } else if (breakpoint instanceof IJavaWatchpoint) {
353                     IJavaWatchpoint wp = (IJavaWatchpoint)breakpoint;
354                     String JavaDoc fieldName = wp.getFieldName();
355                     args = new String JavaDoc[] {thread.getName(), fieldName, typeName};
356                     if (wp.isAccessSuspend(thread.getDebugTarget())) {
357                         key.append("_fieldaccess"); //$NON-NLS-1$
358
} else {
359                         key.append("_fieldmodification"); //$NON-NLS-1$
360
}
361                 } else if (breakpoint instanceof IJavaMethodBreakpoint) {
362                     IJavaMethodBreakpoint me= (IJavaMethodBreakpoint)breakpoint;
363                     String JavaDoc methodName= me.getMethodName();
364                     args = new String JavaDoc[] {thread.getName(), methodName, typeName};
365                     if (me.isEntrySuspend(thread.getDebugTarget())) {
366                         key.append("_methodentry"); //$NON-NLS-1$
367
} else {
368                         key.append("_methodexit"); //$NON-NLS-1$
369
}
370                 } else if (breakpoint instanceof IJavaLineBreakpoint) {
371                     IJavaLineBreakpoint jlbp = (IJavaLineBreakpoint)breakpoint;
372                     int lineNumber= jlbp.getLineNumber();
373                     if (lineNumber > -1) {
374                         args = new String JavaDoc[] {thread.getName(), String.valueOf(lineNumber), typeName};
375                         if (BreakpointUtils.isRunToLineBreakpoint(jlbp)) {
376                             key.append("_runtoline"); //$NON-NLS-1$
377
} else {
378                             key.append("_linebreakpoint"); //$NON-NLS-1$
379
}
380                     }
381                 } else if (breakpoint instanceof IJavaClassPrepareBreakpoint) {
382                     key.append("_classprepare"); //$NON-NLS-1$
383
args = new String JavaDoc[]{thread.getName(), getQualifiedName(breakpoint.getTypeName())};
384                 }
385             }
386     
387             if (args == null) {
388                 // Otherwise, it's just suspended
389
args = new String JavaDoc[] {thread.getName()};
390             }
391         }
392         try {
393             return getFormattedString((String JavaDoc)DebugUIMessages.class.getDeclaredField(key.toString()).get(null), args);
394         } catch (IllegalArgumentException JavaDoc e) {
395             JDIDebugUIPlugin.log(e);
396         } catch (SecurityException JavaDoc e) {
397             JDIDebugUIPlugin.log(e);
398         } catch (IllegalAccessException JavaDoc e) {
399             JDIDebugUIPlugin.log(e);
400         } catch (NoSuchFieldException JavaDoc e) {
401             JDIDebugUIPlugin.log(e);
402         }
403         return DebugUIMessages.JDIModelPresentation_unknown_name__1;
404     }
405
406     /**
407      * Build the text for an IJavaDebugTarget.
408      */

409     protected String JavaDoc getDebugTargetText(IJavaDebugTarget debugTarget) throws DebugException {
410         String JavaDoc labelString= debugTarget.getName();
411         if (debugTarget.isSuspended()) {
412             labelString += DebugUIMessages.JDIModelPresentation_target_suspended;
413         }
414         return labelString;
415     }
416
417     /**
418      * Build the text for an IJavaValue.
419      */

420     public String JavaDoc getValueText(IJavaValue value) throws DebugException {
421         
422         String JavaDoc refTypeName= value.getReferenceTypeName();
423         String JavaDoc valueString= value.getValueString();
424         boolean isString= refTypeName.equals(fgStringName);
425         IJavaType type= value.getJavaType();
426         String JavaDoc signature= null;
427         if (type != null) {
428             signature= type.getSignature();
429         }
430         if ("V".equals(signature)) { //$NON-NLS-1$
431
valueString= DebugUIMessages.JDIModelPresentation__No_explicit_return_value__30;
432         }
433         boolean isObject= isObjectValue(signature);
434         boolean isArray= value instanceof IJavaArray;
435         StringBuffer JavaDoc buffer= new StringBuffer JavaDoc();
436         // Always show type name for objects & arrays (but not Strings)
437
if (isObject && !isString && (refTypeName.length() > 0)) {
438             // Don't show type name for instances and references
439
if (!(value instanceof JDIReferenceListValue || value instanceof JDIAllInstancesValue)){
440                 String JavaDoc qualTypeName= getQualifiedName(refTypeName);
441                 if (isArray) {
442                     qualTypeName= adjustTypeNameForArrayIndex(qualTypeName, ((IJavaArray)value).getLength());
443                 }
444                 buffer.append(qualTypeName);
445                 buffer.append(' ');
446             }
447         }
448         
449         // Put double quotes around Strings
450
if (valueString != null && (isString || valueString.length() > 0)) {
451             if (isString) {
452                 buffer.append('"');
453             }
454             buffer.append(valueString);
455             if (isString) {
456                 buffer.append('"');
457             }
458         }
459         
460         // show unsigned value second, if applicable
461
if (isShowUnsignedValues()) {
462             buffer= appendUnsignedText(value, buffer);
463         }
464         // show hex value third, if applicable
465
if (isShowHexValues()) {
466             buffer= appendHexText(value, buffer);
467         }
468         // show byte character value last, if applicable
469
if (isShowCharValues()) {
470             buffer= appendCharText(value, buffer);
471         }
472         
473         return buffer.toString();
474     }
475     
476
477     private StringBuffer JavaDoc appendUnsignedText(IJavaValue value, StringBuffer JavaDoc buffer) throws DebugException {
478         String JavaDoc unsignedText= getValueUnsignedText(value);
479         if (unsignedText != null) {
480             buffer.append(" ["); //$NON-NLS-1$
481
buffer.append(unsignedText);
482             buffer.append("]"); //$NON-NLS-1$
483
}
484         return buffer;
485     }
486         
487     protected StringBuffer JavaDoc appendHexText(IJavaValue value, StringBuffer JavaDoc buffer) throws DebugException {
488         String JavaDoc hexText = getValueHexText(value);
489         if (hexText != null) {
490             buffer.append(" ["); //$NON-NLS-1$
491
buffer.append(hexText);
492             buffer.append("]"); //$NON-NLS-1$
493
}
494         return buffer;
495     }
496     
497     protected StringBuffer JavaDoc appendCharText(IJavaValue value, StringBuffer JavaDoc buffer) throws DebugException {
498         String JavaDoc charText= getValueCharText(value);
499         if (charText != null) {
500             buffer.append(" ["); //$NON-NLS-1$
501
buffer.append(charText);
502             buffer.append("]"); //$NON-NLS-1$
503
}
504         return buffer;
505     }
506     
507     /**
508      * Given a JNI-style signature String for a IJavaValue, return true
509      * if the signature represents an Object or an array of Objects.
510      */

511     public static boolean isObjectValue(String JavaDoc signature) {
512         if (signature == null) {
513             return false;
514         }
515         char sigChar= ' ';
516         for (int i= 0; i < signature.length(); i++) {
517             sigChar= signature.charAt(i);
518             if (sigChar == '[') {
519                 return true;
520             }
521             break;
522         }
523         if ((sigChar == 'L') || (sigChar == 'Q')) {
524             return true;
525         }
526         return false;
527     }
528     
529     /**
530      * Returns whether the image registry's have been retrieved.
531      *
532      * @return whether image registry's have been retrieved.
533      */

534     public static boolean isInitialized() {
535         return fgJavaElementImageRegistry != null && fgDebugImageRegistry != null;
536     }
537     
538     /**
539      * Returns the type signature for this value if its type is primitive.
540      * For non-primitive types, null is returned.
541      */

542     protected String JavaDoc getPrimitiveValueTypeSignature(IJavaValue value) throws DebugException {
543         IJavaType type= value.getJavaType();
544         if (type != null) {
545             String JavaDoc sig= type.getSignature();
546             if (sig != null && sig.length() == 1) {
547                 return sig;
548             }
549         }
550         return null;
551     }
552     /**
553      * Returns the character string of a byte or <code>null</code> if
554      * the value can not be interpreted as a valid character.
555      */

556     protected String JavaDoc getValueCharText(IJavaValue value) throws DebugException {
557         String JavaDoc sig= getPrimitiveValueTypeSignature(value);
558         if (sig == null) {
559             return null;
560         }
561         String JavaDoc valueString= value.getValueString();
562         long longValue;
563         try {
564             longValue= Long.parseLong(valueString);
565         } catch (NumberFormatException JavaDoc e) {
566             return null;
567         }
568         switch (sig.charAt(0)) {
569             case 'B' : // byte
570
longValue= longValue & 0xFF; // Only lower 8 bits
571
break;
572             case 'I' : // integer
573
longValue= longValue & 0xFFFFFFFF; // Only lower 32 bits
574
if (longValue > 0xFFFF || longValue < 0) {
575                     return null;
576                 }
577                 break;
578             case 'S' : // short
579
longValue= longValue & 0xFFFF; // Only lower 16 bits
580
break;
581             case 'J' :
582                 if (longValue > 0xFFFF || longValue < 0) {
583                     // Out of character range
584
return null;
585                 }
586                 break;
587             default :
588                 return null;
589         }
590         char charValue= (char)longValue;
591         StringBuffer JavaDoc charText = new StringBuffer JavaDoc();
592         if (Character.getType(charValue) == Character.CONTROL) {
593             Character JavaDoc ctrl = new Character JavaDoc((char) (charValue + 64));
594             charText.append('^');
595             charText.append(ctrl);
596             switch (charValue) { // common use
597
case 0: charText.append(" (NUL)"); break; //$NON-NLS-1$
598
case 8: charText.append(" (BS)"); break; //$NON-NLS-1$
599
case 9: charText.append(" (TAB)"); break; //$NON-NLS-1$
600
case 10: charText.append(" (LF)"); break; //$NON-NLS-1$
601
case 13: charText.append(" (CR)"); break; //$NON-NLS-1$
602
case 21: charText.append(" (NL)"); break; //$NON-NLS-1$
603
case 27: charText.append(" (ESC)"); break; //$NON-NLS-1$
604
case 127: charText.append(" (DEL)"); break; //$NON-NLS-1$
605
}
606         } else {
607             charText.append(new Character JavaDoc(charValue));
608         }
609         return charText.toString();
610     }
611
612     protected String JavaDoc getMarkerTypeName(IJavaBreakpoint breakpoint, boolean qualified) throws CoreException {
613         String JavaDoc typeName= null;
614         if (breakpoint instanceof IJavaPatternBreakpoint) {
615             typeName = breakpoint.getMarker().getResource().getName();
616         } else {
617             typeName = breakpoint.getTypeName();
618         }
619         if (!qualified) {
620