1 11 package org.eclipse.jdt.internal.debug.ui; 12 13 import java.util.ArrayList ; 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 import java.util.StringTokenizer ; 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 103 public class JDIModelPresentation extends LabelProvider implements IDebugModelPresentation, IColorProvider { 104 105 113 public final static String DISPLAY_QUALIFIED_NAMES= "DISPLAY_QUALIFIED_NAMES"; 115 protected HashMap fAttributes= new HashMap (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 125 private static boolean fInitialized = false; 126 127 protected static final String fgStringName= "java.lang.String"; 129 private JavaElementLabelProvider fJavaLabelProvider; 130 131 public JDIModelPresentation() { 132 super(); 133 } 134 135 138 public void dispose() { 139 super.dispose(); 140 if (fJavaLabelProvider != null) { 141 fJavaLabelProvider.dispose(); 142 } 143 fAttributes.clear(); 144 } 145 146 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 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 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 196 public String getText(Object 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 label= new StringBuffer (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 label= new StringBuffer (); 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 getJavaOwningTreadText(JavaOwningThread thread) throws CoreException { 273 return getFormattedString(DebugUIMessages.JDIModelPresentation_0, getThreadText(thread.getThread().getThread(), isShowQualifiedNames())); 274 } 275 276 private String getJavaWaitingTreadText(JavaWaitingThread thread) throws CoreException { 277 return getFormattedString(DebugUIMessages.JDIModelPresentation_1, getThreadText(thread.getThread().getThread(), isShowQualifiedNames())); 278 } 279 280 private String getJavaContendedMonitorText(JavaContendedMonitor monitor) throws DebugException { 281 return getFormattedString(DebugUIMessages.JDIModelPresentation_2, getValueText(monitor.getMonitor().getMonitor())); 282 } 283 284 private String 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 295 protected String getThreadText(IJavaThread thread, boolean qualified) throws CoreException { 296 StringBuffer key = new StringBuffer ("thread_"); String [] args = null; 298 IBreakpoint[] breakpoints= thread.getBreakpoints(); 299 if (thread.isDaemon()) { 300 key.append("daemon_"); } 302 if (thread.isSystemThread()) { 303 key.append("system_"); } 305 if (thread.isTerminated()) { 306 key.append("terminated"); args = new String [] {thread.getName()}; 308 } else if (thread.isStepping()) { 309 key.append("stepping"); args = new String [] {thread.getName()}; 311 } else if (thread.isPerformingEvaluation() && breakpoints.length == 0) { 312 key.append("evaluating"); args = new String [] {thread.getName()}; 314 } else if (!thread.isSuspended() || (thread instanceof JDIThread && ((JDIThread)thread).isSuspendedQuiet())) { 315 key.append("running"); args = new String [] {thread.getName()}; 317 } else { 318 key.append("suspended"); 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 breakpoint= (IJavaBreakpoint)breakpoints[i]; 325 break; 326 } 327 } 328 String 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"); String message = problem.getAttribute(IMarker.MESSAGE, DebugUIMessages.JDIModelPresentation_Compilation_error_1); 338 args = new String [] {thread.getName(), message}; 339 } 340 } 341 if (breakpoint instanceof IJavaExceptionBreakpoint && args == null) { 343 key.append("_exception"); String 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 [] {thread.getName(), exName}; 352 } else if (breakpoint instanceof IJavaWatchpoint) { 353 IJavaWatchpoint wp = (IJavaWatchpoint)breakpoint; 354 String fieldName = wp.getFieldName(); 355 args = new String [] {thread.getName(), fieldName, typeName}; 356 if (wp.isAccessSuspend(thread.getDebugTarget())) { 357 key.append("_fieldaccess"); } else { 359 key.append("_fieldmodification"); } 361 } else if (breakpoint instanceof IJavaMethodBreakpoint) { 362 IJavaMethodBreakpoint me= (IJavaMethodBreakpoint)breakpoint; 363 String methodName= me.getMethodName(); 364 args = new String [] {thread.getName(), methodName, typeName}; 365 if (me.isEntrySuspend(thread.getDebugTarget())) { 366 key.append("_methodentry"); } else { 368 key.append("_methodexit"); } 370 } else if (breakpoint instanceof IJavaLineBreakpoint) { 371 IJavaLineBreakpoint jlbp = (IJavaLineBreakpoint)breakpoint; 372 int lineNumber= jlbp.getLineNumber(); 373 if (lineNumber > -1) { 374 args = new String [] {thread.getName(), String.valueOf(lineNumber), typeName}; 375 if (BreakpointUtils.isRunToLineBreakpoint(jlbp)) { 376 key.append("_runtoline"); } else { 378 key.append("_linebreakpoint"); } 380 } 381 } else if (breakpoint instanceof IJavaClassPrepareBreakpoint) { 382 key.append("_classprepare"); args = new String []{thread.getName(), getQualifiedName(breakpoint.getTypeName())}; 384 } 385 } 386 387 if (args == null) { 388 args = new String [] {thread.getName()}; 390 } 391 } 392 try { 393 return getFormattedString((String )DebugUIMessages.class.getDeclaredField(key.toString()).get(null), args); 394 } catch (IllegalArgumentException e) { 395 JDIDebugUIPlugin.log(e); 396 } catch (SecurityException e) { 397 JDIDebugUIPlugin.log(e); 398 } catch (IllegalAccessException e) { 399 JDIDebugUIPlugin.log(e); 400 } catch (NoSuchFieldException e) { 401 JDIDebugUIPlugin.log(e); 402 } 403 return DebugUIMessages.JDIModelPresentation_unknown_name__1; 404 } 405 406 409 protected String getDebugTargetText(IJavaDebugTarget debugTarget) throws DebugException { 410 String labelString= debugTarget.getName(); 411 if (debugTarget.isSuspended()) { 412 labelString += DebugUIMessages.JDIModelPresentation_target_suspended; 413 } 414 return labelString; 415 } 416 417 420 public String getValueText(IJavaValue value) throws DebugException { 421 422 String refTypeName= value.getReferenceTypeName(); 423 String valueString= value.getValueString(); 424 boolean isString= refTypeName.equals(fgStringName); 425 IJavaType type= value.getJavaType(); 426 String signature= null; 427 if (type != null) { 428 signature= type.getSignature(); 429 } 430 if ("V".equals(signature)) { valueString= DebugUIMessages.JDIModelPresentation__No_explicit_return_value__30; 432 } 433 boolean isObject= isObjectValue(signature); 434 boolean isArray= value instanceof IJavaArray; 435 StringBuffer buffer= new StringBuffer (); 436 if (isObject && !isString && (refTypeName.length() > 0)) { 438 if (!(value instanceof JDIReferenceListValue || value instanceof JDIAllInstancesValue)){ 440 String 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 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 if (isShowUnsignedValues()) { 462 buffer= appendUnsignedText(value, buffer); 463 } 464 if (isShowHexValues()) { 466 buffer= appendHexText(value, buffer); 467 } 468 if (isShowCharValues()) { 470 buffer= appendCharText(value, buffer); 471 } 472 473 return buffer.toString(); 474 } 475 476 477 private StringBuffer appendUnsignedText(IJavaValue value, StringBuffer buffer) throws DebugException { 478 String unsignedText= getValueUnsignedText(value); 479 if (unsignedText != null) { 480 buffer.append(" ["); buffer.append(unsignedText); 482 buffer.append("]"); } 484 return buffer; 485 } 486 487 protected StringBuffer appendHexText(IJavaValue value, StringBuffer buffer) throws DebugException { 488 String hexText = getValueHexText(value); 489 if (hexText != null) { 490 buffer.append(" ["); buffer.append(hexText); 492 buffer.append("]"); } 494 return buffer; 495 } 496 497 protected StringBuffer appendCharText(IJavaValue value, StringBuffer buffer) throws DebugException { 498 String charText= getValueCharText(value); 499 if (charText != null) { 500 buffer.append(" ["); buffer.append(charText); 502 buffer.append("]"); } 504 return buffer; 505 } 506 507 511 public static boolean isObjectValue(String 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 534 public static boolean isInitialized() { 535 return fgJavaElementImageRegistry != null && fgDebugImageRegistry != null; 536 } 537 538 542 protected String getPrimitiveValueTypeSignature(IJavaValue value) throws DebugException { 543 IJavaType type= value.getJavaType(); 544 if (type != null) { 545 String sig= type.getSignature(); 546 if (sig != null && sig.length() == 1) { 547 return sig; 548 } 549 } 550 return null; 551 } 552 556 protected String getValueCharText(IJavaValue value) throws DebugException { 557 String sig= getPrimitiveValueTypeSignature(value); 558 if (sig == null) { 559 return null; 560 } 561 String valueString= value.getValueString(); 562 long longValue; 563 try { 564 longValue= Long.parseLong(valueString); 565 } catch (NumberFormatException e) { 566 return null; 567 } 568 switch (sig.charAt(0)) { 569 case 'B' : longValue= longValue & 0xFF; break; 572 case 'I' : longValue= longValue & 0xFFFFFFFF; if (longValue > 0xFFFF || longValue < 0) { 575 return null; 576 } 577 break; 578 case 'S' : longValue= longValue & 0xFFFF; break; 581 case 'J' : 582 if (longValue > 0xFFFF || longValue < 0) { 583 return null; 585 } 586 break; 587 default : 588 return null; 589 } 590 char charValue= (char)longValue; 591 StringBuffer charText = new StringBuffer (); 592 if (Character.getType(charValue) == Character.CONTROL) { 593 Character ctrl = new Character ((char) (charValue + 64)); 594 charText.append('^'); 595 charText.append(ctrl); 596 switch (charValue) { case 0: charText.append(" (NUL)"); break; case 8: charText.append(" (BS)"); break; case 9: charText.append(" (TAB)"); break; case 10: charText.append(" (LF)"); break; case 13: charText.append(" (CR)"); break; case 21: charText.append(" (NL)"); break; case 27: charText.append(" (ESC)"); break; case 127: charText.append(" (DEL)"); break; } 606 } else { 607 charText.append(new Character (charValue)); 608 } 609 return charText.toString(); 610 } 611 612 protected String getMarkerTypeName(IJavaBreakpoint breakpoint, boolean qualified) throws CoreException { 613 String typeName= null; 614 if (breakpoint instanceof IJavaPatternBreakpoint) { 615 typeName = breakpoint.getMarker().getResource().getName(); 616 } else { 617 typeName = breakpoint.getTypeName(); 618 } 619 if (!qualified) { 620 int index= typeName.lastIndexOf('.'); 621 if (index != -1) { 622 typeName= typeName.substring(index + 1); 623 } 624 } 625 return typeName; 626 } 627 628 633 public Image getImage(Object item) { 634 635 initImageRegistries(); 636 637 try { 638 if (item instanceof JDIReferenceListVariable) { 639 return getReferencesImage(item); 640 } 641 if (item instanceof JDIReferenceListEntryVariable){ 642 return getReferenceImage(item); 643 } 644 if (item instanceof IJavaVariable) { 645 return getVariableImage((IAdaptable) item); 646 } 647 if (item instanceof IMarker) { 648 IBreakpoint bp = getBreakpoint((IMarker)item); 649 if (bp != null && bp instanceof IJavaBreakpoint) { 650 return getBreakpointImage((IJavaBreakpoint)bp); 651 } 652 } 653 if (item instanceof IJavaBreakpoint) { 654 return getBreakpointImage((IJavaBreakpoint)item); 655 } 656 if (item instanceof IJavaStackFrame || item instanceof IJavaThread || item instanceof IJavaDebugTarget) { 657 return getDebugElementImage(item); 658 } 659 if (item instanceof IJavaValue) { 660 return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PUBLIC); 661 } 662 if (item instanceof IExpression) { 663 return getExpressionImage(item); 664 } 665 if (item instanceof JavaOwnedMonitor) { 666 return getJavaOwnedMonitorImage((JavaOwnedMonitor)item); 667 } 668 if (item instanceof JavaContendedMonitor) { 669 return getJavaContendedMonitorImage((JavaContendedMonitor)item); 670 } 671 if (item instanceof JavaOwningThread) { 672 return getJavaOwningThreadImage((JavaOwningThread)item); 673 } 674 if (item instanceof JavaWaitingThread) { 675 return getJavaWaitingThreadImage((JavaWaitingThread)item); 676 } 677 if (item instanceof NoMonitorInformationElement) { 678 return getDebugImageRegistry().get(new JDIImageDescriptor( 679 getImageDescriptor(JavaDebugImages.IMG_OBJS_MONITOR), 0)); 680 } 681 } catch (CoreException e) { 682 } 684 return null; 685 } 686 687 690 private synchronized void initImageRegistries() { 691 692 if (!fInitialized && Thread.currentThread().equals(JDIDebugUIPlugin.getStandardDisplay().getThread())) { 694 getDebugImageRegistry(); 696 getJavaElementImageRegistry(); 697 JavaUI.getSharedImages(); 698 fInitialized = true; 699 } 700 } 701 702 706 private Image getJavaWaitingThreadImage(JavaWaitingThread thread) { 707 JDIImageDescriptor descriptor; 708 int flag= JDIImageDescriptor.IN_CONTENTION_FOR_MONITOR | (thread.getThread().isInDeadlock() ? JDIImageDescriptor.IN_DEADLOCK : 0); 709 if (thread.isSuspended()) { 710 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED), flag); 711 } else { 712 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING), flag); 713 } 714 return getDebugImageRegistry().get(descriptor); 715 } 716 717 721 private Image getJavaOwningThreadImage(JavaOwningThread thread) { 722 JDIImageDescriptor descriptor; 723 int flag= JDIImageDescriptor.OWNS_MONITOR | (thread.getThread().isInDeadlock() ? JDIImageDescriptor.IN_DEADLOCK : 0); 724 if (thread.isSuspended()) { 725 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED), flag); 726 } else { 727 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING), flag); 728 } 729 return getDebugImageRegistry().get(descriptor); 730 } 731 732 736 private Image getJavaContendedMonitorImage(JavaContendedMonitor monitor) { 737 int flag= monitor.getMonitor().isInDeadlock() ? JDIImageDescriptor.IN_DEADLOCK : 0; 738 JDIImageDescriptor descriptor= new JDIImageDescriptor( 739 getImageDescriptor(JavaDebugImages.IMG_OBJS_CONTENDED_MONITOR), flag); 740 return getDebugImageRegistry().get(descriptor); 741 } 742 743 747 private Image getJavaOwnedMonitorImage(JavaOwnedMonitor monitor) { 748 int flag= monitor.getMonitor().isInDeadlock() ? JDIImageDescriptor.IN_DEADLOCK : 0; 749 JDIImageDescriptor descriptor= new JDIImageDescriptor(getImageDescriptor(JavaDebugImages.IMG_OBJS_OWNED_MONITOR), flag); 750 return getDebugImageRegistry().get(descriptor); 751 } 752 753 protected Image getBreakpointImage(IJavaBreakpoint breakpoint) throws CoreException { 754 if (breakpoint instanceof IJavaExceptionBreakpoint) { 755 return getExceptionBreakpointImage((IJavaExceptionBreakpoint)breakpoint); 756 } else if (breakpoint instanceof IJavaClassPrepareBreakpoint) { 757 return getClassPrepareBreakpointImage((IJavaClassPrepareBreakpoint)breakpoint); 758 } 759 760 if (breakpoint instanceof IJavaLineBreakpoint && BreakpointUtils.isRunToLineBreakpoint((IJavaLineBreakpoint)breakpoint)) { 761 return null; 762 } 763 return getJavaBreakpointImage(breakpoint); 764 } 765 766 protected Image getExceptionBreakpointImage(IJavaExceptionBreakpoint exception) throws CoreException { 767 int flags= computeBreakpointAdornmentFlags(exception); 768 JDIImageDescriptor descriptor= null; 769 if ((flags & JDIImageDescriptor.ENABLED) == 0) { 770 descriptor= new JDIImageDescriptor(getImageDescriptor(JavaDebugImages.IMG_OBJS_EXCEPTION_DISABLED), flags); 771 } else if (exception.isChecked()) { 772 descriptor= new JDIImageDescriptor(getImageDescriptor(JavaDebugImages.IMG_OBJS_EXCEPTION), flags); 773 } else { 774 descriptor= new JDIImageDescriptor(getImageDescriptor(JavaDebugImages.IMG_OBJS_ERROR), flags); 775 } 776 return getDebugImageRegistry().get(descriptor); 777 } 778 779 protected Image getJavaBreakpointImage(IJavaBreakpoint breakpoint) throws CoreException { 780 if (breakpoint instanceof IJavaMethodBreakpoint) { 781 IJavaMethodBreakpoint mBreakpoint= (IJavaMethodBreakpoint)breakpoint; 782 return getJavaMethodBreakpointImage(mBreakpoint); 783 } else if (breakpoint instanceof IJavaWatchpoint) { 784 IJavaWatchpoint watchpoint= (IJavaWatchpoint)breakpoint; 785 return getJavaWatchpointImage(watchpoint); 786 } else if (breakpoint instanceof IJavaMethodEntryBreakpoint) { 787 IJavaMethodEntryBreakpoint meBreakpoint = (IJavaMethodEntryBreakpoint)breakpoint; 788 return getJavaMethodEntryBreakpointImage(meBreakpoint); 789 } else { 790 int flags= computeBreakpointAdornmentFlags(breakpoint); 791 JDIImageDescriptor descriptor= null; 792 if (breakpoint.isEnabled()) { 793 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_BREAKPOINT), flags); 794 } else { 795 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED), flags); 796 } 797 return getDebugImageRegistry().get(descriptor); 798 } 799 } 800 801 protected Image getJavaMethodBreakpointImage(IJavaMethodBreakpoint mBreakpoint) throws CoreException { 802 int flags= computeBreakpointAdornmentFlags(mBreakpoint); 803 JDIImageDescriptor descriptor= null; 804 if (mBreakpoint.isEnabled()) { 805 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_BREAKPOINT), flags); 806 } else { 807 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED), flags); 808 } 809 810 return getDebugImageRegistry().get(descriptor); 811 } 812 813 protected Image getJavaMethodEntryBreakpointImage(IJavaMethodEntryBreakpoint mBreakpoint) throws CoreException { 814 int flags= computeBreakpointAdornmentFlags(mBreakpoint); 815 JDIImageDescriptor descriptor= null; 816 if (mBreakpoint.isEnabled()) { 817 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_BREAKPOINT), flags); 818 } else { 819 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED), flags); 820 } 821 822 return getDebugImageRegistry().get(descriptor); 823 } 824 825 protected Image getClassPrepareBreakpointImage(IJavaClassPrepareBreakpoint breakpoint) throws CoreException { 826 int flags= computeBreakpointAdornmentFlags(breakpoint); 827 JDIImageDescriptor descriptor= null; 828 if (breakpoint.getMemberType() == IJavaClassPrepareBreakpoint.TYPE_CLASS) { 829 descriptor= new JDIImageDescriptor(JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_CLASS), flags); 830 } else { 831 descriptor= new JDIImageDescriptor(JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_INTERFACE), flags); 832 } 833 return getDebugImageRegistry().get(descriptor); 834 } 835 836 protected Image getJavaWatchpointImage(IJavaWatchpoint watchpoint) throws CoreException { 837 int flags= computeBreakpointAdornmentFlags(watchpoint); 838 JDIImageDescriptor descriptor= null; 839 boolean enabled= (flags & JDIImageDescriptor.ENABLED) != 0; 840 if (watchpoint.isAccess()) { 841 if (watchpoint.isModification()) { 842 if (enabled) { 844 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT), flags); 845 } else { 846 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT_DISABLED), flags); 847 } 848 } else { 849 if (enabled) { 850 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_ACCESS_WATCHPOINT), flags); 851 } else { 852 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_ACCESS_WATCHPOINT_DISABLED), flags); 853 } 854 } 855 } else if (watchpoint.isModification()) { 856 if (enabled) { 857 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_MODIFICATION_WATCHPOINT), flags); 858 } else { 859 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_MODIFICATION_WATCHPOINT_DISABLED), flags); 860 } 861 } else { 862 descriptor= new JDIImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT_DISABLED), flags); 864 } 865 return getDebugImageRegistry().get(descriptor); 866 } 867 868 protected Image getVariableImage(IAdaptable element) { 869 JavaElementImageDescriptor descriptor= new JavaElementImageDescriptor( 870 computeBaseImageDescriptor(element), computeAdornmentFlags(element), BIG_SIZE); 871 872 return getJavaElementImageRegistry().get(descriptor); 873 } 874 875 882 protected Image getReferencesImage(Object element){ 883 return JavaDebugImages.get(JavaDebugImages.IMG_ELCL_ALL_REFERENCES); 884 } 885 886 893 protected Image getReferenceImage(Object element){ 894 return JavaDebugImages.get(JavaDebugImages.IMG_OBJS_REFERENCE); 895 } 896 897 901 protected Image getDebugElementImage(Object element) { 902 ImageDescriptor image= null; 903 if (element instanceof IJavaThread) { 904 IJavaThread thread = (IJavaThread)element; 905 if (thread.isSuspended() && !thread.isPerformingEvaluation()) { 906 image= DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED); 907 } else if (thread.isTerminated()) { 908 image= DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED); 909 } else { 910 image= DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING); 911 } 912 } else { 913 image= DebugUITools.getDefaultImageDescriptor(element); 914 } 915 if (image == null) { 916 return null; 917 } 918 int flags= computeJDIAdornmentFlags(element); 919 JDIImageDescriptor descriptor= new JDIImageDescriptor(image, flags); 920 return getDebugImageRegistry().get(descriptor); 921 } 922 923 927 protected Image getExpressionImage(Object expression) { 928 ImageDescriptor image= null; 929 boolean bigSize = false; 930 if (expression instanceof JavaInspectExpression) { 931 image= JavaDebugImages.getImageDescriptor(JavaDebugImages.IMG_OBJ_JAVA_INSPECT_EXPRESSION); 932 bigSize = true; 933 } 934 if (image == null) { 935 return null; 936 } 937 JDIImageDescriptor descriptor= new JDIImageDescriptor(image, 0); 938 if (bigSize) { 939 descriptor.setSize(BIG_SIZE); 940 } 941 return getDebugImageRegistry().get(descriptor); 942 } 943 944 949 private int computeJDIAdornmentFlags(Object element) { 950 try { 951 if (element instanceof IJavaStackFrame) { 952 IJavaStackFrame javaStackFrame = ((IJavaStackFrame)element); 953 if (javaStackFrame.isOutOfSynch()) { 954 return JDIImageDescriptor.IS_OUT_OF_SYNCH; 955 } 956 if (!javaStackFrame.isObsolete() && javaStackFrame.isSynchronized()) { 957 return JDIImageDescriptor.SYNCHRONIZED; 958 } 959 } 960 if (element instanceof IJavaThread) { 961 int flag= 0; 962 IJavaThread javaThread = ((IJavaThread)element); 963 if (ThreadMonitorManager.getDefault().isInDeadlock(javaThread)) { 964 flag= JDIImageDescriptor.IN_DEADLOCK; 965 } 966 if (javaThread.isOutOfSynch()) { 967 return flag | JDIImageDescriptor.IS_OUT_OF_SYNCH; 968 } 969 if (javaThread.mayBeOutOfSynch()) { 970 return flag | JDIImageDescriptor.MAY_BE_OUT_OF_SYNCH; 971 } 972 return flag; 973 } 974 if (element instanceof IJavaDebugTarget) { 975 if (((IJavaDebugTarget)element).isOutOfSynch()) { 976 return JDIImageDescriptor.IS_OUT_OF_SYNCH; 977 } 978 if (((IJavaDebugTarget)element).mayBeOutOfSynch()) { 979 return JDIImageDescriptor.MAY_BE_OUT_OF_SYNCH; 980 } 981 } 982 } catch (DebugException e) { 983 } 985 return 0; 986 } 987 988 993 private int computeBreakpointAdornmentFlags(IJavaBreakpoint breakpoint) { 994 int flags= 0; 995 try { 996 if (breakpoint.isEnabled()) { 997 flags |= JDIImageDescriptor.ENABLED; 998 } 999 if (breakpoint.isInstalled()) { 1000 flags |= JDIImageDescriptor.INSTALLED; 1001 } 1002 if (breakpoint instanceof IJavaLineBreakpoint) { 1003 if (((IJavaLineBreakpoint)breakpoint).isConditionEnabled()) { 1004 flags |= JDIImageDescriptor.CONDITIONAL; 1005 } 1006 if (breakpoint instanceof IJavaMethodBreakpoint) { 1007 IJavaMethodBreakpoint mBreakpoint= (IJavaMethodBreakpoint)breakpoint; 1008 if (mBreakpoint.isEntry()) { 1009 flags |= JDIImageDescriptor.ENTRY; 1010 } 1011 if (mBreakpoint.isExit()) { 1012 flags |= JDIImageDescriptor.EXIT; 1013 } 1014 } 1015 if (breakpoint instanceof IJavaMethodEntryBreakpoint) { 1016 flags |= JDIImageDescriptor.ENTRY; 1017 } 1018 } else if (breakpoint instanceof IJavaExceptionBreakpoint) { 1019 IJavaExceptionBreakpoint eBreakpoint= (IJavaExceptionBreakpoint)breakpoint; 1020 if (eBreakpoint.isCaught()) { 1021 flags |= JDIImageDescriptor.CAUGHT; 1022 } 1023 if (eBreakpoint.isUncaught()) { 1024 flags |= JDIImageDescriptor.UNCAUGHT; 1025 } 1026 if (eBreakpoint.getExclusionFilters().length > 0 || eBreakpoint.getInclusionFilters().length > 0) { 1027 flags |= JDIImageDescriptor.SCOPED; 1028 } 1029 } 1030 } catch (CoreException e) { 1031 } 1032 return flags; 1033 } 1034 1035 private ImageDescriptor computeBaseImageDescriptor(IAdaptable element) { 1036 IJavaVariable javaVariable= (IJavaVariable) element.getAdapter(IJavaVariable.class); 1037 if (javaVariable != null) { 1038 try { 1039 if (javaVariable.isLocal()) 1040 return JavaDebugImages.getImageDescriptor(JavaDebugImages.IMG_OBJS_LOCAL_VARIABLE); 1041 if (javaVariable.isPublic()) 1042 return JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_PUBLIC); 1043 if (javaVariable.isProtected()) 1044 return JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_PROTECTED); 1045 if (javaVariable.isPrivate()) 1046 return JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_PRIVATE); 1047 } catch (DebugException e) { 1048 } 1050 } 1051 return JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_DEFAULT); 1052 } 1053 1054 private int computeAdornmentFlags(IAdaptable element) { 1055 int flags= 0; 1056 IJavaModifiers javaProperties= (IJavaModifiers)element.getAdapter(IJavaModifiers.class); 1057 try { 1058 if (javaProperties != null) { 1059 if (javaProperties.isFinal()) { 1060 flags |= JavaElementImageDescriptor.FINAL; 1061 } 1062 if (javaProperties.isStatic()) { 1063 flags |= JavaElementImageDescriptor.STATIC; 1064 } 1065 } 1066 } catch(DebugException e) { 1067 } 1069 return flags; 1070 } 1071 1072 1075 public IEditorInput getEditorInput(Object item) { 1076 try { 1077 if (item instanceof IMarker) { 1078 item = getBreakpoint((IMarker)item); 1079 } 1080 if (item instanceof IJavaBreakpoint) { 1081 IType type = BreakpointUtils.getType((IJavaBreakpoint)item); 1082 if (type == null) { 1083 item = ((IJavaBreakpoint)item).getMarker().getResource(); 1085 } else { 1086 item = type; 1087 } 1088 } 1089 if (item instanceof LocalFileStorage) { 1090 return new LocalFileStorageEditorInput((LocalFileStorage)item); 1091 } 1092 if (item instanceof ZipEntryStorage) { 1093 return new ZipEntryStorageEditorInput((ZipEntryStorage)item); 1094 } 1095 if (item instanceof IType) { 1098 IType type = (IType) item; 1099 if (!type.exists()) { 1100 return null; 1101 } 1102 } 1103 return EditorUtility.getEditorInput(item); 1104 } catch (CoreException e) { 1105 JDIDebugUIPlugin.log(e); 1106 return null; 1107 } 1108 } 1109 1110 1113 public String getEditorId(IEditorInput input, Object inputObject) { 1114 try { 1115 IEditorDescriptor descriptor= IDE.getEditorDescriptor(input.getName()); 1116 return descriptor.getId(); 1117 } catch (PartInitException e) { 1118 return null; 1119 } 1120 } 1121 1122 1125 public void setAttribute(String id, Object value) { 1126 if (value == null) { 1127 return; 1128 } 1129 synchronized (fAttributes) { 1130 fAttributes.put(id, value); 1131 } 1132 } 1133 1134 protected boolean isShowQualifiedNames() { 1135 synchronized (fAttributes) { 1136 Boolean showQualified= (Boolean ) fAttributes.get(DISPLAY_QUALIFIED_NAMES); 1137 showQualified= showQualified == null ? Boolean.FALSE : showQualified; 1138 return showQualified.booleanValue(); 1139 } 1140 } 1141 1142 protected boolean isShowVariableTypeNames() { 1143 synchronized (fAttributes) { 1144 Boolean show= (Boolean ) fAttributes.get(DISPLAY_VARIABLE_TYPE_NAMES); 1145 show= show == null ? Boolean.FALSE : show; 1146 return show.booleanValue(); 1147 } 1148 } 1149 1150 protected boolean isShowHexValues() { 1151 return JDIDebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IJDIPreferencesConstants.PREF_SHOW_HEX); 1152 } 1153 1154 protected boolean isShowCharValues() { 1155 return JDIDebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IJDIPreferencesConstants.PREF_SHOW_CHAR); 1156 } 1157 1158 protected boolean isShowUnsignedValues() { 1159 return JDIDebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IJDIPreferencesConstants.PREF_SHOW_UNSIGNED); 1160 } 1161 1162 protected String getVariableText(IJavaVariable var) { 1163 String varLabel= DebugUIMessages.JDIModelPresentation_unknown_name__1; 1164 try { 1165 varLabel= var.getName(); 1166 } catch (DebugException exception) { 1167 } 1168 1169 IJavaValue javaValue= null; 1170 try { 1171 javaValue = (IJavaValue) var.getValue(); 1172 } catch (DebugException e1) { 1173 } 1174 boolean showTypes= isShowVariableTypeNames(); 1175 StringBuffer buff= new StringBuffer (); 1176 String typeName= DebugUIMessages.JDIModelPresentation_unknown_type__2; 1177 try { 1178 typeName= var.getReferenceTypeName(); 1179 if (showTypes) { 1180 typeName= getQualifiedName(typeName); 1181 } 1182 } catch (DebugException exception) { 1183 } 1184 if (showTypes) { 1185 buff.append(typeName); 1186 buff.append(' '); 1187 } 1188 buff.append(varLabel); 1189 1190 if (var instanceof IJavaFieldVariable) { 1192 IJavaFieldVariable field = (IJavaFieldVariable)var; 1193 if (isDuplicateName(field)) { 1194 try { 1195 String decl = field.getDeclaringType().getName(); 1196 buff.append(MessageFormat.format(" ({0})", new String []{getQualifiedName(decl)})); } catch (DebugException e) { 1198 } 1199 } 1200 } 1201 1202 String valueString= getFormattedValueText(javaValue); 1203 1204 if (valueString.length() != 0) { 1206 buff.append("= "); buff.append(valueString); 1208 } 1209 return buff.toString(); 1210 } 1211 1212 1219 public String getFormattedValueText(IJavaValue javaValue) { 1220 String valueString= DebugUIMessages.JDIModelPresentation_unknown_value__3; 1221 if (javaValue != null) { 1222 if (isShowLabelDetails(javaValue)) { 1223 valueString = getVariableDetail(javaValue); 1224 if (valueString == null) { 1225 valueString = DebugUIMessages.JDIModelPresentation_unknown_value__3; 1226 } 1227 } else { 1228 try { 1229 valueString= getValueText(javaValue); 1230 } catch (DebugException exception) { 1231 } 1232 } 1233 } 1234 return valueString; 1235 } 1236 1237 1244 public boolean isShowLabelDetails(IJavaValue value) { 1245 boolean showDetails= false; 1246 String details= JDIDebugUIPlugin.getDefault().getPreferenceStore().getString(IJDIPreferencesConstants.PREF_SHOW_DETAILS); 1247 if (details != null) { 1248 if (details.equals(IJDIPreferencesConstants.INLINE_ALL)) { 1249 showDetails= true; 1250 } else if (details.equals(IJDIPreferencesConstants.INLINE_FORMATTERS)){ 1251 try { 1252 IJavaType javaType = value.getJavaType(); 1253 JavaDetailFormattersManager manager= JavaDetailFormattersManager.getDefault(); 1254 DetailFormatter formatter = manager.getAssociatedDetailFormatter(javaType); 1255 showDetails= formatter != null && formatter.isEnabled(); 1256 } catch (DebugException e) { 1257 } 1258 } 1259 } 1260 return showDetails; 1261 } 1262 1263 1269 private String getVariableDetail(IJavaValue value) { 1270 final String [] detail= new String [1]; 1271 final Object lock= new Object (); 1272 computeDetail(value, new IValueDetailListener() { 1273 1276 public void detailComputed(IValue computedValue, String result) { 1277 synchronized (lock) { 1278 detail[0]= result; 1279 lock.notifyAll(); 1280 } 1281 } 1282 }); 1283 synchronized (lock) { 1284 if (detail[0] == null) { 1285 try { 1286 lock.wait(5000); 1287 } catch (InterruptedException e1) { 1288 } 1290 } 1291 } 1292 return detail[0]; 1293 } 1294 1295 protected String getExpressionText(IExpression expression) throws DebugException { 1296 boolean showTypes= isShowVariableTypeNames(); 1297 StringBuffer buff= new StringBuffer (); 1298 IJavaValue javaValue= (IJavaValue) expression.getValue(); 1299 if (javaValue != null) { 1300 String typeName=null; 1301 try { 1302 typeName= javaValue.getReferenceTypeName(); 1303 } catch (DebugException exception) { 1304 if (exception.getStatus().getException() instanceof ObjectCollectedException) { 1307 return DebugUIMessages.JDIModelPresentation__garbage_collected_object__6; 1308 } 1309 throw exception; 1310 } 1311 if (showTypes ) { 1312 typeName= getQualifiedName(typeName); 1313 if (typeName.length() > 0) { 1314 buff.append(typeName); 1315 buff.append(' '); 1316 } 1317 } 1318 } 1319 buff.append('"' + expression.getExpressionText() + '"'); 1320 1321 if (javaValue != null) { 1322 String valueString= getValueText(javaValue); 1323 if (valueString.length() > 0) { 1324 buff.append("= "); buff.append(valueString); 1326 } 1327 } 1328 return buff.toString(); 1329 } 1330 1331 protected String getWatchExpressionText(IWatchExpression expression) throws DebugException { 1332 return getExpressionText(expression) + (expression.isEnabled() ? "" : DebugUIMessages.JDIModelPresentation_116); } 1334 1335 1339 protected String adjustTypeNameForArrayIndex(String typeName, int arrayIndex) { 1340 int firstBracket= typeName.indexOf("[]"); if (firstBracket < 0) { 1342 return typeName; 1343 } 1344 StringBuffer buffer= new StringBuffer (typeName); 1345 buffer.insert(firstBracket + 1, Integer.toString(arrayIndex)); 1346 return buffer.toString(); 1347 } 1348 1349 protected String getValueUnsignedText(IJavaValue value) throws DebugException { 1350 String sig= getPrimitiveValueTypeSignature(value); 1351 if (sig == null) { 1352 return null; 1353 } 1354 1355 switch (sig.charAt(0)) { 1356 case 'B' : int byteVal; 1358 try { 1359 byteVal= Integer.parseInt(value.getValueString()); 1360 } catch (NumberFormatException e) { 1361 return null; 1362 } 1363 if (byteVal < 0) { 1364 byteVal = byteVal & 0xFF; 1365 return Integer.toString(byteVal); 1366 } 1367 default : 1368 return null; 1369 } 1370 } 1371 1372 protected String getValueHexText(IJavaValue value) throws DebugException { 1373 String sig= getPrimitiveValueTypeSignature(value); 1374 if (sig == null) { 1375 return null; 1376 } 1377 1378 StringBuffer buff= new StringBuffer (); 1379 long longValue; 1380 char sigValue = sig.charAt(0); 1381 try { 1382 if (sigValue == 'C') { 1383 longValue = value.getValueString().charAt(0); 1384 } else { 1385 longValue= Long.parseLong(value.getValueString()); 1386 } 1387 } catch (NumberFormatException e) { 1388 return null; 1389 } 1390 switch (sigValue) { 1391 case 'B' : 1392 buff.append("0x"); longValue &= 0xFF; 1395 buff.append(Long.toHexString(longValue)); 1396 break; 1397 case 'I' : 1398 buff.append("0x"); longValue &= 0xFFFFFFFFl; 1401 buff.append(Long.toHexString(longValue)); 1402 break; 1403 case 'S' : 1404 buff.append("0x"); longValue = longValue & 0xFFFF; 1407 buff.append(Long.toHexString(longValue)); 1408 break; 1409 case 'J' : 1410 buff.append("0x"); buff.append(Long.toHexString(longValue)); 1412 break; 1413 case 'C' : 1414 buff.append("\\u"); String hexString= Long.toHexString(longValue); 1416 int length= hexString.length(); 1417 while (length < 4) { 1418 buff.append('0'); 1419 length++; 1420 } 1421 buff.append(hexString); 1422 break; 1423 default: 1424 return null; 1425 } 1426 return buff.toString(); 1427 } 1428 1429 protected String getBreakpointText(IBreakpoint breakpoint) { 1430 try { 1431 if (breakpoint instanceof IJavaExceptionBreakpoint) { 1432 return getExceptionBreakpointText((IJavaExceptionBreakpoint)breakpoint); 1433 } else if (breakpoint instanceof IJavaWatchpoint) { 1434 return getWatchpointText((IJavaWatchpoint)breakpoint); 1435 } else if (breakpoint instanceof IJavaMethodBreakpoint) { 1436 return getMethodBreakpointText((IJavaMethodBreakpoint)breakpoint); 1437 } else if (breakpoint instanceof IJavaPatternBreakpoint) { 1438 return getJavaPatternBreakpointText((IJavaPatternBreakpoint)breakpoint); 1439 } else if (breakpoint instanceof IJavaTargetPatternBreakpoint) { 1440 return getJavaTargetPatternBreakpointText((IJavaTargetPatternBreakpoint)breakpoint); 1441 } else if (breakpoint instanceof IJavaStratumLineBreakpoint) { 1442 return getJavaStratumLineBreakpointText((IJavaStratumLineBreakpoint)breakpoint); 1443 } else if (breakpoint instanceof IJavaLineBreakpoint) { 1444 return getLineBreakpointText((IJavaLineBreakpoint)breakpoint); 1445 } else if (breakpoint instanceof IJavaClassPrepareBreakpoint) { 1446 return getClassPrepareBreakpointText((IJavaClassPrepareBreakpoint)breakpoint); 1447 } 1448 return ""; } catch (CoreException e) { 1451 IMarker marker = breakpoint.getMarker(); 1453 if (marker == null || !marker.exists()) { 1454 return DebugUIMessages.JDIModelPresentation_6; 1455 } 1456 JDIDebugUIPlugin.log(e); 1457 return DebugUIMessages.JDIModelPresentation_4; 1458 } 1459 } 1460 1461 1465 private String getJavaStratumLineBreakpointText(IJavaStratumLineBreakpoint breakpoint) throws CoreException { 1466 IMember member= BreakpointUtils.getMember(breakpoint); 1467 String sourceName = breakpoint.getSourceName(); 1468 if (sourceName == null) { 1469 sourceName = ""; IMarker marker = breakpoint.getMarker(); 1471 if (marker != null) { 1472 IResource resource = marker.getResource(); 1473 if (resource.getType() == IResource.FILE) { 1474 sourceName = resource.getName(); 1475 } 1476 } 1477 } 1478 StringBuffer label= new StringBuffer (sourceName); 1479 appendLineNumber(breakpoint, label); 1480 appendHitCount(breakpoint, label); 1481 appendSuspendPolicy(breakpoint,label); 1482 appendThreadFilter(breakpoint, label); 1483 1484 if (member != null) { 1485 label.append(" - "); label.append(getJavaLabelProvider().getText(member)); 1487 } 1488 1489 return label.toString(); 1490 } 1491 1492 protected String getExceptionBreakpointText(IJavaExceptionBreakpoint breakpoint) throws CoreException { 1493 StringBuffer buffer = new StringBuffer (); 1494 String typeName = breakpoint.getTypeName(); 1495 buffer.append(getQualifiedName(typeName)); 1496 appendHitCount(breakpoint, buffer); 1497 appendSuspendPolicy(breakpoint, buffer); 1498 if(((JavaExceptionBreakpoint)breakpoint).isSuspendOnSubclasses()) { 1500 buffer.append(DebugUIMessages.JDIModelPresentation_117); 1501 } 1502 appendThreadFilter(breakpoint, buffer); 1503 if (breakpoint.getExclusionFilters().length > 0 || breakpoint.getInclusionFilters().length > 0) { 1504 buffer.append(DebugUIMessages.JDIModelPresentation___scoped__1); 1505 } 1506 appendInstanceFilter(breakpoint, buffer); 1507 String state= null; 1508 boolean c= breakpoint.isCaught(); 1509 boolean u= breakpoint.isUncaught(); 1510 if (c && u) { 1511 state= DebugUIMessages.JDIModelPresentation_caught_and_uncaught_60; 1512 } else if (c) { 1513 state= DebugUIMessages.JDIModelPresentation_caught_61; 1514 } else if (u) { 1515 state= DebugUIMessages.JDIModelPresentation_uncaught_62; 1516 } 1517 String label= null; 1518 if (state == null) { 1519 label= buffer.toString(); 1520 } else { 1521 String format= DebugUIMessages.JDIModelPresentation__1____0__63; 1522 label= MessageFormat.format(format, new Object [] {state, buffer}); 1523 } 1524 return label; 1525 } 1526 1527 protected String getLineBreakpointText(IJavaLineBreakpoint breakpoint) throws CoreException { 1528 1529 String typeName= breakpoint.getTypeName(); 1530 IMember member= BreakpointUtils.getMember(breakpoint); 1531 StringBuffer label= new StringBuffer (); 1532 label.append(getQualifiedName(typeName)); 1533 appendLineNumber(breakpoint, label); 1534 appendHitCount(breakpoint, label); 1535 appendSuspendPolicy(breakpoint,label); 1536 appendThreadFilter(breakpoint, label); 1537 appendConditional(breakpoint, label); 1538 appendInstanceFilter(breakpoint, label); 1539 1540 if (member != null) { 1541 label.append(" - "); label.append(getJavaLabelProvider().getText(member)); 1543 } 1544 1545 return label.toString(); 1546 } 1547 1548 protected String getClassPrepareBreakpointText(IJavaClassPrepareBreakpoint breakpoint) throws CoreException { 1549 String typeName= breakpoint.getTypeName(); 1550 StringBuffer label = new StringBuffer (); 1551 label.append(getQualifiedName(typeName)); 1552 appendHitCount(breakpoint, label); 1553 appendSuspendPolicy(breakpoint, label); 1554 return label.toString(); 1555 } 1556 1557 protected StringBuffer appendLineNumber(IJavaLineBreakpoint breakpoint, StringBuffer label) throws CoreException { 1558 int lineNumber= breakpoint.getLineNumber(); 1559 if (lineNumber > 0) { 1560 label.append(" ["); label.append(DebugUIMessages.JDIModelPresentation_line__65); 1562 label.append(' '); 1563 label.append(lineNumber); 1564 label.append(']'); 1565 1566 } 1567 return label; 1568 } 1569 1570 protected StringBuffer appendHitCount(IJavaBreakpoint breakpoint, StringBuffer label) throws CoreException { 1571 int hitCount= breakpoint.getHitCount(); 1572 if (hitCount > 0) { 1573 label.append(" ["); label.append(DebugUIMessages.JDIModelPresentation_hit_count__67); 1575 label.append(' '); 1576 label.append(hitCount); 1577 label.append(']'); 1578 } 1579 return label; 1580 } 1581 1582 protected String getJavaPatternBreakpointText(IJavaPatternBreakpoint breakpoint) throws CoreException { 1583 1584 IResource resource= breakpoint.getMarker().getResource(); 1585 IMember member= BreakpointUtils.getMember(breakpoint); 1586 StringBuffer label= new StringBuffer (resource.getName()); 1587 appendLineNumber(breakpoint, label); 1588 appendHitCount(breakpoint, label); 1589 appendSuspendPolicy(breakpoint,label); 1590 appendThreadFilter(breakpoint, label); 1591 1592 if (member != null) { 1593 label.append(" - "); label.append(getJavaLabelProvider().getText(member)); 1595 } 1596 1597 return label.toString(); 1598 } 1599 1600 protected String getJavaTargetPatternBreakpointText(IJavaTargetPatternBreakpoint breakpoint) throws CoreException { 1601 IMember member= BreakpointUtils.getMember(breakpoint); 1602 StringBuffer label= new StringBuffer (breakpoint.getSourceName()); 1603 appendLineNumber(breakpoint, label); 1604 appendHitCount(breakpoint, label); 1605 appendSuspendPolicy(breakpoint,label); 1606 appendThreadFilter(breakpoint, label); 1607 1608 if (member != null) { 1609 label.append(" - "); label.append(getJavaLabelProvider().getText(member)); 1611 } 1612 1613 return label.toString(); 1614 } 1615 1616 protected String getWatchpointText(IJavaWatchpoint watchpoint) throws CoreException { 1617 1618 String typeName= watchpoint.getTypeName(); 1619 IMember member= BreakpointUtils.getMember(watchpoint); 1620 StringBuffer label= new StringBuffer (); 1621 label.append(getQualifiedName(typeName)); 1622 appendHitCount(watchpoint, label); 1623 appendSuspendPolicy(watchpoint,label); 1624 appendThreadFilter(watchpoint, label); 1625 1626 1627 boolean access= watchpoint.isAccess(); 1628 boolean modification= watchpoint.isModification(); 1629 if (access && modification) { 1630 label.append(DebugUIMessages.JDIModelPresentation_access_and_modification_70); 1631 } else if (access) { 1632 label.append(DebugUIMessages.JDIModelPresentation_access_71); 1633 } else if (modification) { 1634 label.append(DebugUIMessages.JDIModelPresentation_modification_72); 1635 } 1636 1637 label.append(" - "); if (member != null) { 1639 label.append(getJavaLabelProvider().getText(member)); 1640 } else { 1641 label.append(watchpoint.getFieldName()); 1642 } 1643 1644 return label.toString(); 1645 } 1646 1647 protected String getMethodBreakpointText(IJavaMethodBreakpoint methodBreakpoint) throws CoreException { 1648 1649 String typeName= methodBreakpoint.getTypeName(); 1650 IMember member= BreakpointUtils.getMember(methodBreakpoint); 1651 StringBuffer label= new StringBuffer (); 1652 label.append(getQualifiedName(typeName)); 1653 appendHitCount(methodBreakpoint, label); 1654 appendSuspendPolicy(methodBreakpoint,label); 1655 appendThreadFilter(methodBreakpoint, label); 1656 1657 1658 boolean entry = methodBreakpoint.isEntry(); 1659 boolean exit = methodBreakpoint.isExit(); 1660 if (entry && exit) { 1661 label.append(DebugUIMessages.JDIModelPresentation_entry_and_exit); 1662 } else if (entry) { 1663 label.append(DebugUIMessages.JDIModelPresentation_entry); 1664 } else if (exit) { 1665 label.append(DebugUIMessages.JDIModelPresentation_exit); 1666 } 1667 appendConditional(methodBreakpoint, label); 1668 1669 if (member != null) { 1670 label.append(" - "); label.append(getJavaLabelProvider().getText(member)); 1672 } else { 1673 String methodSig= methodBreakpoint.getMethodSignature(); 1674 String methodName= methodBreakpoint.getMethodName(); 1675 if (methodSig != null) { 1676 label.append(" - "); label.append(Signature.toString(methodSig, methodName, null, false, false)); 1678 } else if (methodName != null) { 1679 label.append(" - "); label.append(methodName); 1681 } 1682 } 1683 1684 return label.toString(); 1685 } 1686 1687 protected String getStackFrameText(IStackFrame stackFrame) throws DebugException { 1688 IJavaStackFrame frame= (IJavaStackFrame) stackFrame.getAdapter(IJavaStackFrame.class); 1689 if (frame != null) { 1690 StringBuffer label= new StringBuffer (); 1691 1692 String dec= DebugUIMessages.JDIModelPresentation_unknown_declaring_type__4; 1693 try { 1694 dec= frame.getDeclaringTypeName(); 1695 } catch (DebugException exception) { 1696 } 1697 if (frame.isObsolete()) { 1698 label.append(DebugUIMessages.JDIModelPresentation__obsolete_method_in__1); 1699 label.append(dec); 1700 label.append('>'); 1701 return label.toString(); 1702 } 1703 1704 boolean javaStratum= true; 1705 try { 1706 javaStratum = frame.getReferenceType().getDefaultStratum().equals("Java"); } catch (DebugException e) { 1708 } 1709 1710 if (javaStratum) { 1711 String rec= DebugUIMessages.JDIModelPresentation_unknown_receiving_type__5; 1713 try { 1714 rec= frame.getReceivingTypeName(); 1715 } catch (DebugException exception) { 1716 } 1717 label.append(getQualifiedName(rec)); 1718 1719 if (!dec.equals(rec)) { 1721 label.append('('); 1722 label.append(getQualifiedName(dec)); 1723 label.append(')'); 1724 } 1725 label.append('.'); 1727 try { 1728 label.append(frame.getMethodName()); 1729 } catch (DebugException exception) { 1730 label.append(DebugUIMessages.JDIModelPresentation_unknown_method_name__6); 1731 } 1732 try { 1733 List args= frame.getArgumentTypeNames(); 1734 if (args.isEmpty()) { 1735 label.append("()"); } else { 1737 label.append('('); 1738 Iterator iter= args.iterator(); 1739 while (iter.hasNext()) { 1740 label.append(getQualifiedName((String ) iter.next())); 1741 if (iter.hasNext()) { 1742 label.append(", "); } else if (frame.isVarArgs()) { 1744 label.replace(label.length() - 2, label.length(), "..."); } 1746 } 1747 label.append(')'); 1748 } 1749 } catch (DebugException exception) { 1750 label.append(DebugUIMessages.JDIModelPresentation__unknown_arguements___7); 1751 } 1752 } else { 1753 if (isShowQualifiedNames()) { 1754 label.append(frame.getSourcePath()); 1755 } else { 1756 label.append(frame.getSourceName()); 1757 } 1758 } 1759 1760 try { 1761 int lineNumber= frame.getLineNumber(); 1762 label.append(' '); 1763 label.append(DebugUIMessages.JDIModelPresentation_line__76); 1764 label.append(' '); 1765 if (lineNumber >= 0) { 1766 label.append(lineNumber); 1767 } else { 1768 label.append(DebugUIMessages.JDIModelPresentation_not_available); 1769 if (frame.isNative()) { 1770 label.append(' '); 1771 label.append(DebugUIMessages.JDIModelPresentation_native_method); 1772 } 1773 } 1774 } catch (DebugException exception) { 1775 label.append(DebugUIMessages.JDIModelPresentation__unknown_line_number__8); 1776 } 1777 1778 if (!frame.wereLocalsAvailable()) { 1779 label.append(' '); 1780 label.append(DebugUIMessages.JDIModelPresentation_local_variables_unavailable); 1781 } 1782 1783 return label.toString(); 1784 1785 } 1786 return null; 1787 } 1788 1789 protected String getQualifiedName(String qualifiedName) { 1790 if (!isShowQualifiedNames()) { 1791 return removeQualifierFromGenericName(qualifiedName); 1792 } 1793 return qualifiedName; 1794 } 1795 1796 1799 public String removeQualifierFromGenericName(String qualifiedName) { 1800 if (qualifiedName.endsWith("...")) { return removeQualifierFromGenericName(qualifiedName.substring(0, qualifiedName.length() - 3)) + "..."; } 1804 if (qualifiedName.endsWith("[]")) { return removeQualifierFromGenericName(qualifiedName.substring(0, qualifiedName.length() - 2)) + "[]"; } 1808 int parameterStart= qualifiedName.indexOf('<'); 1810 if (parameterStart == -1) { 1811 return getSimpleName(qualifiedName); 1812 } 1813 List parameters= getNameList(qualifiedName.substring(parameterStart + 1, qualifiedName.length() - 1)); 1815 StringBuffer name= new StringBuffer (getSimpleName(qualifiedName.substring(0, parameterStart))); 1816 name.append('<'); 1817 Iterator iterator= parameters.iterator(); 1818 if (iterator.hasNext()) { 1819 name.append(removeQualifierFromGenericName((String )iterator.next())); 1820 while (iterator.hasNext()) { 1821 name.append(',').append(removeQualifierFromGenericName((String )iterator.next())); 1822 } 1823 } 1824 name.append('>'); 1825 return name.toString(); 1826 } 1827 1828 1831 private String getSimpleName(String qualifiedName) { 1832 int index = qualifiedName.lastIndexOf('.'); 1833 if (index >= 0) { 1834 return qualifiedName.substring(index + 1); 1835 } 1836 return qualifiedName; 1837 } 1838 1839 1842 private List getNameList(String listName) { 1843 List names= new ArrayList (); 1844 StringTokenizer tokenizer= new StringTokenizer (listName, ",<>", true); int enclosingLevel= 0; 1846 int startPos= 0; 1847 int currentPos= 0; 1848 while (tokenizer.hasMoreTokens()) { 1849 String token= tokenizer.nextToken(); 1850 switch (token.charAt(0)) { 1851 case ',': 1852 if (enclosingLevel == 0) { 1853 names.add(listName.substring(startPos, currentPos)); 1854 startPos= currentPos + 1; 1855 } 1856 break; 1857 case '<': 1858 enclosingLevel++; 1859 break; 1860 case '>': 1861 enclosingLevel--; 1862 break; 1863 } 1864 currentPos += token.length(); 1865 } 1866 names.add(listName.substring(startPos)); 1867 return names; 1868 } 1869 1870 1873 public static String getFormattedString(String key, String arg) { 1874 return getFormattedString(key, new String [] {arg}); 1875 } 1876 1877 1880 public static String getFormattedString(String string, String [] args) { 1881 return MessageFormat.format(string, args); 1882 } 1883 1884 interface IValueDetailProvider { 1885 public void computeDetail(IValue value, IJavaThread thread, IValueDetailListener listener) throws DebugException; 1886 } 1887 1888 protected void appendSuspendPolicy(IJavaBreakpoint breakpoint, StringBuffer buffer) throws CoreException { 1889 if (breakpoint.getSuspendPolicy() == IJavaBreakpoint.SUSPEND_VM) { 1890 buffer.append(' '); 1891 buffer.append(DebugUIMessages.JDIModelPresentation_Suspend_VM); 1892 } 1893 } 1894 1895 protected void appendThreadFilter(IJavaBreakpoint breakpoint, StringBuffer buffer) throws CoreException { 1896 if (breakpoint.getThreadFilters().length != 0) { 1897 buffer.append(' '); 1898 buffer.append(DebugUIMessages.JDIModelPresentation_thread_filtered); 1899 } 1900 } 1901 1902 protected void appendConditional(IJavaLineBreakpoint breakpoint, StringBuffer buffer) throws CoreException { 1903 if (breakpoint.isConditionEnabled() && breakpoint.getCondition() != null) { 1904 buffer.append(' '); 1905 buffer.append(DebugUIMessages.JDIModelPresentation__conditional__2); 1906 } 1907 } 1908 1909 protected void appendInstanceFilter(IJavaBreakpoint breakpoint, StringBuffer buffer) throws CoreException { 1910 IJavaObject[] instances = breakpoint.getInstanceFilters(); 1911 for (int i = 0; i < instances.length; i++) { 1912 String instanceText= instances[i].getValueString(); 1913 if (instanceText != null) { 1914 buffer.append(' '); 1915 buffer.append(MessageFormat.format(DebugUIMessages.JDIModelPresentation_instance_1, new String [] {instanceText})); 1916 } 1917 } 1918 } 1919 1920 protected static ImageDescriptorRegistry getJavaElementImageRegistry() { 1921 if (fgJavaElementImageRegistry == null) { 1922 fgJavaElementImageRegistry = JavaPlugin.getImageDescriptorRegistry(); 1923 } 1924 return fgJavaElementImageRegistry; 1925 } 1926 1927 protected static org.eclipse.jdt.internal.debug.ui.ImageDescriptorRegistry getDebugImageRegistry() { 1928 if (fgDebugImageRegistry == null) { 1929 fgDebugImageRegistry = JDIDebugUIPlugin.getImageDescriptorRegistry(); 1930 } 1931 return fgDebugImageRegistry; 1932 } 1933 1934 protected JavaElementLabelProvider getJavaLabelProvider() { 1935 if (fJavaLabelProvider == null) { 1936 fJavaLabelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); 1937 } 1938 return fJavaLabelProvider; 1939 } 1940 1941 1944 protected boolean isDuplicateName(IJavaFieldVariable variable) { 1945 IJavaReferenceType javaType= variable.getReceivingType(); 1946 try { 1947 String [] names = javaType.getAllFieldNames(); 1948 boolean found= false; 1949 for (int i = 0; i < names.length; i++) { 1950 if (variable.getName().equals(names[i])) { 1951 if (found) { 1952 return true; 1953 } 1954 found= true; 1955 } 1956 } 1957 return false; 1958 } catch (DebugException e) { 1959 } 1960 return false; 1961 } 1962 1963 1966 public Color getForeground(Object element) { 1967 if (element instanceof JavaContendedMonitor && ((JavaContendedMonitor)element).getMonitor().isInDeadlock()) { 1968 return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); 1969 } 1970 if (element instanceof JavaOwnedMonitor && ((JavaOwnedMonitor)element).getMonitor().isInDeadlock()) { 1971 return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); 1972 } 1973 if (element instanceof JavaWaitingThread && ((JavaWaitingThread)element).getThread().isInDeadlock()) { 1974 return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); 1975 } 1976 if (element instanceof JavaOwningThread && ((JavaOwningThread)element).getThread().isInDeadlock()) { 1977 return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); 1978 } 1979 if (element instanceof IJavaThread && ThreadMonitorManager.getDefault().isInDeadlock((IJavaThread)element)) { 1980 return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); 1981 } 1982 return null; 1983 } 1984 1985 1988 public Color getBackground(Object element) { 1989 return null; 1990 } 1991 1992 private ImageDescriptor getImageDescriptor(String key) { 1993 return JavaDebugImages.getImageDescriptor(key); 1994 } 1995} 1996 | Popular Tags |