You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2018/01/20 15:40:19 UTC

svn commit: r1821753 - in /jmeter/trunk: bin/ src/core/org/apache/jmeter/functions/gui/ src/core/org/apache/jmeter/gui/action/ xdocs/ xdocs/usermanual/

Author: pmouawad
Date: Sat Jan 20 15:40:19 2018
New Revision: 1821753

URL: http://svn.apache.org/viewvc?rev=1821753&view=rev
Log:
Bug 62027 Help : Introduce property help.local to allow choosing between local (offline) documentation and online documentation
Bugzilla Id: 62027

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/OpenLinkAction.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1821753&r1=1821752&r2=1821753&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sat Jan 20 15:40:19 2018
@@ -1237,3 +1237,11 @@ jmeter.reportgenerator.apdex_tolerated_t
 
 # Implementation of interface org.apache.jmeter.gui.action.TreeNodeNamingPolicy
 #naming_policy.impl=org.apache.jmeter.gui.action.impl.DefaultTreeNodeNamingPolicy
+
+#---------------------------------------------------------------------------
+# Help Documentation
+#---------------------------------------------------------------------------
+
+# Switch that allows using Local documentation opened in JMeter GUI
+# By default we use Online documentation opened in Browser
+#help.local=false
\ No newline at end of file

Modified: jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java?rev=1821753&r1=1821752&r2=1821753&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/functions/gui/FunctionHelper.java Sat Jan 20 15:40:19 2018
@@ -47,6 +47,7 @@ import org.apache.jmeter.engine.util.Com
 import org.apache.jmeter.functions.Function;
 import org.apache.jmeter.gui.action.ActionNames;
 import org.apache.jmeter.gui.action.ActionRouter;
+import org.apache.jmeter.gui.action.Help;
 import org.apache.jmeter.gui.action.KeyStrokes;
 import org.apache.jmeter.gui.util.JSyntaxTextArea;
 import org.apache.jmeter.gui.util.JTextScrollPane;
@@ -208,9 +209,9 @@ public class FunctionHelper extends JDia
     private class HelpListener implements ActionListener {
         @Override
         public void actionPerformed(ActionEvent e) {
-            String source = functionList.getText();
+            String[] source = new String[] { Help.HELP_FUNCTIONS, functionList.getText() };
             ActionRouter.getInstance().doActionNow(
-                    new ActionEvent(source, e.getID(), ActionNames.LINK_FUNC_REF));
+                    new ActionEvent(source, e.getID(), ActionNames.HELP));
 
         }
     }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java?rev=1821753&r1=1821752&r2=1821753&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java Sat Jan 20 15:40:19 2018
@@ -41,14 +41,15 @@ import org.slf4j.LoggerFactory;
  */
 public class Help extends AbstractAction {
     private static final Logger log = LoggerFactory.getLogger(Help.class);
-
+    private static final boolean USE_LOCAL_HELP = 
+            JMeterUtils.getPropDefault("help.local", false);
     private static final Set<String> commands = new HashSet<>();
 
     private static final String HELP_DOCS = "file:///"  // $NON-NLS-1$
         + JMeterUtils.getJMeterHome()
         + "/printable_docs/usermanual/"; // $NON-NLS-1$
 
-    private static final String HELP_PAGE = HELP_DOCS + "component_reference.html"; // $NON-NLS-1$
+    private static final String HELP_COMPONENTS = HELP_DOCS + "component_reference.html"; // $NON-NLS-1$
 
     public static final String HELP_FUNCTIONS = HELP_DOCS + "functions.html"; // $NON-NLS-1$
 
@@ -70,37 +71,51 @@ public class Help extends AbstractAction
      */
     @Override
     public void doAction(ActionEvent e) {
-        JDialog dialog = initHelpWindow();
-        dialog.setVisible(true); // set the window visible immediately
-
-        /*
-         * This means that a new page will be shown before rendering is complete,
-         * however the correct location will be displayed.
-         * Attempts to use a "page" PropertyChangeListener to detect when the page
-         * has been loaded failed to work any better. 
-         */
-        StringBuilder url=new StringBuilder();
-        if (e.getSource() instanceof String[]) {
-            String[] source = (String[]) e.getSource();
-            url.append(source[0]).append('#').append(source[1]);
+        if(USE_LOCAL_HELP) {
+            JDialog dialog = initHelpWindow();
+            dialog.setVisible(true); // set the window visible immediately
+    
+            /*
+             * This means that a new page will be shown before rendering is complete,
+             * however the correct location will be displayed.
+             * Attempts to use a "page" PropertyChangeListener to detect when the page
+             * has been loaded failed to work any better. 
+             */
+            StringBuilder url=new StringBuilder();
+            if (e.getSource() instanceof String[]) {
+                String[] source = (String[]) e.getSource();
+                url.append(source[0]).append('#').append(source[1]);
+            } else {
+                url.append(HELP_COMPONENTS).append('#').append(GuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor());
+            }
+            try {
+                helpDoc.setPage(url.toString()); // N.B. this only reloads if necessary (ignores the reference)
+            } catch (IOException ioe) {
+                log.error("Error setting page for url, {}", url, ioe);
+                helpDoc.setText("<html><head><title>Problem loading help page</title>"
+                        + "<style><!--"
+                        + ".note { background-color: #ffeeee; border: 1px solid brown; }"
+                        + "div { padding: 10; margin: 10; }"
+                        + "--></style></head>"
+                        + "<body><div class='note'>"
+                        + "<h1>Problem loading help page</h1>"
+                        + "<div>Can't load url: &quot;<em>"
+                        + url.toString() + "</em>&quot;</div>"
+                        + "<div>See log for more info</div>"
+                        + "</body>");
+            }
         } else {
-            url.append(HELP_PAGE).append('#').append(GuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor());
-        }
-        try {
-            helpDoc.setPage(url.toString()); // N.B. this only reloads if necessary (ignores the reference)
-        } catch (IOException ioe) {
-            log.error("Error setting page for url, {}", url, ioe);
-            helpDoc.setText("<html><head><title>Problem loading help page</title>"
-                    + "<style><!--"
-                    + ".note { background-color: #ffeeee; border: 1px solid brown; }"
-                    + "div { padding: 10; margin: 10; }"
-                    + "--></style></head>"
-                    + "<body><div class='note'>"
-                    + "<h1>Problem loading help page</h1>"
-                    + "<div>Can't load url: &quot;<em>"
-                    + url.toString() + "</em>&quot;</div>"
-                    + "<div>See log for more info</div>"
-                    + "</body>");
+            if (e.getSource() instanceof String[]) {
+                ActionRouter.getInstance().doActionNow(
+                        new ActionEvent(e.getSource(), e.getID(), 
+                                ActionNames.LINK_FUNC_REF));
+            } else {
+                String[] source = new String[]{ActionNames.LINK_COMP_REF, 
+                        GuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor()};
+                ActionRouter.getInstance().doActionNow(
+                        new ActionEvent(source, e.getID(), 
+                                ActionNames.LINK_COMP_REF));
+            }
         }
     }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/OpenLinkAction.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/OpenLinkAction.java?rev=1821753&r1=1821752&r2=1821753&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/OpenLinkAction.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/OpenLinkAction.java Sat Jan 20 15:40:19 2018
@@ -65,8 +65,8 @@ public class OpenLinkAction extends Abst
             return; 
         }
         try {
-            if(e.getSource() instanceof String) {
-                url += "#"+((String)e.getSource());
+            if(e.getSource() instanceof String[]) {
+                url += "#"+((String[])e.getSource())[1];
             }
             java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
         } catch (IOException err) {

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1821753&r1=1821752&r2=1821753&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sat Jan 20 15:40:19 2018
@@ -208,7 +208,7 @@ Graphs <i>Latency Vs Request</i> and <i>
     <li><bug>61759</bug>Add <code>__changeCase</code> function to change different cases of a string. Based on a contribution by orimarko at gmail.com</li>
     <li><bug>61561</bug>Function helper dialog should display exception in result</li>
     <li><bug>61738</bug>Function Helper Dialog: Add Copy in Generate and clarify labels. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
-    <li><bug>62027</bug>Function Helper Dialog : Make Help button open browser on function documentation instead of Internal Dialog</li>
+    <li><bug>62027</bug>Help : Introduce property <code>help.local</code> to allow choosing between local (offline) documentation and online documentation</li>
     <li><bug>61593</bug>Remove Detail, Add, Add from Clipboard, Delete buttons in Function Helper GUI</li>
 </ul>
 

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1821753&r1=1821752&r2=1821753&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Sat Jan 20 15:40:19 2018
@@ -1807,6 +1807,16 @@ JMETER-SERVER</source>
 <a href="#">^</a>
 </section>
 
+<section name="&sect-num;.42 Help" anchor="help">
+<description>Controls how documentation in JMeter is displayed</description>
+<properties>
+    <property name="help.local">
+    Switch that allows using Local documentation opened in JMeter GUI.<br/>
+    By default we use Online documentation opened in Browser.
+    Defaults to <code>false</code>
+    </property>
+</properties>
+</section>
 <!-- 
 <section name="&sect-num;.10 Reports" anchor="Reports">
 <description>