1
2
3
4
5
6
7
8
9
10
11
12 package com.eviware.soapui.support.xml;
13
14 import org.syntax.jedit.JEditTextArea;
15
16 import com.eviware.soapui.support.actions.FindAndReplaceable;
17
18 public class ProxyFindAndReplacable implements FindAndReplaceable
19 {
20 protected FindAndReplaceable proxytarget;
21 protected boolean isReplaceAll = false;
22 protected StringBuilder sbtartget;
23 protected String oldValue;
24 protected String newValue;
25 protected int start;
26 protected int end;
27
28 public ProxyFindAndReplacable( FindAndReplaceable proxytarget )
29 {
30 this.proxytarget = proxytarget;
31
32 }
33
34 public void setSBTarget()
35 {
36 this.sbtartget = new StringBuilder();
37 this.sbtartget.append( proxytarget.getText() );
38 }
39
40 public FindAndReplaceable getProxytarget()
41 {
42 return proxytarget;
43 }
44
45 public int getCaretPosition()
46 {
47 return proxytarget.getCaretPosition();
48 }
49
50 public String getSelectedText()
51 {
52 return proxytarget.getSelectedText();
53 }
54
55 public int getSelectionEnd()
56 {
57 return proxytarget.getSelectionEnd();
58 }
59
60 public int getSelectionStart()
61 {
62 return proxytarget.getSelectionStart();
63 }
64
65 public String getText()
66 {
67 if( isReplaceAll )
68 {
69 return sbtartget.toString();
70 }
71 else
72 return proxytarget.getText();
73
74 }
75
76 public String getDialogText()
77 {
78 return proxytarget.getText();
79 }
80
81 public boolean isEditable()
82 {
83 return proxytarget.isEditable();
84 }
85
86 public void select( int start, int end )
87 {
88 if( isReplaceAll )
89 {
90 this.start = start;
91 this.end = end;
92 }
93 else
94 proxytarget.select( start, end );
95
96 }
97
98 public void setSelectedText( String txt )
99 {
100 if( isReplaceAll )
101 {
102 sbtartget.replace( this.start, this.end, newValue );
103 }
104 else
105 proxytarget.setSelectedText( txt );
106
107 }
108
109 public boolean isReplaceAll()
110 {
111 return isReplaceAll;
112 }
113
114 public void setReplaceAll( boolean isReplaceAll )
115 {
116 if( proxytarget instanceof JEditTextArea )
117 {
118 this.isReplaceAll = isReplaceAll;
119 }
120 else
121 {
122 this.isReplaceAll = false;
123 }
124 }
125
126 public String getOldValue()
127 {
128 return oldValue;
129 }
130
131 public void setOldValue( String oldValue )
132 {
133 this.oldValue = oldValue;
134 }
135
136 public String getNewValue()
137 {
138 return newValue;
139 }
140
141 public void setNewValue( String newValue )
142 {
143 this.newValue = newValue;
144 }
145
146 public void flushSBText()
147 {
148 if( proxytarget instanceof JEditTextArea )
149 {
150 ( ( JEditTextArea )proxytarget ).setText( sbtartget.toString() );
151 }
152
153 }
154
155 public void setCarretPosition( boolean forward )
156 {
157 if( proxytarget instanceof JEditTextArea )
158 {
159 ( ( JEditTextArea )proxytarget ).setCaretPosition( forward ? getEnd() : getStart() );
160 }
161 }
162
163 public int getStart()
164 {
165 return start;
166 }
167
168 public int getEnd()
169 {
170 return end;
171 }
172 }