Search in sources :

Example 1 with CounterAnalysis

use of org.eclipse.tracecompass.analysis.counters.core.CounterAnalysis 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)

Aggregations

ArrayList (java.util.ArrayList)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 CounterAnalysis (org.eclipse.tracecompass.analysis.counters.core.CounterAnalysis)1 TmfTreeXYCompositeDataProvider (org.eclipse.tracecompass.internal.tmf.core.model.xy.TmfTreeXYCompositeDataProvider)1 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)1 TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)1 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1