Bug 378401: Implementation of time graph widget.
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 1 Jun 2012 19:49:11 +0000 (15:49 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 1 Jun 2012 19:49:11 +0000 (15:49 -0400)
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java

index 3b8f81c5d2bc83fb9421dc102f99fa622bf8b431..ec7a8bc3a4a3fcaecb4a1000d0e3599c9f24539a 100644 (file)
@@ -106,6 +106,43 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
     protected LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());\r
     protected Color[] fEventColorMap = null;\r
 \r
+    private MouseScrollNotifier fMouseScrollNotifier;\r
+    private Object fMouseScrollNotifierLock = new Object();\r
+    private class MouseScrollNotifier extends Thread {\r
+        private final static long DELAY = 400L;\r
+        private final static long POLLING_INTERVAL = 10L;\r
+        private long fLastScrollTime = Long.MAX_VALUE;\r
+\r
+        @Override\r
+        public void run() {\r
+            while ((System.currentTimeMillis() - fLastScrollTime) < DELAY) {\r
+                try {\r
+                    Thread.sleep(POLLING_INTERVAL);\r
+                } catch (Exception e) {\r
+                    return;\r
+                }\r
+            }\r
+            if (!isInterrupted()) {\r
+                Display.getDefault().asyncExec(new Runnable() {\r
+                    @Override\r
+                    public void run() {\r
+                        if (isDisposed()) {\r
+                            return;\r
+                        }\r
+                        _timeProvider.notifyStartFinishTime();\r
+                    }\r
+                });\r
+            }\r
+            synchronized (fMouseScrollNotifierLock) {\r
+                fMouseScrollNotifier = null;\r
+            }\r
+        }\r
+\r
+        public void mouseScrolled() {\r
+            fLastScrollTime = System.currentTimeMillis();\r
+        }\r
+    }\r
+\r
     public TimeGraphControl(Composite parent, TimeGraphColorScheme colors) {\r
 \r
         super(parent, colors, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.DOUBLE_BUFFERED);\r
@@ -538,6 +575,13 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);\r
         long newTime1 = newTime0 + newInterval;\r
         _timeProvider.setStartFinishTime(newTime0, newTime1);\r
+        synchronized (fMouseScrollNotifierLock) {\r
+            if (fMouseScrollNotifier == null) {\r
+                fMouseScrollNotifier = new MouseScrollNotifier();\r
+                fMouseScrollNotifier.start();\r
+            }\r
+            fMouseScrollNotifier.mouseScrolled();\r
+        }\r
     }\r
 \r
     /**\r
@@ -1277,10 +1321,6 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
                 redraw();\r
             }\r
             _mouseOverSplitLine = mouseOverSplitLine;\r
-            // Make sure any time changes are notified to the application e.g.\r
-            // getting back from the horizontal scroll bar or zoomed using the\r
-            // mouse wheel\r
-            _timeProvider.notifyStartFinishTime();\r
         }\r
         updateCursor(e.x, e.y);\r
     }\r
index a60e1e6f629a1f2762a2652093729af0005691f5..8b776d64d7f7e54777756f0311c26056c7dcd0af 100644 (file)
@@ -217,9 +217,8 @@ public class TimeGraphTooltipHandler {
                 TimeGraphItem item = threadStates.getItem(pt);\r
                 _tipTable.remove(0, _tipTable.getItemCount() - 1);\r
                 fillValues(pt, threadStates, item);\r
-                _tipTable.getColumn(0).setWidth(200);\r
+                _tipTable.getColumn(0).pack();\r
                 _tipTable.getColumn(1).pack();\r
-                _tipTable.setSize(_tipTable.computeSize(SWT.DEFAULT, 200));\r
                 _tipShell.pack();\r
                 _tipPosition = control.toDisplay(pt);\r
                 _tipShell.pack();\r
This page took 0.031207 seconds and 5 git commands to generate.