Search in sources :

Example 16 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testConstructors.

// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
 * Test constructors and getter/setters.
 */
@Test
public void testConstructors() {
    TmfTreeDataModel model0 = createModel(0);
    assertEquals(ID0, model0.getId());
    assertEquals(PARENT_ID0, model0.getParentId());
    assertEquals(LABELS0.get(0), model0.getName());
    assertEquals(LABELS0, model0.getLabels());
    assertTrue(model0.hasRowModel());
    assertEquals(STYLE0, model0.getStyle());
    TmfTreeDataModel model1 = createModel(1);
    assertEquals(ID1, model1.getId());
    assertEquals(PARENT_ID1, model1.getParentId());
    assertEquals(LABELS1.get(0), model1.getName());
    assertEquals(LABELS1, model1.getLabels());
    assertFalse(model1.hasRowModel());
    assertEquals(STYLE1, model1.getStyle());
    TmfTreeDataModel model2 = createModel(2);
    assertEquals(ID2, model2.getId());
    assertEquals(PARENT_ID2, model2.getParentId());
    assertEquals(NAME, model2.getName());
    assertEquals(1, model2.getLabels().size());
    assertEquals(NAME, model2.getLabels().get(0));
    assertTrue(model2.hasRowModel());
    assertEquals(STYLE3, model2.getStyle());
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Test(org.junit.Test)

Example 17 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class CounterDataProvider method getTree.

/**
 * @since 1.2
 */
@Override
protected TmfTreeModel<TmfTreeDataModel> getTree(ITmfStateSystem ss, Map<String, Object> parameters, @Nullable IProgressMonitor monitor) {
    List<TmfTreeDataModel> entries = new ArrayList<>();
    long rootId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
    entries.add(new TmfTreeDataModel(rootId, -1, Collections.singletonList(getTrace().getName())));
    addTreeViewerBranch(ss, rootId, Collections.singletonList(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB), entries);
    addTreeViewerBranch(ss, rootId, Collections.singletonList(CounterAnalysis.UNGROUPED_COUNTER_ASPECTS_ATTRIB), entries);
    return new TmfTreeModel<>(Collections.emptyList(), entries);
}
Also used : ArrayList(java.util.ArrayList) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)

Example 18 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class CounterDataProvider method addTreeViewerBranch.

private void addTreeViewerBranch(ITmfStateSystem ss, long parentId, List<String> branchName, List<TmfTreeDataModel> entries) {
    int quark = ss.optQuarkAbsolute(branchName.get(0));
    if (quark != ITmfStateSystem.INVALID_ATTRIBUTE && !ss.getSubAttributes(quark, false).isEmpty()) {
        long id = getId(quark);
        TmfTreeDataModel branch = new TmfTreeDataModel(id, parentId, branchName);
        entries.add(branch);
        addTreeViewerEntries(ss, id, quark, entries);
    }
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)

Example 19 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class CounterDataProviderFactory method createProvider.

/**
 * @since 2.0
 */
@Override
@Nullable
public ITmfTreeXYDataProvider<? extends ITmfTreeDataModel> createProvider(ITmfTrace trace) {
    Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(trace);
    if (traces.size() == 1) {
        List<ITmfTreeXYDataProvider<TmfTreeDataModel>> dataProviders = new ArrayList<>();
        for (CounterAnalysis module : TmfTraceUtils.getAnalysisModulesOfClass(trace, CounterAnalysis.class)) {
            ITmfTrace subTrace = module.getTrace();
            ITmfTreeXYDataProvider<TmfTreeDataModel> provider = CounterDataProvider.create(Objects.requireNonNull(subTrace), module);
            if (provider != null) {
                dataProviders.add(provider);
            }
        }
        if (dataProviders.isEmpty()) {
            return null;
        } else if (dataProviders.size() == 1) {
            return dataProviders.get(0);
        }
        return new TmfTreeXYCompositeDataProvider<>(dataProviders, TITLE, CounterDataProvider.ID);
    }
    return TmfTreeXYCompositeDataProvider.create(traces, TITLE, CounterDataProvider.ID);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTreeXYCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.xy.TmfTreeXYCompositeDataProvider) CounterAnalysis(org.eclipse.tracecompass.analysis.counters.core.CounterAnalysis) ArrayList(java.util.ArrayList) ITmfTreeXYDataProvider(org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 20 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class DisksIODataProvider method getTree.

@Override
protected TmfTreeModel<TmfTreeDataModel> getTree(ITmfStateSystem ss, Map<String, Object> parameters, @Nullable IProgressMonitor monitor) {
    List<TmfTreeDataModel> nodes = new ArrayList<>();
    long rootId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
    nodes.add(new TmfTreeDataModel(rootId, -1, Collections.singletonList(getTrace().getName()), false, null));
    String readName = Objects.requireNonNull(Messages.DisksIODataProvider_read);
    String writeName = Objects.requireNonNull(Messages.DisksIODataProvider_write);
    int i = 0;
    for (Integer diskQuark : ss.getQuarks(Attributes.DISKS, "*")) {
        // $NON-NLS-1$
        String diskName = DiskUtils.getDiskName(ss, diskQuark);
        long diskId = getId(diskQuark);
        nodes.add(new TmfTreeDataModel(diskId, rootId, Collections.singletonList(diskName), false, null));
        // Do not add the read/write entries if there was no read/write
        int readQuark = ss.optQuarkRelative(diskQuark, Attributes.SECTORS_READ);
        int writeQuark = ss.optQuarkRelative(diskQuark, Attributes.SECTORS_WRITTEN);
        if (readQuark == ITmfStateSystem.INVALID_ATTRIBUTE && writeQuark == ITmfStateSystem.INVALID_ATTRIBUTE) {
            continue;
        }
        // Get read and write color for this disk
        Pair<String, String> pair = COLOR_LIST.get(i % COLOR_LIST.size());
        String seriesStyle = SUPPORTED_STYLES.get((i / COLOR_LIST.size()) % SUPPORTED_STYLES.size());
        if (readQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
            nodes.add(new TmfTreeDataModel(getId(readQuark), diskId, Collections.singletonList(readName), true, new OutputElementStyle(BASE_STYLE, ImmutableMap.of(StyleProperties.COLOR, pair.getFirst(), StyleProperties.SERIES_STYLE, seriesStyle, StyleProperties.STYLE_NAME, diskName + '/' + readName))));
        }
        if (writeQuark != ITmfStateSystem.INVALID_ATTRIBUTE) {
            nodes.add(new TmfTreeDataModel(getId(writeQuark), diskId, Collections.singletonList(writeName), true, new OutputElementStyle(BASE_STYLE, ImmutableMap.of(StyleProperties.COLOR, pair.getSecond(), StyleProperties.SERIES_STYLE, seriesStyle, StyleProperties.STYLE_NAME, diskName + '/' + writeName))));
        }
        i++;
    }
    return new TmfTreeModel<>(Collections.emptyList(), nodes);
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) ArrayList(java.util.ArrayList) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)

Aggregations

TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)21 Test (org.junit.Test)9 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)8 ArrayList (java.util.ArrayList)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)4 HashMap (java.util.HashMap)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)3 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)3 Map (java.util.Map)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)2 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)2 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)2 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)2 ITmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry)2 TmfGenericTreeEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)2