Search in sources :

Example 6 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class HistogramDataProvider method fetchTree.

@Override
public TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    if (fCached != null) {
        return fCached;
    }
    fModule.waitForInitialization();
    Builder<TmfTreeDataModel> builder = ImmutableList.builder();
    builder.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(getTrace().getName())));
    builder.add(new TmfTreeDataModel(fTotalId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Total))));
    ITmfStateSystem eventsSs = Objects.requireNonNull(fModule.getStateSystem(TmfStatisticsEventTypesModule.ID));
    if (eventsSs.optQuarkAbsolute(Attributes.LOST_EVENTS) != ITmfStateSystem.INVALID_ATTRIBUTE) {
        builder.add(new TmfTreeDataModel(fLostId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Lost))));
    }
    if (eventsSs.waitUntilBuilt(0)) {
        TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> response = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
        fCached = response;
        return response;
    }
    return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
Also used : TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 7 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel 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 8 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel 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 9 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class ExampleXYDataProvider method getTree.

@Override
protected TmfTreeModel<TmfTreeDataModel> getTree(ITmfStateSystem ss, Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
    // Make an entry for each base quark
    List<TmfTreeDataModel> entryList = new ArrayList<>();
    for (Integer quark : ss.getQuarks("CPUs", "*")) {
        // $NON-NLS-1$ //$NON-NLS-2$
        // $NON-NLS-1$
        int statusQuark = ss.optQuarkRelative(quark, "Status");
        if (statusQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
            Long id = fIDToDisplayQuark.inverse().computeIfAbsent(statusQuark, q -> sfAtomicId.getAndIncrement());
            entryList.add(new TmfTreeDataModel(id, -1, ss.getAttributeName(quark)));
        }
    }
    return new TmfTreeModel<>(Collections.emptyList(), entryList);
}
Also used : ArrayList(java.util.ArrayList) AtomicLong(java.util.concurrent.atomic.AtomicLong) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)

Example 10 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class SegmentStoreScatterDataProvider method fetchTree.

/**
 * @since 4.0
 */
@Override
public TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    ISegmentStoreProvider provider = fProvider;
    if (provider instanceof IAnalysisModule) {
        IAnalysisModule module = (IAnalysisModule) provider;
        IProgressMonitor mon = monitor != null ? monitor : new NullProgressMonitor();
        module.waitForCompletion(mon);
        if (mon.isCanceled()) {
            return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
        }
    }
    ISegmentStore<ISegment> segStore = provider.getSegmentStore();
    if (segStore == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
    }
    TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
    if (filter == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    long start = filter.getStart();
    long end = filter.getEnd();
    final Iterable<ISegment> intersectingElements = Iterables.filter(segStore.getIntersectingElements(start, end), s -> s.getStart() >= start);
    Map<String, INamedSegment> segmentTypes = new HashMap<>();
    IAnalysisModule module = (provider instanceof IAnalysisModule) ? (IAnalysisModule) provider : null;
    boolean complete = module == null ? true : module.isQueryable(filter.getEnd());
    // Create the list of segment types that will each create a series
    for (INamedSegment segment : Iterables.filter(intersectingElements, INamedSegment.class)) {
        if (monitor != null && monitor.isCanceled()) {
            return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
        }
        segmentTypes.put(segment.getName(), segment);
    }
    Builder<TmfTreeDataModel> nodes = new ImmutableList.Builder<>();
    nodes.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(String.valueOf(getTrace().getName()))));
    Map<IGroupingSegmentAspect, Map<String, Long>> names = new HashMap<>();
    for (Entry<String, INamedSegment> series : segmentTypes.entrySet()) {
        long parentId = fTraceId;
        /*
             * Create a tree sorting aspects by "Grouping aspect" much like
             * counter analyses
             */
        for (IGroupingSegmentAspect aspect : fGroupingAspects) {
            names.putIfAbsent(aspect, new HashMap<>());
            Map<String, Long> map = names.get(aspect);
            if (map == null) {
                break;
            }
            String name = String.valueOf(aspect.resolve(series.getValue()));
            String key = GROUP_PREFIX + name;
            Long uniqueId = map.get(key);
            if (uniqueId == null) {
                uniqueId = getUniqueId(key);
                map.put(key, uniqueId);
                nodes.add(new TmfTreeDataModel(uniqueId, parentId, name));
            }
            parentId = uniqueId;
        }
        long seriesId = getUniqueId(series.getKey());
        nodes.add(new TmfTreeDataModel(seriesId, parentId, series.getKey()));
    }
    return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), nodes.build()), complete ? ITmfResponse.Status.COMPLETED : ITmfResponse.Status.RUNNING, complete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) HashMap(java.util.HashMap) SeriesModelBuilder(org.eclipse.tracecompass.tmf.core.model.SeriesModel.SeriesModelBuilder) Builder(com.google.common.collect.ImmutableList.Builder) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) INamedSegment(org.eclipse.tracecompass.segmentstore.core.segment.interfaces.INamedSegment) IGroupingSegmentAspect(org.eclipse.tracecompass.analysis.timing.core.segmentstore.IGroupingSegmentAspect) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) AtomicLong(java.util.concurrent.atomic.AtomicLong) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) HashMap(java.util.HashMap) HashBiMap(com.google.common.collect.HashBiMap)

Aggregations

TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)21 Test (org.junit.Test)9 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)8 ArrayList (java.util.ArrayList)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)4 HashMap (java.util.HashMap)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)3 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)3 Map (java.util.Map)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)2 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)2 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)2 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)2 ITmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry)2 TmfGenericTreeEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)2