1 11 package org.eclipse.debug.internal.ui.views.memory.renderings; 12 13 import java.math.BigInteger ; 14 15 import org.eclipse.debug.core.model.MemoryByte; 16 import org.eclipse.debug.internal.ui.DebugPluginImages; 17 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 18 import org.eclipse.debug.ui.memory.AbstractTableRendering; 19 import org.eclipse.jface.viewers.ITableLabelProvider; 20 import org.eclipse.jface.viewers.LabelProvider; 21 import org.eclipse.swt.graphics.Image; 22 23 28 abstract public class AbstractTableRenderingLabelProvider extends LabelProvider implements ITableLabelProvider{ 29 30 protected AbstractTableRendering fRendering; 31 32 36 public AbstractTableRenderingLabelProvider() { 37 super(); 38 } 39 40 public AbstractTableRenderingLabelProvider(AbstractTableRendering rendering){ 41 fRendering = rendering; 42 } 43 44 47 public void dispose() { 48 fRendering = null; 49 super.dispose(); 50 } 51 52 55 public Image getColumnImage(Object element, int columnIndex) { 56 57 if (columnIndex == 0) 58 { 59 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); 60 } 61 else if (columnIndex > (fRendering.getBytesPerLine()/fRendering.getBytesPerColumn())) 62 { 63 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); 64 } 65 else 66 { 67 int startOffset = (columnIndex-1)*fRendering.getBytesPerColumn(); 69 int endOffset = startOffset + fRendering.getBytesPerColumn() - 1; 70 if (((TableRenderingLine)element).isRangeChange(startOffset, endOffset)) { 71 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY_CHANGED); 72 } 73 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); 74 } 75 } 76 77 78 81 public String getColumnText(Object element, int columnIndex) { 82 String columnLabel = null; 83 84 if (columnIndex == 0) 85 { 86 columnLabel = ((TableRenderingLine)element).getAddress(); 87 88 } 90 else if (columnIndex > (fRendering.getBytesPerLine()/fRendering.getBytesPerColumn())) 91 { 92 columnLabel = " "; } 94 else 95 { 96 int start = (columnIndex-1)*fRendering.getBytesPerColumn(); 97 int end = start + fRendering.getBytesPerColumn(); 98 99 MemoryByte[] bytes = ((TableRenderingLine)element).getBytes(start, end); 100 BigInteger address = new BigInteger (((TableRenderingLine)element).getAddress(), 16); 101 address = address.add(BigInteger.valueOf(start)); 102 103 columnLabel = fRendering.getString(fRendering.getRenderingId(), address, bytes); 104 } 105 return columnLabel; 106 } 107 } 108 | Popular Tags |