1 11 package org.eclipse.debug.internal.ui.views.memory; 12 13 import java.math.BigInteger ; 14 import org.eclipse.debug.internal.core.memory.MemoryByte; 15 import org.eclipse.debug.internal.ui.DebugPluginImages; 16 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 17 import org.eclipse.jface.viewers.ITableLabelProvider; 18 import org.eclipse.jface.viewers.LabelProvider; 19 import org.eclipse.swt.graphics.Image; 20 21 26 abstract public class AbstractTableViewTabLabelProvider extends LabelProvider implements ITableLabelProvider{ 27 28 protected ITableMemoryViewTab fViewTab; 29 protected AbstractMemoryRenderer fRenderer; 30 31 35 public AbstractTableViewTabLabelProvider() { 36 super(); 37 } 38 39 public AbstractTableViewTabLabelProvider(ITableMemoryViewTab viewTab, AbstractMemoryRenderer renderer){ 40 fViewTab = viewTab; 41 setRenderer(renderer); 42 } 43 44 public void setViewTab(ITableMemoryViewTab viewTab){ 45 fViewTab = viewTab; 46 } 47 48 public void setRenderer(AbstractMemoryRenderer renderer){ 49 fRenderer = renderer; 50 renderer.setViewTab(fViewTab); 51 } 52 53 public AbstractMemoryRenderer getRenderer() 54 { 55 return fRenderer; 56 } 57 58 61 public Image getColumnImage(Object element, int columnIndex) { 62 63 if (columnIndex == 0) 64 { 65 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); 66 } 67 else if (columnIndex > (fViewTab.getBytesPerLine()/fViewTab.getColumnSize())) 68 { 69 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); 70 } 71 else 72 { 73 int startOffset = (columnIndex-1)*fViewTab.getColumnSize(); 75 int endOffset = startOffset + fViewTab.getColumnSize() - 1; 76 if (((MemoryViewLine)element).isRangeChange(startOffset, endOffset)) 77 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY_CHANGED); 78 else 79 return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); 80 } 81 } 82 83 84 87 public String getColumnText(Object element, int columnIndex) { 88 String columnLabel = null; 89 90 if (columnIndex == 0) 91 { 92 columnLabel = ((MemoryViewLine)element).getAddress(); 93 94 } 96 else if (columnIndex > (fViewTab.getBytesPerLine()/fViewTab.getColumnSize())) 97 { 98 columnLabel = " "; } 100 else 101 { 102 int start = (columnIndex-1)*fViewTab.getColumnSize(); 103 int end = start + fViewTab.getColumnSize(); 104 MemoryViewLine line = (MemoryViewLine)element; 105 106 MemoryByte[] bytes = ((MemoryViewLine)element).getBytes(start, end); 107 BigInteger address = new BigInteger (((MemoryViewLine)element).getAddress(), 16); 108 address = address.add(BigInteger.valueOf(start)); 109 110 columnLabel = fRenderer.getString(fViewTab.getRenderingId(), address, bytes, line.getPaddedString()); 111 } 112 return columnLabel; 113 } 114 } 115 | Popular Tags |