tmf: Add support of XML XY-charts
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 26 Jun 2014 19:34:54 +0000 (15:34 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 21 Jul 2014 22:34:38 +0000 (18:34 -0400)
Change-Id: Ib4f2715d621aa51d1935d1a3486a2a33a9b575bd
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/29351
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Hudson CI
16 files changed:
org.eclipse.linuxtools.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/invalid_view_multipledisplays.xml
org.eclipse.linuxtools.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/invalid_xyview_multipleentry.xml [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.core.tests/test_xml_files/test_valid.xml
org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlDefinition.xsd
org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlTimeGraphView.xsd [deleted file]
org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlView.xsd [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.ui/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.analysis.xml.ui/plugin.properties
org.eclipse.linuxtools.tmf.analysis.xml.ui/plugin.xml
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/TmfXmlUiStrings.java
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/XmlXYView.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/package-info.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfXmlAnalysisOutputSource.java

index 9ac7c7c755d6bf329b30d2bb964e29cda9e67e10..3d07d9c8119f9c96c42b3a2894908affa2e1a74a 100644 (file)
@@ -13,7 +13,7 @@
 <tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
 
-    <stateSystemView id="org.eclipse.linuxtools.tmf.analysis.xml.ui.views.statesystem">
+    <timeGraphView id="org.eclipse.linuxtools.tmf.analysis.xml.ui.views.statesystem">
         <head>
             <analysis id="kernel.linux.sp" />
             <label value="Xml kernel View" />
@@ -31,5 +31,5 @@
             <display type="self" />
             <display type="constant" value="a" />
         </entry>
-    </stateSystemView>
+    </timeGraphView>
 </tmfxml>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/invalid_xyview_multipleentry.xml b/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/invalid_xyview_multipleentry.xml
new file mode 100644 (file)
index 0000000..e3d40ce
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***************************************************************************
+* Copyright (c) 2014 École Polytechnique de Montréal
+*
+* All rights reserved. This program and the accompanying materials are
+* made available under the terms of the Eclipse Public License v1.0 which
+* accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*     Geneviève Bastien - Initial API and implementation
+*************************************************************************** -->
+<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
+
+       <xyView id="org.eclipse.linuxtools.tmf.analysis.xml.ui.views.ustmemory">
+               <head>
+                       <analysis id="org.eclipse.linuxtools.lttng2.ust.analysis.memory" />
+                       <label value="Xml XY Memory view" />
+               </head>
+
+               <entry path="*">
+                       <display type="constant" value="Memory" />
+                       <name type="constant" value="Procname" />
+               </entry>
+               <entry path="*/*">
+                       <display type="constant" value="Memory" />
+                       <name type="constant" value="Procname" />
+               </entry>
+       </xyView>
+</tmfxml>
\ No newline at end of file
index b59fd4583b6801cf53837d0ef7ebc16b5cfea083..ebb22c1d94c64b433b4fd61356ac3049d65dc4e1 100644 (file)
         </entry>
     </timeGraphView>
 
+    <xyView id="org.eclipse.linuxtools.tmf.analysis.xml.core.tests.xy">
+        <head>
+            <analysis id="kernel.linux.sp" />
+            <label value="Xml XY view" />
+        </head>
+
+        <entry path="CPUs/*">
+            <display type="constant" value="Status" />
+            <name type="self" />
+        </entry>
+    </xyView>
+
     <stateProvider id="kernel.linux.sp" version="1">
         <head>
             <traceType id="org.eclipse.linuxtools.lttng2.kernel.tracetype" />
index 7f8a8f363aa49318a87196b47c8ee1435fe4211c..f6e059f7966d0a4cc1982f2b517a9be0c0bfe806 100644 (file)
 
        <xs:include schemaLocation="xmlCommon.xsd" />
        <xs:include schemaLocation="xmlStateProvider.xsd" />
-       <xs:include schemaLocation="xmlTimeGraphView.xsd" />
+       <xs:include schemaLocation="xmlView.xsd" />
        <xs:element name="tmfxml">
                <xs:complexType>
                        <xs:choice maxOccurs="unbounded">
                                <xs:element maxOccurs="unbounded" minOccurs="0" name="timeGraphView" type="timeGraphView" >
                                        <xs:annotation>
                                                <xs:documentation>Define a new time graph view.</xs:documentation></xs:annotation></xs:element>
+                               <xs:element maxOccurs="unbounded" minOccurs="0" name="xyView" type="xyView" >
+                                       <xs:annotation>
+                                               <xs:documentation>Define a new XY chart view.</xs:documentation></xs:annotation></xs:element>
                                <xs:element maxOccurs="unbounded" minOccurs="0" name="stateProvider" type="stateProvider" >
                                        <xs:annotation>
                                                <xs:documentation>Define a new state provider</xs:documentation></xs:annotation></xs:element>
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlTimeGraphView.xsd b/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlTimeGraphView.xsd
deleted file mode 100644 (file)
index afd9495..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- ***************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Florian Wininger - Initial API and implementation
- *************************************************************************** -->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
-       attributeFormDefault="unqualified" elementFormDefault="qualified">
-
-       <xs:complexType name="timeGraphView">
-               <xs:annotation>
-                       <xs:documentation>Declares a data-driven time graph view, which defines how the view will display the results of an analysis. For now, only state system analysis are supported by this view.</xs:documentation></xs:annotation>
-               <xs:sequence>
-                       <xs:element maxOccurs="1" minOccurs="0" name="head" type="headOutput" >
-                               <xs:annotation>
-                                       <xs:documentation>Provider meta-information on this view, like labels and analysis it applies to.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="definedValue" type="definedValue" >
-                               <xs:annotation>
-                                       <xs:documentation>Define a mapping between a human-readable text and the value used in the analysis. The "definedValue"'s optional "color" attribute is the color with which this value will be displayed.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="entry" type="viewEntry" >
-                               <xs:annotation>
-                                       <xs:documentation>Define how to determine the entries (lines) to show on the time graph view. An entry may have children entry elements defined as children, where children are sub-elements of this one (for example, child attributes in the state system). A parent/child relationship may be defined for entries of the same level. See the viewEntry element documentation for more details.</xs:documentation></xs:annotation></xs:element>
-               </xs:sequence>
-               <xs:attribute name="id" type="xs:string" use="required" >
-                       <xs:annotation>
-                               <xs:documentation>The unique identifier of this view element. It will be used by the framework to identify this view.</xs:documentation></xs:annotation></xs:attribute>
-       </xs:complexType>
-
-       <xs:complexType name="headOutput">
-               <xs:annotation>
-                       <xs:documentation>Declares the meta-information that can be defined for an XML time graph view.</xs:documentation></xs:annotation>
-               <xs:sequence>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="analysis">
-                               <xs:annotation>
-                                       <xs:documentation>Indicate that the view applies to the analysis identified with the given ID. To have a view apply to an XML-defined state system analysis, you'd use the state provider ID in the "stateProvider" element.</xs:documentation></xs:annotation>
-                               <xs:complexType>
-                                       <xs:attribute name="id" type="xs:string" use="required" >
-                                               <xs:annotation>
-                                                       <xs:documentation>The ID of the analysis this view applies to.</xs:documentation></xs:annotation></xs:attribute>
-                                       <xs:attribute name="ssid" type="xs:string" use="optional" >
-                                               <xs:annotation>
-                                                       <xs:documentation>The ID of the state system this view applies to. The attribute is used only if the analysis contains more than one state system.</xs:documentation></xs:annotation></xs:attribute>
-                               </xs:complexType>
-                       </xs:element>
-                       <xs:element maxOccurs="1" minOccurs="0" name="label">
-                               <xs:annotation>
-                                       <xs:documentation>Add a label to the time graph view. If provided, this text will be displayed to the user to identify this view, otherwise, the view's ID will be used.</xs:documentation></xs:annotation>
-                               <xs:complexType>
-                                       <xs:attribute name="value" use="required" >
-                                               <xs:annotation>
-                                                       <xs:documentation>The text used as a name for this time graph view.</xs:documentation></xs:annotation></xs:attribute>
-                               </xs:complexType>
-                       </xs:element>
-               </xs:sequence>
-       </xs:complexType>
-
-       <xs:complexType name="viewEntry">
-               <xs:annotation>
-                       <xs:documentation>Define a path to entries in the view. If this element is at the top level, the base path to reach the entry is the root of the state system. Otherwise, it will use the parent element's corresponding attribute as the base. Each view entry element corresponds to a time graph view entry that will actually be displayed.</xs:documentation></xs:annotation>
-               <xs:sequence>
-                       <xs:element maxOccurs="1" minOccurs="0" name="display" type="viewStateAttribute" >
-                               <xs:annotation>
-                                       <xs:documentation>Indicate the attribute whose value will be displayed in the time graph (the value that changes over time). If this element is not specified, no entry will be created for this element, and all other elements will be ignored.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="1" minOccurs="0" name="id" type="viewStateAttribute" >
-                               <xs:annotation>
-                                       <xs:documentation>Specify which attribute to use as ID for this entry. This ID will be used in the ID column in the view, and will also be used to build the tree if a parent element is specified. If this element is not present, the display attribute's name will be used as ID.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="1" minOccurs="0" name="parent" type="viewStateAttribute" >
-                               <xs:annotation>
-                                       <xs:documentation>Specify how to find the parent's ID of this entry. By default, the parent/child hierarchy is the same as defined in the timeGraphView element of the XML file. This element will add to this default parent/child relationship so that elements at the same XML-defined level can still have a relationship.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="1" minOccurs="0" name="name" type="viewStateAttribute" >
-                               <xs:annotation>
-                                       <xs:documentation>Specify how to find the name of this entry. Typically, the name will be human-readable. If not specified, the display attribute's name will be used as the name.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="entry" type="viewEntry" >
-                               <xs:annotation>
-                                       <xs:documentation>Define child entries for this entry. Child entries will be shown as children of this entry (with or without additional parent/child relationship defined through the viewEntry element's "parent" element).</xs:documentation></xs:annotation></xs:element>
-               </xs:sequence>
-               <xs:attribute name="path" type="xs:string" use="required" >
-                       <xs:annotation>
-                               <xs:documentation>The path of the entry in the state system. Wildcards '*' may be used. For example, to display entries from all CPUs, the path could be "CPUs/*" and one entry will be created for each sub-attribute of the "CPUs" attribute. Each entry will be used as the base for all child elements, unless specified otherwise.</xs:documentation></xs:annotation></xs:attribute>
-       </xs:complexType>
-
-       <xs:complexType name="viewStateAttribute">
-               <xs:sequence>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="stateAttribute" type="viewStateAttribute" >
-                               <xs:annotation>
-                                       <xs:documentation>If the type is a "query", those stateAttribute elements describe the  elements of the query.</xs:documentation></xs:annotation></xs:element>
-               </xs:sequence>
-               <xs:attribute name="type" use="required">
-                       <xs:annotation>
-                               <xs:documentation>The type of path to this attribute. The value of the other attributes will depend on the selected type.</xs:documentation></xs:annotation>
-                       <xs:simpleType>
-                               <xs:restriction base="xs:string">
-                                       <xs:enumeration value="constant" >
-                                               <xs:annotation>
-                                                       <xs:documentation>This type identifies the state system attribute by a constant string. For instance, if the state system attribute to display is "Status", it would be a constant type with value "Status".</xs:documentation></xs:annotation></xs:enumeration>
-                                       <xs:enumeration value="location" >
-                                               <xs:annotation>
-                                                       <xs:documentation>This type indicates that the path to the attribute is at the specified location. A location avoids having to write the full path to an attribute every time it is being used. The location itself is a sequence of stateAttribute elements. For example, if we previously defined a location named "Procname" for path "Threads/tid/Procname", we can use a stateAttribute of type location with "Procname" value.</xs:documentation></xs:annotation></xs:enumeration>
-                                       <xs:enumeration value="query" >
-                                               <xs:annotation>
-                                                       <xs:documentation>This type indicates that the path to the attribute is the result of a query. If this type is selected, a sequence of stateAttribute elements needs to be specified for this viewStateAttribute. The result of the query is the attribute name of the current element. For example, if the attribute we want is the PID of the current process on CPU 0, that PID can be found through the query "CPUs/0/CurrentThread". The value of this attribute would be for example 1234, which is the attribute we are looking for.</xs:documentation></xs:annotation></xs:enumeration>
-                                       <xs:enumeration value="self" >
-                                               <xs:annotation>
-                                                       <xs:documentation>This type indicates that the requested attribute is the attribute itself. For this attribute, the reference is always relative (setting it to absolute will be ignored).</xs:documentation></xs:annotation></xs:enumeration>
-                               </xs:restriction>
-                       </xs:simpleType>
-               </xs:attribute>
-               <xs:attribute name="value" type="xs:string" >
-                       <xs:annotation>
-                               <xs:documentation>The value of this state attribute. A value should be specified if the type is "constant" or "location".</xs:documentation></xs:annotation></xs:attribute>
-               <xs:attribute name="reference" use="optional" default="relative">
-                       <xs:annotation>
-                               <xs:documentation>Specify which state system attribute to use as the base to reach this path. It is either absolute or relative. By default, it is relative to the current entry.</xs:documentation></xs:annotation>
-                       <xs:simpleType>
-                               <xs:restriction base="xs:string">
-                                       <xs:enumeration value="relative" >
-                                               <xs:annotation>
-                                                       <xs:documentation>The path will be calculated starting from the entry under which this viewStateAttribute element is defined.</xs:documentation></xs:annotation></xs:enumeration>
-                                       <xs:enumeration value="absolute" >
-                                               <xs:annotation>
-                                                       <xs:documentation>The path will be calculated starting from the root of the state system. That means that if the entry itself is one of "CPUs/*", we could reach another attribute from the root of the state system, like "Threads/tid".</xs:documentation></xs:annotation></xs:enumeration>
-                               </xs:restriction>
-                       </xs:simpleType>
-               </xs:attribute>
-       </xs:complexType>
-</xs:schema>
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlView.xsd b/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlView.xsd
new file mode 100644 (file)
index 0000000..9e5d640
--- /dev/null
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- ***************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Florian Wininger - Initial API and implementation
+ *************************************************************************** -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       attributeFormDefault="unqualified" elementFormDefault="qualified">
+
+       <xs:complexType name="timeGraphView">
+               <xs:annotation>
+                       <xs:documentation>Declares a data-driven time graph view, which defines how the view will display the results of an analysis. For now, only state system analysis are supported by this view.</xs:documentation></xs:annotation>
+               <xs:sequence>
+                       <xs:element maxOccurs="1" minOccurs="0" name="head" type="headOutput" >
+                               <xs:annotation>
+                                       <xs:documentation>Provider meta-information on this view, like labels and analysis it applies to.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="definedValue" type="definedValue" >
+                               <xs:annotation>
+                                       <xs:documentation>Define a mapping between a human-readable text and the value used in the analysis. The "definedValue"'s optional "color" attribute is the color with which this value will be displayed.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="entry" type="viewEntry" >
+                               <xs:annotation>
+                                       <xs:documentation>Define how to determine the entries (lines) to show on the time graph view. An entry may have children entry elements defined as children, where children are sub-elements of this one (for example, child attributes in the state system). A parent/child relationship may be defined for entries of the same level. See the viewEntry element documentation for more details.</xs:documentation></xs:annotation></xs:element>
+               </xs:sequence>
+               <xs:attribute name="id" type="xs:string" use="required" >
+                       <xs:annotation>
+                               <xs:documentation>The unique identifier of this view element. It will be used by the framework to identify this view.</xs:documentation></xs:annotation></xs:attribute>
+       </xs:complexType>
+
+       <xs:complexType name="xyView">
+               <xs:annotation>
+                       <xs:documentation>Declares a data-driven XY chart view, which defines how the view will display the results of an analysis. For now, only state system analyses are supported by this view.</xs:documentation></xs:annotation>
+               <xs:sequence>
+                       <xs:element maxOccurs="1" minOccurs="0" name="head" type="headOutput" >
+                               <xs:annotation>
+                                       <xs:documentation>Provider meta-information on this view, like labels and analyses it applies to.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="1" minOccurs="1" name="entry" type="xyViewEntry" >
+                               <xs:annotation>
+                                       <xs:documentation>Define how to determine the entries (series) to show on the XY view. See the xyViewEntry element documentation for more details.</xs:documentation></xs:annotation></xs:element>
+               </xs:sequence>
+               <xs:attribute name="id" type="xs:string" use="required" >
+                       <xs:annotation>
+                               <xs:documentation>The unique identifier of this view element. It will be used by the framework to identify this view.</xs:documentation></xs:annotation></xs:attribute>
+       </xs:complexType>
+
+       <xs:complexType name="headOutput">
+               <xs:annotation>
+                       <xs:documentation>Declares the meta-information that can be defined for an XML time graph view.</xs:documentation></xs:annotation>
+               <xs:sequence>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="analysis">
+                               <xs:annotation>
+                                       <xs:documentation>Indicate that the view applies to the analysis identified with the given ID. To have a view apply to an XML-defined state system analysis, you'd use the state provider ID in the "stateProvider" element.</xs:documentation></xs:annotation>
+                               <xs:complexType>
+                                       <xs:attribute name="id" type="xs:string" use="required" >
+                                               <xs:annotation>
+                                                       <xs:documentation>The ID of the analysis this view applies to.</xs:documentation></xs:annotation></xs:attribute>
+                                       <xs:attribute name="ssid" type="xs:string" use="optional" >
+                                               <xs:annotation>
+                                                       <xs:documentation>The ID of the state system this view applies to. The attribute is used only if the analysis contains more than one state system.</xs:documentation></xs:annotation></xs:attribute>
+                               </xs:complexType>
+                       </xs:element>
+                       <xs:element maxOccurs="1" minOccurs="0" name="label">
+                               <xs:annotation>
+                                       <xs:documentation>Add a label to the time graph view. If provided, this text will be displayed to the user to identify this view, otherwise, the view's ID will be used.</xs:documentation></xs:annotation>
+                               <xs:complexType>
+                                       <xs:attribute name="value" use="required" >
+                                               <xs:annotation>
+                                                       <xs:documentation>The text used as a name for this time graph view.</xs:documentation></xs:annotation></xs:attribute>
+                               </xs:complexType>
+                       </xs:element>
+               </xs:sequence>
+       </xs:complexType>
+
+       <xs:complexType name="viewEntry">
+               <xs:annotation>
+                       <xs:documentation>Define a path to entries in the view. If this element is at the top level, the base path to reach the entry is the root of the state system. Otherwise, it will use the parent element's corresponding attribute as the base. Each view entry element corresponds to a time graph view entry that will actually be displayed.</xs:documentation></xs:annotation>
+               <xs:sequence>
+                       <xs:element maxOccurs="1" minOccurs="0" name="display" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>Indicate the attribute whose value will be displayed in the time graph (the value that changes over time). If this element is not specified, no entry will be created for this element, and all other elements will be ignored.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="1" minOccurs="0" name="id" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>Specify which attribute to use as ID for this entry. This ID will be used in the ID column in the view, and will also be used to build the tree if a parent element is specified. If this element is not present, the display attribute's name will be used as ID.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="1" minOccurs="0" name="parent" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>Specify how to find the parent's ID of this entry. By default, the parent/child hierarchy is the same as defined in the timeGraphView element of the XML file. This element will add to this default parent/child relationship so that elements at the same XML-defined level can still have a relationship.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="1" minOccurs="0" name="name" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>Specify how to find the name of this entry. Typically, the name will be human-readable. If not specified, the display attribute's name will be used as the name.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="entry" type="viewEntry" >
+                               <xs:annotation>
+                                       <xs:documentation>Define child entries for this entry. Child entries will be shown as children of this entry (with or without additional parent/child relationship defined through the viewEntry element's "parent" element).</xs:documentation></xs:annotation></xs:element>
+               </xs:sequence>
+               <xs:attribute name="path" type="xs:string" use="required" >
+                       <xs:annotation>
+                               <xs:documentation>The path of the entry in the state system. Wildcards '*' may be used. For example, to display entries from all CPUs, the path could be "CPUs/*" and one entry will be created for each sub-attribute of the "CPUs" attribute. Each entry will be used as the base for all child elements, unless specified otherwise.</xs:documentation></xs:annotation></xs:attribute>
+       </xs:complexType>
+
+       <xs:complexType name="xyViewEntry">
+               <xs:annotation>
+                       <xs:documentation>Define a path to entries in the view. If this element is at the top level, the base path to reach the entry is the root of the state system. Otherwise, it will use the parent element's corresponding attribute as the base. Each XY view entry element corresponds to a series in the resulting view.</xs:documentation></xs:annotation>
+               <xs:sequence>
+                       <xs:element maxOccurs="1" minOccurs="0" name="display" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>Indicate the attribute whose value will be displayed in the time graph (the value that changes over time). If this element is not specified, no entry will be created for this element, and all other elements will be ignored.</xs:documentation></xs:annotation></xs:element>
+                       <xs:element maxOccurs="1" minOccurs="0" name="name" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>Specify how to find the name of this entry. Typically, the name will be human-readable. If not specified, the display attribute's name will be used as the name.</xs:documentation></xs:annotation></xs:element>
+               </xs:sequence>
+               <xs:attribute name="path" type="xs:string" use="required" >
+                       <xs:annotation>
+                               <xs:documentation>The path of the entry in the state system. Wildcards '*' may be used. For example, to display entries from all CPUs, the path could be "CPUs/*" and one series will be created for each sub-attribute of the "CPUs" attribute. Each entry will be used as the base for all child elements, unless specified otherwise.</xs:documentation></xs:annotation></xs:attribute>
+       </xs:complexType>
+
+       <xs:complexType name="viewStateAttribute">
+               <xs:sequence>
+                       <xs:element maxOccurs="unbounded" minOccurs="0" name="stateAttribute" type="viewStateAttribute" >
+                               <xs:annotation>
+                                       <xs:documentation>If the type is a "query", those stateAttribute elements describe the  elements of the query.</xs:documentation></xs:annotation></xs:element>
+               </xs:sequence>
+               <xs:attribute name="type" use="required">
+                       <xs:annotation>
+                               <xs:documentation>The type of path to this attribute. The value of the other attributes will depend on the selected type.</xs:documentation></xs:annotation>
+                       <xs:simpleType>
+                               <xs:restriction base="xs:string">
+                                       <xs:enumeration value="constant" >
+                                               <xs:annotation>
+                                                       <xs:documentation>This type identifies the state system attribute by a constant string. For instance, if the state system attribute to display is "Status", it would be a constant type with value "Status".</xs:documentation></xs:annotation></xs:enumeration>
+                                       <xs:enumeration value="location" >
+                                               <xs:annotation>
+                                                       <xs:documentation>This type indicates that the path to the attribute is at the specified location. A location avoids having to write the full path to an attribute every time it is being used. The location itself is a sequence of stateAttribute elements. For example, if we previously defined a location named "Procname" for path "Threads/tid/Procname", we can use a stateAttribute of type location with "Procname" value.</xs:documentation></xs:annotation></xs:enumeration>
+                                       <xs:enumeration value="query" >
+                                               <xs:annotation>
+                                                       <xs:documentation>This type indicates that the path to the attribute is the result of a query. If this type is selected, a sequence of stateAttribute elements needs to be specified for this viewStateAttribute. The result of the query is the attribute name of the current element. For example, if the attribute we want is the PID of the current process on CPU 0, that PID can be found through the query "CPUs/0/CurrentThread". The value of this attribute would be for example 1234, which is the attribute we are looking for.</xs:documentation></xs:annotation></xs:enumeration>
+                                       <xs:enumeration value="self" >
+                                               <xs:annotation>
+                                                       <xs:documentation>This type indicates that the requested attribute is the attribute itself. For this attribute, the reference is always relative (setting it to absolute will be ignored).</xs:documentation></xs:annotation></xs:enumeration>
+                               </xs:restriction>
+                       </xs:simpleType>
+               </xs:attribute>
+               <xs:attribute name="value" type="xs:string" >
+                       <xs:annotation>
+                               <xs:documentation>The value of this state attribute. A value should be specified if the type is "constant" or "location".</xs:documentation></xs:annotation></xs:attribute>
+               <xs:attribute name="reference" use="optional" default="relative">
+                       <xs:annotation>
+                               <xs:documentation>Specify which state system attribute to use as the base to reach this path. It is either absolute or relative. By default, it is relative to the current entry.</xs:documentation></xs:annotation>
+                       <xs:simpleType>
+                               <xs:restriction base="xs:string">
+                                       <xs:enumeration value="relative" >
+                                               <xs:annotation>
+                                                       <xs:documentation>The path will be calculated starting from the entry under which this viewStateAttribute element is defined.</xs:documentation></xs:annotation></xs:enumeration>
+                                       <xs:enumeration value="absolute" >
+                                               <xs:annotation>
+                                                       <xs:documentation>The path will be calculated starting from the root of the state system. That means that if the entry itself is one of "CPUs/*", we could reach another attribute from the root of the state system, like "Threads/tid".</xs:documentation></xs:annotation></xs:enumeration>
+                               </xs:restriction>
+                       </xs:simpleType>
+               </xs:attribute>
+       </xs:complexType>
+</xs:schema>
index 421fe4dd462b562d4ddbd24e25f8ee42c0c979fe..9fcfae5b284ef4b7d1852663ac1bd77fffa28656 100644 (file)
@@ -16,5 +16,6 @@ Require-Bundle: org.eclipse.ui,
 Export-Package: org.eclipse.linuxtools.internal.tmf.analysis.xml.ui;x-friends:="org.eclipse.linuxtools.tmf.analysis.xml.ui.tests",
  org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.handler;x-internal:=true,
  org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart;x-internal:=true,
  org.eclipse.linuxtools.tmf.analysis.xml.ui.module,
  org.eclipse.linuxtools.tmf.analysis.xml.ui.views.timegraph
index 67a764c2a8b8076ea2fdd3291c6268ecc5e8ee13..91fd0954a1a3f67c7a4fb9cd6bdb5901a2ee44c6 100644 (file)
@@ -19,3 +19,5 @@ command.xml.import.mnemonic = I
 command.xml.import.description = Import an XML file containing analysis information
 
 xmltimegraph.view.name = XML Time Graph View
+
+xmlxychart.view.name = XML XY Chart View
index a285ef34a181fd055a27c8dd7b1316859629f5a4..d8a56de6cc2b3f98bbe81b714036a9d48ff7c4c7 100644 (file)
             name="%xmltimegraph.view.name"
             restorable="true">
       </view>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.lttng2.ui.views.category"
+            class="org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart.XmlXYView"
+            id="org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xyview"
+            name="%xmlxychart.view.name"
+            restorable="true">
+      </view>
    </extension>
 </plugin>
index 72af61dc615a2af6f8641484f05e14b6b4802d3b..e07339dbbb78a9e0e4d40268bb254fdacbccae2b 100644 (file)
@@ -25,6 +25,7 @@ public interface TmfXmlUiStrings {
 
     /* XML generic Element attribute names */
     static final String TIME_GRAPH_VIEW = "timeGraphView";
+    static final String XY_VIEW = "xyView";
 
     /* View elements and attributes */
     static final String ENTRY_ELEMENT = "entry";
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/Messages.java b/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/Messages.java
new file mode 100644 (file)
index 0000000..e548eec
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Externalized strings for the xml xy chart view package
+ *
+ * @author Geneviève Bastien
+ */
+public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart.messages"; //$NON-NLS-1$
+    /** Default view title */
+    public static @Nullable String XmlXYView_DefaultTitle;
+
+    /** Default Viewer title */
+    public static @Nullable String XmlXYViewer_DefaultViewerTitle;
+    /** Default X axix text */
+    public static @Nullable String XmlXYViewer_DefaultXAxis;
+    /** Default Y axis text */
+    public static @Nullable String XmlXYViewer_DefaultYAxis;
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/XmlXYView.java b/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/XmlXYView.java
new file mode 100644 (file)
index 0000000..fca95f7
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
+import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.XmlViewInfo;
+import org.eclipse.linuxtools.tmf.ui.viewers.xycharts.TmfXYChartViewer;
+import org.eclipse.linuxtools.tmf.ui.views.TmfChartView;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.w3c.dom.Element;
+
+/**
+ * This view displays state system data in an xy chart. It uses an XML
+ * {@link TmfXmlUiStrings#XY_VIEW} element from an XML file. This element
+ * defines which entries from the state system will be shown and also gives
+ * additional information on the presentation of the view.
+ *
+ * @author Geneviève Bastien
+ */
+public class XmlXYView extends TmfChartView {
+
+    /** View ID. */
+    public static final String ID = "org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xyview"; //$NON-NLS-1$
+
+    private final XmlViewInfo fViewInfo = new XmlViewInfo(ID);
+
+    /**
+     * Default constructor
+     */
+    public XmlXYView() {
+        super(Messages.XmlXYView_DefaultTitle);
+
+        this.addPartPropertyListener(new IPropertyChangeListener() {
+            @Override
+            public void propertyChange(@Nullable PropertyChangeEvent event) {
+                if (event == null) {
+                    return;
+                }
+                if (event.getProperty().equals(TmfXmlUiStrings.XML_OUTPUT_DATA)) {
+                    Object newValue = event.getNewValue();
+                    if (newValue instanceof String) {
+                        fViewInfo.setViewData((String) newValue);
+                        setViewTitle();
+                        TmfXYChartViewer viewer = getChartViewer();
+                        if (viewer instanceof XmlXYViewer) {
+                            ((XmlXYViewer) viewer).viewInfoUpdated();
+                        }
+
+                    }
+                }
+            }
+
+        });
+        setViewTitle();
+    }
+
+    @Override
+    public void createPartControl(@Nullable Composite parent) {
+        setChartViewer(new XmlXYViewer(parent, fViewInfo));
+        super.createPartControl(parent);
+    }
+
+    @Override
+    public void setFocus() {
+
+    }
+
+    private void setViewTitle() {
+        /*
+         * Get the view element from the XML file. If the element can't be
+         * found, return.
+         */
+        Element viewElement = fViewInfo.getViewElement(TmfXmlUiStrings.XY_VIEW);
+        if (viewElement == null) {
+            return;
+        }
+
+        String title = fViewInfo.getViewTitle(viewElement);
+        if (title == null) {
+            title = Messages.XmlXYView_DefaultTitle;
+        }
+        final String viewTitle = title;
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                setPartName(viewTitle);
+            }
+        });
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java b/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java
new file mode 100644 (file)
index 0000000..c06e703
--- /dev/null
@@ -0,0 +1,360 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+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.XmlViewInfo;
+import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
+import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.statesystem.core.exceptions.StateSystemDisposedException;
+import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.model.ITmfXmlModelFactory;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.model.ITmfXmlStateAttribute;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.model.TmfXmlLocation;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.model.readonly.TmfXmlReadOnlyModelFactory;
+import org.eclipse.linuxtools.tmf.analysis.xml.core.module.IXmlStateSystemContainer;
+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.core.statesystem.ITmfAnalysisModuleWithStateSystems;
+import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.viewers.xycharts.linecharts.TmfCommonXLineChartViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.w3c.dom.Element;
+
+/**
+ * Main viewer to display XML-defined xy charts. It uses an XML
+ * {@link TmfXmlUiStrings#XY_VIEW} element from an XML file. This element
+ * defines which entries from the state system will be shown and also gives
+ * additional information on the presentation of the view.
+ *
+ * @author Geneviève Bastien
+ */
+public class XmlXYViewer extends TmfCommonXLineChartViewer {
+
+    private static final String SPLIT_STRING = "/"; //$NON-NLS-1$
+    /** Timeout between updates in the updateData thread */
+    private static final long BUILD_UPDATE_TIMEOUT = 500;
+
+    @SuppressWarnings("null")
+    private static final @NonNull Pattern WILDCARD_PATTERN = Pattern.compile("\\*"); //$NON-NLS-1$
+
+    private final ITmfXmlModelFactory fFactory = TmfXmlReadOnlyModelFactory.getInstance();
+    private final Map<Integer, SeriesData> fSeriesData = new HashMap<>();
+
+    private final XmlViewInfo fViewInfo;
+
+    /** XML Model elements to use to create the series */
+    private @Nullable ITmfXmlStateAttribute fDisplay;
+    private @Nullable ITmfXmlStateAttribute fSeriesName;
+    private @Nullable XmlXYEntry fEntry;
+
+    /**
+     * The information related to one series on the chart
+     */
+    private class SeriesData {
+
+        private final double[] fYValues;
+        private final Integer fDisplayQuark;
+        private final String fName;
+
+        public SeriesData(int length, int attributeQuark, String seriesName) {
+            fYValues = new double[length];
+            fDisplayQuark = attributeQuark;
+            fName = seriesName;
+        }
+
+        public double[] getYValues() {
+            return fYValues;
+        }
+
+        public Integer getDisplayQuark() {
+            return fDisplayQuark;
+        }
+
+        public String getSeriesName() {
+            return fName;
+        }
+
+        public void setYValue(int i, double yvalue) {
+            fYValues[i] = yvalue;
+        }
+    }
+
+    private class XmlXYEntry implements IXmlStateSystemContainer {
+
+        private final ITmfStateSystem fStateSystem;
+        private final String fPath;
+
+        public XmlXYEntry(ITmfStateSystem stateSystem, String path) {
+            fStateSystem = stateSystem;
+            fPath = path;
+        }
+
+        @Override
+        public @Nullable String getAttributeValue(@Nullable String name) {
+            return name;
+        }
+
+        @Override
+        public ITmfStateSystem getStateSystem() {
+            return fStateSystem;
+        }
+
+        @Override
+        public @Nullable Iterable<TmfXmlLocation> getLocations() {
+            return Collections.EMPTY_SET;
+        }
+
+        public List<Integer> getQuarks() {
+            /* Get the list of quarks to process with this path */
+            String[] paths = fPath.split(SPLIT_STRING);
+            @SuppressWarnings("null")
+            @NonNull List<Integer> quarks = Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK);
+
+            try {
+                for (String path : paths) {
+                    List<Integer> subQuarks = new LinkedList<>();
+                    /* Replace * by .* to have a regex string */
+                    String name = WILDCARD_PATTERN.matcher(path).replaceAll(".*"); //$NON-NLS-1$
+                    for (int relativeQuark : quarks) {
+                        subQuarks.addAll(fStateSystem.getSubAttributes(relativeQuark, false, name));
+                    }
+                    quarks = subQuarks;
+                }
+            } catch (AttributeNotFoundException e) {
+                /*
+                 * We get all attributes from the state system itself, this
+                 * should not happen.
+                 */
+                throw new IllegalStateException();
+            }
+            return quarks;
+        }
+    }
+
+    /**
+     * Constructor
+     *
+     * @param parent
+     *            parent view
+     * @param viewInfo
+     *            The view info object
+     */
+    public XmlXYViewer(@Nullable Composite parent, XmlViewInfo viewInfo) {
+        super(parent, Messages.XmlXYViewer_DefaultViewerTitle, Messages.XmlXYViewer_DefaultXAxis, Messages.XmlXYViewer_DefaultYAxis);
+        fViewInfo = viewInfo;
+    }
+
+    @Override
+    protected void updateData(long start, long end, int nb, @Nullable IProgressMonitor monitor) {
+
+        ITmfXmlStateAttribute display = fDisplay;
+        ITmfXmlStateAttribute seriesNameAttrib = fSeriesName;
+        XmlXYEntry entry = fEntry;
+        if (getTrace() == null || display == null || entry == null) {
+            return;
+        }
+        ITmfStateSystem ss = entry.getStateSystem();
+
+        double[] xvalues = getXAxis(start, end, nb);
+        setXAxis(xvalues);
+
+        boolean complete = false;
+        long currentEnd = start;
+
+        while (!complete && currentEnd < end) {
+            if (monitor != null && monitor.isCanceled()) {
+                return;
+            }
+
+            complete = ss.waitUntilBuilt(BUILD_UPDATE_TIMEOUT);
+            currentEnd = ss.getCurrentEndTime();
+            try {
+                List<Integer> quarks = entry.getQuarks();
+                long traceStart = getStartTime();
+                long traceEnd = getEndTime();
+                long offset = this.getTimeOffset();
+
+                /* Initialize quarks and series names */
+                for (int quark : quarks) {
+                    String seriesName = null;
+                    if (seriesNameAttrib == null) {
+                        seriesName = ss.getAttributeName(quark);
+                    } else {
+                        int seriesNameQuark = seriesNameAttrib.getAttributeQuark(quark);
+                        try {
+                            ITmfStateValue seriesNameValue = ss.querySingleState(start, seriesNameQuark).getStateValue();
+                            if (!seriesNameValue.isNull()) {
+                                seriesName = seriesNameValue.unboxStr();
+                            }
+                            if (seriesName == null || seriesName.isEmpty()) {
+                                seriesName = ss.getAttributeName(quark);
+                            }
+                        } catch (TimeRangeException e) {
+                            /*
+                             * The attribute did not exist at this point, simply
+                             * use attribute name as series name
+                             */
+                            seriesName = ss.getAttributeName(quark);
+                        }
+                    }
+                    if (seriesName == null) {
+                        throw new IllegalStateException();
+                    }
+                    fSeriesData.put(quark, new SeriesData(xvalues.length, display.getAttributeQuark(quark), seriesName));
+                }
+                double yvalue = 0.0;
+                for (int i = 0; i < xvalues.length; i++) {
+                    if (monitor != null && monitor.isCanceled()) {
+                        return;
+                    }
+                    double x = xvalues[i];
+                    long time = (long) x + offset;
+                    // make sure that time is in the trace range after double to
+                    // long conversion
+                    time = time < traceStart ? traceStart : time;
+                    time = time > traceEnd ? traceEnd : time;
+
+                    for (int quark : quarks) {
+                        try {
+                            yvalue = ss.querySingleState(time, fSeriesData.get(quark).getDisplayQuark()).getStateValue().unboxLong();
+                            fSeriesData.get(quark).setYValue(i, yvalue);
+                        } catch (TimeRangeException e) {
+                            fSeriesData.get(quark).setYValue(i, 0);
+                        }
+                    }
+                }
+                for (int quark : quarks) {
+                    setSeries(fSeriesData.get(quark).getSeriesName(), fSeriesData.get(quark).getYValues());
+                }
+                updateDisplay();
+            } catch (AttributeNotFoundException | StateValueTypeException e) {
+                Activator.logError("Error updating the data of XML XY view", e); //$NON-NLS-1$
+            } catch (StateSystemDisposedException e) {
+                return;
+            }
+        }
+
+    }
+
+    @Override
+    protected void initializeDataSource() {
+        super.initializeDataSource();
+
+        ITmfTrace trace = this.getTrace();
+        if (trace == null) {
+            return;
+        }
+
+        Element viewElement = fViewInfo.getViewElement(TmfXmlUiStrings.XY_VIEW);
+        if (viewElement == null) {
+            return;
+        }
+
+        Iterable<String> analysisIds = fViewInfo.getViewAnalysisIds(viewElement);
+
+        List<ITmfAnalysisModuleWithStateSystems> stateSystemModules = new LinkedList<>();
+        if (!analysisIds.iterator().hasNext()) {
+            /*
+             * No analysis specified, take all state system analysis modules
+             */
+            for (ITmfAnalysisModuleWithStateSystems module : trace.getAnalysisModulesOfClass(ITmfAnalysisModuleWithStateSystems.class)) {
+                stateSystemModules.add(module);
+            }
+        } else {
+            for (String moduleId : analysisIds) {
+                @SuppressWarnings("resource")
+                ITmfAnalysisModuleWithStateSystems module = trace.getAnalysisModuleOfClass(ITmfAnalysisModuleWithStateSystems.class, moduleId);
+                if (module != null) {
+                    stateSystemModules.add(module);
+                }
+            }
+        }
+
+        /** Initialize the data */
+        fDisplay = null;
+        fSeriesName = null;
+        ITmfStateSystem ss = null;
+        fEntry = null;
+
+        /* Schedule all state systems */
+        for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
+            module.schedule();
+            if (module instanceof TmfStateSystemAnalysisModule) {
+                ((TmfStateSystemAnalysisModule) module).waitForInitialization();
+            }
+            for (ITmfStateSystem ssq : module.getStateSystems()) {
+                if (ssq != null) {
+                    ss = ssq;
+                    break;
+                }
+            }
+        }
+        if (ss == null) {
+            return;
+        }
+
+        /*
+         * Initialize state attributes. There should be only one entry element
+         * for XY charts.
+         */
+        List<Element> entries = XmlUtils.getChildElements(viewElement, TmfXmlUiStrings.ENTRY_ELEMENT);
+        Element entryElement = entries.get(0);
+        String path = entryElement.getAttribute(TmfXmlUiStrings.PATH);
+        if (path.isEmpty()) {
+            path = TmfXmlStrings.WILDCARD;
+        }
+        XmlXYEntry entry = new XmlXYEntry(ss, path);
+        fEntry = entry;
+
+        /* Get the display element to use */
+        List<Element> displayElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.DISPLAY_ELEMENT);
+        if (displayElements.isEmpty()) {
+            Activator.logWarning(String.format("XML view: entry for %s should have a display element", path)); //$NON-NLS-1$
+            return;
+        }
+        Element displayElement = displayElements.get(0);
+        fDisplay = fFactory.createStateAttribute(displayElement, entry);
+
+        /* Get the series name element to use */
+        List<Element> seriesNameElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.NAME_ELEMENT);
+        if (!seriesNameElements.isEmpty()) {
+            Element seriesNameElement = seriesNameElements.get(0);
+            fSeriesName = fFactory.createStateAttribute(seriesNameElement, entry);
+        }
+
+    }
+
+    /**
+     * Tells the viewer that the view info has been updated and the viewer needs
+     * to be reinitialized
+     */
+    public void viewInfoUpdated() {
+        reinitialize();
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/messages.properties b/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/messages.properties
new file mode 100644 (file)
index 0000000..77d3f62
--- /dev/null
@@ -0,0 +1,4 @@
+XmlXYView_DefaultTitle=Xml XY view
+XmlXYViewer_DefaultViewerTitle=Xml XY Chart Viewer
+XmlXYViewer_DefaultXAxis=Time
+XmlXYViewer_DefaultYAxis=Unit
diff --git a/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/package-info.java b/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/internal/tmf/analysis/xml/ui/views/xychart/package-info.java
new file mode 100644 (file)
index 0000000..ff37508
--- /dev/null
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    École Polytechnique de Montréal - Initial API and implementation
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xychart;
\ No newline at end of file
index f8d6826c78de5e5bc93d2e3a6445ed01a213d6f8..f1797158c774a33d86595485761caab25c97e87d 100644 (file)
@@ -23,6 +23,7 @@ import javax.xml.parsers.ParserConfigurationException;
 import org.eclipse.core.runtime.IPath;
 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;
 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.views.timegraph.XmlTimeGraphView;
@@ -50,7 +51,8 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
      * Enum to match the name of a view's XML element to its view ID.
      */
     private static enum ViewType {
-        TIME_GRAPH_VIEW(TmfXmlUiStrings.TIME_GRAPH_VIEW, XmlTimeGraphView.ID);
+        TIME_GRAPH_VIEW(TmfXmlUiStrings.TIME_GRAPH_VIEW, XmlTimeGraphView.ID),
+        XY_VIEW(TmfXmlUiStrings.XY_VIEW, XmlXYView.ID);
 
         private final String fXmlElem;
         private final String fViewId;
@@ -69,6 +71,7 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
         }
     }
 
+
     @Override
     public void moduleCreated(IAnalysisModule module) {
         IPath pathToFiles = XmlUtils.getXmlFilesPath();
This page took 0.041012 seconds and 5 git commands to generate.