1 11 package org.eclipse.debug.internal.ui.viewers.update; 12 13 import org.eclipse.debug.core.DebugPlugin; 14 import org.eclipse.debug.core.ILaunch; 15 import org.eclipse.debug.core.ILaunchManager; 16 import org.eclipse.debug.core.ILaunchesListener2; 17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; 18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 19 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; 20 import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; 21 import org.eclipse.jface.viewers.Viewer; 22 23 26 public class LaunchManagerProxy extends AbstractModelProxy implements ILaunchesListener2 { 27 28 private ILaunchManager fLaunchManager; 29 30 33 public void init(IPresentationContext context) { 34 super.init(context); 35 fLaunchManager = DebugPlugin.getDefault().getLaunchManager(); 36 fLaunchManager.addLaunchListener(this); 37 } 38 39 42 public void installed(Viewer viewer) { 43 ILaunch[] launches = fLaunchManager.getLaunches(); 45 launchesAdded(launches); 46 } 47 48 51 public void dispose() { 52 super.dispose(); 53 fLaunchManager.removeLaunchListener(this); 54 fLaunchManager = null; 55 } 56 57 60 public void launchesTerminated(ILaunch[] launches) { 61 } 62 63 66 public void launchesRemoved(ILaunch[] launches) { 67 fireDelta(launches, IModelDelta.REMOVED); 68 } 69 70 73 public void launchesAdded(ILaunch[] launches) { 74 fireDelta(launches, IModelDelta.ADDED | IModelDelta.INSTALL | IModelDelta.EXPAND); 75 } 76 77 80 public void launchesChanged(ILaunch[] launches) { 81 } 82 83 88 protected void fireDelta(ILaunch[] launches, int launchFlags) { 89 ModelDelta delta = new ModelDelta(fLaunchManager, IModelDelta.NO_CHANGE); 90 for (int i = 0; i < launches.length; i++) { 91 delta.addNode(launches[i], launchFlags); 92 } 93 fireModelChanged(delta); 94 } 95 96 } 97 | Popular Tags |