View | Details | Raw Unified | Return to bug 55202
Collapse All | Expand All

(-)src/core/org/apache/jmeter/testbeans/gui/WrapperEditor.java (+4 lines)
Lines 445-448 Link Here
445
            guiEditor.setAsText(lastValidValue);
445
            guiEditor.setAsText(lastValidValue);
446
        }
446
        }
447
    }
447
    }
448
    
449
    public void addChangeListener(PropertyChangeListener listener){
450
    	guiEditor.addPropertyChangeListener(listener);
451
    }
448
}
452
}
(-)src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java (-5 / +22 lines)
Lines 21-26 Link Here
21
import java.awt.GridBagLayout;
21
import java.awt.GridBagLayout;
22
import java.awt.Insets;
22
import java.awt.Insets;
23
import java.beans.BeanInfo;
23
import java.beans.BeanInfo;
24
import java.beans.PropertyChangeListener;
24
import java.beans.PropertyDescriptor;
25
import java.beans.PropertyDescriptor;
25
import java.beans.PropertyEditor;
26
import java.beans.PropertyEditor;
26
import java.beans.PropertyEditorManager;
27
import java.beans.PropertyEditorManager;
Lines 203-208 Link Here
203
204
204
        // Obtain the propertyEditors:
205
        // Obtain the propertyEditors:
205
        editors = new PropertyEditor[descriptors.length];
206
        editors = new PropertyEditor[descriptors.length];
207
        int scriptLanguageIndex=0;
208
        int textAreaEditorIndex=0;
206
        for (int i = 0; i < descriptors.length; i++) { // Index is also used for accessing editors array
209
        for (int i = 0; i < descriptors.length; i++) { // Index is also used for accessing editors array
207
            PropertyDescriptor descriptor = descriptors[i];
210
            PropertyDescriptor descriptor = descriptors[i];
208
            String name = descriptor.getName();
211
            String name = descriptor.getName();
Lines 218-224 Link Here
218
            PropertyEditor propertyEditor;
221
            PropertyEditor propertyEditor;
219
            Object guiType = descriptor.getValue(GUITYPE);
222
            Object guiType = descriptor.getValue(GUITYPE);
220
            if (guiType instanceof TypeEditor) {
223
            if (guiType instanceof TypeEditor) {
221
                propertyEditor = ((TypeEditor) guiType).getInstance(descriptor);            
224
                propertyEditor = ((TypeEditor) guiType).getInstance(descriptor); 
222
            } else {
225
            } else {
223
                Class<?> editorClass = descriptor.getPropertyEditorClass();
226
                Class<?> editorClass = descriptor.getPropertyEditorClass();
224
                if (log.isDebugEnabled()) {
227
                if (log.isDebugEnabled()) {
Lines 267-272 Link Here
267
            {
270
            {
268
                ((TestBeanPropertyEditor)propertyEditor).setDescriptor(descriptor);
271
                ((TestBeanPropertyEditor)propertyEditor).setDescriptor(descriptor);
269
            }
272
            }
273
            
274
            if (propertyEditor instanceof TextAreaEditor)
275
            {
276
            	textAreaEditorIndex = i;
277
            }
270
            if (propertyEditor.getCustomEditor() instanceof JScrollPane) {
278
            if (propertyEditor.getCustomEditor() instanceof JScrollPane) {
271
                scrollerCount++;
279
                scrollerCount++;
272
            }
280
            }
Lines 275-283 Link Here
275
283
276
            // Initialize the editor with the provided default value or null:
284
            // Initialize the editor with the provided default value or null:
277
            setEditorValue(i, descriptor.getValue(DEFAULT));
285
            setEditorValue(i, descriptor.getValue(DEFAULT));
286
            
287
            if (name.equals("scriptLanguage")){
288
            	scriptLanguageIndex=i;
289
            }
278
290
279
        }
291
        }
280
292
        // In case of BSF and JSR elements i want to add textAreaEditor as a listener to scriptLanguage ComboBox.
293
        String beanName = this.beanInfo.getBeanDescriptor().getName();
294
        if (beanName.startsWith("BSF") || beanName.startsWith("JSR223")){
295
        		WrapperEditor we = (WrapperEditor) editors[scriptLanguageIndex];
296
        		TextAreaEditor tae = (TextAreaEditor) editors[textAreaEditorIndex];
297
        		we.addChangeListener(tae);
298
    	}
281
        // Obtain message formats:
299
        // Obtain message formats:
282
        propertyFieldLabelMessage = new MessageFormat(JMeterUtils.getResString("property_as_field_label")); //$NON-NLS-1$
300
        propertyFieldLabelMessage = new MessageFormat(JMeterUtils.getResString("property_as_field_label")); //$NON-NLS-1$
283
        propertyToolTipMessage = new MessageFormat(JMeterUtils.getResString("property_tool_tip")); //$NON-NLS-1$
301
        propertyToolTipMessage = new MessageFormat(JMeterUtils.getResString("property_tool_tip")); //$NON-NLS-1$
Lines 350-356 Link Here
350
                tags[j++] = additionalTag;
368
                tags[j++] = additionalTag;
351
            }
369
            }
352
        }
370
        }
353
371
        
354
        boolean notNull = notNull(descriptor);
372
        boolean notNull = notNull(descriptor);
355
        boolean notExpression = notExpression(descriptor);
373
        boolean notExpression = notExpression(descriptor);
356
        boolean notOther = notOther(descriptor);
374
        boolean notOther = notOther(descriptor);
Lines 363-369 Link Here
363
            e.setNoUndefined(notNull);
381
            e.setNoUndefined(notNull);
364
            e.setNoEdit(notExpression && notOther);
382
            e.setNoEdit(notExpression && notOther);
365
            e.setTags(tags);
383
            e.setTags(tags);
366
384
            
367
            guiEditor = e;
385
            guiEditor = e;
368
        }
386
        }
369
387
Lines 372-378 Link Here
372
                !notExpression, // acceptsExpressions
390
                !notExpression, // acceptsExpressions
373
                !notOther, // acceptsOther
391
                !notOther, // acceptsOther
374
                descriptor.getValue(DEFAULT));
392
                descriptor.getValue(DEFAULT));
375
376
        return wrapper;
393
        return wrapper;
377
    }
394
    }
378
395
(-)src/core/org/apache/jmeter/testbeans/gui/TextAreaEditor.java (-10 / +40 lines)
Lines 24-40 Link Here
24
import java.awt.Component;
24
import java.awt.Component;
25
import java.awt.event.FocusEvent;
25
import java.awt.event.FocusEvent;
26
import java.awt.event.FocusListener;
26
import java.awt.event.FocusListener;
27
import java.beans.PropertyChangeEvent;
28
import java.beans.PropertyChangeListener;
27
import java.beans.PropertyEditorSupport;
29
import java.beans.PropertyEditorSupport;
28
30
29
import javax.swing.JScrollPane;
31
30
import javax.swing.JTextArea;
32
import org.apache.jmeter.util.JMeterUtils;
31
import javax.swing.ScrollPaneConstants;
33
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
34
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
35
import org.fife.ui.rtextarea.RTextScrollPane;
32
36
33
public class TextAreaEditor extends PropertyEditorSupport implements FocusListener {
37
import java.util.Locale;
38
import java.util.Properties;;
34
39
35
    private JTextArea textUI;
40
public class TextAreaEditor extends PropertyEditorSupport implements FocusListener, PropertyChangeListener {
36
41
37
    private JScrollPane scroller;
42
    private RSyntaxTextArea textUI;
43
44
    private RTextScrollPane scroller;
45
    
46
    private Properties languageProperties;
38
47
39
    /** {@inheritDoc} */
48
    /** {@inheritDoc} */
40
    @Override
49
    @Override
Lines 45-59 Link Here
45
    @Override
54
    @Override
46
    public void focusLost(FocusEvent e) {
55
    public void focusLost(FocusEvent e) {
47
        firePropertyChange();
56
        firePropertyChange();
48
    }
57
    } 
49
58
50
    private final void init() {// called from ctor, so must not be overridable
59
    private final void init() {// called from ctor, so must not be overridable
51
        textUI = new JTextArea();
60
        textUI = new RSyntaxTextArea(20,20);
61
        textUI.discardAllEdits();
62
        textUI.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
63
		textUI.setCodeFoldingEnabled(true);
64
		textUI.setAntiAliasingEnabled(true);
52
        textUI.addFocusListener(this);
65
        textUI.addFocusListener(this);
53
        textUI.setWrapStyleWord(true);
66
        textUI.setWrapStyleWord(true);
54
        textUI.setLineWrap(true);
67
        textUI.setLineWrap(true);
55
        scroller = new JScrollPane(textUI, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
68
		scroller = new RTextScrollPane(textUI);
56
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
69
		scroller.setFoldIndicatorEnabled(true);
70
		languageProperties = JMeterUtils.loadProperties("org/apache/jmeter/testbeans/gui/textarea.properties");
57
    }
71
    }
58
72
59
    /**
73
    /**
Lines 112-115 Link Here
112
    public boolean supportsCustomEditor() {
126
    public boolean supportsCustomEditor() {
113
        return true;
127
        return true;
114
    }
128
    }
129
    
130
    @Override
131
	public void propertyChange(PropertyChangeEvent evt){
132
    	Object source = evt.getSource();
133
    	if (source instanceof ComboStringEditor && source !=null){
134
    		ComboStringEditor cse = (ComboStringEditor)source;
135
    		String lang = cse.getAsText().toLowerCase();
136
    		if (languageProperties.containsKey(lang)){
137
    			textUI.setSyntaxEditingStyle(languageProperties.getProperty(lang));
138
    		}
139
    		else{
140
    			textUI.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
141
    		}
142
    		
143
    	}
144
    }
115
}
145
}
(-)src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java (-4 / +9 lines)
Lines 32-37 Link Here
32
import org.apache.jmeter.testelement.TestElement;
32
import org.apache.jmeter.testelement.TestElement;
33
import org.apache.jmeter.testelement.property.BooleanProperty;
33
import org.apache.jmeter.testelement.property.BooleanProperty;
34
import org.apache.jmeter.util.JMeterUtils;
34
import org.apache.jmeter.util.JMeterUtils;
35
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
36
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
37
import org.fife.ui.rtextarea.RTextScrollPane;
35
38
36
public class BeanShellAssertionGui extends AbstractAssertionGui {
39
public class BeanShellAssertionGui extends AbstractAssertionGui {
37
40
Lines 43-49 Link Here
43
46
44
    private JTextField parameters;// parameters to pass to script file (or script)
47
    private JTextField parameters;// parameters to pass to script file (or script)
45
48
46
    private JTextArea scriptField;// script area
49
    private RSyntaxTextArea scriptField;// script area
47
50
48
    public BeanShellAssertionGui() {
51
    public BeanShellAssertionGui() {
49
        init();
52
        init();
Lines 139-146 Link Here
139
    }
142
    }
140
143
141
    private JPanel createScriptPanel() {
144
    private JPanel createScriptPanel() {
142
        scriptField = new JTextArea();
145
        scriptField = new RSyntaxTextArea(20,20);
143
        scriptField.setRows(4);
146
        scriptField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
147
        scriptField.setCodeFoldingEnabled(true);
148
		scriptField.setAntiAliasingEnabled(true);
144
        scriptField.setLineWrap(true);
149
        scriptField.setLineWrap(true);
145
        scriptField.setWrapStyleWord(true);
150
        scriptField.setWrapStyleWord(true);
146
151
Lines 149-155 Link Here
149
154
150
        JPanel panel = new JPanel(new BorderLayout());
155
        JPanel panel = new JPanel(new BorderLayout());
151
        panel.add(label, BorderLayout.NORTH);
156
        panel.add(label, BorderLayout.NORTH);
152
        panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
157
        panel.add(new RTextScrollPane(scriptField), BorderLayout.CENTER);
153
158
154
        JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$
159
        JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$
155
        explain.setLineWrap(true);
160
        explain.setLineWrap(true);
(-)src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BeanShellSamplerGui.java (-4 / +8 lines)
Lines 33-38 Link Here
33
import org.apache.jmeter.testelement.TestElement;
33
import org.apache.jmeter.testelement.TestElement;
34
import org.apache.jmeter.testelement.property.BooleanProperty;
34
import org.apache.jmeter.testelement.property.BooleanProperty;
35
import org.apache.jmeter.util.JMeterUtils;
35
import org.apache.jmeter.util.JMeterUtils;
36
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
37
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
38
import org.fife.ui.rtextarea.RTextScrollPane;
36
39
37
public class BeanShellSamplerGui extends AbstractSamplerGui {
40
public class BeanShellSamplerGui extends AbstractSamplerGui {
38
41
Lines 44-50 Link Here
44
47
45
    private JTextField parameters;// parameters to pass to script file (or script)
48
    private JTextField parameters;// parameters to pass to script file (or script)
46
49
47
    private JTextArea scriptField;// script area
50
    private RSyntaxTextArea scriptField;// script area
48
51
49
    public BeanShellSamplerGui() {
52
    public BeanShellSamplerGui() {
50
        init();
53
        init();
Lines 153-160 Link Here
153
    }
156
    }
154
157
155
    private JPanel createScriptPanel() {
158
    private JPanel createScriptPanel() {
156
        scriptField = new JTextArea();
159
        scriptField = new RSyntaxTextArea(20,20);
157
        scriptField.setRows(4);
160
        scriptField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
161
        scriptField.setCodeFoldingEnabled(true);
158
        scriptField.setLineWrap(true);
162
        scriptField.setLineWrap(true);
159
        scriptField.setWrapStyleWord(true);
163
        scriptField.setWrapStyleWord(true);
160
164
Lines 163-169 Link Here
163
167
164
        JPanel panel = new JPanel(new BorderLayout());
168
        JPanel panel = new JPanel(new BorderLayout());
165
        panel.add(label, BorderLayout.NORTH);
169
        panel.add(label, BorderLayout.NORTH);
166
        panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
170
        panel.add(new RTextScrollPane(scriptField), BorderLayout.CENTER);
167
171
168
        JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_script_variables")); //$NON-NLS-1$
172
        JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_script_variables")); //$NON-NLS-1$
169
        explain.setLineWrap(true);
173
        explain.setLineWrap(true);

Return to bug 55202