Fix infinite paint loop introduced by commit 866cb82
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 17 May 2013 19:28:22 +0000 (15:28 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 21 May 2013 19:14:39 +0000 (15:14 -0400)
Change-Id: I60bc075b3fe8c7ddef082aba8fe86e8433ea7f94
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/12948
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java

index ace939cf0c59dd3507effe8435add5e00c86bb11..6f9d00fa0650b955a0cdef5d6c1fddba39a7ad3d 100644 (file)
@@ -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;
+        }
     }
 
     /**
This page took 0.025871 seconds and 5 git commands to generate.