tmf : Add latency table view for the pattern analysis
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Fri, 4 Mar 2016 21:52:51 +0000 (16:52 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 17 Mar 2016 18:11:01 +0000 (14:11 -0400)
Change-Id: I3e652767dc8e53dc2eb95c27e159f8350e939eaf
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/67478
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
15 files changed:
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/latency.png [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/plugin.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/plugin.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/TmfXmlUiStrings.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/Messages.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/messages.properties [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/AbstractXmlViewInfo.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlLatencyViewInfo.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlViewInfo.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableView.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableViewer.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfXmlAnalysisOutputSource.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfXmlLatencyViewOutput.java [new file with mode: 0644]

index 9cdefedc662a0e52ed23c4d3f46cb92f8983ee4a..92c7ad7f3487231485f6bc974274c4f358483e46 100644 (file)
@@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.segmentstore.core,
  org.eclipse.tracecompass.analysis.timing.core
 Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.core;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.core.tests",
- org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider;x-internal:=true,
+ org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui",
  org.eclipse.tracecompass.tmf.analysis.xml.core.model,
  org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly,
  org.eclipse.tracecompass.tmf.analysis.xml.core.model.readwrite,
index ea13565760ad5bf0607f9449a6b712082826c935..5f16b858dff9b230efbda5c2c79a90fd10977c0d 100644 (file)
@@ -14,10 +14,16 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core,
  org.eclipse.tracecompass.tmf.ui,
- org.eclipse.tracecompass.tmf.analysis.xml.core
+ org.eclipse.tracecompass.tmf.analysis.xml.core,
+ org.eclipse.tracecompass.analysis.timing.core,
+ org.eclipse.tracecompass.analysis.timing.ui,
+ org.eclipse.tracecompass.segmentstore.core,
+ org.swtchart
 Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.ui;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.tests",
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.handler;x-internal:=true,
+ org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views;x-internal:=true,
+ org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;x-internal:=true,
  org.eclipse.tracecompass.tmf.analysis.xml.ui.module,
  org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/latency.png b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/latency.png
new file mode 100644 (file)
index 0000000..723b8da
Binary files /dev/null and b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/latency.png differ
index 0ff6961a2e229a7f935f18be3fd64c4be8f22dfe..ee3996282b0ccf4e7120da15e8a2e2d986628771 100644 (file)
@@ -20,3 +20,5 @@ command.manager.xml.description = Manage XML files containing analysis informati
 xmltimegraph.view.name = XML Time Graph View
 
 xmlxychart.view.name = XML XY Chart View
+
+latency.view.name = Latency Table
index 67fb3b1911e0739cc94f78c19d929cbebf0ea008..2db9e18303d652a0ffa73e32561c96c0dc4dfb1b 100644 (file)
             name="%xmlxychart.view.name"
             restorable="true">
       </view>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternLatencyTableView"
+            icon="icons/eview16/latency.png"
+            id="org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latencytable"
+            name="%latency.view.name"
+            restorable="true">
+      </view>
    </extension>
 </plugin>
index 4ead8262d1ee6be0e09efe122a377a11cce09a04..30c804806698150aa5f063795a3420661cc85880 100644 (file)
@@ -43,4 +43,6 @@ public interface TmfXmlUiStrings {
     /* Generic strings for the XML module */
     static final String XML_OUTPUT_DATA = "xmlOutputData";
 
+    static final String XML_LATENCY_OUTPUT_DATA = "xmlLatencyOutputData";
+
 }
\ No newline at end of file
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/Messages.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/Messages.java
new file mode 100644 (file)
index 0000000..732ab31
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Message for the XML analysis output
+ *
+ * @author Jean-Christian Kouame
+ */
+public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module.messages"; //$NON-NLS-1$
+    /** Latency table */
+    public static String TmfXmlAnalysisOutputSource_LatencyTable;
+
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/messages.properties b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/messages.properties
new file mode 100644 (file)
index 0000000..cd026f4
--- /dev/null
@@ -0,0 +1,9 @@
+###############################################################################
+# Copyright (c) 2016 Ericsson
+#
+# 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
+###############################################################################
+TmfXmlAnalysisOutputSource_LatencyTable=Latency Table
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/AbstractXmlViewInfo.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/AbstractXmlViewInfo.java
new file mode 100644 (file)
index 0000000..84bd4b5
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
+import org.eclipse.tracecompass.tmf.analysis.xml.ui.module.TmfXmlAnalysisOutputSource;
+
+/**
+ * Abstract class to manage information about a view for an XML analysis
+ *
+ * @author Jean-Christian Kouame
+ */
+public abstract class AbstractXmlViewInfo {
+
+    private final String fViewId;
+
+    /**
+     * Constructor
+     *
+     * @param viewId
+     *            The ID of the view
+     */
+    public AbstractXmlViewInfo(String viewId) {
+        fViewId = viewId;
+    }
+
+    /**
+     * Get this view property section from the settings. The property section is
+     * per view ID.
+     *
+     * @return The property section
+     */
+    protected IDialogSettings getPersistentPropertyStore() {
+        IDialogSettings settings = Activator.getDefault().getDialogSettings();
+        IDialogSettings section = settings.getSection(fViewId);
+        if (section == null) {
+            section = settings.addNewSection(fViewId);
+            if (section == null) {
+                throw new IllegalStateException("The persistent property section could not be added"); //$NON-NLS-1$
+            }
+        }
+        return section;
+    }
+
+    /**
+     * Set the data for this view and retrieves from it the parameter the view needs
+     *
+     * @param data
+     *            A string of the form "param1" +
+     *            {@link TmfXmlAnalysisOutputSource#DATA_SEPARATOR} +
+     *            "param2"
+     */
+    public abstract void setViewData(@NonNull String data);
+
+    /**
+     * Save this view persistent data into the settings. For example, user could
+     * save the view ID or the label, ...
+     */
+    protected abstract void savePersistentData();
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlLatencyViewInfo.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlLatencyViewInfo.java
new file mode 100644 (file)
index 0000000..402d405
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.tracecompass.tmf.analysis.xml.ui.module.TmfXmlAnalysisOutputSource;
+
+/**
+ * Class that manages information about a latency view for pattern analysis: its
+ * title, the analysis ID, etc.
+ *
+ * @author Jean-Christian Kouame
+ *
+ */
+public class XmlLatencyViewInfo extends AbstractXmlViewInfo {
+
+    private static final String XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY = "XmlLatencyAnalysisId"; //$NON-NLS-1$
+    private static final String XML_LATENCY_VIEW_LABEL_PROPERTY = "XmlLatencyViewLabel"; //$NON-NLS-1$
+
+    private @Nullable String fAnalysisId = null;
+    private @Nullable String fLabel = null;
+
+    /**
+     * Constructor
+     *
+     * @param viewId
+     *            The ID of the view
+     */
+    public XmlLatencyViewInfo(String viewId) {
+        super(viewId);
+
+        IDialogSettings settings = getPersistentPropertyStore();
+        fAnalysisId = settings.get(XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY);
+        fLabel = settings.get(XML_LATENCY_VIEW_LABEL_PROPERTY);
+    }
+
+    /**
+     * Get the analysis ID this view is for
+     *
+     * @return The analysis ID this view
+     */
+    public String getViewAnalysisId() {
+        return fAnalysisId;
+    }
+
+    /**
+     * 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.
+     *
+     * @param data
+     *            A string of the form "XML analysis ID" +
+     *            {@link TmfXmlAnalysisOutputSource#DATA_SEPARATOR} +
+     *            "latency view label"
+     */
+    @Override
+    public void setViewData(String data) {
+        String[] idFile = data.split(TmfXmlAnalysisOutputSource.DATA_SEPARATOR);
+        fAnalysisId = (idFile.length > 0) ? idFile[0] : null;
+        fLabel = (idFile.length > 1) ? idFile[1] : null;
+        savePersistentData();
+    }
+
+    @Override
+    protected void savePersistentData() {
+        IDialogSettings settings = getPersistentPropertyStore();
+
+        settings.put(XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY, fAnalysisId);
+        settings.put(XML_LATENCY_VIEW_LABEL_PROPERTY, fLabel);
+    }
+}
index 393dac84b870555995218a2969d4c8e759fc3f45..191a6ad35ae543bef2092ce6a176a68dfd3a0cf7 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Set;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
 import org.eclipse.tracecompass.tmf.analysis.xml.ui.module.TmfXmlAnalysisOutputSource;
@@ -31,12 +30,12 @@ import org.w3c.dom.Element;
  * @author Geneviève Bastien
  */
 @NonNullByDefault
-public class XmlViewInfo {
+public class XmlViewInfo extends AbstractXmlViewInfo {
 
     private static final String XML_VIEW_ID_PROPERTY = "XmlViewId"; //$NON-NLS-1$
     private static final String XML_VIEW_FILE_PROPERTY = "XmlViewFile"; //$NON-NLS-1$
 
-    private final String fViewId;
+    /** This is the ID of the view described in the XML file */
     private @Nullable String fId = null;
     private @Nullable String fFilePath = null;
 
@@ -47,10 +46,9 @@ public class XmlViewInfo {
      *            The ID of the view
      */
     public XmlViewInfo(String viewId) {
-        fViewId = viewId;
+        super(viewId);
 
         IDialogSettings settings = getPersistentPropertyStore();
-
         fId = settings.get(XML_VIEW_ID_PROPERTY);
         fFilePath = settings.get(XML_VIEW_FILE_PROPERTY);
     }
@@ -64,6 +62,7 @@ public class XmlViewInfo {
      *            {@link TmfXmlAnalysisOutputSource#DATA_SEPARATOR} +
      *            "path of the file containing the XML element"
      */
+    @Override
     public void setViewData(String data) {
         String[] idFile = data.split(TmfXmlAnalysisOutputSource.DATA_SEPARATOR);
         fId = (idFile.length > 0) ? idFile[0] : null;
@@ -71,19 +70,8 @@ public class XmlViewInfo {
         savePersistentData();
     }
 
-    private IDialogSettings getPersistentPropertyStore() {
-        IDialogSettings settings = Activator.getDefault().getDialogSettings();
-        IDialogSettings section = settings.getSection(fViewId);
-        if (section == null) {
-            section = settings.addNewSection(fViewId);
-            if (section == null) {
-                throw new IllegalStateException();
-            }
-        }
-        return section;
-    }
-
-    private void savePersistentData() {
+    @Override
+    protected void savePersistentData() {
         IDialogSettings settings = getPersistentPropertyStore();
 
         settings.put(XML_VIEW_ID_PROPERTY, fId);
@@ -155,5 +143,4 @@ public class XmlViewInfo {
         }
         return analysisIds;
     }
-
 }
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableView.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableView.java
new file mode 100644 (file)
index 0000000..194d49c
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableView;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo;
+
+/**
+ * The latency table view for pattern analysis
+ *
+ * @author Jean-Christian Kouame
+ */
+public class PatternLatencyTableView extends AbstractSegmentStoreTableView {
+
+    /** The view's ID */
+    public static final @NonNull String ID = "org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latencytable"; //$NON-NLS-1$
+
+    private final XmlLatencyViewInfo fViewInfo = new XmlLatencyViewInfo(ID);
+
+    private PatternLatencyTableViewer fViewer;
+
+    /**
+     * Constructor
+     */
+    public PatternLatencyTableView() {
+        this.addPartPropertyListener(new IPropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent event) {
+                if (event.getProperty().equals(TmfXmlUiStrings.XML_LATENCY_OUTPUT_DATA)) {
+                    Object newValue = event.getNewValue();
+                    if (newValue instanceof String) {
+                        String data = (String) newValue;
+                        fViewInfo.setViewData(data);
+                        loadLatencyView();
+                    }
+                }
+            }
+        });
+    }
+
+    private void loadLatencyView() {
+        if (fViewer != null) {
+            fViewer.updateViewer(fViewInfo.getViewAnalysisId());
+        }
+    }
+
+    @Override
+    protected @NonNull AbstractSegmentStoreTableViewer createSegmentStoreViewer(@NonNull TableViewer tableViewer) {
+        PatternLatencyTableViewer viewer = new PatternLatencyTableViewer(tableViewer);
+        fViewer = viewer;
+        loadLatencyView();
+        return viewer;
+    }
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableViewer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableViewer.java
new file mode 100644 (file)
index 0000000..e163cc2
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+
+/**
+ * Displays the latency analysis data in a column table
+ *
+ * @author Jean-Christian Kouame
+ */
+public class PatternLatencyTableViewer extends AbstractSegmentStoreTableViewer {
+
+    private String fAnalysisId;
+
+    /**
+     * Constructor
+     *
+     * @param tableViewer
+     *            The table viewer
+     */
+    public PatternLatencyTableViewer(@NonNull TableViewer tableViewer) {
+        super(tableViewer);
+    }
+
+    @Override
+    protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) {
+        return fAnalysisId != null ? TmfTraceUtils.getAnalysisModuleOfClass(trace, XmlPatternAnalysis.class, fAnalysisId) : null;
+    }
+
+    /**
+     * Set the analysis ID and update the view
+     *
+     * @param analysisId
+     *            The analysis ID
+     */
+    public void updateViewer(String analysisId) {
+        if (analysisId != null) {
+            fAnalysisId = analysisId;
+            final ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
+            if (trace != null) {
+                setData(getSegmentStoreProvider(trace));
+            }
+        }
+    }
+
+}
index 7db8d7e294320b036293ab7f580b88332060d50b..d6a88f767253ba32e5906e9f8d63ef04e4f52678 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
+ * Copyright (c) 2016 École Polytechnique de Montréal and others
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -22,8 +22,11 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module.Messages;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternLatencyTableView;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart.XmlXYView;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
@@ -31,7 +34,7 @@ import org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph.XmlTimeGraph
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput;
 import org.eclipse.tracecompass.tmf.core.analysis.ITmfNewAnalysisModuleListener;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -83,6 +86,46 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
         }
     }
 
+    /**
+     * Enum for latency view type.
+     *
+     * @author Jean-Christian Kouame
+     * @since 2.0
+     *
+     */
+    public static enum LatencyViewType {
+
+        /**
+         * Latency Table View type
+         */
+        LATENCY_TABLE(PatternLatencyTableView.ID, Messages.TmfXmlAnalysisOutputSource_LatencyTable);
+
+        private @NonNull String fLatencyViewId;
+        private String fLatencyViewLabel;
+
+        private LatencyViewType(@NonNull String viewId, String label) {
+            fLatencyViewId = viewId;
+            fLatencyViewLabel = label;
+        }
+
+        /**
+         * Get the ID of the latency view
+         *
+         * @return The ID
+         */
+        public String getViewId() {
+            return fLatencyViewId;
+        }
+
+        /**
+         * Get the label of the view
+         *
+         * @return The label
+         */
+        public String getLabel() {
+            return fLatencyViewLabel;
+        }
+    }
 
     @Override
     public void moduleCreated(IAnalysisModule module) {
@@ -100,7 +143,7 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
                 doc.getDocumentElement().normalize();
 
                 /* get state provider views if the analysis has state systems */
-                if (module instanceof TmfStateSystemAnalysisModule) {
+                if (module instanceof ITmfAnalysisModuleWithStateSystems) {
                     for (ViewType viewType : ViewType.values()) {
                         NodeList ssViewNodes = doc.getElementsByTagName(viewType.getXmlElem());
                         for (int i = 0; i < ssViewNodes.getLength(); i++) {
@@ -125,6 +168,16 @@ 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);
+                        module.registerOutput(output);
+                    }
+                }
+
             } catch (ParserConfigurationException | SAXException | IOException e) {
                 Activator.logError("Error opening XML file", e); //$NON-NLS-1$
             }
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfXmlLatencyViewOutput.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfXmlLatencyViewOutput.java
new file mode 100644 (file)
index 0000000..f563cb5
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.tmf.analysis.xml.ui.module;
+
+import org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput;
+
+/**
+ * Class overriding the default analysis view output for XML pattern analysis
+ * latency views
+ *
+ * @author Jean-Christian Kouame
+ * @since 2.0
+ *
+ */
+public class TmfXmlLatencyViewOutput extends TmfAnalysisViewOutput {
+
+    private String fLabel;
+
+    /**
+     * @param viewid
+     *            The ID of the view
+     * @param label
+     *            The label of view
+     */
+    public TmfXmlLatencyViewOutput(String viewid, String label) {
+        super(viewid);
+        fLabel = label;
+    }
+
+    @Override
+    public String getName() {
+        return fLabel;
+    }
+}
This page took 0.034606 seconds and 5 git commands to generate.