use of org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtEvent in project tracecompass by tracecompass.
the class TmfTraceElement method instantiateEvent.
/**
* Instantiate a <code>ITmfEvent</code> object based on the trace type and
* the corresponding extension.
*
* @return the <code>ITmfEvent</code> or <code>null</code> for an error
*/
public ITmfEvent instantiateEvent() {
try {
String traceTypeId = getTraceType();
if (traceTypeId != null) {
if (CustomTxtTrace.isCustomTraceTypeId(traceTypeId)) {
for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
String id = CustomTxtTrace.buildTraceTypeId(def.categoryName, def.definitionName);
if (traceTypeId.equals(id)) {
return new CustomTxtEvent(def);
}
}
}
if (CustomXmlTrace.isCustomTraceTypeId(traceTypeId)) {
for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
String id = CustomXmlTrace.buildTraceTypeId(def.categoryName, def.definitionName);
if (traceTypeId.equals(id)) {
return new CustomXmlEvent(def);
}
}
}
IConfigurationElement ce = TRACE_TYPE_ATTRIBUTES.get(traceTypeId);
if (ce == null) {
return null;
}
ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);
return event;
}
} catch (CoreException e) {
// $NON-NLS-1$
Activator.getDefault().logError("Error instantiating ITmfEvent object for trace " + getName(), e);
}
return null;
}
Aggregations