use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class TmfTreeDataModelTest method testConstructors.
// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
* Test constructors and getter/setters.
*/
@Test
public void testConstructors() {
TmfTreeDataModel model0 = createModel(0);
assertEquals(ID0, model0.getId());
assertEquals(PARENT_ID0, model0.getParentId());
assertEquals(LABELS0.get(0), model0.getName());
assertEquals(LABELS0, model0.getLabels());
assertTrue(model0.hasRowModel());
assertEquals(STYLE0, model0.getStyle());
TmfTreeDataModel model1 = createModel(1);
assertEquals(ID1, model1.getId());
assertEquals(PARENT_ID1, model1.getParentId());
assertEquals(LABELS1.get(0), model1.getName());
assertEquals(LABELS1, model1.getLabels());
assertFalse(model1.hasRowModel());
assertEquals(STYLE1, model1.getStyle());
TmfTreeDataModel model2 = createModel(2);
assertEquals(ID2, model2.getId());
assertEquals(PARENT_ID2, model2.getParentId());
assertEquals(NAME, model2.getName());
assertEquals(1, model2.getLabels().size());
assertEquals(NAME, model2.getLabels().get(0));
assertTrue(model2.hasRowModel());
assertEquals(STYLE3, model2.getStyle());
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class CounterDataProvider method getTree.
/**
* @since 1.2
*/
@Override
protected TmfTreeModel<TmfTreeDataModel> getTree(ITmfStateSystem ss, Map<String, Object> parameters, @Nullable IProgressMonitor monitor) {
List<TmfTreeDataModel> entries = new ArrayList<>();
long rootId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
entries.add(new TmfTreeDataModel(rootId, -1, Collections.singletonList(getTrace().getName())));
addTreeViewerBranch(ss, rootId, Collections.singletonList(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB), entries);
addTreeViewerBranch(ss, rootId, Collections.singletonList(CounterAnalysis.UNGROUPED_COUNTER_ASPECTS_ATTRIB), entries);
return new TmfTreeModel<>(Collections.emptyList(), entries);
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class CounterDataProvider method addTreeViewerBranch.
private void addTreeViewerBranch(ITmfStateSystem ss, long parentId, List<String> branchName, List<TmfTreeDataModel> entries) {
int quark = ss.optQuarkAbsolute(branchName.get(0));
if (quark != ITmfStateSystem.INVALID_ATTRIBUTE && !ss.getSubAttributes(quark, false).isEmpty()) {
long id = getId(quark);
TmfTreeDataModel branch = new TmfTreeDataModel(id, parentId, branchName);
entries.add(branch);
addTreeViewerEntries(ss, id, quark, entries);
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel 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.TmfTreeDataModel in project tracecompass by tracecompass.
the class DisksIODataProvider method getTree.
@Override
protected TmfTreeModel<TmfTreeDataModel> getTree(ITmfStateSystem ss, Map<String, Object> parameters, @Nullable IProgressMonitor monitor) {
List<TmfTreeDataModel> nodes = new ArrayList<>();
long rootId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
nodes.add(new TmfTreeDataModel(rootId, -1, Collections.singletonList(getTrace().getName()), false, null));
String readName = Objects.requireNonNull(Messages.DisksIODataProvider_read);
String writeName = Objects.requireNonNull(Messages.DisksIODataProvider_write);
int i = 0;
for (Integer diskQuark : ss.getQuarks(Attributes.DISKS, "*")) {
// $NON-NLS-1$
String diskName = DiskUtils.getDiskName(ss, diskQuark);
long diskId = getId(diskQuark);
nodes.add(new TmfTreeDataModel(diskId, rootId, Collections.singletonList(diskName), false, null));
// Do not add the read/write entries if there was no read/write
int readQuark = ss.optQuarkRelative(diskQuark, Attributes.SECTORS_READ);
int writeQuark = ss.optQuarkRelative(diskQuark, Attributes.SECTORS_WRITTEN);
if (readQuark == ITmfStateSystem.INVALID_ATTRIBUTE && writeQuark == ITmfStateSystem.INVALID_ATTRIBUTE) {
continue;
}
// Get read and write color for this disk
Pair<String, String> pair = COLOR_LIST.get(i % COLOR_LIST.size());
String seriesStyle = SUPPORTED_STYLES.get((i / COLOR_LIST.size()) % SUPPORTED_STYLES.size());
if (readQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
nodes.add(new TmfTreeDataModel(getId(readQuark), diskId, Collections.singletonList(readName), true, new OutputElementStyle(BASE_STYLE, ImmutableMap.of(StyleProperties.COLOR, pair.getFirst(), StyleProperties.SERIES_STYLE, seriesStyle, StyleProperties.STYLE_NAME, diskName + '/' + readName))));
}
if (writeQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
nodes.add(new TmfTreeDataModel(getId(writeQuark), diskId, Collections.singletonList(writeName), true, new OutputElementStyle(BASE_STYLE, ImmutableMap.of(StyleProperties.COLOR, pair.getSecond(), StyleProperties.SERIES_STYLE, seriesStyle, StyleProperties.STYLE_NAME, diskName + '/' + writeName))));
}
i++;
}
return new TmfTreeModel<>(Collections.emptyList(), nodes);
}
Aggregations