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.internal.ui.viewers.model.provisional.IModelDelta; 16 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; 17 import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; 18 19 24 public abstract class DebugEventHandler { 25 26 private AbstractModelProxy fModelProxy; 27 28 33 public DebugEventHandler(AbstractModelProxy proxy) { 34 fModelProxy = proxy; 35 } 36 37 40 public synchronized void dispose() { 41 fModelProxy = null; 42 } 43 44 50 protected synchronized AbstractModelProxy getModelProxy() { 51 return fModelProxy; 52 } 53 54 60 protected abstract boolean handlesEvent(DebugEvent event); 61 62 67 protected void handleCreate(DebugEvent event) { 68 refreshRoot(event); 69 } 70 71 76 protected void handleTerminate(DebugEvent event) { 77 refreshRoot(event); 78 } 79 80 85 protected void handleSuspend(DebugEvent event) { 86 refreshRoot(event); 87 } 88 89 94 protected void handleResumeExpectingSuspend(DebugEvent event) { 95 } 97 98 103 protected void handleResume(DebugEvent event) { 104 refreshRoot(event); 105 } 106 107 112 protected void handleChange(DebugEvent event) { 113 refreshRoot(event); 114 } 115 116 121 protected void handleOther(DebugEvent event) { 122 refreshRoot(event); 123 } 124 125 131 protected void handleSuspendTimeout(DebugEvent event) { 132 refreshRoot(event); 133 } 134 135 142 protected void handleLateSuspend(DebugEvent suspend, DebugEvent resume) { 143 refreshRoot(suspend); 144 } 145 146 151 protected void refreshRoot(DebugEvent event) { 152 ModelDelta delta = new ModelDelta(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.CONTENT); 153 fireDelta(delta); 154 } 155 156 161 protected void fireDelta(IModelDelta delta) { 162 AbstractModelProxy modelProxy = getModelProxy(); 163 if (modelProxy != null) { 164 modelProxy.fireModelChanged(delta); 165 } 166 } 167 168 173 protected synchronized boolean isDisposed() { 174 return fModelProxy == null; 175 } 176 177 protected int indexOf(Object [] list, Object element) { 178 for (int i = 0; i < list.length; i++) { 179 if (element.equals(list[i])) { 180 return i; 181 } 182 } 183 return -1; 184 } 185 186 } 187 | Popular Tags |