From edb7c563f38ca97e5088278bcf043d3655eda52f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Wed, 19 Oct 2016 09:55:08 -0400 Subject: [PATCH] timing: Make scatter viewer update only once MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Before, it was updated when the parent's windowRangeUpdated requested an updateContent and when the viewer itself requested and updateRange, also in the windowRangeUpdated signal. Now the updateRange method overrides the updateContent, so the update is done once only. Change-Id: I8b92367f441c0db62e70e7cc7f2a7c7251b2e598 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/83526 Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam Reviewed-by: Hudson CI --- ...bstractSegmentStoreScatterGraphViewer.java | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java index e55fbe0780..f8b680ef75 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java @@ -31,7 +31,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat; -import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator; import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.scatter.Messages; import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.scatter.SegmentStoreScatterGraphTooltipProvider; @@ -43,7 +42,6 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; -import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; @@ -71,11 +69,13 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL private final class CompactingSegmentStoreQuery extends Job { private static final long MAX_POINTS = 1000; - private final TmfTimeRange fCurrentRange; + private final long fStart; + private final long fEnd; - private CompactingSegmentStoreQuery(TmfTimeRange currentRange) { + private CompactingSegmentStoreQuery(long start, long end) { super(Messages.SegmentStoreScatterGraphViewer_compactTitle); - fCurrentRange = currentRange; + fStart = start; + fEnd = end; } @Override @@ -87,31 +87,25 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL } ISegmentStoreProvider segmentProvider = getSegmentProvider(); - final long startTimeInNanos = fCurrentRange.getStartTime().toNanos(); - final long endTimeInNanos = fCurrentRange.getEndTime().toNanos(); + final long startTime = fStart; + final long endTime = fEnd; if (segmentProvider == null) { - setWindowRange(startTimeInNanos, endTimeInNanos); - redraw(statusMonitor, startTimeInNanos, startTimeInNanos, Collections.EMPTY_LIST); + redraw(statusMonitor, startTime, startTime, Collections.EMPTY_LIST); return new Status(IStatus.WARNING, Activator.PLUGIN_ID, "segment provider not available"); //$NON-NLS-1$ } final ISegmentStore segStore = segmentProvider.getSegmentStore(); if (segStore == null) { - setWindowRange(startTimeInNanos, endTimeInNanos); - redraw(statusMonitor, startTimeInNanos, startTimeInNanos, Collections.EMPTY_LIST); + redraw(statusMonitor, startTime, startTime, Collections.EMPTY_LIST); return new Status(IStatus.INFO, Activator.PLUGIN_ID, "Segment provider does not have segments"); //$NON-NLS-1$ } - final long startTime = fCurrentRange.getStartTime().getValue(); - final long endTime = fCurrentRange.getEndTime().getValue(); fPixelStart = startTime; fPixelSize = Math.max(1, (endTime - startTime) / MAX_POINTS); final Iterable intersectingElements = segStore.getIntersectingElements(startTime, endTime); - final List list = convertIterableToList(intersectingElements, statusMonitor); final List displayData = (!list.isEmpty()) ? compactList(startTime, list, statusMonitor) : list; - setWindowRange(startTimeInNanos, endTimeInNanos); redraw(statusMonitor, startTime, endTime, displayData); if (statusMonitor.isCanceled()) { @@ -310,7 +304,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL fDisplayData = list; } setWindowRange(currentStart, currentEnd); - updateRange(currentRange); + updateContent(); } @Override @@ -425,7 +419,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL timeRange.getStartTime().toNanos(), timeRange.getEndTime().toNanos()); setData(getSegmentStoreProvider(trace)); - updateRange(timeRange); + updateContent(); } } @@ -454,9 +448,10 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL } - private void updateRange(final @Nullable TmfTimeRange timeRange) { + @Override + protected void updateContent() { /* - * Update is request, content is not up to date, fDirty will be + * Update is requested, content is not up to date, fDirty will be * decremented in the compacting job */ fDirty.incrementAndGet(); @@ -464,7 +459,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL if (compactingJob != null && compactingJob.getState() == Job.RUNNING) { compactingJob.cancel(); } - compactingJob = new CompactingSegmentStoreQuery(NonNullUtils.checkNotNull(timeRange)); + compactingJob = new CompactingSegmentStoreQuery(getWindowStartTime(), getWindowEndTime()); fCompactingJob = compactingJob; compactingJob.schedule(); } @@ -490,25 +485,6 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL refresh(); } - /** - * @param signal - * Signal received when window range is updated - */ - @Override - @TmfSignalHandler - public void windowRangeUpdated(@Nullable TmfWindowRangeUpdatedSignal signal) { - super.windowRangeUpdated(signal); - if (signal == null) { - return; - } - if (getTrace() != null) { - final TmfTimeRange currentRange = signal.getCurrentRange(); - updateRange(currentRange); - } else { - Activator.getDefault().logInfo("No Trace to update"); //$NON-NLS-1$ - } - } - private @Nullable ISegmentStoreProvider getSegmentProvider() { return fSegmentProvider; } -- 2.34.1