Search in sources :

Example 1 with TmfXmlXYViewCu

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;
}
Also used : TmfXmlXYViewCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with TmfXmlXYViewCu

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));
    }
}
Also used : DataDrivenXYProviderFactory(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYProviderFactory) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfXmlXYViewCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) Element(org.w3c.dom.Element) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Aggregations

AnalysisCompilationData (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData)2 TmfXmlXYViewCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu)2 Nullable (org.eclipse.jdt.annotation.Nullable)1 DataDrivenXYProviderFactory (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYProviderFactory)1 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)1 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)1 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)1 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1