1 11 package org.eclipse.debug.internal.ui.elements.adapters; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.model.IStackFrame; 16 import org.eclipse.debug.core.model.IValue; 17 import org.eclipse.debug.core.model.IVariable; 18 import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager; 19 import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter; 20 import org.eclipse.ui.progress.IElementCollector; 21 22 23 26 public class DeferredStackFrame extends DeferredDebugElementWorkbenchAdapter { 27 28 31 public Object [] getChildren(Object parent) { 32 if (parent instanceof IStackFrame) { 33 IStackFrame frame = (IStackFrame) parent; 34 try { 35 return frame.getVariables(); 36 } catch (DebugException e) { 37 return new Object []{e}; 38 } 39 } 40 return EMPTY; 41 } 42 43 46 public Object getParent(Object element) { 47 return ((IStackFrame)element).getThread(); 48 } 49 50 53 public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { 54 if (monitor.isCanceled()) { 55 return; 56 } 57 Object [] children = getChildren(object); 58 if (monitor.isCanceled()) { 59 return; 60 } 61 if (children.length > 0) { 62 if (collector instanceof RemoteVariableContentManager.VariableCollector) { 63 RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector; 64 for (int i = 0; i < children.length; i++) { 65 if (monitor.isCanceled()) { 66 return; 67 } 68 Object child = children[i]; 69 remoteCollector.setHasChildren(child, hasChildren(child)); 70 } 71 } 72 collector.add(children, monitor); 73 } 74 collector.done(); 75 } 76 77 84 protected boolean hasChildren(Object child) { 85 if (child instanceof IVariable) { 86 IVariable variable = (IVariable) child; 87 try { 88 IValue value = variable.getValue(); 89 return value.hasVariables(); 90 } catch (DebugException e) { 91 } 92 } 93 return false; 94 } 95 96 } 97 | Popular Tags |