1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support;
14
15 import com.eviware.soapui.impl.wsdl.panels.teststeps.support.GroovyEditor;
16 import com.eviware.soapui.impl.wsdl.panels.teststeps.support.GroovyEditorModel;
17 import com.eviware.soapui.support.components.JUndoableTextArea;
18
19 import javax.swing.*;
20 import javax.swing.text.Document;
21
22 public class DefaultEditorFactory implements EditorFactory
23 {
24 public JComponent buildXPathEditor( EditorModel editorModel )
25 {
26 JUndoableTextArea textArea = new JUndoableTextArea( );
27 textArea.setText( editorModel.getEditorText() );
28 textArea.getDocument().addDocumentListener( new EditorModelDocumentListener( editorModel ) );
29 return new JScrollPane( textArea );
30 }
31
32 public JComponent buildXmlEditor( EditorModel editorModel )
33 {
34 JUndoableTextArea textArea = new JUndoableTextArea( );
35 textArea.setText( editorModel.getEditorText() );
36 textArea.getDocument().addDocumentListener( new EditorModelDocumentListener( editorModel ) );
37 return new JScrollPane( textArea );
38 }
39
40 public JComponent buildGroovyEditor( GroovyEditorModel editorModel )
41 {
42 return new GroovyEditor( editorModel );
43 }
44
45 private static class EditorModelDocumentListener extends DocumentListenerAdapter
46 {
47 private EditorModel editorModel;
48
49 public EditorModelDocumentListener( EditorModel editorModel )
50 {
51 this.editorModel = editorModel;
52 }
53
54 public void update( Document document )
55 {
56 editorModel.setEditorText( getText( document ));
57 }
58 }
59 }