From 715154b141be7428eff165b42f224d5e78e72ba4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Fri, 13 Jun 2014 15:18:50 -0400 Subject: [PATCH] TMF: Register analysis module to parameter provider only if trace active MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Sometimes a module will register itself to a parameter provider, but it does not correspond to the currently active trace, especially for modules from both traces and experiments. This registers only the module for the currently selected trace. Change-Id: If29264c3823968530063cba4c6edd18c679baf69 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/29356 Tested-by: Hudson CI --- .../META-INF/MANIFEST.MF | 2 +- org.eclipse.linuxtools.tmf.core/pom.xml | 2 +- .../analysis/TmfAbstractAnalysisModule.java | 21 +++++++++++++++++++ .../TmfAbstractAnalysisParamProvider.java | 15 ++++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF index 21f1670900..819a5ca821 100644 --- a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor -Bundle-Version: 3.0.0.qualifier +Bundle-Version: 3.1.0.qualifier Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core;singleton:=true Bundle-Activator: org.eclipse.linuxtools.internal.tmf.core.Activator diff --git a/org.eclipse.linuxtools.tmf.core/pom.xml b/org.eclipse.linuxtools.tmf.core/pom.xml index 595239641a..c4e4a511bd 100644 --- a/org.eclipse.linuxtools.tmf.core/pom.xml +++ b/org.eclipse.linuxtools.tmf.core/pom.xml @@ -18,7 +18,7 @@ org.eclipse.linuxtools.tmf.core - 3.0.0-SNAPSHOT + 3.1.0-SNAPSHOT eclipse-plugin Linux Tools TMF Core Plug-in diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java index fefb3a4b20..4747c733e1 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java @@ -33,6 +33,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfStartAnalysisSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal; +import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; import org.eclipse.osgi.util.NLS; @@ -382,6 +383,26 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements } } + /** + * Signal handler for when the trace becomes active + * + * @param signal + * Trace selected signal + * @since 3.1 + */ + @TmfSignalHandler + public void traceSelected(TmfTraceSelectedSignal signal) { + /* + * Since some parameter providers may handle many traces, we need to + * register the current trace to it + */ + if (signal.getTrace() == fTrace) { + for (IAnalysisParameterProvider provider : fParameterProviders) { + provider.registerModule(this); + } + } + } + /** * Returns a full help text to display * diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java index cec9f213e3..7f56b5d221 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisParamProvider.java @@ -12,6 +12,9 @@ package org.eclipse.linuxtools.tmf.core.analysis; +import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; + /** * Abstract class for parameter providers, implements methods and * functionalities to warn the analysis module of parameter changed @@ -31,7 +34,17 @@ public abstract class TmfAbstractAnalysisParamProvider implements IAnalysisParam if (module == null) { throw new IllegalArgumentException(); } - fModule = module; + ITmfTrace selectedTrace = TmfTraceManager.getInstance().getActiveTrace(); + /* If no trace is active, just register the module */ + if (selectedTrace == null) { + fModule = module; + return; + } + IAnalysisModule selectedModule = selectedTrace.getAnalysisModule(module.getId()); + /* register only if the module is for the currently selected trace */ + if (selectedModule == module) { + fModule = module; + } } /** -- 2.34.1