From: Mathieu Denis Date: Wed, 22 Aug 2012 21:34:50 +0000 (-0400) Subject: tmf: Correct the statistics partial event count X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=3c934968638ac80923b6feac74fa8889e028fbd0;p=deliverable%2Ftracecompass.git tmf: Correct the statistics partial event count 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 Reviewed-on: https://git.eclipse.org/r/7357 Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir --- diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java index f2770b69f6..d15f0f281b 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java @@ -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 */ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java index 3504a44f76..f81d785de1 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java @@ -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(); + } } } }