use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu in project tracecompass by tracecompass.
the class XmlDataProviderManager method getTimeGraphProviderFactory.
/**
* Create (if necessary) and get the
* {@link DataDrivenTimeGraphProviderFactory} from the viewElement.
*
* @param viewElement
* the XML time graph view element for which we are querying a
* provider
* @return the unique instance of a time graph provider for the queried
* parameters
*/
@Nullable
public synchronized DataDrivenTimeGraphProviderFactory getTimeGraphProviderFactory(Element viewElement) {
if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
return null;
}
String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
// factory that can be null
if (fTimeGraphFactories.containsKey(viewId)) {
return fTimeGraphFactories.get(viewId);
}
// Create with the trace or experiment first
DataDrivenTimeGraphProviderFactory factory = null;
TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
if (tgViewCu != null) {
factory = tgViewCu.generate();
}
fTimeGraphFactories.put(viewId, factory);
return factory;
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu in project tracecompass by tracecompass.
the class XmlTimeGraphDataProviderTest method testFactory.
/**
* Test the {@link DataDrivenTimeGraphProviderFactory} class
*/
@Test
public void testFactory() {
ITmfTrace trace = getTrace();
assertNotNull(trace);
try {
runModule(trace);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.DATA_PROVIDER_SIMPLE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TIME_GRAPH_VIEW_ID);
assertNotNull(viewElement);
TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
assertNotNull(tgViewCu);
DataDrivenTimeGraphProviderFactory timeGraphFactory = tgViewCu.generate();
// Test the factory with a simple trace
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider = timeGraphFactory.create(trace);
assertNotNull(provider);
assertEquals(DataDrivenTimeGraphDataProvider.ID, provider.getId());
// Test the factory with an ID and state system
ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, ANALYSIS_ID);
assertNotNull(module);
Iterable<@NonNull ITmfStateSystem> stateSystems = module.getStateSystems();
assertNotNull(stateSystems);
provider = DataDrivenTimeGraphProviderFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), getEntries(new AnalysisCompilationData(), viewElement), getvalues(viewElement), ANALYSIS_ID);
assertNotNull(provider);
assertEquals(ANALYSIS_ID, provider.getId());
} finally {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu in project tracecompass by tracecompass.
the class XmlDataProviderManager method getTimeGraphProvider.
/**
* Create (if necessary) and get the time graph data provider for the
* specified trace and viewElement.
*
* @param trace
* trace for which we are querying a provider
* @param viewElement
* the XML time graph view element for which we are querying a
* provider
* @return the unique instance of a time graph provider for the queried
* parameters
*/
@Nullable
public synchronized ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> getTimeGraphProvider(ITmfTrace trace, Element viewElement) {
if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
return null;
}
String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider = fTimeGraphProviders.get(trace, viewId);
if (provider != null) {
return provider;
}
if (Iterables.any(TmfTraceManager.getInstance().getOpenedTraces(), opened -> TmfTraceManager.getTraceSetWithExperiment(opened).contains(trace))) {
// Create with the trace or experiment first
TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
if (tgViewCu != null) {
DataDrivenTimeGraphProviderFactory timeGraphFactory = tgViewCu.generate();
provider = timeGraphFactory.create(trace);
if (provider == null) {
// composite if that's the case
if (trace instanceof TmfExperiment) {
provider = generateExperimentProviderTimeGraph(TmfTraceManager.getTraceSet(trace), viewElement);
}
}
if (provider != null) {
fTimeGraphProviders.put(trace, viewId, provider);
}
return provider;
}
}
return null;
}
Aggregations