tmf: Bug 494767: Events in selection not updated in Statistics view
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / internal / tmf / ui / viewers / statistics / StatisticsUpdateJob.java
index 1b8e9cbdff2354f4d9173fc4e8d2b5e78846c31d..ed2e010a55180bda042a790a2be1229e2684b808 100644 (file)
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.piecharts.model.TmfPieChartStatisticsModel;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeManager;
+import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.tmf.core.statistics.ITmfStatistics;
 import org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsEventTypesModule;
@@ -77,7 +78,9 @@ class StatisticsUpdateJob extends Job {
     protected IStatus run(IProgressMonitor monitor) {
 
         /* Wait until the analysis is ready to be queried */
-        fStatsMod.waitForInitialization();
+        if (!fStatsMod.waitForInitialization()) {
+            return Status.CANCEL_STATUS;
+        }
         ITmfStatistics stats = fStatsMod.getStatistics();
         if (stats == null) {
             /* It should have worked, but didn't */
@@ -173,9 +176,17 @@ class StatisticsUpdateJob extends Job {
          * </pre>
          */
 
-        /* Fill in an the event counts (either cells C or D) */
-        for (Map.Entry<String, Long> entry : map.entrySet()) {
-            statsData.setTypeCount(name, entry.getKey(), fIsGlobal, entry.getValue());
+        if (map.isEmpty() && !fIsGlobal) {
+            /* Reset all time range event counts (cells D) */
+            TmfStatisticsTreeNode eventTypeNode = statsData.getNode(name, TmfStatisticsTree.HEADER_EVENT_TYPES);
+            if (eventTypeNode != null) {
+                eventTypeNode.resetTimeRangeValue();
+            }
+        } else {
+            /* Fill in the event counts (either cells C or D) */
+            for (Map.Entry<String, Long> entry : map.entrySet()) {
+                statsData.setTypeCount(name, entry.getKey(), fIsGlobal, entry.getValue());
+            }
         }
 
         /*
This page took 0.041147 seconds and 5 git commands to generate.