+ /* If the analysis is not a child of the trace, create it */
+ TmfAnalysisElement analysis = childrenMap.remove(module.getId());
+ if (analysis == null) {
+ IFolder analysisRes = ResourcesPlugin.getWorkspace().getRoot().getFolder(nodePath.append(module.getId()));
+ analysis = new TmfAnalysisElement(module.getName(), analysisRes, this, module);
+ addChild(analysis);
+ }
+ analysis.refreshChildren();
+ }
+
+ /* Remove analysis that are not children of this trace anymore */
+ for (TmfAnalysisElement analysis : childrenMap.values()) {
+ removeChild(analysis);
+ }
+ } else if (parent != null) {
+ /* In experiment case collect trace analyses in the aggregate analyses element */
+ Map<String, TmfAggregateAnalysisElement> analysisMap = new LinkedHashMap<>();
+
+ /* Add all new analysis modules or refresh outputs of existing ones */
+ for (IAnalysisModuleHelper module : TmfAnalysisManager.getAnalysisModules(traceClass).values()) {
+
+ /* If the analysis is not a child of the trace, create it */
+ TmfAnalysisElement analysis = childrenMap.remove(module.getId());
+ TmfAggregateAnalysisElement aggregateAnalysisElement = null;
+ if (analysis == null) {
+ IFolder analysisRes = ResourcesPlugin.getWorkspace().getRoot().getFolder(nodePath.append(module.getId()));
+ analysis = new TmfAnalysisElement(module.getName(), analysisRes, this, module);
+ aggregateAnalysisElement = new TmfAggregateAnalysisElement(parent, analysis);
+ addChild(aggregateAnalysisElement);
+ } else {
+ if (analysis instanceof TmfAggregateAnalysisElement) {
+ aggregateAnalysisElement = (TmfAggregateAnalysisElement) analysis;
+ } else {
+ aggregateAnalysisElement = new TmfAggregateAnalysisElement(parent, analysis);
+ }
+ removeChild(analysis);
+ addChild(aggregateAnalysisElement);
+ }
+ analysisMap.put(analysis.getAnalysisId(), aggregateAnalysisElement);
+ }
+
+ /* Now add available all trace analyses */
+ for (TmfAnalysisElement analysis : getParent().getChildrenAvailableAnalysis()) {
+ /* If the analysis is not a child of the trace, create it */
+ TmfAnalysisElement a = childrenMap.remove(analysis.getAnalysisId());
+
+ TmfAggregateAnalysisElement childAnalysis = null;
+
+ if (a instanceof TmfAggregateAnalysisElement) {
+ childAnalysis = (TmfAggregateAnalysisElement) a;
+ } else {
+ childAnalysis = analysisMap.get(analysis.getAnalysisId());
+ }
+
+ if (childAnalysis == null) {
+ childAnalysis = new TmfAggregateAnalysisElement(parent, analysis);
+ addChild(childAnalysis);
+ } else {
+ childAnalysis.addAnalyses(analysis);
+ }
+ analysisMap.put(analysis.getAnalysisId(), childAnalysis);