graph: Pass graph module to critical path constructor

This avoid a parameter change event when the trace is set and thus does
not schedule the critical path at that point. Besides, in the case of
the critical path module being a sub-module of the graph module, it
makes sense that it should know about its parent module at construction
time.

Maybe if the graph is not set anywhere anymore we can remove the graph
parameter altogether and just leave it in the constructor?

Bug: 518264

Change-Id: Ifb684df234c8e2fe8f38661fdcca043dab151fec
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/99342
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java
index 56304fa..b506b32 100644
--- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java
+++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/building/TmfGraphBuilderModule.java
@@ -35,7 +35,14 @@
 
     private @Nullable TmfGraph fGraph;
     private @Nullable ITmfEventRequest fRequest;
-    private final CriticalPathModule fCriticalPathModule = new CriticalPathModule();
+    private final CriticalPathModule fCriticalPathModule;
+
+    /**
+     * Constructor
+     */
+    public TmfGraphBuilderModule() {
+        fCriticalPathModule = new CriticalPathModule(this);
+    }
 
     /**
      * Gets the graph provider to build this graph
@@ -81,9 +88,6 @@
             return ret;
         }
         ret = fCriticalPathModule.setTrace(trace);
-        if (ret) {
-            fCriticalPathModule.setParameter(CriticalPathModule.PARAM_GRAPH, getId());
-        }
         return ret;
     }
 
diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java
index 0ec7cce..1c03527 100644
--- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java
+++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/criticalpath/CriticalPathModule.java
@@ -60,6 +60,22 @@
         setId(ANALYSIS_ID);
     }
 
+    /**
+     * Default constructor
+     *
+     * @param graph
+     *            The graph module that will be used to calculate the critical
+     *            path on
+     * @since 1.1
+     */
+    public CriticalPathModule(TmfGraphBuilderModule graph) {
+        super();
+        addParameter(PARAM_GRAPH);
+        addParameter(PARAM_WORKER);
+        setId(ANALYSIS_ID);
+        fGraphModule = graph;
+    }
+
     @Override
     protected boolean executeAnalysis(final IProgressMonitor monitor) throws TmfAnalysisException {
         /* Get the graph */