Search in sources :

Example 1 with CustomTxtEvent

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;
}
Also used : CustomTxtEvent(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtEvent) CustomXmlEvent(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlEvent) CustomXmlTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition) CoreException(org.eclipse.core.runtime.CoreException) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) CustomTxtTraceDefinition(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)1 CustomTxtEvent (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtEvent)1 CustomTxtTraceDefinition (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition)1 CustomXmlEvent (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlEvent)1 CustomXmlTraceDefinition (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition)1