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.IRegisterGroup; 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 public class DeferredRegisterGroup extends DeferredDebugElementWorkbenchAdapter { 23 24 27 public Object [] getChildren(Object parent) { 28 try { 29 return ((IRegisterGroup)parent).getRegisters(); 30 } catch (DebugException e) { 31 } 32 return EMPTY; 33 } 34 35 38 public Object getParent(Object element) { 39 return null; 40 } 41 42 45 public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { 46 if (monitor.isCanceled()) { 47 return; 48 } 49 Object [] children = getChildren(object); 50 if (monitor.isCanceled()) { 51 return; 52 } 53 if (children.length > 0) { 54 if (collector instanceof RemoteVariableContentManager.VariableCollector) { 55 RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector; 56 for (int i = 0; i < children.length; i++) { 57 if (monitor.isCanceled()) { 58 return; 59 } 60 Object child = children[i]; 61 remoteCollector.setHasChildren(child, hasChildren(child)); 62 } 63 } 64 collector.add(children, monitor); 65 } 66 collector.done(); 67 } 68 69 protected boolean hasChildren(Object child) { 70 if (child instanceof IVariable) { 71 IVariable var = (IVariable) child; 72 try { 73 IValue value = var.getValue(); 74 return value.hasVariables(); 75 } catch (DebugException e) { 76 } 77 } 78 return false; 79 } 80 } 81 | Popular Tags |