Search in sources :

Example 1 with TmfGenericTreeEntry

use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry in project tracecompass by tracecompass.

the class TmfFilteredXYChartViewer method handleCheckStateChangedEvent.

/**
 * Update the chart depending on the selected entries.
 *
 * @param entries
 *            Counters to display on the chart
 */
@Override
public void handleCheckStateChangedEvent(Collection<ITmfTreeViewerEntry> entries) {
    cancelUpdate();
    Iterable<TmfGenericTreeEntry> counterEntries = Iterables.filter(entries, TmfGenericTreeEntry.class);
    Collection<@NonNull Long> selectedIds = Sets.newHashSet(Iterables.transform(counterEntries, e -> e.getModel().getId()));
    if (!selectedIds.containsAll(fSelectedIds)) {
        clearContent();
    }
    fSelectedIds = selectedIds;
    // Update the styles as well
    BaseXYPresentationProvider presProvider = getPresentationProvider();
    for (ITmfTreeViewerEntry entry : entries) {
        if (entry instanceof TmfGenericTreeEntry) {
            TmfGenericTreeEntry<TmfTreeDataModel> genericEntry = (TmfGenericTreeEntry<TmfTreeDataModel>) entry;
            TmfTreeDataModel model = genericEntry.getModel();
            OutputElementStyle style = model.getStyle();
            if (style != null) {
                presProvider.setStyle(model.getId(), style);
            }
        }
    }
    updateContent();
}
Also used : Iterables(com.google.common.collect.Iterables) Chart(org.eclipse.swtchart.Chart) DataProviderManager(org.eclipse.tracecompass.tmf.core.dataprovider.DataProviderManager) ITmfTreeXYDataProvider(org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider) HashMap(java.util.HashMap) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ICheckboxTreeViewerListener(org.eclipse.tracecompass.tmf.ui.viewers.tree.ICheckboxTreeViewerListener) Multimap(com.google.common.collect.Multimap) TmfGenericTreeEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry) Nullable(org.eclipse.jdt.annotation.Nullable) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) ITmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Collection(java.util.Collection) FetchParametersUtils(org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils) IOutputStyleProvider(org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider) DataProviderParameterUtils(org.eclipse.tracecompass.tmf.core.dataprovider.DataProviderParameterUtils) Sets(com.google.common.collect.Sets) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) IYAppearance(org.eclipse.tracecompass.tmf.core.presentation.IYAppearance) Collections(java.util.Collections) NonNull(org.eclipse.jdt.annotation.NonNull) BaseXYPresentationProvider(org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider) ITmfXYDataProvider(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXYDataProvider) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) ITmfTreeViewerEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) TmfGenericTreeEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) BaseXYPresentationProvider(org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider)

Example 2 with TmfGenericTreeEntry

use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry 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 TmfGenericTreeEntry

use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry in project tracecompass by tracecompass.

the class AbstractSegmentsStatisticsViewer method appendToTablePopupMenu.

/**
 * Method to add commands to the context sensitive menu.
 *
 * @param manager
 *            the menu manager
 * @param sel
 *            the current selection
 */
protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
    Object element = sel.getFirstElement();
    if (element instanceof TmfGenericTreeEntry) {
        IAction gotoStartTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMinAction) {

            @Override
            public void run() {
                long start;
                long end;
                if (element instanceof TmfGenericTreeEntry) {
                    SegmentStoreStatisticsModel model = ((TmfGenericTreeEntry<SegmentStoreStatisticsModel>) element).getModel();
                    start = model.getMinStart();
                    end = model.getMinEnd();
                } else {
                    return;
                }
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentsStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end), getTrace()));
                updateContent(start, end, true);
            }
        };
        IAction gotoEndTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMaxAction) {

            @Override
            public void run() {
                long start;
                long end;
                if (element instanceof TmfGenericTreeEntry) {
                    SegmentStoreStatisticsModel model = ((TmfGenericTreeEntry<SegmentStoreStatisticsModel>) element).getModel();
                    start = model.getMaxStart();
                    end = model.getMaxEnd();
                } else {
                    return;
                }
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentsStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end), getTrace()));
                updateContent(start, end, true);
            }
        };
        manager.add(gotoStartTime);
        manager.add(gotoEndTime);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) TmfGenericTreeEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)

Aggregations

TmfGenericTreeEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)3 HashMap (java.util.HashMap)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)2 ITmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry)2 Iterables (com.google.common.collect.Iterables)1 Multimap (com.google.common.collect.Multimap)1 Sets (com.google.common.collect.Sets)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Map (java.util.Map)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 Composite (org.eclipse.swt.widgets.Composite)1 Chart (org.eclipse.swtchart.Chart)1 SegmentStoreStatisticsModel (org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel)1 BaseXYPresentationProvider (org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider)1 FetchParametersUtils (org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils)1 DataProviderManager (org.eclipse.tracecompass.tmf.core.dataprovider.DataProviderManager)1