1 11 package org.eclipse.debug.internal.ui.viewers.update; 12 13 import org.eclipse.debug.core.DebugEvent; 14 import org.eclipse.debug.core.DebugPlugin; 15 import org.eclipse.debug.core.ILaunch; 16 import org.eclipse.debug.core.ILaunchManager; 17 import org.eclipse.debug.core.model.IProcess; 18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; 19 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; 20 import org.eclipse.jface.viewers.Viewer; 21 22 public class ProcessProxy extends EventHandlerModelProxy { 23 24 private IProcess fProcess; 25 26 private DebugEventHandler fProcessEventHandler = new DebugEventHandler(this) { 27 protected boolean handlesEvent(DebugEvent event) { 28 return event.getSource().equals(fProcess); 29 } 30 31 protected void handleChange(DebugEvent event) { 32 fireDelta(IModelDelta.STATE); 33 } 34 35 protected void handleCreate(DebugEvent event) { 36 } 38 39 protected void handleTerminate(DebugEvent event) { 40 fireDelta(IModelDelta.STATE | IModelDelta.UNINSTALL); 41 } 42 43 private void fireDelta(int flags) { 44 ModelDelta delta = null; 45 synchronized (ProcessProxy.this) { 46 if (!isDisposed()) { 47 delta = new ModelDelta(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NO_CHANGE); 48 ModelDelta node = delta; 49 node = node.addNode(fProcess.getLaunch(), IModelDelta.NO_CHANGE); 50 node.addNode(fProcess, flags); 51 } 52 } 53 if (delta != null && !isDisposed()) { 54 fireModelChanged(delta); 55 } 56 } 57 58 }; 59 60 63 public synchronized void dispose() { 64 super.dispose(); 65 fProcess = null; 66 } 67 68 public ProcessProxy(IProcess process) { 69 fProcess = process; 70 } 71 72 protected synchronized boolean containsEvent(DebugEvent event) { 73 return event.getSource().equals(fProcess); 74 } 75 76 protected DebugEventHandler[] createEventHandlers() { 77 return new DebugEventHandler[] {fProcessEventHandler}; 78 } 79 80 83 public void installed(Viewer viewer) { 84 super.installed(viewer); 85 IProcess process = fProcess; 87 if (process != null) { 88 ILaunch launch = process.getLaunch(); 89 if (launch != null && ILaunchManager.RUN_MODE.equals(launch.getLaunchMode())) { 90 ModelDelta delta = new ModelDelta(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NO_CHANGE); 92 ModelDelta node = delta.addNode(process.getLaunch(), IModelDelta.NO_CHANGE); 93 node = node.addNode(process, IModelDelta.SELECT); 94 fireModelChanged(delta); 95 } 96 } 97 } 98 } 99 | Popular Tags |