From e86f7ac47671258d3c7da678217b630f8fea8dec Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Wed, 4 Feb 2015 09:19:48 -0500 Subject: [PATCH] Make XML analysis using custom parsers backwards compatible Change-Id: I96d8c349db4beae868aa611252775724ba82412e Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/41077 Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann --- .../ui/module/TmfAnalysisModuleHelperXml.java | 1 + .../tmf/core/project/model/TmfTraceType.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java index 68a3829869..66120c398b 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java @@ -139,6 +139,7 @@ public class TmfAnalysisModuleHelperXml implements IAnalysisModuleHelper { for (Element element : elements) { String traceTypeId = element.getAttribute(TmfXmlStrings.ID); + traceTypeId = TmfTraceType.buildCompatibilityTraceTypeId(traceTypeId); TraceTypeHelper helper = TmfTraceType.getTraceType(traceTypeId); if ((helper != null) && helper.getTrace().getClass().isAssignableFrom(traceClass)) { return true; diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/project/model/TmfTraceType.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/project/model/TmfTraceType.java index 34b90361f5..6e331b08f8 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/project/model/TmfTraceType.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/project/model/TmfTraceType.java @@ -585,6 +585,28 @@ public final class TmfTraceType { */ public static String getTraceTypeId(IResource resource) throws CoreException { String traceTypeId = resource.getPersistentProperties().get(TmfCommonConstants.TRACETYPE); + return buildCompatibilityTraceTypeId(traceTypeId); + } + + /** + * This methods builds a trace type ID from a given ID taking into + * consideration any format changes that were done for the IDs of custom + * text or XML traces. For example, such format change took place when + * moving to Trace Compass. Trace type IDs that are part of the plug-in + * extension for trace types won't be changed. + * + * This method is useful for IDs that were persisted in the workspace before + * the format changes (e.g. in the persistent properties of a trace + * resource). + * + * It ensures backwards compatibility of the workspace for custom text and + * XML traces. + * + * @param traceTypeId + * the legacy trace type ID + * @return the trace type ID in Trace Compass format + */ + public static String buildCompatibilityTraceTypeId(String traceTypeId) { // Fix custom trace type id with old class name or without category name for backward compatibility if (traceTypeId != null) { String newTraceType = CustomTxtTrace.buildCompatibilityTraceTypeId(traceTypeId); -- 2.34.1