use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class AbstractSegmentStoreTableViewer method appendToTablePopupMenu.
@Override
protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
final ISegment segment = (ISegment) sel.getFirstElement();
if (segment != null) {
IAction gotoStartTime = new Action(Messages.SegmentStoreTableViewer_goToStartEvent) {
@Override
public void run() {
broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getStart()), TmfTimestamp.fromNanos(segment.getStart()), fTrace));
}
};
IAction gotoEndTime = new Action(Messages.SegmentStoreTableViewer_goToEndEvent) {
@Override
public void run() {
broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getEnd()), TmfTimestamp.fromNanos(segment.getEnd()), fTrace));
}
};
manager.add(gotoStartTime);
manager.add(gotoEndTime);
if (segment instanceof ITmfSourceLookup) {
IContributionItem openCallsiteAction = OpenSourceCodeAction.create(Messages.SegmentStoreTableViewer_lookup, (ITmfSourceLookup) segment, getTableViewer().getTable().getShell());
if (openCallsiteAction != null) {
manager.add(openCallsiteAction);
}
}
}
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class AbstractSegmentStoreTableViewer method setData.
/**
* Set the data into the viewer. It will update the model. If the provider
* is an analysis, the analysis will be scheduled.
*
* @param provider
* segment store provider
*/
public synchronized void setData(@Nullable ISegmentStoreProvider provider) {
// Set the current segment store provider
fSegmentProvider = provider;
if (provider == null) {
updateModel(null);
return;
}
createProviderColumns();
/*
* If the listener is null then the table is updated from another viewer.
* Otherwise this class is responsible to load the trace.
*/
SegmentStoreProviderProgressListener listener = fListener;
if (listener == null) {
return;
}
ISegmentStore<ISegment> segStore = provider.getSegmentStore();
// If results are not null, then the segment of the provider is ready
// and model can be updated
// FIXME Filtering should be done at the data provider level
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = generateRegexPredicate();
Predicate<ISegment> predicate = (segment) -> {
// Get the filter external input data
Multimap<@NonNull String, @NonNull Object> input = ISegmentStoreProvider.getFilterInput(provider, segment);
/*
* Test each predicates and set the status of the property
* associated to the predicate
*/
boolean activateProperty = false;
for (Map.Entry<Integer, Predicate<Multimap<String, Object>>> mapEntry : predicates.entrySet()) {
Integer property = Objects.requireNonNull(mapEntry.getKey());
Predicate<Multimap<String, Object>> value = Objects.requireNonNull(mapEntry.getValue());
if (property == CoreFilterProperty.DIMMED || property == CoreFilterProperty.EXCLUDE) {
boolean status = value.test(input);
activateProperty |= status;
}
}
return activateProperty;
};
if (segStore != null) {
// Cancel the current filtering job
Job job = fFilteringJob;
if (job != null) {
job.cancel();
}
if (predicates.isEmpty()) {
updateModel(segStore);
return;
}
job = new Job(Messages.SegmentStoreTableViewer_FilteringData) {
@Override
protected IStatus run(@Nullable IProgressMonitor monitor) {
try (ScopeLog log = new ScopeLog(LOGGER, Level.FINE, "SegmentStoreTable:Filtering")) {
// $NON-NLS-1$
SubMonitor subMonitor = SubMonitor.convert(monitor);
ISegmentStore<ISegment> filteredStore = new ArrayListStore<>();
for (ISegment segment : segStore) {
if (subMonitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (predicate.test(segment)) {
filteredStore.add(segment);
}
}
if (subMonitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
updateModel(filteredStore);
return Status.OK_STATUS;
}
}
};
fFilteringJob = job;
job.schedule();
return;
}
// If results are null, then add completion listener and if the provider
// is an analysis, run the analysis
updateModel(null);
provider.addListener(listener);
if (provider instanceof IAnalysisModule) {
((IAnalysisModule) provider).schedule();
}
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class SegmentStoreContentProvider method setSortOrder.
@Override
public void setSortOrder(@Nullable Comparator<?> comparator) {
SegmentStoreWithRange<?> store = fStore;
final TableViewer tableViewer = fTableViewer;
if (comparator == null || store == null || tableViewer == null) {
return;
}
@SuppressWarnings("unchecked") Comparator<ISegment> comp = (Comparator<ISegment>) comparator;
fComparator = comp;
store.setComparator(comp);
tableViewer.refresh();
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class SegmentStoreContentProvider method updateElement.
@Override
public void updateElement(int index) {
final TableViewer tableViewer = fTableViewer;
SegmentStoreWithRange<?> store = fStore;
if (tableViewer == null || store == null) {
return;
}
ISegment element = store.getElement(index);
if (element != null) {
tableViewer.replace(element, index);
}
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class AbstractTestSegmentStore method testContains.
/**
* Test the contains() method.
*/
@Test
public void testContains() {
ISegment otherSegment = new BasicSegment(0, 20);
assertTrue(fSegmentStore.contains(SEGMENT_2_6));
assertTrue(fSegmentStore.contains(SEGMENT_4_8));
assertFalse(fSegmentStore.contains(otherSegment));
}
Aggregations