tmf.ui: Support secondary ID for TmfAnalysisViewOutput
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 26 Apr 2017 17:47:34 +0000 (13:47 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Mon, 15 May 2017 19:55:04 +0000 (15:55 -0400)
This adds the possibility to add the analysis ID as secondary ID when
constructing the TmfAnalysisViewOutput objects.

This is useful for views that support a type of analysis instead of
only one analysis. Analyses of this type will associate the view and
the analysis ID to obtain a view output that will create a different
view for each analysis.

For example, each callstack analysis under a trace or experiment could
automatically have their own flamegraph associated.

Change-Id: Ife0da12d20ab7f77649d00fb580997ff3acd80a6
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/95832
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/analysis/TmfAnalysisViewOutput.java

index 0e3553ffda25e02e3adfefbd561cb60b2b4f485d..cfde5d4b95f428a71f860cdde3cebc424a159629 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExecutableExtension;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput;
@@ -43,13 +44,14 @@ import org.eclipse.ui.views.IViewDescriptor;
 public class TmfAnalysisViewOutput implements IAnalysisOutput, IExecutableExtension {
 
     private String fViewId;
+    private final @Nullable String fSecondaryId;
     private final Map<String, String> fProperties = new HashMap<>();
 
     /**
      * Default constructor
      */
     public TmfAnalysisViewOutput() {
-
+        fSecondaryId = null;
     }
 
     /**
@@ -60,6 +62,25 @@ public class TmfAnalysisViewOutput implements IAnalysisOutput, IExecutableExtens
      */
     public TmfAnalysisViewOutput(String viewid) {
         fViewId = viewid;
+        fSecondaryId = null;
+    }
+
+    /**
+     * Constructor
+     *
+     * @param viewid
+     *            id of the view to display as output
+     * @param secondaryId
+     *            The secondary ID for this view, for example, an analysis ID
+     *            for views supporting multiple analyses. If not
+     *            <code>null</code>, the view will be opened with id
+     *            "viewid:secondaryId", so multiple instances of the same view
+     *            can be opened at the same time.
+     * @since 3.0
+     */
+    public TmfAnalysisViewOutput(String viewid, String secondaryId) {
+        fViewId = viewid;
+        fSecondaryId = secondaryId;
     }
 
     /**
@@ -91,7 +112,13 @@ public class TmfAnalysisViewOutput implements IAnalysisOutput, IExecutableExtens
         final IWorkbench wb = PlatformUI.getWorkbench();
         final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
 
-        return activePage.showView(fViewId);
+        String viewId = fViewId;
+        String secondaryId = fSecondaryId;
+        if (secondaryId != null) {
+            viewId += ':' + secondaryId;
+        }
+
+        return activePage.showView(viewId);
     }
 
     @Override
This page took 0.026014 seconds and 5 git commands to generate.