xml.ui: Enable multiple XML latency views instances
authorMikael Ferland <mikael.ferland@ericsson.com>
Wed, 17 May 2017 15:09:13 +0000 (11:09 -0400)
committerJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tue, 23 May 2017 13:34:02 +0000 (09:34 -0400)
Make use of the secondary id to identify different analysis. Also, use
the secondary id of the analysis as an identifier for the view property
subsection in the persistent property store. This will allow the
application to retrieve the correct name of an analysis when restarting.

Change-Id: I01dfdb7ff5714dcbc6d5e2a35df570e7f80b02e6
Signed-off-by: Mikael Ferland <mikael.ferland@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/97442
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/TmfXmlLatencyViewOutput.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/AbstractXmlViewInfo.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlLatencyViewInfo.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/XmlViewInfo.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternDensityView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternScatterGraphView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsView.java

index c2e30a47b6d327a2c86f61eb9fc85271a6451f94..97d550640df3734e1b9e533e5ddb7d6e91acec3f 100644 (file)
@@ -27,7 +27,7 @@ public class TmfXmlLatencyViewOutput extends TmfAnalysisViewOutput {
      *            The label of view
      */
     public TmfXmlLatencyViewOutput(String viewid, String label) {
-        super(viewid);
+        super(viewid, label);
         fLabel = label;
     }
 
index ac707e0630e259901825339d10331c4068071097..9c394de1a6bdd31b62dfaee4631d84cd5f775625 100644 (file)
@@ -22,7 +22,7 @@ import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module.TmfXmlAnalys
 public abstract class AbstractXmlViewInfo {
 
     private final String fViewId;
-    private @Nullable String fViewName;
+    private @Nullable String fSubsectionName;
 
     /**
      * Constructor
@@ -32,27 +32,27 @@ public abstract class AbstractXmlViewInfo {
      */
     public AbstractXmlViewInfo(String viewId) {
         fViewId = viewId;
-        fViewName = null;
+        fSubsectionName = null;
     }
 
     /**
-     * Set the view's name, which should correspond to a secondary ID
+     * Set the name of the view property subsection, which should correspond to a secondary ID
      *
      * @param name
-     *            The view's name
+     *            The name of the view property subsection
      */
     public void setName(@NonNull String name) {
-        fViewName = name;
+        fSubsectionName = name;
     }
 
     /**
-     * Get the name of the view, which should correspond to the view's secondary
+     * Get the name of the view property subsection, which should correspond to the view's secondary
      * ID. If this name is not null, it will never be null again
      *
-     * @return The name of the view
+     * @return The name of the view property subsection
      */
     protected @Nullable String getName() {
-        return fViewName;
+        return fSubsectionName;
     }
 
     /**
@@ -70,15 +70,15 @@ public abstract class AbstractXmlViewInfo {
                 throw new IllegalStateException("The persistent property section could not be added " + fViewId); //$NON-NLS-1$
             }
         }
-        if (fViewName == null) {
+        if (fSubsectionName == null) {
             return section;
         }
         // FIXME: when a file is removed from TraceCompass, its view section should also be deleted
-        IDialogSettings subSection = section.getSection(fViewName);
+        IDialogSettings subSection = section.getSection(fSubsectionName);
         if (subSection == null) {
-            subSection = section.addNewSection(fViewName);
+            subSection = section.addNewSection(fSubsectionName);
             if (subSection == null) {
-                throw new IllegalStateException("The persistent property section could not be added: " + fViewName); //$NON-NLS-1$
+                throw new IllegalStateException("The persistent property section could not be added: " + fSubsectionName); //$NON-NLS-1$
             }
         }
         return subSection;
index b2b4b4ddb6cbc85ad8341b2ddc8658aad346d6dd..ae918d9a203f288c3ef5016a3a61f40c20a9ddd7 100644 (file)
@@ -26,6 +26,8 @@ public class XmlLatencyViewInfo extends AbstractXmlViewInfo {
 
     private @Nullable String fAnalysisId = null;
     private @Nullable String fLabel = null;
+    // If true, properties were set but not saved to persistent storage
+    private boolean fIsDirty = false;
 
     /**
      * Constructor
@@ -59,6 +61,18 @@ public class XmlLatencyViewInfo extends AbstractXmlViewInfo {
         return fLabel;
     }
 
+    @Override
+    public synchronized void setName(String name) {
+        super.setName(name);
+        if (fIsDirty) {
+            savePersistentData();
+        } else {
+            IDialogSettings settings = getPersistentPropertyStore();
+            fAnalysisId = settings.get(XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY);
+            fLabel = settings.get(XML_LATENCY_VIEW_LABEL_PROPERTY);
+        }
+    }
+
     /**
      * 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.
@@ -73,7 +87,12 @@ public class XmlLatencyViewInfo extends AbstractXmlViewInfo {
         String[] idFile = data.split(TmfXmlAnalysisOutputSource.DATA_SEPARATOR);
         fAnalysisId = (idFile.length > 0) ? idFile[0] : null;
         fLabel = (idFile.length > 1) ? idFile[1] : null;
-        savePersistentData();
+        String viewSubsectionName = getName();
+        if (viewSubsectionName != null) {
+            savePersistentData();
+        } else {
+            fIsDirty = true;
+        }
     }
 
     @Override
index 423662925754b1c1c69d7967f0827cff39e36839..a43f466d41675633a3af78287c59fcfe19285a15 100644 (file)
@@ -15,7 +15,6 @@ package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.CountDownLatch;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
@@ -36,8 +35,6 @@ 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$
 
-    /* Initialization is completed when name is set */
-    private final CountDownLatch fInitialized = new CountDownLatch(1);
     /** This is the ID of the view described in the XML file */
     private @Nullable String fId = null;
     private @Nullable String fFilePath = null;
@@ -55,21 +52,6 @@ public class XmlViewInfo extends AbstractXmlViewInfo {
         /* Cannot get the properties yet, need to wait for the name */
     }
 
-    /**
-     * Waits for the view info's initialization to be completed. This happens
-     * once the name has been set
-     *
-     * @return Whether the initialization has completed successfully
-     */
-    public boolean waitForInitialization() {
-        try {
-            fInitialized.await();
-        } catch (InterruptedException e) {
-            return false;
-        }
-        return true;
-    }
-
     /**
      * Set the data for this view and retrieves from it the view ID and the file
      * path of the XML element this view uses.
@@ -102,7 +84,6 @@ public class XmlViewInfo extends AbstractXmlViewInfo {
             fId = settings.get(XML_VIEW_ID_PROPERTY);
             fFilePath = settings.get(XML_VIEW_FILE_PROPERTY);
         }
-        fInitialized.countDown();
     }
 
     @Override
index 835014b8ef0f5a4b5041fe10bfb679a5768c4ea0..b69e055e8ef48d30d902c2dbcb6032291090764d 100644 (file)
@@ -9,11 +9,13 @@
 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.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density.AbstractSegmentStoreDensityView;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density.AbstractSegmentStoreDensityViewer;
@@ -59,6 +61,22 @@ public class PatternDensityView extends AbstractSegmentStoreDensityView {
         });
     }
 
+    @Override
+    public void createPartControl(@Nullable Composite parent) {
+        String name = getViewSite().getSecondaryId();
+        if (name != null) {
+            /* must initialize view info before calling super */
+            fViewInfo.setName(name);
+        }
+        super.createPartControl(parent);
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                setPartName(fViewInfo.getLabel());
+            }
+        });
+    }
+
     private void loadTableViewer() {
         if (fTableViewer != null) {
             fTableViewer.updateViewer(fViewInfo.getViewAnalysisId());
index 6b500b260b9e2b83c7022c13309dcb604afd79f5..3008fa28529fa8c2fee626d1aec5a8ee1331f15a 100644 (file)
@@ -9,9 +9,12 @@
 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.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 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;
@@ -51,6 +54,22 @@ public class PatternLatencyTableView extends AbstractSegmentStoreTableView {
         });
     }
 
+    @Override
+    public void createPartControl(@Nullable Composite parent) {
+        String name = getViewSite().getSecondaryId();
+        if (name != null) {
+            /* must initialize view info before calling super */
+            fViewInfo.setName(name);
+        }
+        super.createPartControl(parent);
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                setPartName(fViewInfo.getLabel());
+            }
+        });
+    }
+
     private void loadLatencyView() {
         if (fViewer != null) {
             fViewer.updateViewer(fViewInfo.getViewAnalysisId());
index b96c52e73f53a130d79128b0e8e280f8c623bb40..054b4a001224579b586a03352ad83276ddfe822f 100644 (file)
@@ -11,9 +11,11 @@ package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo;
 import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer;
@@ -54,6 +56,22 @@ public class PatternScatterGraphView extends TmfChartView {
         });
     }
 
+    @Override
+    public void createPartControl(@Nullable Composite parent) {
+        String name = getViewSite().getSecondaryId();
+        if (name != null) {
+            /* must initialize view info before calling super */
+            fViewInfo.setName(name);
+        }
+        super.createPartControl(parent);
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                setPartName(fViewInfo.getLabel());
+            }
+        });
+    }
+
     private void loadLatencyView() {
         if (fViewer != null) {
             fViewer.updateViewer(fViewInfo.getViewAnalysisId());
index 52c19da524f1b62270c66368929c335b26f8c11c..760cf26adcafe7ec85ef5d2f14f7a8774dbab078 100644 (file)
@@ -9,9 +9,11 @@
 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.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentsStatisticsView;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo;
@@ -50,6 +52,22 @@ public class PatternStatisticsView extends AbstractSegmentsStatisticsView {
         });
     }
 
+    @Override
+    public void createPartControl(@Nullable Composite parent) {
+        String name = getViewSite().getSecondaryId();
+        if (name != null) {
+            /* must initialize view info before calling super */
+            fViewInfo.setName(name);
+        }
+        super.createPartControl(parent);
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                setPartName(fViewInfo.getLabel());
+            }
+        });
+    }
+
     private void loadStatisticView() {
         if (fViewer != null) {
             fViewer.updateViewer(fViewInfo.getViewAnalysisId());
This page took 0.031294 seconds and 5 git commands to generate.