1 11 package org.eclipse.debug.internal.ui.model.elements; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.DebugPlugin; 15 import org.eclipse.debug.core.model.IDebugTarget; 16 import org.eclipse.debug.core.model.IMemoryBlockRetrieval; 17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; 19 import org.eclipse.debug.ui.IDebugUIConstants; 20 21 24 public class DebugTargetContentProvider extends ElementContentProvider { 25 26 29 protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 30 String id = context.getId(); 31 if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) 32 { 33 return ((IDebugTarget)element).getThreads().length; 34 } 35 else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 36 { 37 return getAllChildren(element, context, monitor).length; 38 } 39 return 0; 40 } 41 42 45 protected boolean supportsContextId(String id) { 46 return IDebugUIConstants.ID_DEBUG_VIEW.equals(id) || IDebugUIConstants.ID_MEMORY_VIEW.equals(id); 47 } 48 49 52 protected Object [] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 53 return getElements(getAllChildren(parent, context, monitor), index, length); 54 } 55 56 protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 57 String id = context.getId(); 58 if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) 59 { 60 return ((IDebugTarget)element).hasThreads(); 61 } 62 else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 63 { 64 return getAllChildren(element, context, monitor).length > 0; 65 } 66 return false; 67 } 68 69 protected Object [] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 70 String id = context.getId(); 71 if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) 72 { 73 return ((IDebugTarget)parent).getThreads(); 74 } 75 else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 76 { 77 if (parent instanceof IMemoryBlockRetrieval) 78 { 79 if (((IMemoryBlockRetrieval)parent).supportsStorageRetrieval()) 80 return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent); 81 } 82 } 83 return EMPTY; 84 } 85 86 87 } 88 | Popular Tags |