timing: Add a generic statistics table view
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.timing.ui / src / org / eclipse / tracecompass / analysis / timing / ui / views / segmentstore / statistics / SegmentStoreStatisticsViewer.java
1 /*******************************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
16 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
17 import org.eclipse.tracecompass.segmentstore.core.ISegment;
18 import org.eclipse.tracecompass.segmentstore.core.segment.interfaces.INamedSegment;
19 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
20 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
21 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
22
23 /**
24 * Generic viewer to show segment store statistics analysis data.
25 *
26 * @since 1.4
27 */
28 public class SegmentStoreStatisticsViewer extends AbstractSegmentsStatisticsViewer {
29
30 private final String fAnalysisId;
31
32 /**
33 * Constructor
34 *
35 * @param parent
36 * The parent composite
37 * @param analysisId
38 * The ID of the segment store provider to do statistics on
39 */
40 public SegmentStoreStatisticsViewer(Composite parent, String analysisId) {
41 super(parent);
42 fAnalysisId = analysisId;
43 }
44
45 @Override
46 protected @Nullable TmfAbstractAnalysisModule createStatisticsAnalysiModule() {
47 AbstractSegmentStatisticsAnalysis module = new AbstractSegmentStatisticsAnalysis() {
48
49 @Override
50 protected @Nullable String getSegmentType(@NonNull ISegment segment) {
51 if (segment instanceof INamedSegment) {
52 return ((INamedSegment) segment).getName();
53 }
54 return null;
55 }
56
57 @Override
58 protected @Nullable ISegmentStoreProvider getSegmentProviderAnalysis(@NonNull ITmfTrace trace) {
59 IAnalysisModule m = trace.getAnalysisModule(fAnalysisId);
60 if (!(m instanceof ISegmentStoreProvider)) {
61 return null;
62 }
63 return (ISegmentStoreProvider) m;
64 }
65
66 };
67 return module;
68 }
69
70 }
This page took 0.032063 seconds and 5 git commands to generate.