1 11 package org.eclipse.debug.internal.ui.model.elements; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.model.IMemoryBlock; 15 import org.eclipse.debug.core.model.IMemoryBlockExtension; 16 import org.eclipse.debug.internal.ui.DebugPluginImages; 17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 18 import org.eclipse.debug.ui.IDebugUIConstants; 19 import org.eclipse.jface.resource.ImageDescriptor; 20 import org.eclipse.jface.viewers.TreePath; 21 22 public class MemoryBlockLabelProvider extends DebugElementLabelProvider { 23 24 protected String getLabel(TreePath elementPath, 25 IPresentationContext presentationContext, String columnId) 26 throws CoreException { 27 Object element = elementPath.getLastSegment(); 28 29 if (element instanceof IMemoryBlock) 30 return getLabel((IMemoryBlock)element); 31 32 return super.getLabel(elementPath, presentationContext, columnId); 33 } 34 35 protected ImageDescriptor getImageDescriptor(TreePath elementPath, 36 IPresentationContext presentationContext, String columnId) 37 throws CoreException { 38 39 Object element = elementPath.getLastSegment(); 40 41 if (element instanceof IMemoryBlock) 42 return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_VARIABLE); 43 44 return super.getImageDescriptor(elementPath, presentationContext, columnId); 45 } 46 47 51 private String getLabel(IMemoryBlock memoryBlock) { 52 53 String memoryBlockLabel = " "; if (memoryBlock instanceof IMemoryBlockExtension) 55 { 56 if (((IMemoryBlockExtension)memoryBlock).getExpression() != null) 59 { 60 memoryBlockLabel += ((IMemoryBlockExtension)memoryBlock).getExpression(); 61 } 62 } 63 else 64 { 65 long address = memoryBlock.getStartAddress(); 66 memoryBlockLabel = Long.toHexString(address); 67 } 68 return memoryBlockLabel; 69 } 70 71 } 72 | Popular Tags |