use of org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor in project tracecompass by tracecompass.
the class TableColumnDescriptorTest method test.
// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
* Test @{link TableColumnDescriptor) construction using {@link Builder}.
*/
@Test
public void test() {
TableColumnDescriptor.Builder builder = new TableColumnDescriptor.Builder();
ITableColumnDescriptor desc = builder.setText(COLUMN_TEXT0).build();
assertEquals("Column header", COLUMN_TEXT0, desc.getText());
assertTrue("Empty tooltip", desc.getTooltip().isEmpty());
builder = new TableColumnDescriptor.Builder();
desc = builder.setText(COLUMN_TEXT0).setTooltip(COLUMN_TOOLTIP0).build();
assertEquals("Column header", COLUMN_TEXT0, desc.getText());
assertEquals("Column tooltip", COLUMN_TOOLTIP0, desc.getTooltip());
builder = new TableColumnDescriptor.Builder();
desc = builder.setTooltip(COLUMN_TOOLTIP0).build();
assertTrue("Empty Text", desc.getText().isEmpty());
assertEquals("Column tooltip", COLUMN_TOOLTIP0, desc.getTooltip());
}
use of org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor in project tracecompass by tracecompass.
the class TableColumnDescriptorTest method testHashCode.
// ------------------------------------------------------------------------
// TableColumnDescriptor#hashCode
// ------------------------------------------------------------------------
/**
* Run the {@link ITableColumnDescriptor#hashCode} method test.
*/
@Test
public void testHashCode() {
ITableColumnDescriptor model0 = createDescriptor(0);
ITableColumnDescriptor model1 = createDescriptor(1);
assertEquals(HASH_CODE, fModel0.hashCode(), model0.hashCode());
assertEquals(HASH_CODE, fModel1.hashCode(), model1.hashCode());
assertNotEquals(HASH_CODE, fModel0.hashCode(), model1.hashCode());
assertNotEquals(HASH_CODE, fModel1.hashCode(), model0.hashCode());
}
use of org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor in project tracecompass by tracecompass.
the class TableColumnDescriptorTest method testToString.
/**
* Test {@link TableColumnDescriptor#toString()}
*/
@Test
public void testToString() {
TableColumnDescriptor.Builder builder = new TableColumnDescriptor.Builder();
ITableColumnDescriptor desc = builder.setText(COLUMN_TEXT0).setTooltip(COLUMN_TOOLTIP0).build();
assertEquals(TO_STRING, "[text=Name tooltip=Tooltip]", desc.toString());
}
use of org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor in project tracecompass by tracecompass.
the class TmfTreeCompositeDataProvider method fetchTree.
@Override
public TmfModelResponse<TmfTreeModel<M>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
boolean isComplete = true;
List<Entry<M, Object>> entries = new ArrayList<>();
List<ITableColumnDescriptor> columnDescriptor = null;
Table<Object, Long, @NonNull M> scopedEntries = HashBasedTable.create();
for (P dataProvider : fProviders) {
Map<Long, AtomicInteger> indexMap = new HashMap<>();
TmfModelResponse<TmfTreeModel<M>> response = dataProvider.fetchTree(fetchParameters, monitor);
isComplete &= response.getStatus() == ITmfResponse.Status.COMPLETED;
TmfTreeModel<M> model = response.getModel();
if (model != null) {
Object scope = (model.getScope() == null) ? dataProvider : model.getScope();
Map<Long, @NonNull M> row = scopedEntries.row(scope);
for (M entry : model.getEntries()) {
M previous = row.putIfAbsent(entry.getId(), entry);
// Ignore duplicate entries from different data providers
if (previous == null) {
if (entry.getParentId() == -1) {
entries.add(new SimpleEntry(entry, scope));
} else {
/*
* Insert new entries from subsequent data providers
* at the correct position in the entries list. New
* entries are inserted before sibling entries from
* previous data providers.
*/
int index = indexMap.computeIfAbsent(entry.getParentId(), l -> new AtomicInteger()).getAndIncrement();
int pos = 0;
while (pos < entries.size()) {
Entry<M, Object> added = entries.get(pos);
if (added.getValue().equals(scope) && added.getKey().getParentId() == entry.getParentId()) {
if (index == 0) {
break;
}
index--;
}
pos++;
}
if (pos < entries.size()) {
entries.add(pos, new SimpleEntry(entry, scope));
} else {
entries.add(new SimpleEntry(entry, scope));
}
}
} else {
indexMap.computeIfAbsent(entry.getParentId(), l -> new AtomicInteger()).getAndIncrement();
}
}
// Use the column descriptor of the first model. All descriptors are supposed to be the same
if (columnDescriptor == null) {
columnDescriptor = model.getColumnDescriptors();
}
}
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
}
TmfTreeModel.Builder<M> treeModelBuilder = new TmfTreeModel.Builder<>();
if (columnDescriptor == null) {
columnDescriptor = Collections.emptyList();
}
treeModelBuilder.setColumnDescriptors(columnDescriptor).setEntries(Lists.transform(entries, e -> e.getKey()));
if (isComplete) {
return new TmfModelResponse<>(treeModelBuilder.build(), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
return new TmfModelResponse<>(treeModelBuilder.build(), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
use of org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor in project tracecompass by tracecompass.
the class SegmentStoreStatisticsDataProviderTest method testFetchTreeWithMapperFullRange.
/**
* Test to verify
* {@link SegmentStoreStatisticsDataProvider#fetchTree(Map, org.eclipse.core.runtime.IProgressMonitor)}
* for the full trace
*/
@Test
public void testFetchTreeWithMapperFullRange() {
Map<@NonNull String, @NonNull Object> fetchParameters = new HashMap<>();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull SegmentStoreStatisticsModel>> response = fTestDataProvider2.fetchTree(fetchParameters, new NullProgressMonitor());
assertNotNull(response);
TmfTreeModel<@NonNull SegmentStoreStatisticsModel> treeModel = response.getModel();
assertNotNull(treeModel);
assertEquals("Header list size", EXPECTED_HEADER_LIST.size(), treeModel.getHeaders().size());
assertEquals("Header list", EXPECTED_HEADER_LIST, treeModel.getHeaders());
List<@NonNull ITableColumnDescriptor> columnDescriptors = treeModel.getColumnDescriptors();
assertEquals("Header descriptor list size", EXPECTED_HEADER_LIST.size(), columnDescriptors.size());
assertEquals("Column descriptor list", fExpectedDescriptors, columnDescriptors);
assertNull("Scope", treeModel.getScope());
List<@NonNull SegmentStoreStatisticsModel> entries = treeModel.getEntries();
assertNotNull("Entries", entries);
verifyEntries(LIST_OF_EXPECTED_LABELS_WITH_MAPPER_FULL, EXPECTED_STATS_WITH_MAPPER_FULL, entries, 0, EXPECTED_STATS_WITH_MAPPER_FULL.size());
}
Aggregations