From 76be6c0057085b6263c863d5f2bfaee037082a37 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Tue, 29 Sep 2015 10:34:31 -0400 Subject: [PATCH] lttng: Add possibility to remove latency listener from latency view Also, store the listener in a ListenerList instead of a HashSet. Change-Id: Ia8a7d272db34f09bfc457f74c98b5b928b6a82d7 Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/56962 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- .../linux/core/latency/LatencyAnalysis.java | 1 - .../AbstractSegmentStoreAnalysisModule.java | 25 +++++++++++++++---- ...bstractSegmentStoreScatterGraphViewer.java | 2 +- .../AbstractSegmentStoreTableViewer.java | 5 ++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/LatencyAnalysis.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/LatencyAnalysis.java index 99fbeb68ad..31657bd96f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/LatencyAnalysis.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/LatencyAnalysis.java @@ -49,7 +49,6 @@ public class LatencyAnalysis extends AbstractSegmentStoreAnalysisModule { private static final Collection BASE_ASPECTS = checkNotNull(ImmutableList.of(SyscallNameAspect.INSTANCE)); - @Override public String getId() { return ID; diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java index ba5fff2d4a..c949c04de7 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java @@ -16,11 +16,12 @@ import java.io.ObjectOutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ListenerList; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; @@ -47,7 +48,7 @@ import com.google.common.collect.ImmutableList; */ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnalysisModule { - private final Set fListeners = new HashSet<>(); + private final ListenerList fListeners = new ListenerList(ListenerList.IDENTITY); private @Nullable ISegmentStore fSegmentStore; @@ -63,12 +64,26 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal fListeners.add(listener); } + /** + * Removes a listener for the viewers + * + * @param listener + * listener for each type of viewer to remove + */ + public void removeListener(IAnalysisProgressListener listener) { + fListeners.remove(listener); + } + /** * Returns all the listeners - * @return latency listners + * @return latency listeners */ protected Iterable getListeners() { - return fListeners; + List listeners = new ArrayList<>(); + for (Object listener : fListeners.getListeners()) { + listeners.add((IAnalysisProgressListener) listener); + } + return listeners; } /** diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java index 30abb1ed30..b56877d2b7 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java @@ -493,7 +493,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL if (TmfTraceManager.getInstance().getActiveTrace() == null) { AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule(); if (analysis != null) { - // TODO remove listener analysis. + analysis.removeListener(fListener); } clearContent(); } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java index 91a5ca2266..eaea28fcca 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java @@ -345,6 +345,11 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView getTableViewer().setInput(null); refresh(); } + + AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule(); + if ((analysis != null)) { + analysis.removeListener(fListener); + } } } } -- 2.34.1