use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal in project tracecompass by tracecompass.
the class XmlDataProviderManagerTest method testOneTrace.
/**
* Test getting the XML data provider for one trace, with an analysis that
* applies to a trace
*/
@Test
public void testOneTrace() {
ITmfTrace trace = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
((TmfTrace) trace).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
assertNotNull(timeGraphProvider);
} finally {
if (trace != null) {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal in project tracecompass by tracecompass.
the class XmlDataProviderManagerTest method testExperimentWithTraceAnalysis.
/**
* Test getting the XML data provider for an experiment, with an analysis that
* applies to a trace
*/
@Test
public void testExperimentWithTraceAnalysis() {
ITmfTrace trace = null;
ITmfTrace trace2 = null;
ITmfTrace experiment = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
trace2 = XmlUtilsTest.initializeTrace(TEST_TRACE2);
ITmfTrace[] traces = { trace, trace2 };
experiment = new TmfExperiment(ITmfEvent.class, "Xml Experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, experiment, null);
((TmfTrace) trace).traceOpened(signal);
((TmfTrace) trace2).traceOpened(signal);
((TmfTrace) experiment).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
Iterable<@NonNull DataDrivenAnalysisModule> modules = TmfTraceUtils.getAnalysisModulesOfClass(experiment, DataDrivenAnalysisModule.class);
modules.forEach(module -> {
module.schedule();
assertTrue(module.waitForCompletion());
});
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(experiment, viewElement);
assertNotNull(timeGraphProvider);
assertTrue(timeGraphProvider instanceof TmfTimeGraphCompositeDataProvider);
} finally {
if (trace != null) {
trace.dispose();
}
if (trace2 != null) {
trace2.dispose();
}
if (experiment != null) {
experiment.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, experiment));
}
}
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal in project tracecompass by tracecompass.
the class XmlTimeGraphDataProviderTest method testTwoLevels.
/**
* 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 testTwoLevels() 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.TIME_GRAPH_VIEW, TIME_GRAPH_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
assertNotNull(timeGraphProvider);
List<String> expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedTimeGraphTree"));
Map<Long, String> tree = assertAndGetTree(timeGraphProvider, trace, expectedStrings);
expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedTimeGraphRows"));
assertRows(timeGraphProvider, tree, expectedStrings);
} finally {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal in project tracecompass by tracecompass.
the class TmfTraceManager method traceClosed.
/**
* Signal handler for the traceClosed signal.
*
* @param signal
* The incoming signal
*/
@TmfSignalHandler
public synchronized void traceClosed(final TmfTraceClosedSignal signal) {
fTraces.remove(signal.getTrace());
IResource resource = signal.getTrace().getResource();
if (resource != null && fTraces.keySet().stream().noneMatch(trace -> resource.equals(trace.getResource()))) {
/* Reset the instance count only when no other instance remains */
fInstanceCounts.setCount(resource, 0);
}
if (fTraces.size() == 0) {
fCurrentTrace = null;
/*
* In other cases, we should receive a traceSelected signal that
* will indicate which trace is the new one.
*/
}
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal in project tracecompass by tracecompass.
the class TmfEventsEditor method propertyChanged.
@Override
public void propertyChanged(final Object source, final int propId) {
if (propId == IEditorPart.PROP_INPUT && getEditorInput() instanceof TmfEditorInput) {
if (fTrace != null) {
broadcast(new TmfTraceClosedSignal(this, fTrace));
saveState();
}
fEventsTable.dispose();
fFile = ((TmfEditorInput) getEditorInput()).getFile();
fTrace = ((TmfEditorInput) getEditorInput()).getTrace();
/* change the input to a FileEditorInput to allow open handlers to find this editor */
super.setInput(new FileEditorInput(fFile));
createAndInitializeTable();
// because the editor already had focus.
if (!PlatformUI.getWorkbench().isClosing() && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() == getSite().getPart()) {
fEventsTable.setFocus();
}
fParent.layout();
}
}
Aggregations