analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / project / model / TmfAnalysisElement.java
index 16c2dccc776fb7b694559d18c8d100f3783f7c9a..485196d80a5f59a5130d0167479147d416497c1f 100644 (file)
@@ -22,12 +22,12 @@ import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.viewers.StyledString.Styler;
 import org.eclipse.swt.graphics.TextStyle;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput;
-import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisManager;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.osgi.framework.Bundle;
 
@@ -35,7 +35,6 @@ import org.osgi.framework.Bundle;
  * Class for project elements of type analysis modules
  *
  * @author Geneviève Bastien
- * @since 3.0
  */
 public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfStyledProjectModelElement {
 
@@ -46,7 +45,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
         }
     };
 
-    private final String fAnalysisId;
+    private final @NonNull IAnalysisModuleHelper fAnalysisHelper;
     private boolean fCanExecute = true;
 
     /**
@@ -58,12 +57,13 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
      *            The resource
      * @param parent
      *            Parent of the analysis
-     * @param id
-     *            The analysis module id
+     * @param module
+     *            The analysis module helper
+     * @since 1.0
      */
-    protected TmfAnalysisElement(String name, IResource resource, ITmfProjectModelElement parent, String id) {
+    protected TmfAnalysisElement(String name, IResource resource, ITmfProjectModelElement parent, @NonNull IAnalysisModuleHelper module) {
         super(name, resource, parent);
-        fAnalysisId = id;
+        fAnalysisHelper = module;
         parent.addChild(this);
     }
 
@@ -81,12 +81,6 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
             childrenMap.put(output.getName(), output);
         }
 
-        IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(fAnalysisId);
-        if (helper == null) {
-            deleteOutputs();
-            return;
-        }
-
         /** Get base path for resource */
         IPath path = getProject().getTracesFolder().getPath();
         if (fResource instanceof IFolder) {
@@ -105,7 +99,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
                 return;
             }
 
-            IAnalysisModule module = trace.getAnalysisModule(fAnalysisId);
+            IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
             if (module == null) {
                 deleteOutputs();
                 /*
@@ -170,7 +164,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
      * @return The analysis id
      */
     public String getAnalysisId() {
-        return fAnalysisId;
+        return fAnalysisHelper.getId();
     }
 
     /**
@@ -186,23 +180,18 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
             TmfTraceElement traceElement = (TmfTraceElement) parent;
             trace = traceElement.getTrace();
             if (trace != null) {
-                IAnalysisModule module = trace.getAnalysisModule(fAnalysisId);
+                IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
                 if (module != null) {
                     return module.getHelpText(trace);
                 }
             }
         }
 
-        IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(fAnalysisId);
-        if (helper == null) {
-            return new String();
-        }
-
         if (trace != null) {
-            return helper.getHelpText(trace);
+            return fAnalysisHelper.getHelpText(trace);
         }
 
-        return helper.getHelpText();
+        return fAnalysisHelper.getHelpText();
     }
 
     /**
@@ -211,11 +200,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
      * @return The analysis icon file name
      */
     public String getIconFile() {
-        IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(fAnalysisId);
-        if (helper == null) {
-            return null;
-        }
-        return helper.getIcon();
+        return fAnalysisHelper.getIcon();
     }
 
     /**
@@ -224,11 +209,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
      * @return The analysis bundle
      */
     public Bundle getBundle() {
-        IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(fAnalysisId);
-        if (helper == null) {
-            return null;
-        }
-        return helper.getBundle();
+        return fAnalysisHelper.getBundle();
     }
 
     /** Delete all outputs under this analysis element */
This page took 0.036093 seconds and 5 git commands to generate.