1 11 package org.eclipse.debug.internal.ui.viewers.update; 12 13 import org.eclipse.debug.core.DebugEvent; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.DebugPlugin; 16 import org.eclipse.debug.core.ILaunch; 17 import org.eclipse.debug.core.ILaunchManager; 18 import org.eclipse.debug.core.model.IDebugElement; 19 import org.eclipse.debug.core.model.IDebugTarget; 20 import org.eclipse.debug.core.model.IStackFrame; 21 import org.eclipse.debug.core.model.IThread; 22 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; 23 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; 24 import org.eclipse.jface.viewers.Viewer; 25 26 31 public class DebugTargetProxy extends EventHandlerModelProxy { 32 33 private IDebugTarget fDebugTarget; 34 35 public DebugTargetProxy(IDebugTarget target) { 36 fDebugTarget = target; 37 } 38 39 42 public synchronized void dispose() { 43 super.dispose(); 44 fDebugTarget = null; 45 } 46 47 50 protected boolean containsEvent(DebugEvent event) { 51 Object source = event.getSource(); 52 if (source instanceof IDebugElement) { 53 IDebugTarget debugTarget = ((IDebugElement) source).getDebugTarget(); 54 if (debugTarget != null) { 56 return debugTarget.equals(fDebugTarget); 57 } 58 } 59 return false; 60 } 61 62 65 protected DebugEventHandler[] createEventHandlers() { 66 ThreadEventHandler threadEventHandler = new ThreadEventHandler(this); 67 return new DebugEventHandler[] { new DebugTargetEventHandler(this), threadEventHandler, 68 new StackFrameEventHandler(this, threadEventHandler) }; 69 } 70 71 74 public void installed(Viewer viewer) { 75 IDebugTarget target = fDebugTarget; 77 if (target != null) { 78 try { 79 IThread[] threads = target.getThreads(); 80 ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); 81 ILaunch launch = target.getLaunch(); 82 int launchIndex = indexOf(manager.getLaunches(), target.getLaunch()); 83 for (int i = 0; i < threads.length; i++) { 84 IThread thread = threads[i]; 85 if (thread.isSuspended()) { 86 IStackFrame frame = thread.getTopStackFrame(); 87 if (frame != null) { 88 ModelDelta delta = new ModelDelta(manager, IModelDelta.NO_CHANGE); 89 ModelDelta node = delta.addNode(launch, launchIndex, IModelDelta.NO_CHANGE, target.getLaunch().getChildren().length); 90 node = node.addNode(target, 0, IModelDelta.NO_CHANGE, threads.length); 91 node = node.addNode(thread, i, IModelDelta.NO_CHANGE | IModelDelta.EXPAND, thread.getStackFrames().length); 92 node = node.addNode(frame, 0, IModelDelta.NO_CHANGE | IModelDelta.SELECT, 0); 93 fireModelChanged(delta); 94 return; 95 } 96 } 97 } 98 ModelDelta delta = new ModelDelta(manager, IModelDelta.NO_CHANGE); 100 ModelDelta node = delta.addNode(launch, launchIndex, IModelDelta.NO_CHANGE, target.getLaunch().getChildren().length); 101 node = node.addNode(target, 0, IModelDelta.EXPAND | IModelDelta.SELECT, threads.length); 102 fireModelChanged(delta); 103 } catch (DebugException e) { 104 } 105 } 106 } 107 108 109 110 } 111 | Popular Tags |