Search in sources :

Example 1 with TmfTreeViewerEntry

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;
}
Also used : ITmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry) TmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry) TmfTreeColumnData(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeColumnData) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) AbstractTmfTreeViewer(org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 2 with TmfTreeViewerEntry

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;
}
Also used : ITmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry) TmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry) HashMap(java.util.HashMap) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) TmfGenericTreeEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with TmfTreeViewerEntry

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;
}
Also used : TmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry) ITmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry) HashMap(java.util.HashMap) CpuUsageEntryModel(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.CpuUsageEntryModel)

Aggregations

ITmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry)3 TmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry)3 HashMap (java.util.HashMap)2 Nullable (org.eclipse.jdt.annotation.Nullable)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 CpuUsageEntryModel (org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.CpuUsageEntryModel)1 TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)1 AbstractTmfTreeViewer (org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer)1 TmfGenericTreeEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)1 TmfTreeColumnData (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeColumnData)1