use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry in project tracecompass by tracecompass.
the class AbstractSegmentsStatisticsViewer method createTmfTreeColumnData.
private static TmfTreeColumnData createTmfTreeColumnData(@Nullable String name, Comparator<TmfTreeViewerEntry> comparator) {
TmfTreeColumnData column = new TmfTreeColumnData(name);
column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
if ((e1 == null) || (e2 == null)) {
return 0;
}
TmfTreeViewerEntry n1 = (TmfTreeViewerEntry) e1;
TmfTreeViewerEntry n2 = (TmfTreeViewerEntry) e2;
return comparator.compare(n1, n2);
}
});
return column;
}
use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry in project tracecompass by tracecompass.
the class AbstractSegmentsStatisticsViewer method modelToTree.
/**
* Algorithm to convert a model (List of {@link SegmentStoreStatisticsModel}) to
* the tree.
*
* @param trace
* trace / experiment.
* @param model
* model to convert
* @return the resulting {@link TmfTreeViewerEntry}.
*/
@Nullable
private TmfTreeViewerEntry modelToTree(ITmfTrace trace, List<SegmentStoreStatisticsModel> model) {
TmfTreeViewerEntry root = getRoot(trace);
if (root == null) {
return null;
}
synchronized (root) {
root.getChildren().clear();
Map<Long, TmfTreeViewerEntry> map = new HashMap<>();
map.put(-1L, root);
for (TmfTreeDataModel entry : model) {
TmfTreeViewerEntry viewerEntry = new TmfGenericTreeEntry<>(entry);
map.put(entry.getId(), viewerEntry);
TmfTreeViewerEntry parent = map.get(entry.getParentId());
if (parent != null && !parent.getChildren().contains(viewerEntry)) {
parent.addChild(viewerEntry);
}
}
}
return root;
}
use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry in project tracecompass by tracecompass.
the class CpuUsageTreeViewer method modelToTree.
@Override
protected ITmfTreeViewerEntry modelToTree(long start, long end, List<ITmfTreeDataModel> model) {
double time = end - start;
Map<Long, TmfTreeViewerEntry> map = new HashMap<>();
// $NON-NLS-1$
TmfTreeViewerEntry root = new TmfTreeViewerEntry("");
map.put(-1L, root);
for (CpuUsageEntryModel entryModel : Iterables.filter(model, CpuUsageEntryModel.class)) {
// Add a total series to the presentation provider if the tid is < 0
int tid = entryModel.getTid();
if (tid < 0) {
fPresentationProvider.addTotalSeries(entryModel.getId());
}
CpuUsageEntry cpuUsageEntry = new CpuUsageEntry(entryModel, entryModel.getTime() / time);
map.put(entryModel.getId(), cpuUsageEntry);
TmfTreeViewerEntry parent = map.get(entryModel.getParentId());
if (parent != null) {
parent.addChild(cpuUsageEntry);
}
}
return root;
}
Aggregations