Bug61607 Add browse button in all beanshell elements to select beanshell script

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1811895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Antonio Gomes Rodrigues 2017-10-11 21:50:34 +00:00
parent 6c7f7a803b
commit 45a2905e9c
4 changed files with 19 additions and 26 deletions

View File

@ -33,6 +33,7 @@ import org.apache.jmeter.gui.util.JTextScrollPane;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.gui.util.FilePanelEntry;
public class BeanShellAssertionGui extends AbstractAssertionGui {
@ -40,7 +41,7 @@ public class BeanShellAssertionGui extends AbstractAssertionGui {
private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution
private JTextField filename;// script file name (if present)
private final FilePanelEntry filename = new FilePanelEntry(JMeterUtils.getResString("bsh_script_file"),".bsh"); // script file name (if present)
private JTextField parameters;// parameters to pass to script file (or script)
@ -54,7 +55,7 @@ public class BeanShellAssertionGui extends AbstractAssertionGui {
public void configure(TestElement element) {
scriptField.setInitialText(element.getPropertyAsString(BeanShellAssertion.SCRIPT));
scriptField.setCaretPosition(0);
filename.setText(element.getPropertyAsString(BeanShellAssertion.FILENAME));
filename.setFilename(element.getPropertyAsString(BeanShellAssertion.FILENAME));
parameters.setText(element.getPropertyAsString(BeanShellAssertion.PARAMETERS));
resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellAssertion.RESET_INTERPRETER));
super.configure(element);
@ -77,7 +78,7 @@ public class BeanShellAssertionGui extends AbstractAssertionGui {
te.clear();
super.configureTestElement(te);
te.setProperty(BeanShellAssertion.SCRIPT, scriptField.getText());
te.setProperty(BeanShellAssertion.FILENAME, filename.getText());
te.setProperty(BeanShellAssertion.FILENAME, filename.getFilename());
te.setProperty(BeanShellAssertion.PARAMETERS, parameters.getText());
te.setProperty(new BooleanProperty(BeanShellAssertion.RESET_INTERPRETER, resetInterpreter.isSelected()));
}
@ -87,17 +88,12 @@ public class BeanShellAssertionGui extends AbstractAssertionGui {
return "bsh_assertion_title"; // $NON-NLS-1$
}
private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
private JPanel createFilenamePanel()
{
JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); //$NON-NLS-1$
filename = new JTextField(10);
filename.setName(BeanShellAssertion.FILENAME);
label.setLabelFor(filename);
JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
filenamePanel.add(label, BorderLayout.WEST);
JPanel filenamePanel = new JPanel(new BorderLayout());
filenamePanel.add(filename, BorderLayout.CENTER);
return filenamePanel;
}
@ -162,7 +158,7 @@ public class BeanShellAssertionGui extends AbstractAssertionGui {
@Override
public void clearGui() {
super.clearGui();
filename.setText(""); // $NON-NLS-1$
filename.setFilename(""); // $NON-NLS-1$
parameters.setText(""); // $NON-NLS-1$
scriptField.setInitialText(""); // $NON-NLS-1$
resetInterpreter.setSelected(false);

View File

@ -23,6 +23,7 @@ import java.beans.PropertyDescriptor;
import org.apache.jmeter.testbeans.BeanInfoSupport;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testbeans.gui.TextAreaEditor;
import org.apache.jmeter.testbeans.gui.FileEditor;
/**
* Parent class to handle common GUI design
@ -56,7 +57,7 @@ public abstract class BeanShellBeanInfoSupport extends BeanInfoSupport {
p = property("script");
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, "");
p.setPropertyEditorClass(TextAreaEditor.class);
p.setPropertyEditorClass(FileEditor.class);
createPropertyGroup("scripting", new String[] { "script" });
}

View File

@ -34,6 +34,7 @@ import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.gui.util.JSyntaxTextArea;
import org.apache.jmeter.gui.util.JTextScrollPane;
import org.apache.jmeter.gui.util.FilePanelEntry;
public class BeanShellSamplerGui extends AbstractSamplerGui {
@ -41,7 +42,7 @@ public class BeanShellSamplerGui extends AbstractSamplerGui {
private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution
private JTextField filename;// script file name (if present)
private final FilePanelEntry filename = new FilePanelEntry(JMeterUtils.getResString("bsh_script_file"),".bsh"); // script file name (if present)
private JTextField parameters;// parameters to pass to script file (or script)
@ -55,7 +56,7 @@ public class BeanShellSamplerGui extends AbstractSamplerGui {
public void configure(TestElement element) {
scriptField.setInitialText(element.getPropertyAsString(BeanShellSampler.SCRIPT));
scriptField.setCaretPosition(0);
filename.setText(element.getPropertyAsString(BeanShellSampler.FILENAME));
filename.setFilename(element.getPropertyAsString(BeanShellSampler.FILENAME));
parameters.setText(element.getPropertyAsString(BeanShellSampler.PARAMETERS));
resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellSampler.RESET_INTERPRETER));
super.configure(element);
@ -78,7 +79,7 @@ public class BeanShellSamplerGui extends AbstractSamplerGui {
te.clear();
super.configureTestElement(te);
te.setProperty(BeanShellSampler.SCRIPT, scriptField.getText());
te.setProperty(BeanShellSampler.FILENAME, filename.getText());
te.setProperty(BeanShellSampler.FILENAME, filename.getFilename());
te.setProperty(BeanShellSampler.PARAMETERS, parameters.getText());
te.setProperty(new BooleanProperty(BeanShellSampler.RESET_INTERPRETER, resetInterpreter.isSelected()));
}
@ -90,7 +91,7 @@ public class BeanShellSamplerGui extends AbstractSamplerGui {
public void clearGui() {
super.clearGui();
filename.setText(""); //$NON-NLS-1$
filename.setFilename(""); //$NON-NLS-1$
parameters.setText(""); //$NON-NLS-1$
scriptField.setInitialText(""); //$NON-NLS-1$
resetInterpreter.setSelected(false);
@ -101,17 +102,11 @@ public class BeanShellSamplerGui extends AbstractSamplerGui {
return "bsh_sampler_title"; // $NON-NLS-1$
}
private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
private JPanel createFilenamePanel()
{
JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); // $NON-NLS-1$
filename = new JTextField(10);
filename.setName(BeanShellSampler.FILENAME);
label.setLabelFor(filename);
JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
filenamePanel.add(label, BorderLayout.WEST);
JPanel filenamePanel = new JPanel(new BorderLayout());
filenamePanel.add(filename, BorderLayout.CENTER);
return filenamePanel;
}

View File

@ -119,6 +119,7 @@ Summary
<ul>
<li><bug>61549</bug>Thread Group : Remove start and end date</li>
<li><bug>61529</bug>Migration to Java 9. Partly contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
<li><bug>61607</bug>Add browse button in all beanshell elements to select beanshell script</li>
</ul>
<ch_section>Non-functional changes</ch_section>