1 11 package org.eclipse.debug.internal.ui.views.memory.renderings; 12 13 import java.math.BigInteger ; 14 15 import org.eclipse.core.runtime.PlatformObject; 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.debug.core.model.IMemoryBlock; 18 import org.eclipse.debug.core.model.IMemoryBlockExtension; 19 import org.eclipse.debug.internal.ui.memory.provisional.AbstractAsyncTableRendering; 20 import org.eclipse.debug.ui.memory.AbstractTableRendering; 21 import org.eclipse.debug.ui.memory.IMemoryRendering; 22 23 27 public class TableRenderingContentInput extends PlatformObject { 28 29 private IMemoryRendering fRendering; 30 private int fPreBuffer; private int fPostBuffer; private BigInteger fLoadAddress; private int fNumLines; private boolean fUpdateDelta; private BigInteger fMemoryBlockBaseAddress; private BigInteger fStartAddress; 37 private BigInteger fEndAddress; 38 39 public TableRenderingContentInput(IMemoryRendering rendering, int preBuffer, int postBuffer, BigInteger loadAddress, int numOfLines, boolean updateDelta, BigInteger contentBaseAddress) 40 { 41 fRendering = rendering; 42 fPreBuffer = preBuffer; 43 fPostBuffer = postBuffer; 44 fLoadAddress = loadAddress; 45 fNumLines = numOfLines; 46 fUpdateDelta = updateDelta; 47 48 if (contentBaseAddress == null) 49 { 50 try { 51 updateContentBaseAddress(); 52 } catch (DebugException e) { 53 } 54 } 55 else 56 { 57 fMemoryBlockBaseAddress = contentBaseAddress; 58 } 59 } 60 61 public int getPostBuffer() { 62 return fPostBuffer; 63 } 64 public int getPreBuffer() { 65 return fPreBuffer; 66 } 67 public BigInteger getLoadAddress() { 68 return fLoadAddress; 69 } 70 71 public IMemoryBlock getMemoryBlock() 72 { 73 return fRendering.getMemoryBlock(); 74 } 75 public void setPostBuffer(int postBuffer) { 76 fPostBuffer = postBuffer; 77 } 78 public void setPreBuffer(int preBuffer) { 79 fPreBuffer = preBuffer; 80 } 81 public boolean isUpdateDelta() { 82 return fUpdateDelta; 83 } 84 public void setUpdateDelta(boolean updateDelta) { 85 fUpdateDelta = updateDelta; 86 } 87 88 public void setLoadAddress(BigInteger address) 89 { 90 fLoadAddress = address; 91 } 92 public BigInteger getContentBaseAddress() { 93 94 if (fMemoryBlockBaseAddress == null) 95 { 96 try { 97 updateContentBaseAddress(); 98 } catch (DebugException e) { 99 fMemoryBlockBaseAddress = new BigInteger ("0"); } 101 } 102 103 return fMemoryBlockBaseAddress; 104 } 105 106 public void updateContentBaseAddress() throws DebugException { 107 IMemoryBlock memoryBlock = fRendering.getMemoryBlock(); 108 if (memoryBlock instanceof IMemoryBlockExtension) 109 fMemoryBlockBaseAddress = ((IMemoryBlockExtension)memoryBlock).getBigBaseAddress(); 110 else 111 fMemoryBlockBaseAddress = BigInteger.valueOf(memoryBlock.getStartAddress()); 112 } 113 114 117 public BigInteger getStartAddress() 118 { 119 if (fStartAddress == null) 120 { 121 try { 122 IMemoryBlock memoryBlock = fRendering.getMemoryBlock(); 123 if(memoryBlock instanceof IMemoryBlockExtension) 124 { 125 BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); 126 if (startAddress != null) 127 fStartAddress = startAddress; 128 } 129 } catch (DebugException e) { 130 fStartAddress = BigInteger.valueOf(0); 132 } 133 134 if (fStartAddress == null) 135 fStartAddress = BigInteger.valueOf(0); 136 } 137 return fStartAddress; 138 } 139 140 143 public BigInteger getEndAddress() 144 { 145 if (fEndAddress == null) 146 { 147 IMemoryBlock memoryBlock = fRendering.getMemoryBlock(); 148 if(memoryBlock instanceof IMemoryBlockExtension) 149 { 150 BigInteger endAddress; 151 try { 152 endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); 153 if (endAddress != null) 154 fEndAddress = endAddress; 155 } catch (DebugException e) { 156 fEndAddress = null; 157 } 158 159 if (fEndAddress == null) 160 { 161 int addressSize; 162 try { 163 addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); 164 } catch (DebugException e) { 165 addressSize = 4; 166 } 167 168 endAddress = BigInteger.valueOf(2); 169 endAddress = endAddress.pow(addressSize*8); 170 endAddress = endAddress.subtract(BigInteger.valueOf(1)); 171 fEndAddress = endAddress; 172 } 173 } 174 175 if (fEndAddress == null) 176 fEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); 177 } 178 return fEndAddress; 179 } 180 181 public int getNumLines() 182 { 183 return fNumLines; 184 } 185 186 public void setNumLines(int numLines) 187 { 188 fNumLines = numLines; 189 } 190 191 public Object getAdapter(Class adapter) { 192 if (adapter == AbstractTableRendering.class) 193 { 194 if (fRendering instanceof AbstractTableRendering) 195 return fRendering; 196 } 197 if (adapter == AbstractAsyncTableRendering.class) 198 { 199 if (fRendering instanceof AbstractAsyncTableRendering) 200 return fRendering; 201 } 202 203 return super.getAdapter(adapter); 204 } 205 } 206 | Popular Tags |