use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class FlameChartView method synchingToTime.
/**
* @since 1.2
*/
@Override
protected void synchingToTime(final long time) {
List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries != null) {
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
Iterable<TimeGraphEntry> unfiltered = Utils.flatten(traceEntry);
Map<Long, TimeGraphEntry> map = Maps.uniqueIndex(unfiltered, e -> e.getEntryModel().getId());
// use time -1 as a lower bound for the end of Time events to be included.
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(time - 1, time, 2, map.keySet());
TmfModelResponse<@NonNull TimeGraphModel> response = traceEntry.getProvider().fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
TimeGraphModel model = response.getModel();
if (model != null) {
for (ITimeGraphRowModel row : model.getRows()) {
syncToRow(row, time, map);
}
}
}
}
fSyncSelection = false;
if (Display.getCurrent() != null) {
getTimeGraphViewer().refresh();
}
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter 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.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class FetchParametersTest method testSelectionTimeQuery.
/**
* Test
* {@link FetchParametersUtils#selectionTimeQueryToMap(SelectionTimeQueryFilter)}
* and {@link FetchParametersUtils#createSelectionTimeQuery(Map)}
*/
@Test
public void testSelectionTimeQuery() {
TimeQueryFilter selectionTimeQuery = FetchParametersUtils.createSelectionTimeQuery(fExpectedSelectionTimeQueryMap);
assertNotNull(selectionTimeQuery);
assertEquals(fExpectedSelectionTimeQuery, selectionTimeQuery);
Map<String, Object> selectionTimeQueryMap = FetchParametersUtils.selectionTimeQueryToMap(fExpectedSelectionTimeQuery);
assertFalse(selectionTimeQueryMap.isEmpty());
assertEquals(fExpectedSelectionTimeQueryMap, selectionTimeQueryMap);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class SegmentStoreScatterDataProvider method initTypes.
private Map<String, Series> initTypes(String prefix, TimeQueryFilter filter) {
if (!(filter instanceof SelectionTimeQueryFilter)) {
return Collections.emptyMap();
}
Map<String, Series> segmentTypes = new HashMap<>();
synchronized (fIdToType) {
for (Long id : ((SelectionTimeQueryFilter) filter).getSelectedItems()) {
String string = fIdToType.get(id);
if (string == null) {
continue;
}
String name = prefix + string;
segmentTypes.put(name, new Series(id));
}
}
return segmentTypes;
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class HistogramDataProviderTest method testHelloLost.
/**
* Test the {@link HistogramDataProvider} with the
* {@link CtfTestTrace#HELLO_LOST} trace. Ensure that the expected tree and xy
* models are returned
*
* @throws TmfAnalysisException
* if the trace is set more that once
*/
@Test
public void testHelloLost() throws TmfAnalysisException {
CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.HELLO_LOST);
TmfStatisticsModule module = new TmfStatisticsModule();
module.setName("Statistics");
assertTrue("Statistics Analysis should apply to this trace", module.setTrace(trace));
assertEquals("Statistics Analysis shouls be schedulable", Status.OK_STATUS, module.schedule());
assertTrue("Statistics Analysis should run successfully", module.waitForCompletion());
try {
HistogramDataProvider provider = new HistogramDataProvider(trace, module);
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> treeResponse = provider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(START, END, 2)), null);
assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
TmfTreeModel<@NonNull TmfTreeDataModel> treeModel = treeResponse.getModel();
assertNotNull(treeModel);
assertEquals(EXPECTED_FULL_PATHS, getFullPaths(treeModel.getEntries()));
List<Long> ids = Lists.transform(treeModel.getEntries(), TmfTreeDataModel::getId);
SelectionTimeQueryFilter selectionFilter = new SelectionTimeQueryFilter(START, END, 100, ids);
TmfModelResponse<@NonNull ITmfXyModel> xyResponse = provider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(selectionFilter), null);
assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, xyResponse.getStatus());
ITmfXyModel xyModel = xyResponse.getModel();
assertNotNull(xyModel);
assertEquals(EXPECTED_YDATA, Maps.uniqueIndex(xyModel.getSeriesData(), ISeriesModel::getId));
} finally {
module.dispose();
CtfTmfTestTraceUtils.dispose(CtfTestTrace.HELLO_LOST);
}
}
Aggregations