From: Patrick Tasse Date: Fri, 17 May 2013 19:28:22 +0000 (-0400) Subject: Fix infinite paint loop introduced by commit 866cb82 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=c9787691b1ec69bb96006d94210e35ce97f59128;hp=da1a4b39d333c503762aaca9571caa6ea7451891;p=deliverable%2Ftracecompass.git Fix infinite paint loop introduced by commit 866cb82 Change-Id: I60bc075b3fe8c7ddef082aba8fe86e8433ea7f94 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/12948 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann --- diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java index ace939cf0c..6f9d00fa06 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java @@ -122,6 +122,8 @@ public class TmfVirtualTable extends Composite { */ private IDoubleClickListener doubleClickListener = null; + private boolean fResetTopIndex = false; + // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ @@ -356,15 +358,20 @@ public class TmfVirtualTable extends Composite { ); /* - * When a partially visible table item is selected, sometimes the top index - * or the origin is changed to ensure the selected item is fully visible. - * This leaves a blank space at the bottom of the virtual table and hides - * the first row. The solution is to ensure that the top index is set to 0. + * Feature in Windows. When a partially visible table item is selected, + * after ~500 ms the top index is changed to ensure the selected item is + * fully visible. This leaves a blank space at the bottom of the virtual + * table. The workaround is to reset the top index to 0 if it is not 0. + * Also reset the top index to 0 if indicated by the flag that was set + * at table selection of a partially visible table item. */ fTable.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { - fTable.setTopIndex(0); + if (fTable.getTopIndex() != 0 || fResetTopIndex) { + fTable.setTopIndex(0); + } + fResetTopIndex = false; } }); } @@ -379,6 +386,17 @@ public class TmfVirtualTable extends Composite { } else { fSelectedEventRank = fTableTopEventRank + selectedRow; } + + /* + * Feature in Linux. When a partially visible table item is selected, + * the origin is changed to ensure the selected item is fully visible. + * This makes the first row partially visible. The solution is to force + * reset the origin by setting the top index to 0. This should happen + * only once at the next redraw by the paint listener. + */ + if (selectedRow >= fFullyVisibleRows) { + fResetTopIndex = true; + } } /**