Search in sources :

Example 11 with ITmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.

the class XmlXyDataProviderTest method testXYDataProviderDelta.

/**
 * Test getting the XML XY data provider for one trace, with an analysis that
 * applies to a trace, and requesting relative values (delta) for the y axis.
 *
 * @throws IOException
 *             Exception thrown by analyses
 */
@Test
public void testXYDataProviderDelta() throws IOException {
    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);
        ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> xyProvider = XmlDataProviderManager.getInstance().getXyProvider(trace, viewElement);
        assertNotNull(xyProvider);
        List<String> expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedXYTree"));
        Map<Long, String> tree = assertAndGetTree(xyProvider, trace, expectedStrings);
        expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedXYDataDelta"));
        assertRows(xyProvider, tree, expectedStrings);
    } finally {
        trace.dispose();
        TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) Element(org.w3c.dom.Element) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 12 with ITmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.

the class XmlXyDataProviderTest method testXYDataProvider.

/**
 * Test getting the XML data provider for one trace, with an analysis that
 * applies to a trace
 *
 * @throws IOException
 *             Exception thrown by analyses
 */
@Test
public void testXYDataProvider() throws IOException {
    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);
        assertNotNull(viewElement);
        ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> xyProvider = XmlDataProviderManager.getInstance().getXyProvider(trace, viewElement);
        assertNotNull(xyProvider);
        List<String> expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedXYTree"));
        Map<Long, String> tree = assertAndGetTree(xyProvider, trace, expectedStrings);
        expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedXYData"));
        assertRows(xyProvider, tree, expectedStrings);
    } finally {
        trace.dispose();
        TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) Element(org.w3c.dom.Element) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 13 with ITmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.

the class DataProviderManagerTest method testGetter.

/**
 * Test different get methods
 */
@SuppressWarnings("unchecked")
@Test
public void testGetter() {
    ITmfTrace trace = fKernelTrace;
    assertNotNull(trace);
    ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> dp = DataProviderManager.getInstance().getExistingDataProvider(trace, CPU_USAGE_DP_ID, ITmfTreeXYDataProvider.class);
    assertNull(dp);
    dp = DataProviderManager.getInstance().getOrCreateDataProvider(trace, CPU_USAGE_DP_ID, ITmfTreeXYDataProvider.class);
    assertNotNull(dp);
    ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> dp2 = DataProviderManager.getInstance().getExistingDataProvider(trace, CPU_USAGE_DP_ID, ITmfTreeXYDataProvider.class);
    assertNotNull(dp2);
    assertTrue(dp == dp2);
    ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> dp3 = DataProviderManager.getInstance().getOrCreateDataProvider(trace, CPU_USAGE_DP_ID, ITmfTreeXYDataProvider.class);
    assertNotNull(dp3);
    assertTrue(dp == dp3);
    assertTrue(dp == dp2);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) ITmfTreeXYDataProvider(org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider) Test(org.junit.Test)

Example 14 with ITmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.

the class CounterDataProviderFactory method createProvider.

/**
 * @since 2.0
 */
@Override
@Nullable
public ITmfTreeXYDataProvider<? extends ITmfTreeDataModel> createProvider(ITmfTrace trace) {
    Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(trace);
    if (traces.size() == 1) {
        List<ITmfTreeXYDataProvider<TmfTreeDataModel>> dataProviders = new ArrayList<>();
        for (CounterAnalysis module : TmfTraceUtils.getAnalysisModulesOfClass(trace, CounterAnalysis.class)) {
            ITmfTrace subTrace = module.getTrace();
            ITmfTreeXYDataProvider<TmfTreeDataModel> provider = CounterDataProvider.create(Objects.requireNonNull(subTrace), module);
            if (provider != null) {
                dataProviders.add(provider);
            }
        }
        if (dataProviders.isEmpty()) {
            return null;
        } else if (dataProviders.size() == 1) {
            return dataProviders.get(0);
        }
        return new TmfTreeXYCompositeDataProvider<>(dataProviders, TITLE, CounterDataProvider.ID);
    }
    return TmfTreeXYCompositeDataProvider.create(traces, TITLE, CounterDataProvider.ID);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTreeXYCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.xy.TmfTreeXYCompositeDataProvider) CounterAnalysis(org.eclipse.tracecompass.analysis.counters.core.CounterAnalysis) ArrayList(java.util.ArrayList) ITmfTreeXYDataProvider(org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 15 with ITmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.

the class ResourcesView method fillTimeEventContextMenu.

@Override
protected void fillTimeEventContextMenu(@NonNull IMenuManager menuManager) {
    ISelection selection = getSite().getSelectionProvider().getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sSel = (IStructuredSelection) selection;
        if (sSel.getFirstElement() instanceof TimeGraphEntry) {
            TimeGraphEntry resourcesEntry = (TimeGraphEntry) sSel.getFirstElement();
            ITmfTreeDataModel model = resourcesEntry.getEntryModel();
            if (sSel.toArray()[1] instanceof NamedTimeEvent && ((ResourcesEntryModel) model).getType() == Type.CURRENT_THREAD) {
                ITmfTrace trace = getTrace(resourcesEntry);
                NamedTimeEvent event = (NamedTimeEvent) sSel.toArray()[1];
                TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
                HostThread data = (HostThread) ctx.getData(HostThread.SELECTED_HOST_THREAD_KEY);
                if (data != null) {
                    menuManager.add(new UnfollowThreadAction(ResourcesView.this));
                } else {
                    menuManager.add(new FollowThreadAction(ResourcesView.this, null, event.getValue(), trace));
                }
            }
        }
    }
    super.fillTimeEventContextMenu(menuManager);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) HostThread(org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) FollowThreadAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction) ISelection(org.eclipse.jface.viewers.ISelection) UnfollowThreadAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.UnfollowThreadAction) ResourcesEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) NamedTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent)

Aggregations

ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)20 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)9 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)8 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)7 ArrayList (java.util.ArrayList)4 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)4 Test (org.junit.Test)4 ISelection (org.eclipse.jface.viewers.ISelection)3 ResourcesEntryModel (org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel)3 ModuleEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel)3 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)3 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)3 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)3 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)3 ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)3 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)3 Element (org.w3c.dom.Element)3 HashMap (java.util.HashMap)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 Nullable (org.eclipse.jdt.annotation.Nullable)2