1 /*******************************************************************************
2 * Copyright (c) 2016 Ericsson
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 package org
.eclipse
.tracecompass
.internal
.tmf
.analysis
.xml
.ui
.views
.latency
;
11 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
13 import java
.util
.List
;
15 import java
.util
.Map
.Entry
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.jdt
.annotation
.Nullable
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
20 import org
.eclipse
.tracecompass
.analysis
.timing
.core
.segmentstore
.statistics
.SegmentStoreStatistics
;
21 import org
.eclipse
.tracecompass
.analysis
.timing
.ui
.views
.segmentstore
.statistics
.AbstractSegmentStoreStatisticsViewer
;
22 import org
.eclipse
.tracecompass
.internal
.tmf
.analysis
.xml
.core
.pattern
.stateprovider
.XmlPatternLatencyStatisticsAnalysis
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAbstractAnalysisModule
;
24 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.tree
.ITmfTreeViewerEntry
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.tree
.TmfTreeViewerEntry
;
28 * A tree viewer implementation for displaying pattern latency statistics
30 * @author Jean-Christian Kouame
32 public class PatternStatisticsViewer
extends AbstractSegmentStoreStatisticsViewer
{
34 private String fAnalysisId
;
36 private static final @NonNull String PATTERN_SEGMENTS_LEVEL
= "Pattern Segments"; //$NON-NLS-1$
42 * The parent composite
44 public PatternStatisticsViewer(@NonNull Composite parent
) {
49 protected @Nullable TmfAbstractAnalysisModule
createStatisticsAnalysiModule() {
50 return new XmlPatternLatencyStatisticsAnalysis(fAnalysisId
);
54 protected ITmfTreeViewerEntry
updateElements(long start
, long end
, boolean isSelection
) {
55 if (isSelection
|| (start
== end
)) {
59 TmfAbstractAnalysisModule analysisModule
= getStatisticsAnalysisModule();
61 if (getTrace() == null || !(analysisModule
instanceof XmlPatternLatencyStatisticsAnalysis
)) {
65 XmlPatternLatencyStatisticsAnalysis module
= (XmlPatternLatencyStatisticsAnalysis
) analysisModule
;
67 module
.waitForCompletion();
69 TmfTreeViewerEntry root
= new TmfTreeViewerEntry(""); //$NON-NLS-1$
70 final SegmentStoreStatistics entry
= module
.getTotalStats();
73 List
<ITmfTreeViewerEntry
> entryList
= root
.getChildren();
75 TmfTreeViewerEntry child
= new SegmentStoreStatisticsEntry(checkNotNull("Total"), entry
); //$NON-NLS-1$
77 HiddenTreeViewerEntry segments
= new HiddenTreeViewerEntry(PATTERN_SEGMENTS_LEVEL
);
78 child
.addChild(segments
);
80 final Map
<@NonNull String
, @NonNull SegmentStoreStatistics
> perTypeStats
= module
.getPerSegmentTypeStats();
81 if (perTypeStats
!= null) {
82 for (Entry
<@NonNull String
, @NonNull SegmentStoreStatistics
> statsEntry
: perTypeStats
.entrySet()) {
83 segments
.addChild(new SegmentStoreStatisticsEntry(statsEntry
.getKey(), statsEntry
.getValue()));
91 * Set the analysis ID and update the view
96 public void updateViewer(String analysisId
) {
97 if (analysisId
!= null) {
98 fAnalysisId
= analysisId
;
99 initializeDataSource();