scripting: bug 552408 Provide scripting module help

This allows the help to appear in the Module Explorer

Also fix the javadoc, while @module work well with the EASE doclet, it
does not produce the desired result with the "normal" javadoc and causes
errors.

Also the TraceScriptingUI module in UI does not have to extend the one from
core, as it only overrides a method that is unsupported anyway in the
core.

Change-Id: Ia65f8a4b878e91cb515089ce0ca8ef101029f965
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/153668
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
diff --git a/pom.xml b/pom.xml
index 2a76da4..8c80884 100644
--- a/pom.xml
+++ b/pom.xml
@@ -270,6 +270,41 @@
         <sonar.skip>true</sonar.skip>
       </properties>
     </profile>
+
+     <profile>
+        <id>build-api-docs</id>
+        <build>
+            <plugins>
+               <plugin>
+                   <groupId>org.apache.maven.plugins</groupId>
+                   <artifactId>maven-javadoc-plugin</artifactId>
+                   <version>3.1.0</version>
+                   <configuration>
+                      <groups>
+                         <group>
+                            <title>Trace Compass EASE Scripting</title>
+                            <packages>org.eclipse.tracecompass.incubator.scripting.*</packages>
+                         </group>
+                      </groups>
+                      <excludePackageNames>org.eclipse.tracecompass.incubator.internal.*:*.test*</excludePackageNames>
+                      <overview>overview.html</overview>
+                      <noindex>true</noindex>
+                      <nodeprecated>false</nodeprecated>
+                      <nodeprecatedlist>false</nodeprecatedlist>
+                      <nohelp>true</nohelp>
+                      <notree>true</notree>
+                      <doctitle>Trace Compass Incubator API</doctitle>
+                      <show>public</show>
+                      <links>
+                         <link>https://archive.eclipse.org/tracecompass/doc/javadoc/apidocs/</link>
+                      </links>
+                      <verbose>true</verbose>
+                   </configuration>
+                </plugin>
+            </plugins>
+        </build>
+     </profile>
+
   </profiles>
 
   <modules>
@@ -564,33 +599,6 @@
         </plugin>
 
         <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-javadoc-plugin</artifactId>
-          <version>3.1.0</version>
-          <configuration>
-            <groups>
-              <group>
-                <title>Trace Compass EASE Scripting</title>
-                <packages>org.eclipse.tracecompass.incubator.scripting.*</packages>
-              </group>
-            </groups>
-            <excludePackageNames>org.eclipse.tracecompass.incubator.internal.*:*.test*</excludePackageNames>
-            <overview>overview.html</overview>
-            <noindex>true</noindex>
-            <nodeprecated>true</nodeprecated>
-            <nodeprecatedlist>true</nodeprecatedlist>
-            <nohelp>true</nohelp>
-            <notree>true</notree>
-            <doctitle>Trace Compass Incubator API</doctitle>
-            <show>public</show>
-            <links>
-               <link>https://archive.eclipse.org/tracecompass/doc/javadoc/apidocs/</link>
-            </links>
-            <verbose>true</verbose>
-          </configuration>
-        </plugin>
-
-        <plugin>
           <groupId>org.jboss.tools.tycho-plugins</groupId>
           <artifactId>repository-utils</artifactId>
           <version>1.0.0</version>
diff --git a/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/analysis/AnalysisScriptingModule.java b/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/analysis/AnalysisScriptingModule.java
index df30fb9..56f6ff5 100644
--- a/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/analysis/AnalysisScriptingModule.java
+++ b/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/analysis/AnalysisScriptingModule.java
@@ -31,8 +31,8 @@
  * </p>
  * <p>
  * Example scripts with data providers can be found here:
- * <ul>
  * </p>
+ * <ul>
  * <li><a href="../doc-files/scriptedDataProvider.js">A scripted time graph data
  * provider</a> with script-defined entries and arrows (javascript)</li>
  * <li><a href="../doc-files/basicAnalysis.js">A basic analysis</a> building an
diff --git a/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/data/provider/DataProviderScriptingModule.java b/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/data/provider/DataProviderScriptingModule.java
index d7cb1a3..69c4ec6 100644
--- a/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/data/provider/DataProviderScriptingModule.java
+++ b/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/data/provider/DataProviderScriptingModule.java
@@ -49,6 +49,7 @@
  * views or other means of exportation.
  * <p>
  * Example scripts with data providers can be found here:
+ * </p>
  * <ul>
  * <li><a href="../../doc-files/scriptedDataProvider.js">A scripted time graph
  * data provider</a> with script-defined entries and arrows</li>
diff --git a/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/trace/TraceScriptingModule.java b/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/trace/TraceScriptingModule.java
index e7816b0..b57470a 100644
--- a/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/trace/TraceScriptingModule.java
+++ b/scripting/org.eclipse.tracecompass.incubator.scripting.core/src/org/eclipse/tracecompass/incubator/scripting/core/trace/TraceScriptingModule.java
@@ -54,11 +54,13 @@
      * @param isExperiment
      *            is the trace an experiment
      * @return The trace
-     * @throws FileNotFoundException
-     *             Exception thrown if the file or the trace doesn't exist
+     * @deprecated This method was never supported, to open a trace in Trace
+     *             Compass, use the <code>openTrace</code> method from the
+     *             <code>'/TraceCompass/TraceUI'</code> module
      */
+    @Deprecated
     @WrapToScript
-    public ITmfTrace openTrace(String projectName, String traceName, @ScriptParameter(defaultValue = "false") boolean isExperiment) throws FileNotFoundException {
+    public ITmfTrace openTrace(String projectName, String traceName, @ScriptParameter(defaultValue = "false") boolean isExperiment) {
         // TODO may need to be implemented for Theia.
         // Can not do anything without the UI
         throw new UnsupportedOperationException("Load the /TraceCompass/TraceUI module instead"); //$NON-NLS-1$
diff --git a/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/trace/TraceScriptingUI.java b/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/trace/TraceScriptingUI.java
index e221a77..d579855 100644
--- a/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/trace/TraceScriptingUI.java
+++ b/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/trace/TraceScriptingUI.java
@@ -19,7 +19,6 @@
 import org.eclipse.ease.modules.WrapToScript;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.incubator.internal.scripting.core.trace.Messages;
-import org.eclipse.tracecompass.incubator.scripting.core.trace.TraceScriptingModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ui.project.model.ITmfProjectModelElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement;
@@ -28,14 +27,29 @@
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
 
 /**
- * Extension of the {@link TraceScriptingModule} class that allows to interact
- * with the Trace Compass UI to open an import traces.
+ * Trace scripting module that allows to interact with the Trace Compass UI to
+ * open an import traces.
  *
  * @author Benjamin Saint-Cyr
  */
-public class TraceScriptingUI extends TraceScriptingModule {
+public class TraceScriptingUI {
 
-    @Override
+    /**
+     * Fully open a trace in the Trace Compass application, ie it will open as
+     * if the user had opened it in the UI, running all automatic analyses, etc.
+     * If the trace is successfully opened, it becomes the currently active
+     * trace.
+     *
+     * @param projectName
+     *            The name of the project
+     * @param traceName
+     *            the trace to open
+     * @param isExperiment
+     *            is the trace an experiment
+     * @return The trace
+     * @throws FileNotFoundException
+     *             Exception thrown if the file or the trace doesn't exist
+     */
     @WrapToScript
     public ITmfTrace openTrace(String projectName, String traceName, @ScriptParameter(defaultValue = "false") boolean isExperiment) throws FileNotFoundException {
         IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -62,7 +76,7 @@
         Display.getDefault().syncExec(new Runnable() {
             @Override
             public void run() {
-                TmfOpenTraceHelper.openTraceFromElement((TmfCommonProjectElement) traceChild);
+                TmfOpenTraceHelper.openFromElement((TmfCommonProjectElement) traceChild);
             }
         });
         // Return the trace
diff --git a/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/views/ViewModule.java b/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/views/ViewModule.java
index 46ef57a..d54978c 100644
--- a/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/views/ViewModule.java
+++ b/scripting/org.eclipse.tracecompass.incubator.scripting.ui/src/org/eclipse/tracecompass/incubator/scripting/ui/views/ViewModule.java
@@ -28,7 +28,7 @@
 /**
  * Scripting module that allow to interact with views using EASE in the Trace
  * Compass UI.
- * <p>
+ *
  * Example scripts using views can be found here:
  * <ul>
  * <li><a href="../../core/analysis/doc-files/scriptedDataProvider.js">A
@@ -77,15 +77,15 @@
     /**
      * Open any view in Trace Compass, using its view ID, with an optional
      * secondary ID.
-     * <p>
+     *
      * For many views that are common for many analyses, for example, the table
      * views, scatter views, statistics, flame chart/graph, the secondary ID is
      * the ID of the analysis. This value can be found by selecting the analysis
      * that will be the source of the view and looking in the 'Properties' view
      * for the ID property.
-     * <p>
+     *
      * For example, to open a table view for the LTTng-UST CallStack (Incubator) analysis, the follow call can be make
-     * <p>
+     *
      * <pre>
      * showView(org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.SegmentStoreTableView.ID, "org.eclipse.tracecompass.incubator.callstack.core.lttng.ust");
      * </pre>
diff --git a/scripting/pom.xml b/scripting/pom.xml
index 15ea301..4240e5e 100644
--- a/scripting/pom.xml
+++ b/scripting/pom.xml
@@ -35,4 +35,77 @@
     <!-- insert modules here -->
   </modules>
 
+<profiles>
+   <profile>
+        <!-- build help pages for modules using javadoc. Needs variable doclet.path 
+             to be set to the location of the ModuleDoclet jar. The jar can be built with: 
+             mvn clean package -f org.eclipse.ease.core/developers/org.eclipse.ease.helpgenerator/pom.xml 
+             in which case the doclet.path would be: org.eclipse.ease.core/developers/org.eclipse.ease.helpgenerator/target/ease.module.doclet.jar 
+             or the pre-built jar can downloaded from: https://ci.eclipse.org/ease/job/ease.build.module.doclet/lastSuccessfulBuild/artifact/developers/org.eclipse.ease.helpgenerator/target/ease.module.doclet.jar -->
+        <id>module-docs</id>
+        <properties>
+            <platform.api>org.eclipse.platform.doc.isv/reference/api</platform.api>
+            <doclet.path>${user.dir}/ease.module.doclet.jar</doclet.path>
+        </properties>
+        <build>
+            <plugins>
+
+                <!-- enable module documentation builder -->
+                <plugin>
+                    <artifactId>maven-javadoc-plugin</artifactId>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <version>2.9.1</version>
+                    <configuration>
+                        <outputDirectory>${project.build.directory}/../mydocs </outputDirectory>
+                        <doclet>org.eclipse.ease.helpgenerator.V8ModuleDoclet</doclet>
+                        <docletPath>${doclet.path}</docletPath>
+			<additionalparam>-root ${basedir} -failOnHTMLError true
+                                           -failOnMissingDocs true</additionalparam>
+
+                        <useStandardDocletOptions>true</useStandardDocletOptions>
+                        <excludePackageNames>org.eclipse.tracecompass.incubator.internal.*:*.test*</excludePackageNames>
+                        <links>
+                            <link>https://osgi.org/javadoc/r6/cmpn</link>
+                            <link>http://docs.oracle.com/javase/8/docs/api/</link>
+                            <link>https://archive.eclipse.org/tracecompass/doc/javadoc/apidocs/</link>
+                        </links>
+                        <verbose>true</verbose>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>build-docs</id>
+                            <phase>generate-resources</phase>
+                            <goals>
+                                <goal>javadoc</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <plugin>
+                    <artifactId>build-helper-maven-plugin</artifactId>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <version>1.9.1</version>
+                    <executions>
+                        <execution>
+                            <id>add_help</id>
+                            <phase>generate-resources</phase>
+                            <goals>
+                                <goal>add-resource</goal>
+                            </goals>
+                            <configuration>
+                                <resources>
+                                    <resource>
+                                        <directory>${basedir}/help</directory>
+                                        <targetPath>help</targetPath>
+                                    </resource>
+                                </resources>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </build>
+    </profile>
+</profiles>
 </project>