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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations