use of org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter in project tracecompass by tracecompass.
the class TmfEventsTable method applyEventFilter.
private ITmfFilterTreeNode applyEventFilter(ITmfFilter filter) {
stopFilterThread();
stopSearchThread();
fFilterMatchCount = 0;
fFilterCheckCount = 0;
ITmfFilterTreeNode rootFilter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ);
if (rootFilter == null) {
rootFilter = new TmfFilterRootNode();
}
if (filter instanceof TmfFilterRootNode) {
TmfFilterRootNode parentFilter = (TmfFilterRootNode) filter;
for (ITmfFilterTreeNode child : parentFilter.getChildren()) {
rootFilter.addChild(child);
}
} else if (filter instanceof TmfCollapseFilter) {
fCollapseFilterEnabled = true;
} else if (filter instanceof ITmfFilterTreeNode) {
rootFilter.addChild((ITmfFilterTreeNode) filter);
} else {
rootFilter.addChild(new TmfFilterObjectNode(filter));
}
fCache.applyFilter(rootFilter, fCollapseFilterEnabled);
fHeaderBar.addFilter(filter);
fTable.clearAll();
fTable.setData(Key.FILTER_OBJ, rootFilter);
/* +1 for header row, +2 for top and bottom filter status rows */
fTable.setItemCount(3);
startFilterThread();
return rootFilter;
}
use of org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter in project tracecompass by tracecompass.
the class TmfEventTableDataProvider method fetchLines.
@Override
public TmfModelResponse<ITmfVirtualTableModel<EventTableLine>> fetchLines(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
if (!fetchParameters.containsKey(DataProviderParameterUtils.REQUESTED_TABLE_INDEX_KEY) && fetchParameters.containsKey(DataProviderParameterUtils.REQUESTED_TIME_KEY)) {
fetchParameters.put(DataProviderParameterUtils.REQUESTED_TABLE_INDEX_KEY, getTableIndex(fetchParameters));
}
if (!fetchParameters.containsKey(DataProviderParameterUtils.REQUESTED_COLUMN_IDS_KEY)) {
fetchParameters.put(DataProviderParameterUtils.REQUESTED_COLUMN_IDS_KEY, Collections.emptyList());
}
VirtualTableQueryFilter queryFilter = FetchParametersUtils.createVirtualTableQueryFilter(fetchParameters);
if (queryFilter == null) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
@Nullable ITmfFilter filter = extractFilter(fetchParameters);
@Nullable ITmfFilter searchFilter = extractSearchFilter(fetchParameters);
@Nullable TmfCollapseFilter collapseFilter = extractCollapseFilter(fetchParameters);
Map<Long, ITmfEventAspect<?>> aspects = getAspectsFromColumnsId(queryFilter.getColumnsId());
if (aspects.isEmpty()) {
return new TmfModelResponse<>(new TmfVirtualTableModel<>(Collections.emptyList(), Collections.emptyList(), queryFilter.getIndex(), 0), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
List<Long> columnsIds = new ArrayList<>(aspects.keySet());
if (getTrace().getNbEvents() == 0) {
return new TmfModelResponse<>(new TmfVirtualTableModel<>(columnsIds, Collections.emptyList(), queryFilter.getIndex(), 0), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
/*
* Search for the next or previous event starting from the given event index
*/
Object directionValue = fetchParameters.get(TABLE_SEARCH_DIRECTION_KEY);
// ///////////////////////////////////
// TODO remove isFiltered when Theia front-end is updated to use TABLE_SEARCH_DIRECTION_KEY instead
Boolean isFiltered = DataProviderParameterUtils.extractIsFiltered(fetchParameters);
boolean isIndexRequest = isFiltered != null && isFiltered;
if (isIndexRequest && directionValue == null) {
directionValue = Direction.NEXT.name();
}
if (searchFilter != null && directionValue != null) {
Direction direction = directionValue.equals(Direction.PREVIOUS.name()) ? Direction.PREVIOUS : Direction.NEXT;
@Nullable WrappedEvent event = null;
Predicate<@NonNull ITmfEvent> predicate;
if (filter == null) {
predicate = searchFilter::matches;
} else {
predicate = e -> (filter.matches(e) && searchFilter.matches(e));
}
if (direction == Direction.NEXT) {
event = getNextWrappedEventMatching(getTrace(), Math.abs(queryFilter.getIndex()), predicate, monitor);
} else if (direction == Direction.PREVIOUS) {
event = getPreviousWrappedEventMatching(getTrace(), Math.abs(queryFilter.getIndex()), predicate, monitor);
}
List<EventTableLine> lines = new ArrayList<>();
long rank = queryFilter.getIndex();
if (event != null) {
rank = event.getRank();
// create new queryFilter with updated start rank to get number of events starting from first matching event
queryFilter = new VirtualTableQueryFilter(queryFilter.getColumnsId(), rank, queryFilter.getCount());
lines.add(buildEventTableLine(aspects, event.getOriginalEvent(), rank, rank, true));
}
if ((queryFilter.getCount() == 1) || (event == null)) {
/**
* If no event was found or the number of requested events is one
* reply here since all required data for the reply is available.
*/
TmfVirtualTableModel<EventTableLine> model = new TmfVirtualTableModel<>(columnsIds, lines, rank, getTrace().getNbEvents());
return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
}
/*
* Collect queryFilter.getCount() number of events from start rank
*/
/*
* TODO implement upper limit of queryFilter.getCount() to avoid running out of memory.
* TBD if the check and should be handled here or in the calling methods.
*/
TableEventRequest request;
if (filter != null) {
request = filteredTableRequest(Math.abs(queryFilter.getCount()), queryFilter.getIndex(), aspects, filter, searchFilter, collapseFilter, monitor);
} else {
request = tableRequest(Math.abs(queryFilter.getCount()), queryFilter.getIndex(), aspects, searchFilter, collapseFilter, monitor);
request.setEventCount(getTrace().getNbEvents());
}
getTrace().sendRequest(request);
try {
request.waitForCompletion();
} catch (InterruptedException e) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, NonNullUtils.nullToEmptyString(e.getMessage()));
}
if (request.isCancelled()) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
TmfVirtualTableModel<EventTableLine> model = new TmfVirtualTableModel<>(columnsIds, request.getEventLines(), queryFilter.getIndex(), request.getCurrentCount());
return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Aggregations