1 11 12 package org.eclipse.debug.internal.ui.elements.adapters; 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.DebugPlugin; 16 import org.eclipse.debug.core.model.IDebugTarget; 17 import org.eclipse.debug.core.model.IMemoryBlockRetrieval; 18 import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter; 19 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext; 20 import org.eclipse.debug.ui.IDebugUIConstants; 21 22 public class DebugTargetContentAdapter extends AsynchronousContentAdapter { 23 24 25 29 protected Object [] getChildren(Object parent, IPresentationContext context) throws CoreException { 30 String id = context.getPart().getSite().getId(); 31 if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) 32 return ((IDebugTarget) parent).getThreads(); 33 else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 34 { 35 if (parent instanceof IMemoryBlockRetrieval) 36 { 37 return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent); 38 } 39 } 40 return EMPTY; 41 } 42 43 47 protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException { 48 String id = context.getPart().getSite().getId(); 49 if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW)) 50 return ((IDebugTarget)element).hasThreads(); 51 if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) 52 { 53 if (element instanceof IMemoryBlockRetrieval) 54 { 55 if (((IMemoryBlockRetrieval)element).supportsStorageRetrieval()) 56 return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)element).length > 0; 57 } 58 } 59 return false; 60 } 61 62 63 67 protected boolean supportsPartId(String id) { 68 return IDebugUIConstants.ID_DEBUG_VIEW.equals(id) || IDebugUIConstants.ID_MEMORY_VIEW.equals(id); 69 } 70 71 } 72 | Popular Tags |