1 11 package org.eclipse.jdt.internal.debug.ui.monitors; 12 13 import org.eclipse.core.runtime.Platform; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.ILaunch; 16 import org.eclipse.debug.core.ILaunchConfiguration; 17 import org.eclipse.debug.core.model.IDebugElement; 18 import org.eclipse.debug.core.model.IDebugTarget; 19 import org.eclipse.debug.core.model.ITerminate; 20 21 26 public class JavaWaitingThread implements IDebugElement, ITerminate { 27 28 31 private JavaMonitorThread fThread; 32 33 36 private JavaOwnedMonitor[] fOwnedMonitors; 37 40 private JavaOwnedMonitor fParent; 41 42 public JavaWaitingThread(JavaMonitorThread thread, JavaOwnedMonitor parent) { 43 fThread= thread; 44 thread.addElement(this); 45 fParent= parent; 46 } 47 48 public JavaMonitorThread getThread() { 49 return fThread; 50 } 51 52 public JavaOwnedMonitor getParent() { 53 return fParent; 54 } 55 56 public JavaOwnedMonitor[] getOwnedMonitors() { 57 JavaMonitor[] ownedMonitors= fThread.getOwnedMonitors0(); 58 JavaOwnedMonitor[] tmp= new JavaOwnedMonitor[ownedMonitors.length]; 59 if (fOwnedMonitors == null) { 60 for (int i= 0; i < ownedMonitors.length; i++) { 62 tmp[i]= new JavaOwnedMonitor(ownedMonitors[i], this); 63 } 64 } else { 65 outer: for (int i= 0; i < ownedMonitors.length; i++) { 67 JavaMonitor ownedMonitor= ownedMonitors[i]; 68 for (int j= 0; j < fOwnedMonitors.length; j++) { 69 if (fOwnedMonitors[j].getMonitor() == ownedMonitor) { 70 tmp[i]= fOwnedMonitors[j]; 71 continue outer; 72 } 73 } 74 tmp[i]= new JavaOwnedMonitor(ownedMonitor, this); 75 } 76 } 77 fOwnedMonitors= tmp; 78 return fOwnedMonitors; 79 } 80 81 84 public String getModelIdentifier() { 85 return fThread.getModelIdentifier(); 86 } 87 88 91 public IDebugTarget getDebugTarget() { 92 return fThread.getDebugTarget(); 93 } 94 95 98 public ILaunch getLaunch() { 99 return fThread.getLaunch(); 100 } 101 102 105 public Object getAdapter(Class adapter) { 106 if(adapter == IDebugTarget.class) { 107 return getDebugTarget(); 108 } 109 if(adapter.equals(ILaunchConfiguration.class)) { 111 return getLaunch().getLaunchConfiguration(); 112 } 113 return Platform.getAdapterManager().getAdapter(this, adapter); 114 } 115 116 119 public boolean isSuspended() { 120 return fThread.isSuspended(); 121 } 122 123 126 public boolean canTerminate() { 127 return getDebugTarget().canTerminate(); 128 } 129 130 133 public boolean isTerminated() { 134 return getDebugTarget().isTerminated(); 135 } 136 137 140 public void terminate() throws DebugException { 141 getDebugTarget().terminate(); 142 } 143 } 144 | Popular Tags |