1 11 package org.eclipse.debug.internal.ui.views.variables; 12 13 14 import java.util.ArrayList ; 15 16 import org.eclipse.debug.core.DebugEvent; 17 import org.eclipse.debug.core.model.IDebugTarget; 18 import org.eclipse.debug.core.model.IExpression; 19 import org.eclipse.debug.core.model.IStackFrame; 20 import org.eclipse.debug.core.model.ISuspendResume; 21 import org.eclipse.debug.core.model.IThread; 22 import org.eclipse.debug.core.model.IVariable; 23 import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler; 24 import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager; 25 import org.eclipse.debug.ui.AbstractDebugView; 26 27 30 public class VariablesViewEventHandler extends AbstractDebugEventHandler { 31 32 private RemoteTreeContentManager fContentManager = null; 33 34 39 public VariablesViewEventHandler(AbstractDebugView view) { 40 super(view); 41 } 42 43 46 protected void doHandleDebugEvents(DebugEvent[] events, Object data) { 47 for (int i = 0; i < events.length; i++) { 48 DebugEvent event = events[i]; 49 switch (event.getKind()) { 50 case DebugEvent.SUSPEND: 51 doHandleSuspendEvent(event); 52 break; 53 case DebugEvent.CHANGE: 54 doHandleChangeEvent(event); 55 break; 56 case DebugEvent.RESUME: 57 doHandleResumeEvent(event); 58 break; 59 } 60 } 61 } 62 63 66 protected void updateForDebugEvents(DebugEvent[] events, Object data) { 67 for (int i = 0; i < events.length; i++) { 68 DebugEvent event = events[i]; 69 switch (event.getKind()) { 70 case DebugEvent.TERMINATE: 71 doHandleTerminateEvent(event); 72 break; 73 } 74 } 75 } 76 77 80 protected void doHandleResumeEvent(DebugEvent event) { 81 if (!event.isStepStart() && !event.isEvaluation()) { 82 getVariablesView().clearExpandedVariables(event.getSource()); 84 } 85 if (!event.isEvaluation()) { 86 Object input = getVariablesView().getVariablesViewer().getInput(); 87 if (input instanceof IStackFrame) { 88 IStackFrame frame = (IStackFrame)input; 89 if (event.getSource().equals(frame.getThread())) { 90 fContentManager.cancel(); 91 } 92 } 93 } 94 } 95 96 101 protected void doHandleTerminateEvent(DebugEvent event) { 102 getVariablesView().clearExpandedVariables(event.getSource()); 103 } 104 105 108 protected void doHandleSuspendEvent(DebugEvent event) { 109 if (event.getDetail() != DebugEvent.EVALUATION_IMPLICIT) { 110 if (event.getSource() instanceof ISuspendResume) { 112 if (!((ISuspendResume)event.getSource()).isSuspended()) { 113 return; 115 } 116 } 117 refresh(); 118 getVariablesView().populateDetailPane(); 119 } 120 } 121 122 125 protected void doHandleChangeEvent(DebugEvent event) { 126 if (event.getDetail() == DebugEvent.STATE) { 127 if (event.getSource() instanceof IVariable) { 129 refresh(event.getSource()); 130 getVariablesView().populateDetailPane(); 131 } 132 } else { 133 if (!(event.getSource() instanceof IExpression)) { 134 if (event.getSource() instanceof IVariable) { 135 refresh(event.getSource()); 136 } else { 137 refresh(); 138 } 139 getVariablesView().populateDetailPane(); 140 } 141 } 142 } 143 144 147 protected VariablesView getVariablesView() { 148 return (VariablesView)getView(); 149 } 150 151 156 protected void viewBecomesVisible() { 157 super.viewBecomesVisible(); 158 getVariablesView().populateDetailPane(); 159 } 160 161 164 protected DebugEvent[] filterEvents(DebugEvent[] events) { 165 ArrayList filtered = null; 166 for (int i=0; i<events.length; i++) { 167 if (isFiltered(events[i])) { 168 if (events.length == 1) { 169 return EMPTY_EVENT_SET; 170 } 171 if (filtered == null) { 172 filtered = new ArrayList (); 173 } 174 filtered.add(events[i]); 175 } 176 } 177 if (filtered == null) { 178 return events; 179 } 180 if (filtered.size() == events.length) { 181 return EMPTY_EVENT_SET; 182 } 183 ArrayList all = new ArrayList (events.length); 184 for (int i = 0; i < events.length; i++) { 185 all.add(events[i]); 186 } 187 all.removeAll(filtered); 188 return (DebugEvent[]) all.toArray(new DebugEvent[all.size()]); 189 } 190 191 public void setContentManager(RemoteTreeContentManager manager) { 192 fContentManager = manager; 193 } 194 195 protected boolean isFiltered(DebugEvent event) { 196 if (event.getKind() == DebugEvent.CHANGE) { 197 Object source = event.getSource(); 198 switch (event.getDetail()) { 199 case DebugEvent.CONTENT: 200 if (source instanceof IVariable || 201 source instanceof IStackFrame || 202 source instanceof IThread || 203 source instanceof IDebugTarget) { 204 return false; 205 } 206 return true; 207 case DebugEvent.STATE: 208 if (source instanceof IVariable) { 209 return false; 210 } 211 return true; 212 default: return true; 214 } 215 } 216 return false; 217 } 218 } 219 220 | Popular Tags |