TMF: Add the possibility to specify a content provider for time graphs
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 9 Feb 2015 03:28:02 +0000 (22:28 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 26 Mar 2015 02:39:43 +0000 (22:39 -0400)
This gives more flexibility to manage time graph entries instead of
building the list only once when the trace is loaded.

For example, a view like the Critical Path View where the list of
entries depend on the selection from another view can be managed using a
content provider.

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

index 5eb02b1e8c143600eac205a72f1c06a850a09c38..20b2ab7720315505501c02d3437a7dd521ca2ff2 100644 (file)
@@ -150,6 +150,9 @@ public abstract class AbstractTimeGraphView extends TmfView {
     /** The tree label provider, or null if combo is not used */
     private TreeLabelProvider fLabelProvider = null;
 
+    /** The time graph content provider */
+    private @NonNull ITimeGraphContentProvider fTimeGraphContentProvider = new TimeGraphContentProvider();
+
     /** The relative weight of the sash, ignored if combo is not used */
     private int[] fWeight = { 1, 1 };
 
@@ -559,6 +562,18 @@ public abstract class AbstractTimeGraphView extends TmfView {
         fLabelProvider = tlp;
     }
 
+    /**
+     * Sets the time graph content provider. This should be called from the
+     * constructor.
+     *
+     * @param tgcp
+     *            The time graph content provider
+     * @since 1.0
+     */
+    protected void setTimeGraphContentProvider(final @NonNull ITimeGraphContentProvider tgcp) {
+        fTimeGraphContentProvider = tgcp;
+    }
+
     /**
      * Sets the relative weight of each part of the time graph combo.
      * This should be called from the constructor.
@@ -795,22 +810,21 @@ public abstract class AbstractTimeGraphView extends TmfView {
 
     @Override
     public void createPartControl(Composite parent) {
-        ITimeGraphContentProvider contentProvider = new TimeGraphContentProvider();
         if (fColumns == null || fLabelProvider == null) {
             fTimeGraphWrapper = new TimeGraphViewerWrapper(parent, SWT.NONE);
             TimeGraphViewer viewer = fTimeGraphWrapper.getTimeGraphViewer();
-            viewer.setTimeGraphContentProvider(contentProvider);
+            viewer.setTimeGraphContentProvider(fTimeGraphContentProvider);
         } else {
             TimeGraphComboWrapper wrapper = new TimeGraphComboWrapper(parent, SWT.NONE);
             fTimeGraphWrapper = wrapper;
             TimeGraphCombo combo = wrapper.getTimeGraphCombo();
-            combo.setTreeContentProvider(contentProvider);
+            combo.setTreeContentProvider(fTimeGraphContentProvider);
             combo.setTreeLabelProvider(fLabelProvider);
             combo.setTreeColumns(fColumns);
-            combo.setFilterContentProvider(contentProvider);
+            combo.setFilterContentProvider(fTimeGraphContentProvider);
             combo.setFilterLabelProvider(fFilterLabelProvider);
             combo.setFilterColumns(fFilterColumns);
-            combo.setTimeGraphContentProvider(contentProvider);
+            combo.setTimeGraphContentProvider(fTimeGraphContentProvider);
         }
 
         fTimeGraphWrapper.setTimeGraphProvider(fPresentation);
This page took 0.045516 seconds and 5 git commands to generate.