use of org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider in project tracecompass by tracecompass.
the class AbstractSegmentStoreTableViewer method setSegmentProvider.
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/**
* Sets the segment provider, use only in test, only run in display thread
*
* @param segmentProvider
* the segment provider
* @since 1.2
*/
@VisibleForTesting
public void setSegmentProvider(ISegmentStoreProvider segmentProvider) {
fSegmentProvider = segmentProvider;
// Sort order of the content provider is by start time by default
getTableViewer().setContentProvider(new SegmentStoreContentProvider());
Table table = getTableViewer().getTable();
table.setRedraw(false);
while (table.getColumnCount() > 0) {
table.getColumn(0).dispose();
}
createColumns();
createProviderColumns();
getTableViewer().getTable().addSelectionListener(new TableSelectionListener());
addPackListener();
table.setRedraw(true);
}
use of org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider in project tracecompass by tracecompass.
the class AbstractSegmentStoreTableViewer method updateModel.
/**
* Update the data in the table viewer
*
* @param dataInput
* New data input
*/
public void updateModel(@Nullable final Object dataInput) {
final TableViewer tableViewer = getTableViewer();
Display.getDefault().asyncExec(() -> {
try (ScopeLog sl = new ScopeLog(LOGGER, Level.FINE, "updateModel")) {
// $NON-NLS-1$
if (!tableViewer.getTable().isDisposed()) {
// Go to the top of the table
tableViewer.getTable().setTopIndex(0);
ISelection selection = tableViewer.getSelection();
ISegment selected = null;
if (!selection.isEmpty() && selection instanceof StructuredSelection) {
Object firstElement = ((StructuredSelection) selection).getFirstElement();
if (firstElement instanceof ISegment) {
selected = (ISegment) firstElement;
}
}
// Reset selected row
if (dataInput == null) {
tableViewer.setSelection(StructuredSelection.EMPTY);
tableViewer.setInput(null);
tableViewer.setItemCount(0);
return;
}
addPackListener();
tableViewer.setInput(dataInput);
SegmentStoreContentProvider contentProvider = (SegmentStoreContentProvider) getTableViewer().getContentProvider();
long segmentCount = contentProvider.getSegmentCount();
String contentProviderName = contentProvider.getClass().getSimpleName();
// $NON-NLS-1$
TraceCompassLogUtils.traceCounter(LOGGER, Level.FINE, "SegmentStoreTableViewer#updateModel", contentProviderName, segmentCount);
if (segmentCount > MAX_ITEMS) {
tableViewer.setItemCount(MAX_ITEMS);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Activator.getDefault().logWarning("Too many items to display for " + contentProviderName + ". Cannot display " + segmentCount + " in a reasonable timeframe.");
} else {
tableViewer.setItemCount((int) segmentCount);
}
boolean found = false;
if (selected != null && dataInput instanceof ISegmentStore<?>) {
ISegmentStore<?> store = (ISegmentStore<?>) dataInput;
for (ISegment segment : store.getIntersectingElements(selected.getEnd())) {
if (isSameish(segment, selected)) {
selection = new StructuredSelection(segment);
tableViewer.setSelection(selection, true);
found = true;
break;
}
}
}
if (!found) {
tableViewer.setSelection(StructuredSelection.EMPTY);
}
}
}
});
}
Aggregations