Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantha Chan2007-01-12 15:12:28 -0500
committerSamantha Chan2007-01-12 15:12:28 -0500
commit768d61da28d64fef33b37c8b10d7570071c41f99 (patch)
treed25045d503319d6eabac27a05bc0c5053fd6c4db
parent919f030d80860e9aec0096c8dc22d2b49630cfd3 (diff)
downloadeclipse.platform.debug-768d61da28d64fef33b37c8b10d7570071c41f99.tar.gz
eclipse.platform.debug-768d61da28d64fef33b37c8b10d7570071c41f99.tar.xz
eclipse.platform.debug-768d61da28d64fef33b37c8b10d7570071c41f99.zip
Bug 166234 - [Memory View] More flexible buffer size in table renderings
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties12
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java141
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/IVirtualContentListener.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java20
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java223
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java139
12 files changed, 447 insertions, 146 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
index a30bac0fa..507fbd5fc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
@@ -173,10 +173,16 @@ public class DebugUIMessages extends NLS {
public static String TableRenderingPropertiesPage_25;
public static String TableRenderingPropertiesPage_26;
public static String TableRenderingPrefAction_0;
- public static String TableRenderingPreferencePage_1;
+ public static String TableRenderingPreferencePage_0;
public static String TableRenderingPreferencePage_2;
public static String TableRenderingPreferencePage_3;
public static String TableRenderingPreferencePage_4;
+ public static String TableRenderingPreferencePage_5;
+ public static String TableRenderingPreferencePage_6;
+ public static String TableRenderingPreferencePage_7;
+ public static String TableRenderingPreferencePage_8;
+ public static String TableRenderingPreferencePage_9;
+ public static String TableRenderingPreferencePage_10;
public static String TableRenderingContentProvider_0;
public static String TableRenderingContentProvider_1;
public static String TableRenderingContentProvider_2;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
index f50a3bbc2..3205f49b5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
@@ -195,10 +195,16 @@ TableRenderingPropertiesPage_26=Units Per Line:
TableRenderingContentProvider_0=Unable to load memory from the specified address: 0x
TableRenderingContentProvider_1=Buffer start and end address are invalid.
TableRenderingContentProvider_2=Buffer start and end address are invalid.
-TableRenderingPreferencePage_1=Automatically load next page of memory when scrolled to end of buffer
-TableRenderingPreferencePage_2=Number of Lines per Page:
+TableRenderingPreferencePage_10=Select memory loading mode when rendering is scrolled to end of buffer:
+TableRenderingPreferencePage_2=Number of lines per page:
TableRenderingPreferencePage_3=Page size cannot be less than 1.
-TableRenderingPreferencePage_4=Page size is invalid.
+TableRenderingPreferencePage_4=Sizes specified are invalid.
+TableRenderingPreferencePage_0=Automatic
+TableRenderingPreferencePage_5=Number of lines to preload
+TableRenderingPreferencePage_6=Before visible region:
+TableRenderingPreferencePage_7=After visible region:
+TableRenderingPreferencePage_8=Manual
+TableRenderingPreferencePage_9=Minimum number of lines to preload is 1.
TableRenderingPrefAction_0=Table Renderings
SwitchMemoryBlockAction_0=Unknown
SwitchMemoryBlockAction_4=Pending
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java
index 2a0e53997..03585e4d5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java
@@ -118,6 +118,8 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer
prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
prefs.setDefault(IDebugPreferenceConstants.PREF_RESET_MEMORY_BLOCK, IDebugPreferenceConstants.RESET_VISIBLE);
+ prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE,IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
+ prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE,IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
/**
* new launch configuration filtering options
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java
index 71cf1a685..a85116f33 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java
@@ -127,6 +127,9 @@ public class MemoryBlockContentAdapter extends AsynchronousContentAdapter {
if (descriptor == null)
return new Object[0];
+ if (descriptor.getNumLines() <= 0)
+ return new Object[0];
+
// calculate top buffered address
BigInteger loadAddress = descriptor.getLoadAddress();
if (loadAddress == null)
@@ -164,7 +167,17 @@ public class MemoryBlockContentAdapter extends AsynchronousContentAdapter {
bufferStart = mbStart;
if (bufferEnd.compareTo(mbEnd) > 0)
+ {
bufferEnd = mbEnd;
+
+ int numLines = bufferEnd.subtract(bufferStart).divide(BigInteger.valueOf(addressableUnitsPerLine)).intValue();
+ if (numLines < descriptor.getNumLines())
+ {
+ // re-calculate buffer start since we may not have enough lines to popoulate the view
+ bufferStart = bufferEnd.subtract(BigInteger.valueOf(descriptor.getNumLines()*addressableUnitsPerLine));
+ bufferStart = bufferStart.subtract(BigInteger.valueOf(descriptor.getPreBuffer()*addressableUnitsPerLine));
+ }
+ }
// buffer end must be greater than buffer start
if (bufferEnd.compareTo(bufferStart) <= 0)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java
index 315f06148..7ced6f399 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java
@@ -104,6 +104,8 @@ import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
@@ -115,7 +117,9 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
@@ -198,6 +202,8 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
* This property is used for synchronization between renderings.
*/
public static final String PROPERTY_ROW_SIZE = AbstractTableRendering.PROPERTY_ROW_SIZE;
+
+ private static final int DEFAULT_BUFFER_THRESHOLD = 1;
private boolean fActivated = false;
@@ -379,6 +385,8 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
private String fLabel;
private IWorkbenchAdapter fWorkbenchAdapter;
private int fPageSize;
+ private int fPreBufferSize = -1;
+ private int fPostBufferSize = -1;
private SashForm fSashForm;
private GoToAddressComposite fGoToAddressComposite;
@@ -460,11 +468,14 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
}};
private IVirtualContentListener fViewerListener = new IVirtualContentListener() {
+
+ private int startThreshold;
+ private int endThreshold;
public void handledAtBufferStart() {
if (getMemoryBlock() instanceof IMemoryBlockExtension)
{
- if (isDynamicLoad())
+ if (isDynamicLoad() && startThreshold != 0)
{
BigInteger address = getTopVisibleAddress();
if (address != null && !isAtTopLimit())
@@ -476,7 +487,7 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
public void handleAtBufferEnd() {
if (getMemoryBlock() instanceof IMemoryBlockExtension)
{
- if (isDynamicLoad())
+ if (isDynamicLoad() && endThreshold != 0)
{
BigInteger address = getTopVisibleAddress();
if (address != null && !isAtBottomLimit())
@@ -485,8 +496,31 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
}
}
- public int getThreshold() {
- return 3;
+ public int getThreshold(int bufferEndOrStart) {
+
+ int threshold = DEFAULT_BUFFER_THRESHOLD;
+
+ if (bufferEndOrStart == IVirtualContentListener.BUFFER_START)
+ {
+ if (threshold > getPreBufferSize())
+ {
+ threshold = getPreBufferSize();
+ }
+ }
+ else
+ {
+ if (threshold > getPostBufferSize())
+ {
+ threshold = getPostBufferSize();
+ }
+ }
+
+ if (bufferEndOrStart == IVirtualContentListener.BUFFER_START)
+ startThreshold = threshold;
+ else
+ endThreshold = threshold;
+
+ return threshold;
}};
private IPresentationErrorListener fPresentationErrorListener = new IPresentationErrorListener() {
@@ -625,11 +659,22 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
int numberOfLines = getNumLinesToLoad();
fContentDescriptor.setNumLines(numberOfLines);
+ if (numberOfLines == 0)
+ {
+ // if the table viewer is not initialized yet, add listener
+ // and load table when we can get the height of the table
+ fTableViewer.getTable().addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ fTableViewer.getTable().removePaintListener(this);
+ fContentDescriptor.setNumLines(getNumLinesToLoad());
+ refresh();
+ }});
+ }
+
BigInteger baseAddress = finalMbBaseAddress;
if (baseAddress == null)
baseAddress = BigInteger.ZERO;
-
if (!(getMemoryBlock() instanceof IMemoryBlockExtension) || !isDynamicLoad())
{
// If not extended memory block, do not create any buffer
@@ -672,6 +717,15 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
fTableViewer.addSelectionChangedListener(fViewerSelectionChangedListener);
fTableViewer.getTable().getVerticalBar().addSelectionListener(fScrollBarSelectionListener);
+ // add resize listener to figure out number of visible lines
+ // so that the viewer get refreshed with the correct number of lines on the
+ // next refresh request
+ fTableViewer.getTable().addListener(SWT.Resize, new Listener() {
+ public void handleEvent(Event event) {
+ if (!fTableViewer.getTable().isDisposed())
+ fContentDescriptor.setNumLines(getNumLinesToLoad());
+ }});
+
createToolTip();
// now the rendering is successfully created
@@ -915,7 +969,6 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
-
if (!fIsCreated)
return;
@@ -931,11 +984,21 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
}
Object evtSrc = event.getSource();
-
+
+ // always update page size, only refresh if the table is visible
if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE)) {
- // always update page size, only refresh if the table is visible
getPageSizeFromPreference();
}
+ if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE))
+ {
+ getPreBufferSizeFromPreference();
+ fContentDescriptor.setPreBuffer(getPreBufferSize());
+ }
+ if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE))
+ {
+ getPostBufferSizeFromPreference();
+ fContentDescriptor.setPostBuffer(getPostBufferSize());
+ }
// do not handle event if the rendering is displaying an error
// or if it's not visible
@@ -958,6 +1021,16 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
return;
}
+ if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE) ||
+ event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE))
+ {
+ if (!fIsDisposed)
+ {
+ fTableViewer.refresh(true);
+ }
+ return;
+ }
+
if (event.getProperty().equals(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM)) {
handleDyanicLoadChanged();
return;
@@ -1111,7 +1184,7 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
int elementsCnt = fTableViewer.getVirtualContentModel().getElements().length;
int numLinesLeft = elementsCnt - bottomIdx;
- if (numLinesLeft <= 3)
+ if (numLinesLeft < fViewerListener.getThreshold(IVirtualContentListener.BUFFER_END))
return true;
return false;
@@ -1120,7 +1193,7 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
private boolean isAtTopBuffer(BigInteger address)
{
int topIdx = fTableViewer.indexOf(address);
- if (topIdx <= 3)
+ if (topIdx < fViewerListener.getThreshold(IVirtualContentListener.BUFFER_START))
return true;
return false;
@@ -1419,6 +1492,11 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
height = fTableViewer.getTable().getParent().getSize().y;
}
+ if (height == 0)
+ {
+ return 0;
+ }
+
// height of border
int border = fTableViewer.getTable().getHeaderHeight();
@@ -1434,7 +1512,7 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
int numberOfLines = height/lineHeight;
if (numberOfLines <= 0)
- return 20;
+ return 0;
return numberOfLines;
}
@@ -2142,6 +2220,16 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
fPageSize = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE);
}
+ private void getPreBufferSizeFromPreference()
+ {
+ fPreBufferSize = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE);
+ }
+
+ private void getPostBufferSizeFromPreference()
+ {
+ fPostBufferSize = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE);
+ }
+
private void updateDynamicLoadProperty() {
boolean value = DebugUIPlugin
@@ -2155,8 +2243,8 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
if (!fIsDisposed) {
if (isDynamicLoad()) {
- fContentDescriptor.setPostBuffer(20);
- fContentDescriptor.setPreBuffer(20);
+ fContentDescriptor.setPostBuffer(getPostBufferSize());
+ fContentDescriptor.setPreBuffer(getPreBufferSize());
fContentDescriptor.setNumLines(getNumberOfVisibleLines());
} else {
@@ -2854,8 +2942,8 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
*/
private void createContentDescriptor(final BigInteger topVisibleAddress) {
fContentDescriptor = new TableRenderingContentDescriptor(AbstractAsyncTableRendering.this);
- fContentDescriptor.setPostBuffer(20);
- fContentDescriptor.setPreBuffer(20);
+ fContentDescriptor.setPostBuffer(getPostBufferSize());
+ fContentDescriptor.setPreBuffer(getPreBufferSize());
fContentDescriptor.setLoadAddress(topVisibleAddress);
try {
fContentDescriptor.updateContentBaseAddress();
@@ -2889,7 +2977,30 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende
if (fContentDescriptor.getAddressSize() <= 0)
fContentDescriptor.setAddressSize(4);
}
+ }
+
+ /**
+ * Return the number of lines to be bufferred before the top visible line of the memory rendering
+ * @return number of lines to be buffered before the top visible line in the memory rendering
+ */
+ private int getPreBufferSize()
+ {
+ if (fPreBufferSize < 0)
+ getPreBufferSizeFromPreference();
+
+ return fPreBufferSize;
+ }
+
+ /**
+ * Returns the number of lines to be bufferred after the last visible line in the memory rendering
+ * @return the number of lines to be bufferred after the last visible line in the memory rendering
+ */
+ private int getPostBufferSize()
+ {
+ if (fPostBufferSize < 0)
+ getPostBufferSizeFromPreference();
+ return fPostBufferSize;
}
private TableRenderingContentDescriptor getContentDescriptor()
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
index 362f9d456..3a28f0858 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
@@ -253,6 +253,22 @@ public interface IDebugPreferenceConstants {
* @since 3.2
*/
public static final String PREF_COL_SIZE_BY_MODEL = "org.eclipse.debug.ui.AbstractTableRendering.colSize"; //$NON-NLS-1$
+
+ /**
+ * Number of lines to preload before the visible region in the table rendering
+ *
+ * @since 3.3
+ */
+ public static final String PREF_TABLE_RENDERING_PRE_BUFFER_SIZE = "org.eclispe.debug.ui.memory.preBufferSize"; //$NON-NLS-1$
+
+ /**
+ * Number of lines to preload after the visible region in the table rendering
+ *
+ * @since 3.3
+ */
+ public static final String PREF_TABLE_RENDERING_POST_BUFFER_SIZE = "org.eclispe.debug.ui.memory.postBufferSize"; //$NON-NLS-1$
+
}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java
index 2ae633f45..b5e86fa64 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java
@@ -237,7 +237,7 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi
for (int i = 0; i < listeners.length; i++) {
final IVirtualContentListener listener = (IVirtualContentListener) listeners[i];
- if (topIdx <= listener.getThreshold())
+ if (topIdx < listener.getThreshold(IVirtualContentListener.BUFFER_START))
{
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
@@ -261,7 +261,7 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi
for (int i = 0; i < listeners.length; i++) {
final IVirtualContentListener listener = (IVirtualContentListener) listeners[i];
- if (numLinesLeft <= listener.getThreshold())
+ if (numLinesLeft <= listener.getThreshold(IVirtualContentListener.BUFFER_END))
{
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/IVirtualContentListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/IVirtualContentListener.java
index c5e7f8635..8b8996f1f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/IVirtualContentListener.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/IVirtualContentListener.java
@@ -13,6 +13,9 @@ package org.eclipse.debug.internal.ui.views.memory.renderings;
public interface IVirtualContentListener {
+ public int BUFFER_START = 0;
+ public int BUFFER_END = 1;
+
/**
* Called when the viewer is at the beginning of its bufferred content
*/
@@ -26,6 +29,6 @@ public interface IVirtualContentListener {
/**
* @return
*/
- public int getThreshold();
+ public int getThreshold(int bufferEndOrStart);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java
index 8db67e848..00c234f14 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java
@@ -29,7 +29,6 @@ public class TableRenderingContentInput extends PlatformObject {
private IMemoryRendering fRendering;
private int fPreBuffer; // number of lines before the top visible line
private int fPostBuffer; // number of lines after thes last visible line
- private int fDefaultBufferSize;
private BigInteger fLoadAddress; // Top address to load at the table
private int fNumLines; // number of visible lines
private boolean fUpdateDelta; // should the content provider calculate delta info
@@ -37,14 +36,13 @@ public class TableRenderingContentInput extends PlatformObject {
private BigInteger fStartAddress;
private BigInteger fEndAddress;
- public TableRenderingContentInput(IMemoryRendering rendering, int preBuffer, int postBuffer, int defaultBufferSize, BigInteger loadAddress, int numOfLines, boolean updateDelta, BigInteger contentBaseAddress)
+ public TableRenderingContentInput(IMemoryRendering rendering, int preBuffer, int postBuffer, BigInteger loadAddress, int numOfLines, boolean updateDelta, BigInteger contentBaseAddress)
{
fRendering = rendering;
fPreBuffer = preBuffer;
fPostBuffer = postBuffer;
fLoadAddress = loadAddress;
fNumLines = numOfLines;
- fDefaultBufferSize = defaultBufferSize;
fUpdateDelta = updateDelta;
if (contentBaseAddress == null)
@@ -80,12 +78,6 @@ public class TableRenderingContentInput extends PlatformObject {
public void setPreBuffer(int preBuffer) {
fPreBuffer = preBuffer;
}
- public int getDefaultBufferSize() {
- return fDefaultBufferSize;
- }
- public void setDefaultBufferSize(int defaultBufferSize) {
- fDefaultBufferSize = defaultBufferSize;
- }
public boolean isUpdateDelta() {
return fUpdateDelta;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java
index cefef9644..9a5b2623a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java
@@ -128,6 +128,9 @@ public class TableRenderingContentProvider extends BasicDebugViewContentProvider
}
}
+ if (lineCache.isEmpty())
+ return lineCache.toArray();
+
// check to see if the row size has changed
TableRenderingLine line = (TableRenderingLine)lineCache.get(0);
int currentRowSize = line.getByteArray().length;
@@ -168,7 +171,6 @@ public class TableRenderingContentProvider extends BasicDebugViewContentProvider
// get as much memory as the memory block can handle
fInput.setPreBuffer(0);
fInput.setPostBuffer(0);
- fInput.setDefaultBufferSize(0);
long startAddress = fInput.getMemoryBlock().getStartAddress();
BigInteger address = BigInteger.valueOf(startAddress);
long length = fInput.getMemoryBlock().getLength();
@@ -181,6 +183,10 @@ public class TableRenderingContentProvider extends BasicDebugViewContentProvider
*/
public void loadContentForExtendedMemoryBlock() throws DebugException {
+ // do not load if number of lines needed is < 0
+ if (fInput.getNumLines() <= 0)
+ return;
+
// calculate top buffered address
BigInteger loadAddress = fInput.getLoadAddress();
if (loadAddress == null)
@@ -216,7 +222,17 @@ public class TableRenderingContentProvider extends BasicDebugViewContentProvider
bufferStart = mbStart;
if (bufferEnd.compareTo(mbEnd) > 0)
+ {
bufferEnd = mbEnd;
+
+ int numLines = bufferEnd.subtract(bufferStart).divide(BigInteger.valueOf(addressableUnitsPerLine)).intValue();
+ if (numLines < fInput.getNumLines())
+ {
+ // re-calculate buffer start since we may not have enough lines to popoulate the view
+ bufferStart = bufferEnd.subtract(BigInteger.valueOf(fInput.getNumLines()*addressableUnitsPerLine));
+ bufferStart = bufferStart.subtract(BigInteger.valueOf(fInput.getPreBuffer()*addressableUnitsPerLine));
+ }
+ }
// buffer end must be greater than buffer start
if (bufferEnd.compareTo(bufferStart) <= 0)
@@ -773,7 +789,7 @@ public class TableRenderingContentProvider extends BasicDebugViewContentProvider
*/
public boolean isAddressOutOfRange(BigInteger address)
{
- if (lineCache != null)
+ if (lineCache != null && !lineCache.isEmpty())
{
TableRenderingLine first = (TableRenderingLine)lineCache.firstElement();
TableRenderingLine last = (TableRenderingLine) lineCache.lastElement();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java
index ab9b9a070..93e029be7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java
@@ -13,9 +13,9 @@ package org.eclipse.debug.internal.ui.views.memory.renderings;
import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.SWTUtil;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
@@ -23,117 +23,132 @@ import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.PlatformUI;
public class TableRenderingPreferencePage extends PreferencePage implements
- IPropertyChangeListener{
+ IPropertyChangeListener, SelectionListener{
+
+ private Button fAuto;
+ private Button fManual;
+ private IntegerFieldEditor fPreBufferSize;
+ private IntegerFieldEditor fPostBufferSize;
+ private IntegerFieldEditor fPageSize;
+ private Group fGroup;
+ private Composite fComposite;
- private BooleanFieldEditor fAutoLoadPref;
- private IntegerFieldEditor fPageSizePref;
- private Composite fBufferComposite;
- public TableRenderingPreferencePage(String title)
- {
+ public TableRenderingPreferencePage(String title) {
super(title);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
+
protected Control createContents(Composite parent) {
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".table_renderings_preference_page_context"); //$NON-NLS-1$
- Composite composite = new Composite(parent, SWT.NONE);
- GridData data = new GridData();
- data.horizontalAlignment = SWT.FILL;
- composite.setLayoutData(data);
+ fComposite = new Composite(parent, SWT.NONE);
+ fComposite.setLayout(new GridLayout());
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
+ fComposite.setLayoutData(data);
+
+ GridData hspanData = new GridData(SWT.FILL, SWT.FILL, true, false);
+ hspanData.horizontalSpan = 2;
- fAutoLoadPref = new BooleanFieldEditor(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, DebugUIMessages.TableRenderingPreferencePage_1, composite);
- fAutoLoadPref.setPreferenceStore(getPreferenceStore());
- fAutoLoadPref.load();
+ SWTUtil.createWrapLabel(fComposite, DebugUIMessages.TableRenderingPreferencePage_10, 2, 300);
- fBufferComposite = new Composite(composite, SWT.NONE);
- data = new GridData();
- data.horizontalAlignment = SWT.FILL;
- fBufferComposite.setLayoutData(data);
+ fAuto = new Button(fComposite, SWT.RADIO);
+ fAuto.setText(DebugUIMessages.TableRenderingPreferencePage_0);
+ fAuto.setLayoutData(hspanData);
- fPageSizePref = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, DebugUIMessages.TableRenderingPreferencePage_2, fBufferComposite);
- fPageSizePref.setPreferenceStore(getPreferenceStore());
- fPageSizePref.load();
+ fGroup = new Group(fComposite, SWT.NONE);
+ fGroup.setText(DebugUIMessages.TableRenderingPreferencePage_5);
+ GridData groupData = new GridData(SWT.FILL, SWT.FILL, true, false);
+ groupData.horizontalSpan = 2;
+ fGroup.setLayoutData(groupData);
+ fPreBufferSize = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE, DebugUIMessages.TableRenderingPreferencePage_6, fGroup);
+ fPreBufferSize.setPreferenceStore(getPreferenceStore());
+ fPreBufferSize.load();
+ fPostBufferSize = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE, DebugUIMessages.TableRenderingPreferencePage_7, fGroup);
+ fPostBufferSize.setPreferenceStore(getPreferenceStore());
+ fPostBufferSize.load();
- boolean autoLoad = getPreferenceStore().getBoolean(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM);
- if (autoLoad)
- fPageSizePref.setEnabled(false, fBufferComposite);
- else
- fPageSizePref.setEnabled(true, fBufferComposite);
+ fManual = new Button(fComposite, SWT.RADIO);
+ fManual.setText(DebugUIMessages.TableRenderingPreferencePage_8);
+ fManual.setLayoutData(hspanData);
- fAutoLoadPref.setPropertyChangeListener(this);
- fPageSizePref.setPropertyChangeListener(this);
- fPageSizePref.setValidRange(1, Integer.MAX_VALUE);
+ fPageSize = new IntegerFieldEditor(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, DebugUIMessages.TableRenderingPreferencePage_2, fComposite);
+ fPageSize.setPreferenceStore(getPreferenceStore());
+ fPageSize.load();
- return composite;
- }
-
-
- public boolean performOk() {
- fAutoLoadPref.store();
- fPageSizePref.store();
- return super.performOk();
- }
-
- protected void performDefaults() {
- fAutoLoadPref.loadDefault();
- fPageSizePref.loadDefault();
- updatePageSizePref();
- super.performDefaults();
+ fPreBufferSize.setPropertyChangeListener(this);
+ fPostBufferSize.setPropertyChangeListener(this);
+ fPageSize.setPropertyChangeListener(this);
+
+ fAuto.addSelectionListener(this);
+ fManual.addSelectionListener(this);
+
+ loadLoadingModeFromPreference();
+ updateTextEditorsEnablement();
+
+ return fComposite;
}
- protected IPreferenceStore doGetPreferenceStore() {
- return DebugUIPlugin.getDefault().getPreferenceStore();
+ /**
+ *
+ */
+ private void loadLoadingModeFromPreference() {
+ boolean isAuto = getPreferenceStore().getBoolean(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM);
+ fAuto.setSelection(isAuto);
+ fManual.setSelection(!isAuto);
}
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.VALUE))
{
- if (event.getSource().equals(fAutoLoadPref))
- {
- updatePageSizePref();
- validatePageSize();
- }
- }
- if (event.getProperty().equals(FieldEditor.VALUE))
- {
- if (event.getSource().equals(fPageSizePref))
+ if (event.getSource().equals(fPageSize) ||
+ event.getSource().equals(fPostBufferSize) ||
+ event.getSource().equals(fPreBufferSize))
{
validatePageSize();
}
}
+
}
-
- private void updatePageSizePref() {
- boolean autoLoad = fAutoLoadPref.getBooleanValue();
- if (autoLoad)
- {
- fPageSizePref.setEnabled(false, fBufferComposite);
- }
- else
- {
- fPageSizePref.setEnabled(true, fBufferComposite);
- }
- }
-
+
private void validatePageSize() {
- boolean autoLoad = fAutoLoadPref.getBooleanValue();
+ boolean autoLoad = fAuto.getSelection();
try {
- int bufferSize = fPageSizePref.getIntValue();
+ int bufferSize = fPageSize.getIntValue();
+ int preBuffer = fPreBufferSize.getIntValue();
+ int postBuffer = fPostBufferSize.getIntValue();
if (!autoLoad && bufferSize < 1)
{
setValid(false);
setErrorMessage(DebugUIMessages.TableRenderingPreferencePage_3);
}
+ else if (autoLoad)
+ {
+ // For auto load mode, we must have have > 1 buffer size
+ // otherwise, the rendering cannot be loaded dynamically
+
+ if (preBuffer < 1 || postBuffer < 1)
+ {
+ setValid(false);
+ setErrorMessage(DebugUIMessages.TableRenderingPreferencePage_9);
+ }
+ else
+ {
+ setValid(true);
+ setErrorMessage(null);
+ }
+ }
else
{
setValid(true);
@@ -141,18 +156,64 @@ public class TableRenderingPreferencePage extends PreferencePage implements
}
} catch (NumberFormatException e) {
- if (!autoLoad)
- {
setValid(false);
setErrorMessage(DebugUIMessages.TableRenderingPreferencePage_4);
- }
}
}
-
+
+ protected IPreferenceStore doGetPreferenceStore() {
+ return DebugUIPlugin.getDefault().getPreferenceStore();
+ }
+
public void dispose() {
-
- fAutoLoadPref.setPropertyChangeListener(null);
- fPageSizePref.setPropertyChangeListener(null);
+ fAuto.removeSelectionListener(this);
+ fManual.removeSelectionListener(this);
+ fPageSize.setPropertyChangeListener(null);
+ fPreBufferSize.setPropertyChangeListener(null);
+ fPostBufferSize.setPropertyChangeListener(null);
super.dispose();
}
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ updateTextEditorsEnablement();
+ }
+
+ public boolean performOk() {
+ boolean auto = fAuto.getSelection();
+ boolean currentValue = getPreferenceStore().getBoolean(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM);
+ if (auto != currentValue)
+ getPreferenceStore().setValue(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, auto);
+
+ fPageSize.store();
+ fPreBufferSize.store();
+ fPostBufferSize.store();
+ return super.performOk();
+ }
+
+ protected void performDefaults() {
+
+ boolean auto = getPreferenceStore().getDefaultBoolean(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM);
+ fAuto.setSelection(auto);
+ fManual.setSelection(!auto);
+ updateTextEditorsEnablement();
+
+ fPageSize.loadDefault();
+ fPreBufferSize.loadDefault();
+ fPostBufferSize.loadDefault();
+ super.performDefaults();
+ }
+
+ /**
+ *
+ */
+ private void updateTextEditorsEnablement() {
+ boolean auto = fAuto.getSelection();
+ fPreBufferSize.setEnabled(auto, fGroup);
+ fPostBufferSize.setEnabled(auto, fGroup);
+ fPageSize.setEnabled(!auto, fComposite);
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java
index 68969375f..4678e5510 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java
@@ -27,11 +27,11 @@ import org.eclipse.debug.internal.ui.memory.IMemoryBlockConnection;
import org.eclipse.debug.internal.ui.memory.IPersistableDebugElement;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
+import org.eclipse.debug.internal.ui.views.memory.renderings.AbstractBaseTableRendering;
import org.eclipse.debug.internal.ui.views.memory.renderings.CopyTableRenderingToClipboardAction;
import org.eclipse.debug.internal.ui.views.memory.renderings.FormatTableRenderingAction;
import org.eclipse.debug.internal.ui.views.memory.renderings.FormatTableRenderingDialog;
import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction;
-import org.eclipse.debug.internal.ui.views.memory.renderings.AbstractBaseTableRendering;
import org.eclipse.debug.internal.ui.views.memory.renderings.PrintTableRenderingAction;
import org.eclipse.debug.internal.ui.views.memory.renderings.ReformatAction;
import org.eclipse.debug.internal.ui.views.memory.renderings.ResetToBaseAddressAction;
@@ -75,6 +75,8 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
@@ -165,6 +167,10 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
*/
public static final String PROPERTY_ROW_SIZE = "rowSize"; //$NON-NLS-1$
+ private static final int BUFFER_THRESHOLD = 1; // threshold value
+ private static final int BUFFER_START = 0; // flag to indicate asking for threshold at buffer start
+ private static final int BUFFER_END = 1; // flat to indicate asking for threshold at buffer end
+
private PageBook fPageBook;
private TableViewer fTableViewer;
private TextViewer fTextViewer;
@@ -217,6 +223,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
private IMenuListener fMenuListener;
+ private int fPreBuffer;
+ private int fPostBuffer;
+
private class EventHandleLock
{
Object fOwner;
@@ -351,7 +360,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
Object evtSrc = event.getSource();
- if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE)) {
+ if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE) ||
+ event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE) ||
+ event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE)) {
// always update page size, only refresh if the table is visible
getPageSizeFromPreference();
}
@@ -378,6 +389,16 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
return;
}
+ if (event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE) ||
+ event.getProperty().equals(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE)) {
+ if (isDynamicLoad())
+ {
+ // only refresh if in non-autoload mode
+ refresh();
+ }
+ return;
+ }
+
if (evtSrc == this)
return;
@@ -456,13 +477,11 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
if (isDynamicLoad()) {
fContentInput.setPostBuffer(20);
fContentInput.setPreBuffer(20);
- fContentInput.setDefaultBufferSize(20);
fContentInput.setNumLines(getNumberOfVisibleLines());
} else {
fContentInput.setPostBuffer(0);
fContentInput.setPreBuffer(0);
- fContentInput.setDefaultBufferSize(0);
fContentInput.setNumLines(fPageSize);
}
}
@@ -538,7 +557,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
{
Table table = fTableViewer.getTable();
int index = findAddressIndex(address);
- if (index >= 3 && table.getItemCount() - (index+getNumberOfVisibleLines()) >= 3)
+ int startThreshold = getBufferThreshold(BUFFER_START);
+ int endThrreshold = getBufferThreshold(BUFFER_END);
+ if (index >= startThreshold && table.getItemCount() - (index+getNumberOfVisibleLines()) >= endThrreshold)
{
// update cursor position
setTopIndex(table, index);
@@ -546,7 +567,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
else
{
int numInBuffer = table.getItemCount();
- if (index < 3)
+ if (index < getBufferThreshold(BUFFER_START))
{
if(isAtTopLimit())
{
@@ -554,15 +575,15 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
}
else
{
- if (isDynamicLoad())
+ if (isDynamicLoad() && getBufferThreshold(BUFFER_START) > 0)
reloadTable(address, false);
else
setTopIndex(table, index);
}
}
- else if ((numInBuffer-(index+getNumberOfVisibleLines())) < 3)
+ else if ((numInBuffer-(index+getNumberOfVisibleLines())) <= getBufferThreshold(BUFFER_END))
{
- if (!isAtBottomLimit() && isDynamicLoad())
+ if (!isAtBottomLimit() && isDynamicLoad() && getBufferThreshold(BUFFER_END) > 0)
reloadTable(address, false);
else
setTopIndex(table, index);
@@ -748,8 +769,25 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
getPageSizeFromPreference();
+
if (isDynamicLoad())
- fContentInput = new TableRenderingContentInput(this, 20, 20, 20, topVisibleAddress, getNumberOfVisibleLines(), false, null);
+ {
+ int numLines = getNumberOfVisibleLines();
+ if (numLines <= 0)
+ {
+ // add listener to reload when we know the number of lines to load
+ fTableViewer.getTable().addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ fTableViewer.getTable().removePaintListener(this);
+ fContentInput.setNumLines(getNumberOfVisibleLines());
+ reloadTable(fContentInput.getLoadAddress(), false);
+ resizeColumnsToPreferredSize();
+ setCursorAtAddress(fSelectedAddress);
+ fTableCursor.setVisible(true);
+ }});
+ }
+ fContentInput = new TableRenderingContentInput(this, fPreBuffer, fPostBuffer, topVisibleAddress, numLines, false, null);
+ }
else
{
BigInteger addressToLoad = topVisibleAddress;
@@ -760,7 +798,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
{
addressToLoad = (BigInteger)obj;
}
- fContentInput = new TableRenderingContentInput(this, 0, 0, 0, addressToLoad, fPageSize, false, null);
+ fContentInput = new TableRenderingContentInput(this, 0, 0, addressToLoad, fPageSize, false, null);
}
fTableViewer.setInput(fContentInput);
@@ -778,7 +816,6 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
// no scrolling
fContentInput.setPreBuffer(0);
fContentInput.setPostBuffer(0);
- fContentInput.setDefaultBufferSize(0);
}
// set up table cursor
@@ -1056,6 +1093,8 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
private void getPageSizeFromPreference()
{
fPageSize = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE);
+ fPreBuffer = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PRE_BUFFER_SIZE);
+ fPostBuffer = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_TABLE_RENDERING_POST_BUFFER_SIZE);
}
private void createCursor(Table table, BigInteger address)
@@ -1191,9 +1230,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
{
int row = fTableViewer.getTable().indexOf(item);
- if (row < 3)
+ if (row < getBufferThreshold(BUFFER_START))
{
- if (!isAtTopLimit())
+ if (!isAtTopLimit() && getBufferThreshold(BUFFER_START) > 0)
{
if (isDynamicLoad())
{
@@ -1202,9 +1241,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
}
}
}
- else if (row >= fTableViewer.getTable().getItemCount() - 3)
+ else if (row >= fTableViewer.getTable().getItemCount() - getBufferThreshold(BUFFER_END))
{
- if (!isAtBottomLimit())
+ if (!isAtBottomLimit() && getBufferThreshold(BUFFER_END) > 0)
{
if (isDynamicLoad())
{
@@ -1290,6 +1329,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
*/
private boolean setCursorAtAddress(BigInteger address)
{
+ if (fContentProvider.getBufferTopAddress() == null)
+ return false;
+
// selected address is out of range, simply return false
if (address.compareTo(fContentProvider.getBufferTopAddress()) < 0)
return false;
@@ -1596,6 +1638,22 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
height = fTableViewer.getTable().getParent().getSize().y;
}
+ int numberOfLines = doGetNumberOfVisibleLines(table, height);
+
+ if (numberOfLines <= 0)
+ {
+ return 0;
+ }
+
+ return numberOfLines;
+ }
+
+ /**
+ * @param table
+ * @param height
+ * @return
+ */
+ private int doGetNumberOfVisibleLines(Table table, int height) {
// height of border
int border = fTableViewer.getTable().getHeaderHeight();
@@ -1609,11 +1667,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
int lineHeight = getMinTableItemHeight(table);
int numberOfLines = height/lineHeight;
-
- if (numberOfLines <= 0)
- return 20;
-
- return numberOfLines;
+ return numberOfLines;
}
private static void setTopIndex(Table table, int index)
@@ -2090,9 +2144,9 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
TableRenderingContentInput input;
if (isDynamicLoad())
- input = new TableRenderingContentInput(this, fContentInput.getPreBuffer(), fContentInput.getPostBuffer(), fContentInput.getDefaultBufferSize(), topAddress, getNumberOfVisibleLines(), updateDelta, null);
+ input = new TableRenderingContentInput(this, fPreBuffer, fPostBuffer, topAddress, getNumberOfVisibleLines(), updateDelta, null);
else
- input = new TableRenderingContentInput(this, fContentInput.getPreBuffer(), fContentInput.getPostBuffer(), fContentInput.getDefaultBufferSize(), topAddress, fPageSize, updateDelta, null);
+ input = new TableRenderingContentInput(this, fContentInput.getPreBuffer(), fContentInput.getPostBuffer(), topAddress, fPageSize, updateDelta, null);
fContentInput = input;
fTableViewer.setInput(fContentInput);
@@ -2190,7 +2244,12 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
{
int index = table.getTopIndex();
- TableItem item = table.getItem(index);
+ TableItem item;
+ try {
+ item = table.getItem(index);
+ } catch (IllegalArgumentException e) {
+ return 0;
+ }
int cnt = table.getItemCount();
while (item.getBounds(0).y < 0)
@@ -2480,20 +2539,21 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
Table table = fTableViewer.getTable();
int numInBuffer = table.getItemCount();
int index = findAddressIndex(address);
- if (index < 3)
+ if (index < getBufferThreshold(BUFFER_START))
{
if (isAtTopLimit())
{
setTopIndex(table, index);
}
- else
+ else if (getBufferThreshold(BUFFER_START) > 0)
{
reloadTable(address, false);
}
}
- else if ((numInBuffer-(index+getNumberOfVisibleLines())) < 3)
+ else if (getBufferThreshold(BUFFER_END) != 0 &&
+ (numInBuffer-(index+getNumberOfVisibleLines())) <= getBufferThreshold(BUFFER_END))
{
- if (!isAtBottomLimit())
+ if (!isAtBottomLimit() && getBufferThreshold(BUFFER_END) > 0)
reloadTable(address, false);
}
}
@@ -2580,17 +2640,17 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
// if there are only 3 lines left at the top, refresh
BigInteger numTopLine = topVisibleAddress.subtract(startAddress).divide(BigInteger.valueOf(addressableUnit));
- if (numTopLine.compareTo(BigInteger.valueOf(3)) <= 0 && (startAddress.compareTo(BigInteger.valueOf(0)) != 0))
+ if (numTopLine.compareTo(BigInteger.valueOf(getBufferThreshold(BUFFER_START))) <= 0 && (startAddress.compareTo(BigInteger.valueOf(0)) != 0))
{
- if (!isAtTopLimit())
+ if (!isAtTopLimit() && getBufferThreshold(BUFFER_START) > 0)
return true;
}
// if there are only 3 lines left at the bottom, refresh
BigInteger numBottomLine = lastAddress.subtract(lastVisibleAddrss).divide(BigInteger.valueOf(addressableUnit));
- if (numBottomLine.compareTo(BigInteger.valueOf(3)) <= 0)
+ if (numBottomLine.compareTo(BigInteger.valueOf(getBufferThreshold(BUFFER_END))) <= 0)
{
- if (!isAtBottomLimit())
+ if (!isAtBottomLimit() && getBufferThreshold(BUFFER_END) > 0)
return true;
}
@@ -3703,6 +3763,21 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering
col = DebugUITools.getPreferenceStore().getInt(getColumnPrefId(modelId));
return col;
}
+
+ private int getBufferThreshold(int startOrEnd)
+ {
+ if (startOrEnd == BUFFER_START)
+ {
+ if (BUFFER_THRESHOLD > fPreBuffer)
+ return fPreBuffer;
+ return BUFFER_THRESHOLD;
+ }
+
+ if (BUFFER_THRESHOLD > fPostBuffer)
+ return fPostBuffer;
+
+ return BUFFER_THRESHOLD;
+ }
/**

Back to the top