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.DebugPlugin; 16 import org.eclipse.debug.core.IExpressionManager; 17 import org.eclipse.debug.core.model.IExpression; 18 import org.eclipse.debug.core.model.IValue; 19 import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager; 20 import org.eclipse.debug.ui.DeferredDebugElementWorkbenchAdapter; 21 import org.eclipse.ui.progress.IElementCollector; 22 23 public class DeferredExpressionManager extends DeferredDebugElementWorkbenchAdapter { 24 25 28 public Object [] getChildren(Object parent) { 29 return ((IExpressionManager)parent).getExpressions(); 30 } 31 32 35 public Object getParent(Object element) { 36 return null; 37 } 38 39 42 public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { 43 if (monitor.isCanceled()) { 44 return; 45 } 46 Object [] children = getChildren(object); 47 if (monitor.isCanceled()) { 48 return; 49 } 50 if (children.length > 0) { 51 if (collector instanceof RemoteVariableContentManager.VariableCollector) { 52 RemoteVariableContentManager.VariableCollector remoteCollector = (RemoteVariableContentManager.VariableCollector) collector; 53 for (int i = 0; i < children.length; i++) { 54 if (monitor.isCanceled()) { 55 return; 56 } 57 IExpression child = (IExpression) children[i]; 58 try { 59 IValue value = child.getValue(); 60 if (value == null) { 61 remoteCollector.setHasChildren(child, false); 62 } else { 63 remoteCollector.setHasChildren(child, value.hasVariables()); 64 } 65 } catch (DebugException e) { 66 } 67 } 68 } 69 collector.add(children, monitor); 70 } 71 collector.done(); 72 } 73 74 77 public boolean isContainer() { 78 return DebugPlugin.getDefault().getExpressionManager().hasExpressions(); 79 } 80 81 82 } 83 | Popular Tags |