use of org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider in project tracecompass by tracecompass.
the class TmfTreeXYCompositeDataProvider method create.
/**
* Return a composite {@link ITmfTreeXYDataProvider} from a list of traces.
*
* @param traces
* A list of traces from which to generate a provider.
* @param title
* Chart's title
* @param id
* the provider's ID
* @param secondaryId
* The provider's secondaryId
* @return null if the non of the traces returns a provider, the provider if the
* lists only return one, else a {@link TmfTreeXYCompositeDataProvider}
* encapsulating the providers
*/
@Nullable
public static ITmfTreeXYDataProvider<ITmfTreeDataModel> create(Collection<ITmfTrace> traces, String title, String id, @Nullable String secondaryId) {
String providerId = secondaryId == null ? id : id + ':' + secondaryId;
List<@NonNull ITmfTreeXYDataProvider<ITmfTreeDataModel>> providers = new ArrayList<>();
for (ITmfTrace child : traces) {
ITmfTreeXYDataProvider<ITmfTreeDataModel> provider = DataProviderManager.getInstance().getDataProvider(child, providerId, ITmfTreeXYDataProvider.class);
if (provider != null) {
providers.add(provider);
}
}
if (providers.isEmpty()) {
return null;
} else if (providers.size() == 1) {
return providers.get(0);
}
return new TmfTreeXYCompositeDataProvider<>(providers, title, providerId);
}
use of org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider 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.xy.ITmfTreeXYDataProvider 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);
}
Aggregations