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));
}
}
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));
}
}
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);
}
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);
}
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);
}
Aggregations