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.memory.provisional.AbstractAsyncTextRendering; 17 import org.eclipse.debug.ui.DebugUITools; 18 import org.eclipse.debug.ui.IDebugUIConstants; 19 import org.eclipse.jface.util.PropertyChangeEvent; 20 21 22 23 24 28 public class ASCIIRendering extends AbstractAsyncTextRendering{ 29 30 private final int numCharsPerByte = 1; 31 32 33 public ASCIIRendering(String renderingId) 34 { 35 super(renderingId); 36 String codepage = DebugUITools.getPreferenceStore().getString(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE); 37 setCodePage(codepage); 38 } 39 40 public void dispose() { 41 super.dispose(); 42 } 43 44 47 public int getNumCharsPerByte() { 48 return numCharsPerByte; 49 } 50 51 52 55 public byte[] getBytes( 56 String renderingId, 57 BigInteger address, 58 MemoryByte[] currentValues, 59 String data) { 60 61 byte[] bytes = super.getBytes(renderingId, address, currentValues, data); 62 63 for (int i=0; i<bytes.length && i < currentValues.length; i++) 65 { 66 if (bytes[i] == 1 && currentValues[i].getValue() == 0) 67 { 68 bytes[i] = 0; 69 } 70 } 71 72 return bytes; 73 74 } 75 76 79 public String getString( 80 String renderingId, 81 BigInteger address, 82 MemoryByte[] data) { 83 84 MemoryByte[] copy = new MemoryByte[data.length]; 85 86 for (int i=0; i<data.length; i++){ 90 copy[i] = new MemoryByte(); 91 if (data[i].getValue() == 0) 92 { 93 copy[i].setValue((byte)1); 94 } 95 else 96 { 97 copy[i].setValue(data[i].getValue()); 98 } 99 copy[i].setFlags(data[i].getFlags()); 100 } 101 102 return super.getString(renderingId, address, copy); 103 } 104 105 108 public void propertyChange(PropertyChangeEvent event) { 109 110 if (event.getProperty().equals(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE)) 112 { 113 String codePage = (String )event.getNewValue(); 114 setCodePage(codePage); 115 116 if (isVisible()) 117 updateLabels(); 119 } 120 121 super.propertyChange(event); 122 } 123 } 124 | Popular Tags |