use of org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType.TraceElementType in project tracecompass by tracecompass.
the class TmfTraceTypeUIUtils method getEventTable.
/**
* Get the Event Table type specified by the trace type's extension point,
* if there is one.
*
* @param trace
* The trace for which we want the events table.
* @param parent
* The parent composite that the event table will have
* @param cacheSize
* The cache size to use with this event table. Should be defined
* by the trace type.
* @return The corresponding Event Table, or 'null' if this trace type did
* not specify any.
*/
@Nullable
public static TmfEventsTable getEventTable(ITmfTrace trace, Composite parent, int cacheSize) {
final String traceType = getTraceType(trace);
if (traceType == null) {
return null;
}
TraceElementType elType = (trace instanceof TmfExperiment) ? TraceElementType.EXPERIMENT : TraceElementType.TRACE;
for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(elType)) {
if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(traceType)) {
final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceTypeUIUtils.EVENTS_TABLE_TYPE_ELEM);
if (eventsTableTypeCE.length != 1) {
break;
}
final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.CLASS_ATTR);
final boolean useTraceAspects = Boolean.parseBoolean(eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.USE_TRACE_ASPECTS_ATTR));
if ((eventsTableType == null) || eventsTableType.isEmpty()) {
break;
}
try {
final Bundle bundle = Platform.getBundle(ce.getContributor().getName());
final Class<?> c = bundle.loadClass(eventsTableType);
Class<?>[] constructorArgs = null;
Object[] args = null;
if (useTraceAspects) {
args = new Object[] { parent, cacheSize, trace.getEventAspects() };
constructorArgs = new Class[] { Composite.class, int.class, Iterable.class };
} else {
args = new Object[] { parent, cacheSize };
constructorArgs = new Class[] { Composite.class, int.class };
}
final Constructor<?> constructor = c.getConstructor(constructorArgs);
return (TmfEventsTable) constructor.newInstance(args);
} catch (NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
return null;
}
}
}
return null;
}
use of org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType.TraceElementType in project tracecompass by tracecompass.
the class TmfTraceTypeUIUtils method getPerspectiveId.
/**
* Get the perspective id specified by the trace type's extension point, if
* there is one.
*
* @param trace
* The trace for which we want the perspective id.
* @return The corresponding perspective id, or 'null' if this trace type
* did not specify any.
* @since 2.3
*/
@Nullable
public static String getPerspectiveId(ITmfTrace trace) {
final String traceType = getTraceType(trace);
if (traceType == null) {
return null;
}
TraceElementType elType = (trace instanceof TmfExperiment) ? TraceElementType.EXPERIMENT : TraceElementType.TRACE;
for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(elType)) {
if (ce.getAttribute(TRACETYPE_ATTR).equals(traceType)) {
final IConfigurationElement[] perspectiveCE = ce.getChildren(PERSPECTIVE_ELEM);
if (perspectiveCE.length != 1) {
break;
}
final String perspectiveId = perspectiveCE[0].getAttribute(ID_ATTR);
if (!perspectiveId.isEmpty()) {
return perspectiveId;
}
break;
}
}
return null;
}
Aggregations