use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu in project tracecompass by tracecompass.
the class XmlDataProviderManager method getXyProviderFactory.
/**
* Create (if necessary) and get the {@link DataDrivenXYProviderFactory} for
* the specified trace and viewElement.
*
* @param viewElement
* the XML XY view element for which we are querying a provider
* @return the unique instance of an XY provider for the queried parameters
*/
@Nullable
public synchronized DataDrivenXYProviderFactory getXyProviderFactory(Element viewElement) {
if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
return null;
}
String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
// factory that can be null
if (fXYFactories.containsKey(viewId)) {
return fXYFactories.get(viewId);
}
// Create with the trace or experiment first
DataDrivenXYProviderFactory factory = null;
TmfXmlXYViewCu tgViewCu = TmfXmlXYViewCu.compile(new AnalysisCompilationData(), viewElement);
if (tgViewCu != null) {
factory = tgViewCu.generate();
}
fXYFactories.put(viewId, factory);
return factory;
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu in project tracecompass by tracecompass.
the class XmlXyDataProviderTest method testXYFactory.
/**
* Test the {@link DataDrivenXYProviderFactory} class
*/
@Test
public void testXYFactory() {
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.XY_VIEW, XY_VIEW_ID_DELTA);
assertNotNull(viewElement);
TmfXmlXYViewCu tgViewCu = TmfXmlXYViewCu.compile(new AnalysisCompilationData(), viewElement);
assertNotNull(tgViewCu);
DataDrivenXYProviderFactory XYFactory = tgViewCu.generate();
// Test the factory with a simple trace
ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> provider = XYFactory.create(trace);
assertNotNull(provider);
assertEquals(DataDrivenXYDataProvider.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 = DataDrivenXYProviderFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), getEntries(new AnalysisCompilationData(), viewElement), ANALYSIS_ID);
assertNotNull(provider);
assertEquals(ANALYSIS_ID, provider.getId());
} finally {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
Aggregations