Bug 42947 - GUI editor for Beanshell doesn't always pick up changes, code is lost
GUI editor for Beanshell doesn't always pick up changes, code is lost
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.3
Macintosh Mac OS X 10.4
: P2 major (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-07-20 14:16 UTC by David Martinez
Modified: 2007-08-31 02:37 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Martinez 2007-07-20 14:16:58 UTC
Most of the time, copying code and pasting it into the beanshell script areas does not work. Pasting 
content then using control-S to save makes the content get cleared immediately. Pasting content then 
running the script uses the old content. Making small changes to the content then saving also keeps 
the old content.

It's annoying because It's much easier to use an editor without proper syntax highlighting, completion, 
etcetera (especially since most of JMeter's beanshell nodes do not support just making reference to a 
file, but that's a request for another day).
This makes it impossible to use any editor other than the jmeter included editor (and even then small 
edits are usually lost). I'm much more productive in (insert actual programmer's editor here).

To reproduce, try this:
1. Add a beanshell postprocessor
2. Type "See me dissapear!" in the Script: Area
3. WIthout moving focus away, press Control-S to save.

Expected: The text does not dissapear.
Actual: Text dissapears

As a workaround you can move away to another node then come back. But THIS DOES NOT ALWAYS 
WORK on longer scripts for some reason.
Comment 1 Scott Marlowe 2007-08-15 14:09:38 UTC
Note that I get the exact same goofy and unpredictable behaviour when editing a
regular expression dialog in a regex postprocessor.  The text is in the box, but
when I hit run, jmeter doesn't actually run, and when I click out of the dialog
and back in, my old regex is there staring back at me, laughing.

Using Jmeter 2.3RC3
Comment 2 Sebb 2007-08-18 10:08:45 UTC
It appears that using Control+S to save a test plan has always been broken for 
GUI items that use TestBeanGUI. 

For example, using CSV Dataset: enter a value in the filename field, and save 
the plan using control+S. Exit and reload the plan - the value has not been 
saved.

The difference in 2.3RC3 is that this behaviour has become obvious, as the 
saved version is now reflected in the GUI.

The same problem applies to other short-cut keys such as Control+R.

Normally the value in the GUI field is saved whenever there is a focus-lost 
event however this does not happen for short-cut keys.
Comment 3 Alf Hogemark 2007-08-29 11:40:35 UTC
(In reply to comment #2)
> It appears that using Control+S to save a test plan has always been broken for 
> GUI items that use TestBeanGUI. 
> 
> For example, using CSV Dataset: enter a value in the filename field, and save 
> the plan using control+S. Exit and reload the plan - the value has not been 
> saved.
> 
> The difference in 2.3RC3 is that this behaviour has become obvious, as the 
> saved version is now reflected in the GUI.
> 
> The same problem applies to other short-cut keys such as Control+R.
> 
> Normally the value in the GUI field is saved whenever there is a focus-lost 
> event however this does not happen for short-cut keys.

The problem seems to be that the "propertyChange" event for the PropertyEditor
in the TestBeanGui is not fired until after the changes have been stored. If you
change the comment of the BeanShell Postprocessor and hit Ctrl+S, that change is
saved.

The problem is that the PropertyChange events have not been processed before the    
TestBeanGui.modifyTestElement method is moving changes from gui to model.
Therefore, the changes are not saved.

I do not see an easy fix at the moment, will have to investigate more on how the
 java PropertyEditor works in conjunction with keyboard shortcuts.
Comment 4 Alf Hogemark 2007-08-29 12:00:01 UTC
(In reply to comment #1)
> Note that I get the exact same goofy and unpredictable behaviour when editing a
> regular expression dialog in a regex postprocessor.  The text is in the box, but
> when I hit run, jmeter doesn't actually run, and when I click out of the dialog
> and back in, my old regex is there staring back at me, laughing.
> 
> Using Jmeter 2.3RC3

I think you are in fact observing bug 43122, which I have just made a patch for. 
Comment 5 Sebb 2007-08-30 16:58:43 UTC
Added code to TestBeanGUI.modifyTestElement() to copy the values of the fields 
from the GUI.

Applied to SVN in r571348.
Comment 6 Sebb 2007-08-31 02:37:52 UTC
There was a slight problem with the previous fix - only one change was saved, 
as there was a return in the loop.

This has been corrected in r571407.

BTW, I looked into propertyChange events - the event was not being fired for 
short-cut keys. This appears to be a feature of Swing/AWT.

The propertyChange code became redundant; now both TestBeanGUI and other GUI 
classes save the field contents in modifyTestElement().