Closed asfimport closed 11 years ago
Marko (migrated from Bugzilla): Created attachment BeanShellSamplerGui.java.diff: Patch for BeanShellSamplerGui.java
Marko (migrated from Bugzilla): Created attachment GenericTestBeanCustomizer.java.diff: Patch for GenericTestBeanCusomizer.java
Marko (migrated from Bugzilla): Created attachment TextAreaEditor.java.diff: Patch for TextAreaEditor.java
Marko (migrated from Bugzilla): Created attachment WrapperEditor.java.diff: Patch for WrapperEditor.java
Marko (migrated from Bugzilla): Created attachment build.properties: build.properties file that includes rsyntaxtextarea.jar
Marko (migrated from Bugzilla): Created attachment textarea.properties: Mapping between ComboBox elements and Syntaxes
Marko (migrated from Bugzilla): Created attachment build.xml.diff: Patch for ant build file to include rsysntaxtextarea.jar
Marko (migrated from Bugzilla): Created attachment Screen Shot 2013-07-05 at 2.05.39 PM.png: ScreenShot of Syntax Highlight in jmeter
Marko (migrated from Bugzilla): Created attachment RSyntaxTextArea.patch: RSyntaxTextArea.patch contains the full patch of all java files
@milamberspace (migrated from Bugzilla): Thanks for your contribution, seems to be a very cool improvement.
Can you confirm than the file textarea.properties is under Apache License 2 or upload a new version with the AL2 Header, please.
@Sebb, the component RSyntaxTextArea is distributed under a "modified BSD license." See: http://fifesoft.com/rsyntaxtextarea/RSyntaxTextArea.License.txt It's seems be compliant with the AL2, I think.
The only change (compare to BSD license) is :
For memory, the license compliant with AL2 (BSD is included) http://www.apache.org/legal/resolved.html#category-a
== The LICENSE and NOTICE files must modify to include the mention of RSyntaxTextArea's license. (I can do this)
Sebb (migrated from Bugzilla): (In reply to Milamber from comment 10)
@Sebb, the component RSyntaxTextArea is distributed under a "modified BSD license." See: http://fifesoft.com/rsyntaxtextarea/RSyntaxTextArea.License.txt It's seems be compliant with the AL2, I think.
The only change (compare to BSD license) is :
- Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
For memory, the license compliant with AL2 (BSD is included) http://www.apache.org/legal/resolved.html#category-a
That seems OK, but IANAL.
== The LICENSE and NOTICE files must modify to include the mention of RSyntaxTextArea's license. (I can do this)
Obviously the new license needs including in LICENSE (or as a separate file linked from it).
Are you sure that the NOTICE file needs updating? It's important not to add anything to NOTICE that is not strictly required. This may need asking on the legal-discuss list.
Marko (migrated from Bugzilla): I will add the header to the file. No problem. Do you require unit test too? Documentation updates?
Marko (migrated from Bugzilla): Created attachment textarea.properties: Adding mapping between languages and available syntaxes
@milamberspace (migrated from Bugzilla): (In reply to Sebb from comment 11)
(In reply to Milamber from comment 10)
> == > The LICENSE and NOTICE files must modify to include the mention of > RSyntaxTextArea's license. (I can do this)
Obviously the new license needs including in LICENSE (or as a separate file linked from it).
Are you sure that the NOTICE file needs updating?
I prefer, because in Mvnrepository site, the indicated license is LGPL, but perhaps it's a doc's bug. In official site, the license is clearly indicated.
http://mvnrepository.com/artifact/com.fifesoft/rsyntaxtextarea/2.0.7
It's important not to add anything to NOTICE that is not strictly required. This may need asking on the legal-discuss list.
@milamberspace (migrated from Bugzilla): (In reply to Marko from comment 12)
I will add the header to the file. No problem. Do you require unit test too? Documentation updates?
Test unit doesn't seems needed because this is only an visual improvement.
In the docs, some screenshots must be update, but I can do this too.
Now It's time for me to test your patch :-)
Sebb (migrated from Bugzilla): (In reply to Milamber from comment 14)
(In reply to Sebb from comment 11) > (In reply to Milamber from comment 10) >
> Are you sure that the NOTICE file needs updating?
I prefer, because in Mvnrepository site, the indicated license is LGPL, but perhaps it's a doc's bug. In official site, the license is clearly indicated.
That's not sufficient reason to add anything to the NOTICE file.
It looks like the code is built using Ant, not Maven, so maybe it was uploaded by a 3rd party who got the pom wrong.
But clearly we cannot depend on the jar from Maven Central.
http://mvnrepository.com/artifact/com.fifesoft/rsyntaxtextarea/2.0.7
> It's important not to add anything to NOTICE that is not strictly required. > This may need asking on the legal-discuss list.
@milamberspace (migrated from Bugzilla):
Thanks. Committed in last trunk. (some changes in your patch: de-tabulation: prefer spaces for indentation, alphabetical order in jars listing, remove unused imports, formatting code)
Docs screenshots to do (tomorrow)
URL: http://svn.apache.org/r1500124 Log: https://github.com/apache/jmeter/issues/3157 - Proposal to add RSyntaxTextArea for BeanShell, BSF, and JSR223 elements https://github.com/apache/jmeter/issues/3157
Added: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/textarea.properties (with props) Modified: jmeter/trunk/LICENSE jmeter/trunk/build.properties jmeter/trunk/build.xml jmeter/trunk/eclipse.classpath jmeter/trunk/res/maven/ApacheJMeter_parent.pom jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TextAreaEditor.java jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/WrapperEditor.java jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BeanShellSamplerGui.java jmeter/trunk/xdocs/changes.xml
@milamberspace (migrated from Bugzilla): URL: http://svn.apache.org/r1500390 Log: Get rsyntaxtextarea jar file from official binary zip https://github.com/apache/jmeter/issues/3157
Modified: jmeter/trunk/build.properties jmeter/trunk/build.xml
@milamberspace (migrated from Bugzilla): URL: http://svn.apache.org/r1500408 Log: Update docs with new screenshots https://github.com/apache/jmeter/issues/3157
Added: jmeter/trunk/docs/images/screenshots/beanshell_assertion.png (with props) jmeter/trunk/xdocs/images/screenshots/beanshell_assertion.png (with props) Modified: jmeter/trunk/docs/images/screenshots/beanshell_listener.png jmeter/trunk/docs/images/screenshots/beanshell_postprocessor.png jmeter/trunk/docs/images/screenshots/beanshell_preprocessor.png jmeter/trunk/docs/images/screenshots/beanshellsampler.png jmeter/trunk/docs/images/screenshots/bsf_assertion.png jmeter/trunk/docs/images/screenshots/bsf_listener.png jmeter/trunk/docs/images/screenshots/bsf_postprocessor.png jmeter/trunk/docs/images/screenshots/bsf_preprocessor.png jmeter/trunk/docs/images/screenshots/bsfsampler.png jmeter/trunk/docs/images/screenshots/bsh_assertion.png jmeter/trunk/docs/images/screenshots/jsr223-sampler.png jmeter/trunk/docs/images/screenshots/mongodb-script.png jmeter/trunk/docs/images/screenshots/timers/beanshell_timer.png jmeter/trunk/docs/images/screenshots/timers/bsf_timer.png jmeter/trunk/xdocs/images/screenshots/beanshell_listener.png jmeter/trunk/xdocs/images/screenshots/beanshell_postprocessor.png jmeter/trunk/xdocs/images/screenshots/beanshell_preprocessor.png jmeter/trunk/xdocs/images/screenshots/beanshellsampler.png jmeter/trunk/xdocs/images/screenshots/bsf_assertion.png jmeter/trunk/xdocs/images/screenshots/bsf_listener.png jmeter/trunk/xdocs/images/screenshots/bsf_postprocessor.png jmeter/trunk/xdocs/images/screenshots/bsf_preprocessor.png jmeter/trunk/xdocs/images/screenshots/bsfsampler.png jmeter/trunk/xdocs/images/screenshots/bsh_assertion.png jmeter/trunk/xdocs/images/screenshots/jsr223-sampler.png jmeter/trunk/xdocs/images/screenshots/mongodb-script.png jmeter/trunk/xdocs/images/screenshots/timers/beanshell_timer.png jmeter/trunk/xdocs/images/screenshots/timers/bsf_timer.png jmeter/trunk/xdocs/usermanual/component_reference.xml
@milamberspace (migrated from Bugzilla):
Seems everything is ok. I close it.
@pmouawad (migrated from Bugzilla): Thanks. Great feature. There is still a little one, in JDBC Sampler syntax highlight is done on Java not SQL.
Sebb (migrated from Bugzilla): URL: http://svn.apache.org/r1501306 Log: Add syntax color for scripts elements (BeanShell, BSF, and JSR223) with RSyntaxTextArea JDBC now uses SQL language format https://github.com/apache/jmeter/issues/3157
Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TextAreaEditor.java jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/JDBCTestElementBeanInfoSupport.java
@pmouawad (migrated from Bugzilla): Date: Thu Sep 26 06:44:29 2013 New Revision: 1526398
URL: http://svn.apache.org/r1526398 Log: https://github.com/apache/jmeter/issues/3157 - Add syntax color for scripts elements (BeanShell, BSF, and JSR223) and JDBC elements with RSyntaxTextArea Add missing configuration properties in jmeter.properties https://github.com/apache/jmeter/issues/3157
Modified: jmeter/trunk/bin/jmeter.properties
Date: Thu Sep 26 06:46:36 2013 New Revision: 1526400
URL: http://svn.apache.org/r1526400 Log: https://github.com/apache/jmeter/issues/3157 - Add syntax color for scripts elements (BeanShell, BSF, and JSR223) and JDBC elements with RSyntaxTextArea Add a way to disable undo feature in JSyntaxtTextArea, thanks Robert Futrell https://github.com/apache/jmeter/issues/3157
Modified: jmeter/trunk/bin/jmeter.properties jmeter/trunk/src/core/org/apache/jmeter/gui/util/JSyntaxTextArea.java
@pmouawad (migrated from Bugzilla): Date: Thu Sep 26 19:39:31 2013 New Revision: 1526656
URL: http://svn.apache.org/r1526656 Log: https://github.com/apache/jmeter/issues/3157 - Add syntax color for scripts elements (BeanShell, BSF, and JSR223) and JDBC elements with RSyntaxTextArea Fixed bad configuration https://github.com/apache/jmeter/issues/3157
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/JSyntaxTextArea.java
Marko (Bug 55202): Problem Statement: In my daily work i used BeanShell elements extensively and i find them to be very powerful giving the edge to jmeter over the other test frameworks. However, writing Java or Python code in JTextArea is really painful and error prone (and it can hurt the eyes too).
Proposal: I would like to propose to Jmeter Dev Community to include rsyntaxtextarea-2.0.7.jar library that can do syntax highlighting, code folding, undo typing, and redo typing. The library is published under BSD license and more details can be found here: http://fifesoft.com/rsyntaxtextarea/ The jar file needs to be compiled from source (It is very easy to do. Took me only 5 minutes to compile and add it to jmeter project in eclipse)
Implementation change Proposal: The following is the list of files that i changed to make Syntax Highlighting work: M src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BeanShellSamplerGui.java M src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java ? src/core/org/apache/jmeter/testbeans/gui/textarea.properties M src/core/org/apache/jmeter/testbeans/gui/TextAreaEditor.java M src/core/org/apache/jmeter/testbeans/gui/WrapperEditor.java M src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
I also had to add the following in build.properties rsyntaxtextarea.version = 2.0.7 rsyntaxtextarea.jar = rsyntaxtextarea-${rsyntaxtextarea.version}.jar rsyntaxtextarea.md5 = a4bdaabc88ff5464002a43c654bbf856
the following in .classpath <classpathentry kind="lib" path="lib/rsyntaxtextarea-2.0.7.jar"/>
And the following in build.xml <include name="${lib.dir}/${rsyntaxtextarea.jar}"/> </patternset> ... <pathelement location="${lib.dir}/${xstream.jar}"/> <pathelement location="${lib.dir}/${rsyntaxtextarea.jar}"/> ...
Implementation Details TextAreaEditor.java and textarea.properties: Instead of JTextArea, textUI uses RSyntaxTextArea. In order to have numbers for lines i also changes the scroller to RTextScrollPane. To support different languages from BSF and JSR elements new private field languageProperties is added. This field keeps mapping between different languages and syntaxes available in SyntaxConstants interface. Mappings are defined in textarea.properties file Also the TextAreaEditor implements PropertyChangeListener so that propertyChange events can be captured. In summary:
public class TextAreaEditor extends PropertyEditorSupport implements FocusListener, PropertyChangeListener {
... private final void init() {// called from ctor, so must not be overridable textUI = new RSyntaxTextArea(20,20); textUI.discardAllEdits(); textUI.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textUI.setCodeFoldingEnabled(true); textUI.setAntiAliasingEnabled(true); textUI.addFocusListener(this); textUI.setWrapStyleWord(true); textUI.setLineWrap(true); scroller = new RTextScrollPane(textUI); scroller.setFoldIndicatorEnabled(true); languageProperties = JMeterUtils.loadProperties("org/apache/jmeter/testbeans/gui/textarea.properties"); } ... @Override public void propertyChange(PropertyChangeEvent evt){ Object source = evt.getSource(); if (source instanceof ComboStringEditor && source !=null){ ComboStringEditor cse = (ComboStringEditor)source; String lang = cse.getAsText().toLowerCase(); if (languageProperties.containsKey(lang)){ textUI.setSyntaxEditingStyle(languageProperties.getProperty(lang)); } else{ textUI.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE); }
Implementation Details BeanShellAssertionGui.java and BeanShellSamplerGui.java This is not a java bean element so direct change was applied:
Implementation Details GenericTestBeanCustomizer.java Changes made here were necessary to enable Syntax Highlighting changes when different language is selected in ComboBox in BSF and JSR elements.
Implementation Details WrapperEditor.java In the GenericTestBeanCustomizer constructor i used e.addChangeListener(tae) to add listener to comboBox. Consequently, WrapperEditor class had to be modified, thus addChangeListener method is added that will do actual listener adding on the guiEditor
Conclusion I found Syntax Highlighting to significantly improve look and feel of Scripting elements in Jmeter. Especially revording was to find that RSyntaxTextArea has integrated undo/redo. It is available by simply right clicking in the TextArea. Nevertheless, all the changes proposed are cosmetic and up to you to decide if it would be worth changing in Jmeter.
Best Regards
Created attachment BeanShellAssertionGui.java.diff: Patch for BeanShellAssertionGui
BeanShellAssertionGui.java.diff
````diff Index: src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java =================================================================== --- src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java (revision 1496951) +++ src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java (working copy) @@ -32,6 +32,9 @@ import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.property.BooleanProperty; import org.apache.jmeter.util.JMeterUtils; +import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; +import org.fife.ui.rsyntaxtextarea.SyntaxConstants; +import org.fife.ui.rtextarea.RTextScrollPane; public class BeanShellAssertionGui extends AbstractAssertionGui { @@ -43,7 +46,7 @@ private JTextField parameters;// parameters to pass to script file (or script) - private JTextArea scriptField;// script area + private RSyntaxTextArea scriptField;// script area public BeanShellAssertionGui() { init(); @@ -139,8 +142,10 @@ } private JPanel createScriptPanel() { - scriptField = new JTextArea(); - scriptField.setRows(4); + scriptField = new RSyntaxTextArea(20,20); + scriptField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + scriptField.setCodeFoldingEnabled(true); + scriptField.setAntiAliasingEnabled(true); scriptField.setLineWrap(true); scriptField.setWrapStyleWord(true); @@ -149,7 +154,7 @@ JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.NORTH); - panel.add(new JScrollPane(scriptField), BorderLayout.CENTER); + panel.add(new RTextScrollPane(scriptField), BorderLayout.CENTER); JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$ explain.setLineWrap(true); ````OS: All