Search in sources :

Example 1 with TmfTraceClosedSignal

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));
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Element(org.w3c.dom.Element) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 2 with TmfTraceClosedSignal

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));
        }
    }
}
Also used : Element(org.w3c.dom.Element) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTimeGraphCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.timegraph.TmfTimeGraphCompositeDataProvider) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) Test(org.junit.Test)

Example 3 with TmfTraceClosedSignal

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));
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Element(org.w3c.dom.Element) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 4 with TmfTraceClosedSignal

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.
             */
    }
}
Also used : TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Iterables(com.google.common.collect.Iterables) IFolder(org.eclipse.core.resources.IFolder) Multiset(com.google.common.collect.Multiset) URISyntaxException(java.net.URISyntaxException) UnaryOperator(java.util.function.UnaryOperator) CoreException(org.eclipse.core.runtime.CoreException) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TmfEventFilterAppliedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal) StringUtils(org.apache.commons.lang3.StringUtils) NonNullUtils(org.eclipse.tracecompass.common.core.NonNullUtils) LinkedHashMap(java.util.LinkedHashMap) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) URIUtil(org.eclipse.core.runtime.URIUtil) Activator(org.eclipse.tracecompass.internal.tmf.core.Activator) IProject(org.eclipse.core.resources.IProject) Nullable(org.eclipse.jdt.annotation.Nullable) HashMultiset(com.google.common.collect.HashMultiset) Map(java.util.Map) IFile(org.eclipse.core.resources.IFile) NonNullUtils.checkNotNull(org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) NonNullByDefault(org.eclipse.jdt.annotation.NonNullByDefault) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) TmfCommonConstants(org.eclipse.tracecompass.tmf.core.TmfCommonConstants) File(java.io.File) Objects(java.util.Objects) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) List(java.util.List) IResource(org.eclipse.core.resources.IResource) Path(org.eclipse.core.runtime.Path) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceModelSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceModelSignal) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Collections(java.util.Collections) NonNull(org.eclipse.jdt.annotation.NonNull) IResource(org.eclipse.core.resources.IResource) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 5 with TmfTraceClosedSignal

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();
    }
}
Also used : IFileEditorInput(org.eclipse.ui.IFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)

Aggregations

TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)16 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)10 Test (org.junit.Test)10 Element (org.w3c.dom.Element)10 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)7 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)5 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)4 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)3 AnalysisCompilationData (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData)2 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)2 TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)2 After (org.junit.After)2 HashMultiset (com.google.common.collect.HashMultiset)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Multiset (com.google.common.collect.Multiset)1 File (java.io.File)1