Lines 24-41
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; |
|
|
30 |
import javax.swing.JTextArea; |
31 |
import javax.swing.ScrollPaneConstants; |
32 |
|
31 |
|
33 |
public class TextAreaEditor extends PropertyEditorSupport implements FocusListener { |
32 |
import org.apache.jmeter.util.JMeterUtils; |
|
|
33 |
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; |
34 |
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; |
35 |
import org.fife.ui.rtextarea.RTextScrollPane; |
34 |
|
36 |
|
35 |
private JTextArea textUI; |
37 |
import java.util.Locale; |
|
|
38 |
import java.util.Properties;; |
36 |
|
39 |
|
37 |
private JScrollPane scroller; |
40 |
public class TextAreaEditor extends PropertyEditorSupport implements FocusListener, PropertyChangeListener { |
38 |
|
41 |
|
|
|
42 |
private RSyntaxTextArea textUI; |
43 |
|
44 |
private RTextScrollPane scroller; |
45 |
|
46 |
private Properties languageProperties; |
47 |
|
39 |
/** {@inheritDoc} */ |
48 |
/** {@inheritDoc} */ |
40 |
@Override |
49 |
@Override |
41 |
public void focusGained(FocusEvent e) { |
50 |
public void focusGained(FocusEvent e) { |
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 |
} |