TMF: Fix a bug where the label of an XML XY chart is not considered
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 2 Sep 2014 17:45:52 +0000 (13:45 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 19 Sep 2014 19:08:52 +0000 (15:08 -0400)
Change-Id: I055395e8ab91b0551f54d91fb54ef71d9df4c1a7
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/32728
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfXmlAnalysisOutputSource.java
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfXmlViewOutput.java

index f1797158c774a33d86595485761caab25c97e87d..bdad0a4728ed8dbb0551ae561589f23b9ba76866 100644 (file)
@@ -21,6 +21,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.Activator;
 import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
 import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart.XmlXYView;
@@ -49,24 +50,36 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
 
     /**
      * Enum to match the name of a view's XML element to its view ID.
+     * @since 1.1
      */
-    private static enum ViewType {
+    public static enum ViewType {
+        /**
+         * Time graph view element
+         */
         TIME_GRAPH_VIEW(TmfXmlUiStrings.TIME_GRAPH_VIEW, XmlTimeGraphView.ID),
+        /**
+         * XY chart view element
+         */
         XY_VIEW(TmfXmlUiStrings.XY_VIEW, XmlXYView.ID);
 
-        private final String fXmlElem;
+        private final @NonNull String fXmlElem;
         private final String fViewId;
 
-        private ViewType(String xmlElem, String viewId) {
+        private ViewType(@NonNull String xmlElem, String viewId) {
             fXmlElem = xmlElem;
             fViewId = viewId;
         }
 
-        public String getXmlElem() {
+        /**
+         * Get the XML element corresponding to this view type
+         *
+         * @return The XML element corresponding to this type
+         */
+        public @NonNull String getXmlElem() {
             return fXmlElem;
         }
 
-        public String getViewId() {
+        private String getViewId() {
             return fViewId;
         }
     }
@@ -109,7 +122,7 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
                                 String analysisId = analysis.getAttribute(TmfXmlStrings.ID);
                                 if (analysisId.equals(module.getId())) {
                                     String viewId = viewType.getViewId();
-                                    IAnalysisOutput output = new TmfXmlViewOutput(viewId);
+                                    IAnalysisOutput output = new TmfXmlViewOutput(viewId, viewType);
                                     output.setOutputProperty(TmfXmlUiStrings.XML_OUTPUT_DATA, node.getAttribute(TmfXmlStrings.ID) + DATA_SEPARATOR + xmlFile.getAbsolutePath(), false);
                                     module.registerOutput(output);
                                 }
index e6a4e95dc28f4a0c47b8af5aff7c3cfb59d88084..abbcfc466b0bf2788ae82492c3d1e7abae82d1df 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
 import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlUtils;
 import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
+import org.eclipse.linuxtools.tmf.analysis.xml.ui.module.TmfXmlAnalysisOutputSource.ViewType;
 import org.eclipse.linuxtools.tmf.ui.analysis.TmfAnalysisViewOutput;
 import org.w3c.dom.Element;
 
@@ -34,6 +35,7 @@ import org.w3c.dom.Element;
 public class TmfXmlViewOutput extends TmfAnalysisViewOutput {
 
     private String fLabel = null;
+    private final @NonNull ViewType fViewType;
 
     /**
      * Constructor
@@ -42,7 +44,21 @@ public class TmfXmlViewOutput extends TmfAnalysisViewOutput {
      *            id of the view to display as output
      */
     public TmfXmlViewOutput(String viewid) {
+        this(viewid, ViewType.TIME_GRAPH_VIEW);
+    }
+
+    /**
+     * Constructor
+     *
+     * @param viewid
+     *            id of the view to display as output
+     * @param viewType
+     *            type of view this output is for
+     * @since 1.1
+     */
+    public TmfXmlViewOutput(String viewid, @NonNull ViewType viewType) {
         super(viewid);
+        fViewType = viewType;
     }
 
     @Override
@@ -64,7 +80,7 @@ public class TmfXmlViewOutput extends TmfAnalysisViewOutput {
             if ((viewId == null) || (filePath == null)) {
                 return;
             }
-            Element viewElement = XmlUtils.getElementInFile(filePath, TmfXmlUiStrings.TIME_GRAPH_VIEW, viewId);
+            Element viewElement = XmlUtils.getElementInFile(filePath, fViewType.getXmlElem(), viewId);
             if (viewElement == null) {
                 return;
             }
This page took 0.026296 seconds and 5 git commands to generate.