Make Custom Parser trace type backwards compatible to Linux Tools
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / project / model / TmfTraceElement.java
index 8daf7095ed1603a01c2797c668149cd5a309298e..a4187a4480c18ce07799900de9fa4ef273e64675 100644 (file)
@@ -241,22 +241,25 @@ public class TmfTraceElement extends TmfCommonProjectElement implements IActionF
             // make sure that supplementary folder exists
             refreshSupplementaryFolder();
 
-            if (getTraceType() != null) {
-                if (getTraceType().startsWith(CustomTxtTrace.class.getCanonicalName())) {
+            String traceTypeId = getTraceType();
+            if (traceTypeId != null) {
+                if (CustomTxtTrace.isCustomTraceTypeId(traceTypeId)) {
                     for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
-                        if (getTraceType().equals(CustomTxtTrace.class.getCanonicalName() + ':' + def.categoryName+ ':' + def.definitionName)) {
+                        String id = CustomTxtTrace.buildTraceTypeId(def.categoryName, def.definitionName);
+                        if (traceTypeId.equals(id)) {
                             return new CustomTxtTrace(def);
                         }
                     }
                 }
-                if (getTraceType().startsWith(CustomXmlTrace.class.getCanonicalName())) {
+                if (CustomXmlTrace.isCustomTraceTypeId(traceTypeId)) {
                     for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
-                        if (getTraceType().equals(CustomXmlTrace.class.getCanonicalName() + ':' + def.categoryName+ ':' + def.definitionName)) {
+                        String id = CustomXmlTrace.buildTraceTypeId(def.categoryName, def.definitionName);
+                        if (traceTypeId.equals(id)) {
                             return new CustomXmlTrace(def);
                         }
                     }
                 }
-                IConfigurationElement ce = sfTraceTypeAttributes.get(getTraceType());
+                IConfigurationElement ce = sfTraceTypeAttributes.get(traceTypeId);
                 if (ce == null) {
                     return null;
                 }
@@ -277,22 +280,25 @@ public class TmfTraceElement extends TmfCommonProjectElement implements IActionF
      */
     public ITmfEvent instantiateEvent() {
         try {
-            if (getTraceType() != null) {
-                if (getTraceType().startsWith(CustomTxtTrace.class.getCanonicalName())) {
+            String traceTypeId = getTraceType();
+            if (traceTypeId != null) {
+                if (CustomTxtTrace.isCustomTraceTypeId(traceTypeId)) {
                     for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
-                        if (getTraceType().equals(CustomTxtTrace.class.getCanonicalName() + ':' + def.categoryName+ ':' + def.definitionName)) {
+                        String id = CustomTxtTrace.buildTraceTypeId(def.categoryName, def.definitionName);
+                        if (traceTypeId.equals(id)) {
                             return new CustomTxtEvent(def);
                         }
                     }
                 }
-                if (getTraceType().startsWith(CustomXmlTrace.class.getCanonicalName())) {
+                if (CustomXmlTrace.isCustomTraceTypeId(traceTypeId)) {
                     for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
-                        if (getTraceType().equals(CustomXmlTrace.class.getCanonicalName() + ':' + def.categoryName+ ':' + def.definitionName)) {
+                        String id = CustomXmlTrace.buildTraceTypeId(def.categoryName, def.definitionName);
+                        if (traceTypeId.equals(id)) {
                             return new CustomXmlEvent(def);
                         }
                     }
                 }
-                IConfigurationElement ce = sfTraceTypeAttributes.get(getTraceType());
+                IConfigurationElement ce = sfTraceTypeAttributes.get(traceTypeId);
                 if (ce == null) {
                     return null;
                 }
@@ -307,13 +313,12 @@ public class TmfTraceElement extends TmfCommonProjectElement implements IActionF
 
     @Override
     public String getEditorId() {
-        if (getTraceType() != null) {
-            if (getTraceType().startsWith(CustomTxtTrace.class.getCanonicalName())) {
-                return TmfEventsEditor.ID;
-            }
-            if (getTraceType().startsWith(CustomXmlTrace.class.getCanonicalName())) {
+        String traceTypeId = getTraceType();
+        if (traceTypeId != null) {
+            if (CustomTxtTrace.isCustomTraceTypeId(traceTypeId) || CustomXmlTrace.isCustomTraceTypeId(traceTypeId)) {
                 return TmfEventsEditor.ID;
             }
+
             IConfigurationElement ce = sfTraceTypeUIAttributes.get(getTraceType());
             if (ce == null) {
                 /* This trace type does not define UI attributes */
This page took 0.026514 seconds and 5 git commands to generate.