xml.ui: Add label prefix for XML Latency Views
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Fri, 12 May 2017 15:33:00 +0000 (11:33 -0400)
committerJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Wed, 17 May 2017 18:16:30 +0000 (14:16 -0400)
This patch adds an element to the <header> of the xml analysis
description The new element is a prefix for the XML analyses latency
views. The new name of the latency table will be like "PREFIX_LABEL
Latency Table".
This could be easily extendable to all type of xml view.

Change-Id: I697424b2e5d9ac4a15d96760fd0ca5011159a93e
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/96966
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
13 files changed:
lttng/org.eclipse.tracecompass.lttng2.kernel.core/analysis.xml/org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.xml.futex/futex_analysis_lttng.xml
lttng/org.eclipse.tracecompass.lttng2.kernel.core/analysis.xml/org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.xml.irq/irq_analysis_lttng.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/pattern/stateprovider/XmlPatternAnalysis.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/TmfAnalysisModuleHelperXml.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/TmfXmlStrings.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/xmlPatternStateProvider.xsd
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/TmfXmlAnalysisOutputSource.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlLatencyViewInfo.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternDensityView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternScatterGraphView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsView.java

index d3394f356bcfdcae8c232fdf3a2678f0ebdf8839..1491066ed5db6a12593e969f02c6367d8d43c6ee 100644 (file)
@@ -98,6 +98,7 @@ TRYLOCK_PI    136             264
        <head>
                <traceType id="org.eclipse.linuxtools.lttng2.kernel.tracetype" />
                <label value="XML Futex Contention Analysis" />
+               <viewLabelPrefix value="Contention" />
        </head>
 
        <location id="CurrentCPU">
index aa1e126de6fde3b2b0d29fc082291b51f1a5ac1c..a14e146512f14a2e4b81886d19294407ebe8a5f5 100644 (file)
@@ -40,6 +40,7 @@
         <head>
             <traceType id="org.eclipse.linuxtools.lttng2.kernel.tracetype" />
             <label value="XML IRQ Analysis"/>
+            <viewLabelPrefix value="IRQ" />
         </head>
 
         <storedField id="ret" alias="ret" />
index dbd171cb5f7a2429e28243e8a8d2823c20e63dba..b9246fcefe27a4ee171cc194ea322406e1d0293e 100644 (file)
@@ -61,6 +61,7 @@ public class XmlPatternAnalysis extends TmfAbstractAnalysisModule implements ITm
     private XmlPatternStateSystemModule fStateSystemModule;
     private XmlPatternSegmentStoreModule fSegmentStoreModule;
     private boolean fInitializationSucceeded;
+    private String fViewLabelPrefix;
 
     /**
      * Constructor
@@ -86,6 +87,25 @@ public class XmlPatternAnalysis extends TmfAbstractAnalysisModule implements ITm
         return fStateSystemModule.getStateSystems();
     }
 
+    /**
+     * Set the associated view label prefix
+     *
+     * @param viewLabelPrefix
+     *            The view label prefix
+     */
+    public void setViewLabelPrefix(String viewLabelPrefix) {
+        fViewLabelPrefix = viewLabelPrefix;
+    }
+
+    /**
+     * Get the associated view label prefix
+     *
+     * @return The view label prefix
+     */
+    public String getViewLabelPrefix() {
+        return fViewLabelPrefix;
+    }
+
     @Override
     public boolean waitForInitialization() {
         try {
index 2efccd7f8f72ac32a8ff581d074c55304e6c053d..24213f89bdb00183234cbfb931aaf5cfc31f8f96 100644 (file)
@@ -109,6 +109,27 @@ public class TmfAnalysisModuleHelperXml implements IAnalysisModuleHelper, ITmfPr
         return name;
     }
 
+    /**
+     * Get the XML view prefix label
+     *
+     * @return XML view prefix label or empty string if the value is missing in
+     *         the XML element
+     */
+    public @NonNull String getViewLabelPrefix() {
+        if (!fType.equals(XmlAnalysisModuleType.PATTERN)) {
+            return TmfXmlStrings.EMPTY_STRING;
+        }
+        String viewLabel = TmfXmlStrings.EMPTY_STRING;
+        List<Element> head = TmfXmlUtils.getChildElements(fSourceElement, TmfXmlStrings.HEAD);
+        if (head.size() == 1) {
+            List<Element> labels = TmfXmlUtils.getChildElements(head.get(0), TmfXmlStrings.VIEW_LABEL_PREFIX);
+            if (!labels.isEmpty()) {
+                viewLabel = labels.get(0).getAttribute(TmfXmlStrings.VALUE);
+            }
+        }
+        return viewLabel;
+    }
+
     @Override
     public boolean isAutomatic() {
         return false;
@@ -121,12 +142,12 @@ public class TmfAnalysisModuleHelperXml implements IAnalysisModuleHelper, ITmfPr
 
     @Override
     public String getHelpText() {
-        return ""; //$NON-NLS-1$
+        return TmfXmlStrings.EMPTY_STRING;
     }
 
     @Override
     public String getHelpText(@NonNull ITmfTrace trace) {
-        return ""; //$NON-NLS-1$
+        return TmfXmlStrings.EMPTY_STRING;
     }
 
     @Override
@@ -193,6 +214,7 @@ public class TmfAnalysisModuleHelperXml implements IAnalysisModuleHelper, ITmfPr
             module.setId(analysisid);
             XmlPatternAnalysis paModule = (XmlPatternAnalysis) module;
             paModule.setXmlFile(fSourceFile.toPath());
+            paModule.setViewLabelPrefix(getViewLabelPrefix());
 
             break;
         case OTHER:
index 4e7fb64af7b8c4c43cdf0a6763941c826bad845c..e0a336dee721e5c06f1986d4b8495b25e5d26f0a 100644 (file)
@@ -171,4 +171,5 @@ public interface TmfXmlStrings {
     String MAPPING_GROUP = "mappingGroup";
     String ENTRY = "entry";
     String INITIAL_STATE = "initialState";
+    String VIEW_LABEL_PREFIX = "viewLabelPrefix";
 }
\ No newline at end of file
index 88a292954b8256478a4d160416b8c144b1427542..d4c04ae06b74da370f6caad9d99f10563e4a4558 100644 (file)
                                                        <xs:documentation>The text to name this pattern provider (and the analysis it will generate).</xs:documentation></xs:annotation></xs:attribute>
                                </xs:complexType>
                        </xs:element>
+                       <xs:element maxOccurs="1" minOccurs="0" name="viewLabelPrefix">
+                <xs:annotation>
+                    <xs:documentation>Adds a label prefix to the pattern latency views. If provided, this text will be used as prefix for the name of the latency views associated with this analysis</xs:documentation></xs:annotation>
+                <xs:complexType>
+                    <xs:attribute name="value" >
+                        <xs:annotation>
+                            <xs:documentation>The text to use as prefix name this pattern latency views.</xs:documentation></xs:annotation></xs:attribute>
+                </xs:complexType>
+            </xs:element>
                </xs:sequence>
        </xs:complexType>
 
index b3a3b1fcb430a028e5adaf54794763ac05d0416a..bab799cbda19fad7978ae69a4cd6ef7588b1fdc6 100644 (file)
@@ -29,6 +29,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.ui;x-friends:
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.timegraph;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;x-internal:=true
-Import-Package: com.google.common.collect,
+Import-Package: com.google.common.base;version="15.0.0",
+ com.google.common.collect,
  org.apache.commons.lang3,
  org.eclipse.ui.views.properties
index df6f1c150290f758752b7c3cf8751b2d74382a60..72b1d16298158b5d58629b9faf024951cfd1867b 100644 (file)
@@ -50,6 +50,7 @@ import org.xml.sax.SAXException;
  */
 public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener {
 
+    private static final String LATENCY_STRING = "Latency"; //$NON-NLS-1$
     /** String separating data elements for the output properties */
     public static final @NonNull String DATA_SEPARATOR = ";;;"; //$NON-NLS-1$
 
@@ -189,8 +190,10 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
                 // Add the latency views for pattern analysis
                 if (module instanceof XmlPatternAnalysis) {
                     for (LatencyViewType viewType : LatencyViewType.values()) {
-                        IAnalysisOutput output = new TmfXmlLatencyViewOutput(viewType.getViewId(), viewType.getLabel());
-                        output.setOutputProperty(TmfXmlUiStrings.XML_LATENCY_OUTPUT_DATA, module.getId() + DATA_SEPARATOR + viewType.getLabel(), false);
+                        String viewLabelPrefix = ((XmlPatternAnalysis) module).getViewLabelPrefix();
+                        String label = viewLabelPrefix.isEmpty() ? viewType.getLabel() : viewType.getLabel().replaceFirst(LATENCY_STRING, viewLabelPrefix);
+                        IAnalysisOutput output = new TmfXmlLatencyViewOutput(viewType.getViewId(), label);
+                        output.setOutputProperty(TmfXmlUiStrings.XML_LATENCY_OUTPUT_DATA, module.getId() + DATA_SEPARATOR + output.getName(), false);
                         module.registerOutput(output);
                     }
                 }
index c225b41250faaf06acc68cb95a6caa99134c69a6..b2b4b4ddb6cbc85ad8341b2ddc8658aad346d6dd 100644 (file)
@@ -50,6 +50,15 @@ public class XmlLatencyViewInfo extends AbstractXmlViewInfo {
         return fAnalysisId;
     }
 
+    /**
+     * Get the view label
+     *
+     * @return The view label
+     */
+    public String getLabel() {
+        return fLabel;
+    }
+
     /**
      * Set the data for this view and retrieves from it the analysis ID of the
      * pattern analysis this view belongs to and the view label.
index d71c6b6cf2efc2dd8c43dbbf87ad692c6baa4aaa..835014b8ef0f5a4b5041fe10bfb679a5768c4ea0 100644 (file)
@@ -50,6 +50,7 @@ public class PatternDensityView extends AbstractSegmentStoreDensityView {
                     if (newValue instanceof String) {
                         String data = (String) newValue;
                         fViewInfo.setViewData(data);
+                        setPartName(fViewInfo.getLabel());
                         loadTableViewer();
                         loadDensityViewer();
                     }
index 194d49ccf87bf3c6855f0830f9b2f5bb1043d4a4..6b500b260b9e2b83c7022c13309dcb604afd79f5 100644 (file)
@@ -43,6 +43,7 @@ public class PatternLatencyTableView extends AbstractSegmentStoreTableView {
                     if (newValue instanceof String) {
                         String data = (String) newValue;
                         fViewInfo.setViewData(data);
+                        setPartName(fViewInfo.getLabel());
                         loadLatencyView();
                     }
                 }
index 413f057b6317c02941a1060fcd86ec5eb0bb83d6..b96c52e73f53a130d79128b0e8e280f8c623bb40 100644 (file)
@@ -46,6 +46,7 @@ public class PatternScatterGraphView extends TmfChartView {
                     if (newValue instanceof String) {
                         String data = (String) newValue;
                         fViewInfo.setViewData(data);
+                        setPartName(fViewInfo.getLabel());
                         loadLatencyView();
                     }
                 }
index 9aafc1c77dd456bc20d86306a0fa05781fa589f0..52c19da524f1b62270c66368929c335b26f8c11c 100644 (file)
@@ -42,6 +42,7 @@ public class PatternStatisticsView extends AbstractSegmentsStatisticsView {
                     if (newValue instanceof String) {
                         String data = (String) newValue;
                         fViewInfo.setViewData(data);
+                        setPartName(fViewInfo.getLabel());
                         loadStatisticView();
                     }
                 }
This page took 0.032271 seconds and 5 git commands to generate.