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.model.IMemoryBlock; 16 import org.eclipse.debug.core.model.IMemoryBlockExtension; 17 import org.eclipse.debug.internal.ui.DebugPluginImages; 18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 19 import org.eclipse.debug.ui.IDebugUIConstants; 20 import org.eclipse.jface.resource.ImageDescriptor; 21 22 public class MemoryBlockLabelAdapter extends AsynchronousDebugLabelAdapter { 23 24 protected ImageDescriptor[] getImageDescriptors(Object element, IPresentationContext context) throws CoreException { 25 if (element instanceof IMemoryBlock) 26 return new ImageDescriptor[]{DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_VARIABLE)}; 27 28 return new ImageDescriptor[0]; 29 } 30 31 35 private String getLabel(IMemoryBlock memoryBlock) { 36 37 String memoryBlockLabel = " "; if (memoryBlock instanceof IMemoryBlockExtension) 39 { 40 if (((IMemoryBlockExtension)memoryBlock).getExpression() != null) 43 { 44 memoryBlockLabel += ((IMemoryBlockExtension)memoryBlock).getExpression(); 45 } 46 } 47 else 48 { 49 long address = memoryBlock.getStartAddress(); 50 memoryBlockLabel = Long.toHexString(address); 51 } 52 return memoryBlockLabel; 53 } 54 55 protected String [] getLabels(Object element, IPresentationContext context) throws CoreException { 56 if (element instanceof IMemoryBlock) 57 return new String []{getLabel((IMemoryBlock)element)}; 58 return super.getLabels(element, context); 59 } 60 } 61 | Popular Tags |