timing.ui: move logic of segment stats logic to abstract class
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 8 Sep 2016 01:49:34 +0000 (21:49 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 19 Sep 2016 13:48:34 +0000 (09:48 -0400)
Change-Id: I541df669302d72bf28610632ada5db4daf5c5be7
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/80652
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/Messages.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/messages.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsViewer.java

index 49e8b376ffc437bde3bbb5de888d4e7b9b58e00f..26f70c80cda244472af9e609e92a6d6df5705de1 100644 (file)
@@ -13,18 +13,12 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.sta
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.SystemCallLatencyStatisticsAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
 
 /**
  * A tree viewer implementation for displaying latency statistics
@@ -58,40 +52,15 @@ public class SystemCallLatencyStatisticsViewer extends AbstractSegmentStoreStati
     }
 
     @Override
-    protected @Nullable ITmfTreeViewerEntry updateElements(long start, long end, boolean isSelection) {
-        if (isSelection || (start == end)) {
-            return null;
-        }
-
-        TmfAbstractAnalysisModule analysisModule = getStatisticsAnalysisModule();
-
-        if (getTrace() == null || !(analysisModule instanceof SystemCallLatencyStatisticsAnalysisModule)) {
-            return null;
-        }
-
-        SystemCallLatencyStatisticsAnalysisModule module = (SystemCallLatencyStatisticsAnalysisModule) analysisModule;
-
-        module.waitForCompletion();
-
-        TmfTreeViewerEntry root = new TmfTreeViewerEntry(""); //$NON-NLS-1$
-        final SegmentStoreStatistics entry = module.getTotalStats();
-        if (entry != null) {
+    protected @NonNull final String getTotalLabel() {
+        return checkNotNull(Messages.LatencyStatistics_TotalLabel);
+    }
 
-            List<ITmfTreeViewerEntry> entryList = root.getChildren();
+    @Override
+    protected @NonNull final String getTypeLabel() {
+        return SYSCALL_LEVEL;
+    }
 
-            TmfTreeViewerEntry child = new SegmentStoreStatisticsEntry(checkNotNull(Messages.LatencyStatistics_TotalLabel), entry);
-            entryList.add(child);
-            HiddenTreeViewerEntry syscalls = new HiddenTreeViewerEntry(SYSCALL_LEVEL);
-            child.addChild(syscalls);
 
-            Map<String, SegmentStoreStatistics> perSyscallStats = module.getPerSegmentTypeStats();
-            if (perSyscallStats != null) {
-                for (Entry<String, SegmentStoreStatistics> statsEntry : perSyscallStats.entrySet()) {
-                    syscalls.addChild(new SegmentStoreStatisticsEntry(statsEntry.getKey(), statsEntry.getValue()));
-                }
-            }
-        }
-        return root;
-    }
 
 }
index e6472353ce0b4f5194ba51ae84fee3729d1a39dd..cf264dfc75b120d3e76059a95f345b24fcc375d2 100644 (file)
@@ -16,6 +16,8 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import java.text.Format;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.action.Action;
@@ -30,6 +32,7 @@ import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Menu;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
 import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator;
@@ -41,6 +44,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer;
 import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeColumnDataProvider;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry;
 import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeColumnData;
 import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
 
@@ -302,13 +306,14 @@ public abstract class AbstractSegmentStoreStatisticsViewer extends AbstractTmfTr
 
     /**
      * Method to add commands to the context sensitive menu.
+     *
      * @param manager
-     *          the menu manager
+     *            the menu manager
      * @param sel
-     *          the current selection
+     *            the current selection
      */
     protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
-        Object element =  sel.getFirstElement();
+        Object element = sel.getFirstElement();
         if ((element instanceof SegmentStoreStatisticsEntry) && !(element instanceof HiddenTreeViewerEntry)) {
             final SegmentStoreStatisticsEntry segment = (SegmentStoreStatisticsEntry) element;
             IAction gotoStartTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMinAction) {
@@ -380,6 +385,63 @@ public abstract class AbstractSegmentStoreStatisticsViewer extends AbstractTmfTr
 
     }
 
+    @Override
+    protected @Nullable ITmfTreeViewerEntry updateElements(long start, long end, boolean isSelection) {
+        if (isSelection || (start == end)) {
+            return null;
+        }
+
+        TmfAbstractAnalysisModule analysisModule = getStatisticsAnalysisModule();
+
+        if (getTrace() == null || !(analysisModule instanceof AbstractSegmentStatisticsAnalysis)) {
+            return null;
+        }
+
+        AbstractSegmentStatisticsAnalysis module = (AbstractSegmentStatisticsAnalysis) analysisModule;
+
+        module.waitForCompletion();
+
+        TmfTreeViewerEntry root = new TmfTreeViewerEntry(""); //$NON-NLS-1$
+        final SegmentStoreStatistics entry = module.getTotalStats();
+        if (entry != null) {
+
+            List<ITmfTreeViewerEntry> entryList = root.getChildren();
+
+            TmfTreeViewerEntry aggregateEntry = new SegmentStoreStatisticsEntry(getTotalLabel(), entry);
+            entryList.add(aggregateEntry);
+            HiddenTreeViewerEntry category = new HiddenTreeViewerEntry(getTypeLabel());
+            aggregateEntry.addChild(category);
+
+            Map<String, SegmentStoreStatistics> perSegmentStats = module.getPerSegmentTypeStats();
+            if (perSegmentStats != null) {
+                for (Entry<String, SegmentStoreStatistics> statsEntry : perSegmentStats.entrySet()) {
+                    category.addChild(new SegmentStoreStatisticsEntry(statsEntry.getKey(), statsEntry.getValue()));
+                }
+            }
+        }
+        return root;
+    }
+
+    /**
+     * Get the type label
+     *
+     * @return the label
+     * @since 1.1
+     */
+    protected String getTypeLabel() {
+        return checkNotNull(Messages.AbstractSegmentStoreStatisticsViewer_types);
+    }
+
+    /**
+     * Get the total column label
+     *
+     * @return the totals column label
+     * @since 1.1
+     */
+    protected String getTotalLabel() {
+        return checkNotNull(Messages.AbstractSegmentStoreStatisticsViewer_total);
+    }
+
     /**
      * Class to define a level in the tree that doesn't have any values.
      */
index cadeaa8f41bb8907f996f15f4df6613e251b6190..2e4579e7cf04d2cf639b24bc99cd50f07b17dcc4 100644 (file)
@@ -22,6 +22,11 @@ public class Messages extends NLS {
 
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics.messages"; //$NON-NLS-1$
 
+    /** Default "total" label in statistics viewer */
+    public static String AbstractSegmentStoreStatisticsViewer_total;
+    /** Default "category" label in statistics viewer */
+    public static String AbstractSegmentStoreStatisticsViewer_types;
+
     /** Name of level column */
     public static String SegmentStoreStatistics_LevelLabel;
     /** Name of the minimum column */
index beb2de0fc6ef7401821c77b4725226e002c6ff60..73a47d34ca2ba19d8f82d2ca4c6998f79f63cff5 100644 (file)
@@ -9,6 +9,8 @@
 # Contributors:
 #     Bernd Hufmann - Initial API and implementation
 ###############################################################################
+AbstractSegmentStoreStatisticsViewer_total=Total
+AbstractSegmentStoreStatisticsViewer_types=Types
 SegmentStoreStatistics_LevelLabel=Level
 SegmentStoreStatistics_Statistics_MinLabel=Minimum
 SegmentStoreStatistics_MaxLabel=Maximum
index a0a6f16f4d0ce6d1e12f4541b753113033561a07..916a788fdd01f4171ad77397da98a14f9d4fde3d 100644 (file)
@@ -8,21 +8,12 @@
  *******************************************************************************/
 package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternLatencyStatisticsAnalysis;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
 
 /**
  * A tree viewer implementation for displaying pattern latency statistics
@@ -51,40 +42,8 @@ public class PatternStatisticsViewer extends AbstractSegmentStoreStatisticsViewe
     }
 
     @Override
-    protected ITmfTreeViewerEntry updateElements(long start, long end, boolean isSelection) {
-        if (isSelection || (start == end)) {
-            return null;
-        }
-
-        TmfAbstractAnalysisModule analysisModule = getStatisticsAnalysisModule();
-
-        if (getTrace() == null || !(analysisModule instanceof XmlPatternLatencyStatisticsAnalysis)) {
-            return null;
-        }
-
-        XmlPatternLatencyStatisticsAnalysis module = (XmlPatternLatencyStatisticsAnalysis) analysisModule;
-
-        module.waitForCompletion();
-
-        TmfTreeViewerEntry root = new TmfTreeViewerEntry(""); //$NON-NLS-1$
-        final SegmentStoreStatistics entry = module.getTotalStats();
-        if (entry != null) {
-
-            List<ITmfTreeViewerEntry> entryList = root.getChildren();
-
-            TmfTreeViewerEntry child = new SegmentStoreStatisticsEntry(checkNotNull("Total"), entry); //$NON-NLS-1$
-            entryList.add(child);
-            HiddenTreeViewerEntry segments = new HiddenTreeViewerEntry(PATTERN_SEGMENTS_LEVEL);
-            child.addChild(segments);
-
-            final Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = module.getPerSegmentTypeStats();
-            if (perTypeStats != null) {
-                for (Entry<@NonNull String, @NonNull SegmentStoreStatistics> statsEntry : perTypeStats.entrySet()) {
-                    segments.addChild(new SegmentStoreStatisticsEntry(statsEntry.getKey(), statsEntry.getValue()));
-                }
-            }
-        }
-        return root;
+    protected @NonNull String getTypeLabel() {
+        return PATTERN_SEGMENTS_LEVEL;
     }
 
     /**
This page took 0.031189 seconds and 5 git commands to generate.