tmf: Correct the statistics partial event count
authorMathieu Denis <mathieu.denis@polymtl.ca>
Wed, 22 Aug 2012 21:34:50 +0000 (17:34 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 23 Aug 2012 21:50:31 +0000 (17:50 -0400)
Fixes bug 387838

Reload correctly the partial event count in the statistics view when an
experiment is reselected during its indexing.

Change-Id: I1f5aaf7d54812ba2f934e173df5268c7eb24e869
Signed-off-by: Mathieu Denis <mathieu.denis@polymtl.ca>
Reviewed-on: https://git.eclipse.org/r/7357
Reviewed-by: Bernd Hufmann <bhufmann@gmail.com>
IP-Clean: Bernd Hufmann <bhufmann@gmail.com>
Tested-by: Bernd Hufmann <bhufmann@gmail.com>
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java

index f2770b69f605198d282741f55d884dee14f2e6da..d15f0f281b9e4781a89b3a1bb57e4a77070ef7c8 100644 (file)
@@ -122,6 +122,11 @@ public class TmfStatisticsViewer extends TmfViewer {
      */
     protected final Object fStatisticsUpdateSyncObj = new Object();
 
+    /**
+     * Update range synchronization object.
+     */
+    protected final Object fStatisticsRangeUpdateSyncObj = new Object();
+
     /**
      * Indicates to process all events
      */
@@ -243,16 +248,18 @@ public class TmfStatisticsViewer extends TmfViewer {
             return;
         }
 
-        // Sends the time range request only once in this method.
-        if (fSendRangeRequest) {
-            fSendRangeRequest = false;
-            // Calculate the selected time range to request
-            long startTime = signal.getRange().getStartTime().normalize(0, TIME_SCALE).getValue();
-            TmfTimestamp startTS = new TmfTimestamp(startTime, TIME_SCALE);
-            TmfTimestamp endTS = new TmfTimestamp(startTime + INITIAL_WINDOW_SPAN, TIME_SCALE);
-            TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
-
-            requestTimeRangeData(experiment, timeRange);
+        synchronized (fStatisticsRangeUpdateSyncObj) {
+            // Sends the time range request only once from this method.
+            if (fSendRangeRequest) {
+                fSendRangeRequest = false;
+                // Calculate the selected time range to request
+                long startTime = signal.getRange().getStartTime().normalize(0, TIME_SCALE).getValue();
+                TmfTimestamp startTS = new TmfTimestamp(startTime, TIME_SCALE);
+                TmfTimestamp endTS = new TmfTimestamp(startTime + INITIAL_WINDOW_SPAN, TIME_SCALE);
+                TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
+
+                requestTimeRangeData(experiment, timeRange);
+            }
         }
         requestData(experiment, signal.getRange());
     }
@@ -382,6 +389,15 @@ public class TmfStatisticsViewer extends TmfViewer {
         });
     }
 
+    /**
+     * Will force a request on the partial event count if one is needed.
+     */
+    public void sendPartialRequestOnNextUpdate() {
+        synchronized (fStatisticsRangeUpdateSyncObj) {
+            fSendRangeRequest = true;
+        }
+    }
+
     /**
      * Focus on the statistics tree of the viewer
      */
index 3504a44f76dd9aea4fa1371961d124bef1c64ab9..f81d785de1b782789e23b17f8c11ee7e140dac57 100755 (executable)
@@ -164,6 +164,22 @@ public class TmfStatisticsView extends TmfView {
                     fExperiment.endSynch(new TmfEndSynchSignal(0));
                     fRequestData = false;
                 }
+            } else {
+                /*
+                 * If the same experiment is reselected, sends a notification to
+                 * the viewers to make sure they reload correctly their partial
+                 * event count.
+                 */
+                TmfStatisticsViewer statsViewer;
+                for (ITmfViewer viewer : fStatsViewers.getViewers()) {
+                    if (!(viewer instanceof TmfStatisticsViewer)) {
+                        Activator.getDefault().logError("Error - cannot cast viewer to a statistics viewer"); //$NON-NLS-1$
+                        continue;
+                    }
+                    statsViewer = (TmfStatisticsViewer) viewer;
+                    // Will update the partial event count if needed.
+                    statsViewer.sendPartialRequestOnNextUpdate();
+                }
             }
         }
     }
This page took 0.056499 seconds and 5 git commands to generate.