Search in sources :

Example 1 with ITimeGraphDataProvider

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider in project tracecompass by tracecompass.

the class BaseDataProviderTimeGraphView method getLinkList.

@Override
protected List<@NonNull ILinkEvent> getLinkList(long zoomStartTime, long zoomEndTime, long resolution, @NonNull IProgressMonitor monitor) {
    Collection<ITimeGraphDataProvider<? extends @NonNull TimeGraphEntryModel>> providers = getProviders(getTrace());
    if (providers.isEmpty()) {
        return Collections.emptyList();
    }
    List<@NonNull ILinkEvent> linkList = new ArrayList<>();
    List<@NonNull Long> times = StateSystemUtils.getTimes(zoomStartTime, zoomEndTime, resolution);
    Map<@NonNull String, @NonNull Object> parameters = getFetchArrowsParameters(times);
    for (ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider : providers) {
        TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(parameters, monitor);
        List<ITimeGraphArrow> model = response.getModel();
        if (model != null) {
            for (ITimeGraphArrow arrow : model) {
                ITimeGraphEntry prevEntry;
                ITimeGraphEntry nextEntry;
                synchronized (fEntries) {
                    prevEntry = fEntries.get(provider, arrow.getSourceId());
                    nextEntry = fEntries.get(provider, arrow.getDestinationId());
                }
                if (prevEntry != null && nextEntry != null) {
                    linkList.add(new TimeLinkEvent(arrow, prevEntry, nextEntry));
                }
            }
        }
    }
    return linkList;
}
Also used : ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) ArrayList(java.util.ArrayList) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) TimeLinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent)

Example 2 with ITimeGraphDataProvider

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider in project tracecompass by tracecompass.

the class FlameChartView method getPreviousEventAction.

/**
 * Get the previous event action.
 *
 * @return The Action object
 */
private Action getPreviousEventAction() {
    Action prevAction = fPrevEventAction;
    if (prevAction == null) {
        Action superPrevAction = getTimeGraphViewer().getPreviousEventAction();
        prevAction = new Action() {

            @Override
            public void run() {
                TimeGraphViewer viewer = getTimeGraphViewer();
                ITimeGraphEntry entry = viewer.getSelection();
                if (entry instanceof TimeGraphEntry) {
                    TimeGraphEntry callStackEntry = (TimeGraphEntry) entry;
                    ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = getProvider(callStackEntry);
                    long selectionBegin = viewer.getSelectionBegin();
                    SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(Lists.newArrayList(Long.MIN_VALUE, selectionBegin), Collections.singleton(callStackEntry.getEntryModel().getId()));
                    TmfModelResponse<@NonNull TimeGraphModel> response = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
                    TimeGraphModel model = response.getModel();
                    if (model == null || model.getRows().size() != 1) {
                        return;
                    }
                    List<@NonNull ITimeGraphState> row = model.getRows().get(0).getStates();
                    if (row.size() != 1) {
                        return;
                    }
                    ITimeGraphState stackInterval = row.get(0);
                    viewer.setSelectedTimeNotify(stackInterval.getStartTime(), true);
                    int stackLevel = stackInterval.getValue();
                    ITimeGraphEntry selectedEntry = callStackEntry.getParent().getChildren().get(Integer.max(0, stackLevel - 1));
                    viewer.setSelection(selectedEntry, true);
                    viewer.getTimeGraphControl().fireSelectionChanged();
                    startZoomThread(viewer.getTime0(), viewer.getTime1());
                }
            }
        };
        prevAction.setText(superPrevAction.getText());
        prevAction.setToolTipText(superPrevAction.getToolTipText());
        prevAction.setImageDescriptor(superPrevAction.getImageDescriptor());
        fPrevEventAction = prevAction;
    }
    return prevAction;
}
Also used : Action(org.eclipse.jface.action.Action) ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull) TimeGraphViewer(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with ITimeGraphDataProvider

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider in project tracecompass by tracecompass.

the class TmfTimeGraphCompositeDataProvider method create.

/**
 * Return a composite {@link ITimeGraphDataProvider} from a list of traces.
 *
 * @param traces
 *            A list of traces from which to generate a provider.
 * @param id
 *            the provider's ID
 * @param secondaryId
 *            The provider's secondaryId
 * @return null if the non of the traces returns a provider, the provider if the
 *         lists only return one, else a {@link TmfTimeGraphCompositeDataProvider}
 *         encapsulating the providers
 */
@Nullable
public static ITimeGraphDataProvider<ITimeGraphEntryModel> create(Collection<ITmfTrace> traces, String id, @Nullable String secondaryId) {
    String providerId = secondaryId == null ? id : id + ':' + secondaryId;
    List<@NonNull ITimeGraphDataProvider<ITimeGraphEntryModel>> providers = new ArrayList<>();
    for (ITmfTrace child : traces) {
        ITimeGraphDataProvider<ITimeGraphEntryModel> provider = DataProviderManager.getInstance().getDataProvider(child, providerId, ITimeGraphDataProvider.class);
        if (provider != null) {
            providers.add(provider);
        }
    }
    if (providers.isEmpty()) {
        return null;
    } else if (providers.size() == 1) {
        return providers.get(0);
    }
    return new TmfTimeGraphCompositeDataProvider<>(providers, providerId);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) ArrayList(java.util.ArrayList) ITimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphEntryModel) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 4 with ITimeGraphDataProvider

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider in project tracecompass by tracecompass.

the class CriticalPathView method getLinkList.

@Override
protected List<ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
    List<@NonNull TimeGraphEntry> traceEntries = getEntryList(getTrace());
    if (traceEntries == null) {
        return Collections.emptyList();
    }
    List<@NonNull ILinkEvent> linkList = new ArrayList<>();
    TimeQueryFilter queryFilter = new TimeQueryFilter(startTime, endTime, 2);
    /*
         * group entries by critical path data provider as several hosts may refer to
         * the same data provider
         */
    Table<ITimeGraphDataProvider<?>, Long, TimeGraphEntry> table = HashBasedTable.create();
    for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
        for (TimeGraphEntry entry : Utils.flatten(traceEntry)) {
            table.put(traceEntry.getProvider(), entry.getEntryModel().getId(), entry);
        }
    }
    for (Map.Entry<ITimeGraphDataProvider<?>, Map<Long, TimeGraphEntry>> entry : table.rowMap().entrySet()) {
        ITimeGraphDataProvider<?> provider = entry.getKey();
        Map<Long, TimeGraphEntry> map = entry.getValue();
        TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(FetchParametersUtils.timeQueryToMap(queryFilter), monitor);
        List<ITimeGraphArrow> model = response.getModel();
        if (monitor.isCanceled()) {
            return null;
        }
        if (model != null) {
            for (ITimeGraphArrow arrow : model) {
                ITimeGraphEntry src = map.get(arrow.getSourceId());
                ITimeGraphEntry dst = map.get(arrow.getDestinationId());
                if (src != null && dst != null) {
                    linkList.add(new TimeLinkEvent(src, dst, arrow.getStartTime(), arrow.getDuration(), arrow.getValue()));
                }
            }
        }
    }
    return linkList;
}
Also used : ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) ArrayList(java.util.ArrayList) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) ArrayList(java.util.ArrayList) List(java.util.List) TimeLinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent) Map(java.util.Map)

Example 5 with ITimeGraphDataProvider

use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider in project tracecompass by tracecompass.

the class FlameChartView method getNextEventAction.

/**
 * Get the the next event action.
 *
 * @return The action object
 */
private Action getNextEventAction() {
    Action nextAction = fNextEventAction;
    if (nextAction == null) {
        Action superNextAction = getTimeGraphViewer().getNextEventAction();
        nextAction = new Action() {

            @Override
            public void run() {
                TimeGraphViewer viewer = getTimeGraphViewer();
                ITimeGraphEntry entry = viewer.getSelection();
                if (entry instanceof TimeGraphEntry) {
                    TimeGraphEntry callStackEntry = (TimeGraphEntry) entry;
                    ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = getProvider(callStackEntry);
                    long selectionBegin = viewer.getSelectionBegin();
                    SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(selectionBegin, Long.MAX_VALUE, 2, Collections.singleton(callStackEntry.getEntryModel().getId()));
                    TmfModelResponse<@NonNull TimeGraphModel> response = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
                    TimeGraphModel model = response.getModel();
                    if (model == null || model.getRows().size() != 1) {
                        return;
                    }
                    List<@NonNull ITimeGraphState> row = model.getRows().get(0).getStates();
                    if (row.size() != 1) {
                        return;
                    }
                    ITimeGraphState stackInterval = row.get(0);
                    if (stackInterval.getStartTime() <= selectionBegin && selectionBegin <= stackInterval.getStartTime() + stackInterval.getDuration()) {
                        viewer.setSelectedTimeNotify(stackInterval.getStartTime() + stackInterval.getDuration() + 1, true);
                    } else {
                        viewer.setSelectedTimeNotify(stackInterval.getStartTime(), true);
                    }
                    int stackLevel = stackInterval.getValue();
                    ITimeGraphEntry selectedEntry = callStackEntry.getParent().getChildren().get(Integer.max(0, stackLevel - 1));
                    viewer.setSelection(selectedEntry, true);
                    viewer.getTimeGraphControl().fireSelectionChanged();
                    startZoomThread(viewer.getTime0(), viewer.getTime1());
                }
            }
        };
        nextAction.setText(superNextAction.getText());
        nextAction.setToolTipText(superNextAction.getToolTipText());
        nextAction.setImageDescriptor(superNextAction.getImageDescriptor());
        fNextEventAction = nextAction;
    }
    return nextAction;
}
Also used : Action(org.eclipse.jface.action.Action) ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull) TimeGraphViewer(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ITimeGraphDataProvider (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider)9 ArrayList (java.util.ArrayList)7 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)7 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)6 List (java.util.List)5 NonNull (org.eclipse.jdt.annotation.NonNull)5 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)5 TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)4 Collection (java.util.Collection)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IOutputAnnotationProvider (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider)3 ITimeGraphArrow (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow)3 ITimeGraphState (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState)3 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)3 ILinkEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent)3 TimeLinkEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent)3 ImmutableList (com.google.common.collect.ImmutableList)2 Map (java.util.Map)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2