Mercurial > 510Connectbot
comparison src/org/tn5250j/framework/tn5250/ScreenField.java @ 112:77ac18bc1b2f
cleanup java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 18 Jun 2014 13:03:01 -0700 |
parents | 294435151b0c |
children | 29076621bab0 |
comparison
equal
deleted
inserted
replaced
111:6a0ad4d384ea | 112:77ac18bc1b2f |
---|---|
25 */ | 25 */ |
26 package org.tn5250j.framework.tn5250; | 26 package org.tn5250j.framework.tn5250; |
27 | 27 |
28 public class ScreenField { | 28 public class ScreenField { |
29 | 29 |
30 protected ScreenField(Screen5250 s) { | 30 protected ScreenField(Screen5250 s) { |
31 | 31 this.s = s; |
32 this.s = s; | 32 } |
33 | 33 |
34 } | 34 protected ScreenField setField(int attr, int len, int ffw1, int ffw2, |
35 | 35 int fcw1, int fcw2) { |
36 protected ScreenField setField(int attr, int len, int ffw1, int ffw2, | 36 return setField(attr, |
37 int fcw1, int fcw2) { | 37 s.getCurrentRow() - 1, |
38 | 38 s.getCurrentCol() - 1, |
39 return setField(attr, | 39 len, |
40 s.getCurrentRow() - 1, | 40 ffw1, |
41 s.getCurrentCol() - 1, | 41 ffw2, |
42 len, | 42 fcw1, |
43 ffw1, | 43 fcw2); |
44 ffw2, | 44 } |
45 fcw1, | 45 |
46 fcw2); | 46 protected ScreenField setField(int attr, int row, int col, int len, int ffw1, int ffw2, |
47 } | 47 int fcw1, int fcw2) { |
48 | |
49 protected ScreenField setField(int attr, int row, int col, int len, int ffw1, int ffw2, | |
50 int fcw1, int fcw2) { | |
51 | |
52 // startRow = row; | 48 // startRow = row; |
53 // startCol = col; | 49 // startCol = col; |
54 cursorProg = 0; | 50 cursorProg = 0; |
55 fieldId = 0; | 51 fieldId = 0; |
56 length = len; | 52 length = len; |
57 startPos = (row * s.getColumns()) + col; | 53 startPos = (row * s.getColumns()) + col; |
58 endPos = startPos + length - 1; | 54 endPos = startPos + length - 1; |
59 this.attr = attr; | 55 this.attr = attr; |
60 setFFWs(ffw1,ffw2); | 56 setFFWs(ffw1, ffw2); |
61 setFCWs(fcw1,fcw2); | 57 setFCWs(fcw1, fcw2); |
62 | 58 next = null; |
63 next = null; | 59 prev = null; |
64 prev = null; | 60 return this; |
65 | 61 } |
66 return this; | 62 |
67 | 63 public int getAttr() { |
68 } | 64 return attr; |
69 | 65 } |
70 public int getAttr(){ | 66 |
71 return attr; | 67 public int getHighlightedAttr() { |
72 } | 68 return (fcw2 & 0x0f) | 0x20; |
73 | 69 } |
74 public int getHighlightedAttr(){ | 70 |
75 return (fcw2 & 0x0f) | 0x20; | 71 public int getLength() { |
76 } | 72 return length; |
77 | 73 } |
78 public int getLength(){ | 74 |
79 return length; | 75 protected boolean setFFWs(int ffw1, int ffw2) { |
80 } | 76 this.ffw1 = ffw1; |
81 | 77 this.ffw2 = ffw2; |
82 protected boolean setFFWs(int ffw1, int ffw2) { | 78 int adj = getAdjustment(); |
83 | 79 |
84 this.ffw1 = ffw1; | 80 if (adj > 0) { |
85 this.ffw2 = ffw2; | 81 checkCanSend = true; |
86 | 82 |
87 int adj = getAdjustment(); | 83 switch (adj) { |
88 | 84 case 5: |
89 if (adj > 0) { | 85 case 6: |
90 checkCanSend = true; | 86 rightAdjd = false; |
91 | 87 break; |
92 switch (adj) { | 88 |
93 | 89 case 7: |
94 case 5: | 90 manditoried = false; |
95 case 6: | 91 break; |
96 rightAdjd = false; | 92 } |
97 break; | 93 } |
98 case 7: | 94 |
99 manditoried = false; | 95 mdt = (ffw1 & 0x8) == 0x8; |
100 break; | |
101 } | |
102 | |
103 } | |
104 mdt = (ffw1 & 0x8 ) == 0x8; | |
105 // if (mdt) | 96 // if (mdt) |
106 // s.masterMDT = true; | 97 // s.masterMDT = true; |
107 return mdt; | 98 return mdt; |
108 } | 99 } |
109 | 100 |
110 | 101 |
111 public int getFFW1(){ | 102 public int getFFW1() { |
112 return ffw1; | 103 return ffw1; |
113 } | 104 } |
114 public int getFFW2(){ | 105 public int getFFW2() { |
115 return ffw2; | 106 return ffw2; |
116 } | 107 } |
117 | 108 |
118 protected void setFCWs(int fcw1, int fcw2) { | 109 protected void setFCWs(int fcw1, int fcw2) { |
119 | 110 this.fcw1 = fcw1; |
120 this.fcw1 = fcw1; | 111 this.fcw2 = fcw2; |
121 this.fcw2 = fcw2; | |
122 | 112 |
123 // if ((fcw1 & 0x88) == 0x88) { | 113 // if ((fcw1 & 0x88) == 0x88) { |
124 if (fcw1 == 0x88) { | 114 if (fcw1 == 0x88) { |
125 | 115 cursorProg = fcw2; |
126 cursorProg = fcw2; | 116 } |
127 } | 117 } |
128 } | 118 |
129 | 119 public int getFCW1() { |
130 public int getFCW1(){ | 120 return fcw1; |
131 return fcw1; | 121 } |
132 } | 122 |
133 | 123 public int getFCW2() { |
134 public int getFCW2(){ | 124 return fcw2; |
135 return fcw2; | 125 } |
136 } | 126 |
137 | 127 public int getFieldLength() { |
138 public int getFieldLength(){ | 128 return length; |
139 return length; | 129 } |
140 } | 130 |
141 | 131 public int getCursorProgression() { |
142 public int getCursorProgression() { | 132 return cursorProg; |
143 return cursorProg; | 133 } |
144 } | 134 |
145 | 135 public int getFieldId() { |
146 public int getFieldId() { | 136 return fieldId; |
147 return fieldId; | 137 } |
148 } | 138 |
149 | 139 protected void setFieldId(int fi) { |
150 protected void setFieldId(int fi) { | 140 fieldId = fi; |
151 fieldId = fi; | 141 } |
152 } | 142 |
153 | 143 public int getCursorRow() { |
154 public int getCursorRow() { | 144 return cursorPos / s.getColumns(); |
155 | 145 } |
156 return cursorPos / s.getColumns(); | 146 |
157 } | 147 public int getCursorCol() { |
158 | 148 return cursorPos % s.getColumns(); |
159 public int getCursorCol() { | 149 } |
160 | 150 |
161 return cursorPos % s.getColumns(); | 151 protected void changePos(int i) { |
162 } | 152 cursorPos += i; |
163 | 153 } |
164 protected void changePos(int i) { | 154 |
165 | 155 protected String getText() { |
166 cursorPos += i; | 156 StringBuffer text = new StringBuffer(); |
167 | 157 getKeyPos(endPos); |
168 } | 158 int x = length; |
169 | 159 text.setLength(x); |
170 protected String getText() { | 160 |
171 StringBuffer text = new StringBuffer(); | 161 while (x-- > 0) { |
172 getKeyPos(endPos); | 162 // here we manipulate the unicode characters a little for attributes |
173 int x = length; | 163 // that are imbedded in input fields. We will offset them by unicode |
174 text.setLength(x); | 164 // \uff00. All routines that process these fields will have to |
175 while (x-- > 0) { | 165 // return them to their proper offsets. |
176 | 166 // example: |
177 // here we manipulate the unicode characters a little for attributes | 167 // if we read an attribute byte of 32 for normal display the unicode |
178 // that are imbedded in input fields. We will offset them by unicode | 168 // character for this is \u0020 and the unicode character for |
179 // \uff00. All routines that process these fields will have to | 169 // a space is also \u0020 thus the offset. |
180 // return them to their proper offsets. | 170 if (s.planes.isAttributePlace(cursorPos)) { |
181 // example: | 171 text.setCharAt(x, (char)('\uff00' + s.planes.getCharAttr(cursorPos))); |
182 // if we read an attribute byte of 32 for normal display the unicode | 172 } |
183 // character for this is \u0020 and the unicode character for | 173 else { |
184 // a space is also \u0020 thus the offset. | 174 text.setCharAt(x, s.planes.getChar(cursorPos)); |
185 if (s.planes.isAttributePlace(cursorPos)) { | 175 } |
186 text.setCharAt(x,(char)('\uff00' + s.planes.getCharAttr(cursorPos))); | 176 |
187 } | 177 changePos(-1); |
188 else { | 178 } |
189 text.setCharAt(x,s.planes.getChar(cursorPos)); | 179 |
190 } | 180 // Since only the mdt of the first continued field is set we will get |
191 changePos(-1); | 181 // the text of the next continued field if we are dealing with continued |
192 | 182 // fields. See routine setMDT for the whys of this. This is only |
193 } | 183 // executed if this is the first field of a continued field. |
194 | 184 if (isContinued() && isContinuedFirst()) { |
195 // Since only the mdt of the first continued field is set we will get | 185 ScreenField sf = this; |
196 // the text of the next continued field if we are dealing with continued | 186 |
197 // fields. See routine setMDT for the whys of this. This is only | 187 do { |
198 // executed if this is the first field of a continued field. | 188 sf = sf.next; |
199 if (isContinued() && isContinuedFirst()) { | 189 text.append(sf.getText()); |
200 ScreenField sf = this; | 190 } |
201 do { | 191 while (!sf.isContinuedLast()); |
202 sf = sf.next; | 192 |
203 text.append(sf.getText()); | 193 sf = null; |
204 } | 194 } |
205 while (!sf.isContinuedLast()); | 195 |
206 | 196 return text.toString(); |
207 sf = null; | 197 } |
208 } | 198 |
209 | 199 public String getString() { |
210 return text.toString(); | 200 StringBuffer text = new StringBuffer(); |
211 | 201 getKeyPos(endPos); |
212 } | 202 int x = length; |
213 | 203 text.setLength(x); |
214 public String getString() { | 204 |
215 | 205 while (x-- > 0) { |
216 | 206 // here we manipulate the unicode characters a little for attributes |
217 StringBuffer text = new StringBuffer(); | 207 // that are imbedded in input fields. We will offset them by unicode |
218 getKeyPos(endPos); | 208 // \uff00. All routines that process these fields will have to |
219 int x = length; | 209 // return them to their proper offsets. |
220 text.setLength(x); | 210 // example: |
221 while (x-- > 0) { | 211 // if we read an attribute byte of 32 for normal display the unicode |
222 | 212 // character for this is \u0020 and the unicode character for |
223 // here we manipulate the unicode characters a little for attributes | 213 // a space is also \u0020 thus the offset. |
224 // that are imbedded in input fields. We will offset them by unicode | 214 if (s.planes.isAttributePlace(cursorPos)) { |
225 // \uff00. All routines that process these fields will have to | 215 text.setCharAt(x, (char)('\uff00' + s.planes.getCharAttr(cursorPos))); |
226 // return them to their proper offsets. | 216 } |
227 // example: | 217 else { |
228 // if we read an attribute byte of 32 for normal display the unicode | 218 if (s.planes.getChar(cursorPos) < ' ') |
229 // character for this is \u0020 and the unicode character for | 219 text.setCharAt(x, ' '); |
230 // a space is also \u0020 thus the offset. | 220 else |
231 if (s.planes.isAttributePlace(cursorPos)) { | 221 text.setCharAt(x, s.planes.getChar(cursorPos)); |
232 text.setCharAt(x,(char)('\uff00' + s.planes.getCharAttr(cursorPos))); | 222 } |
233 } | 223 |
234 else { | 224 changePos(-1); |
235 if (s.planes.getChar(cursorPos) < ' ') | 225 } |
236 text.setCharAt(x,' '); | 226 |
237 else | 227 // Since only the mdt of the first continued field is set we will get |
238 text.setCharAt(x,s.planes.getChar(cursorPos)); | 228 // the text of the next continued field if we are dealing with continued |
239 } | 229 // fields. See routine setMDT for the whys of this. This is only |
240 changePos(-1); | 230 // executed if this is the first field of a continued field. |
241 | 231 if (isContinued() && isContinuedFirst()) { |
242 } | 232 ScreenField sf = this; |
243 | 233 |
244 // Since only the mdt of the first continued field is set we will get | 234 do { |
245 // the text of the next continued field if we are dealing with continued | 235 sf = sf.next; |
246 // fields. See routine setMDT for the whys of this. This is only | 236 text.append(sf.getString()); |
247 // executed if this is the first field of a continued field. | 237 } |
248 if (isContinued() && isContinuedFirst()) { | 238 while (!sf.isContinuedLast()); |
249 ScreenField sf = this; | 239 |
250 do { | 240 sf = null; |
251 sf = sf.next; | 241 } |
252 text.append(sf.getString()); | 242 |
253 } | 243 return text.toString(); |
254 while (!sf.isContinuedLast()); | 244 } |
255 | 245 |
256 sf = null; | 246 public void setFieldChar(char c) { |
257 } | 247 int x = length; |
258 | 248 cursorPos = startPos; |
259 return text.toString(); | 249 |
260 | 250 while (x-- > 0) { |
261 } | 251 s.planes.setChar(cursorPos, c); |
262 | 252 changePos(1); |
263 public void setFieldChar(char c) { | 253 } |
264 | 254 } |
265 int x = length; | 255 |
266 cursorPos = startPos; | 256 public void setFieldChar(int lastPos, char c) { |
267 while (x-- > 0) { | 257 int x = endPos - lastPos + 1; |
268 s.planes.setChar(cursorPos,c); | 258 cursorPos = lastPos; |
269 changePos(1); | 259 |
270 } | 260 while (x-- > 0) { |
271 | 261 s.planes.setChar(cursorPos, c); |
272 } | 262 s.setDirty(cursorPos); |
273 | 263 changePos(1); |
274 public void setFieldChar(int lastPos, char c) { | 264 } |
275 | 265 } |
276 int x = endPos - lastPos + 1; | 266 |
277 cursorPos = lastPos; | 267 protected void setRightAdjusted() { |
278 while (x-- > 0) { | 268 rightAdjd = true; |
279 s.planes.setChar(cursorPos,c); | 269 } |
280 s.setDirty(cursorPos); | 270 |
281 changePos(1); | 271 protected void setManditoryEntered() { |
282 } | 272 manditoried = true; |
283 } | 273 } |
284 | 274 |
285 protected void setRightAdjusted() { | 275 protected void resetMDT() { |
286 rightAdjd = true; | 276 mdt = false; |
287 } | 277 } |
288 | 278 |
289 protected void setManditoryEntered() { | 279 protected void setMDT() { |
290 | 280 // get the first field of a continued edit field if it is continued |
291 manditoried = true; | 281 if (isContinued() && !isContinuedFirst()) { |
292 } | 282 ScreenField sf = prev; |
293 | 283 |
294 protected void resetMDT() { | 284 while (sf.isContinued() && !sf.isContinuedFirst()) { |
295 mdt = false; | 285 sf = sf.prev; |
296 | 286 } |
297 } | 287 |
298 | 288 sf.setMDT(); |
299 protected void setMDT() { | 289 sf = null; |
300 | 290 } |
301 // get the first field of a continued edit field if it is continued | 291 else { |
302 if (isContinued() && !isContinuedFirst()) { | 292 mdt = true; |
303 ScreenField sf = prev; | 293 } |
304 while (sf.isContinued() && !sf.isContinuedFirst()) { | 294 } |
305 | 295 |
306 sf = sf.prev; | 296 public boolean isBypassField() { |
307 | 297 return (ffw1 & 0x20) == 0x20; |
308 } | 298 } |
309 sf.setMDT(); | 299 |
310 sf = null; | 300 public int getAdjustment() { |
311 } | 301 return (ffw2 & 0x7); |
312 else { | 302 } |
313 mdt = true; | 303 |
314 } | 304 // is field exit required |
315 | 305 public boolean isFER() { |
316 } | 306 return (ffw2 & 0x40) == 0x40; |
317 | 307 } |
318 public boolean isBypassField() { | 308 |
319 | 309 // is field manditory enter |
320 return (ffw1 & 0x20) == 0x20; | 310 public boolean isMandatoryEnter() { |
321 | 311 return (ffw2 & 0x8) == 0x8; |
322 } | 312 } |
323 | 313 |
324 public int getAdjustment () { | 314 public boolean isToUpper() { |
325 | 315 return (ffw2 & 0x20) == 0x20; |
326 return (ffw2 & 0x7); | 316 } |
327 } | 317 |
328 | 318 // bits 5 - 7 |
329 // is field exit required | 319 public int getFieldShift() { |
330 public boolean isFER () { | 320 return (ffw1 & 0x7); |
331 | 321 } |
332 return (ffw2 & 0x40) == 0x40; | 322 |
333 } | 323 public boolean isHiglightedEntry() { |
334 | 324 return (fcw1 == 0x89); |
335 // is field manditory enter | 325 } |
336 public boolean isMandatoryEnter() { | 326 |
337 | 327 public boolean isAutoEnter() { |
338 return (ffw2 & 0x8) == 0x8; | 328 return (ffw2 & 0x80) == 0x80; |
339 | 329 } |
340 } | 330 |
341 | 331 public boolean isSignedNumeric() { |
342 public boolean isToUpper() { | 332 return (getFieldShift() == 7); |
343 | 333 } |
344 return (ffw2 & 0x20) == 0x20; | 334 |
345 | 335 public boolean isRightToLeft() { |
346 } | 336 return (getFieldShift() == 0x04); |
347 | 337 } |
348 // bits 5 - 7 | 338 |
349 public int getFieldShift () { | 339 public boolean isNumeric() { |
350 | 340 return (getFieldShift() == 3); |
351 return (ffw1 & 0x7); | 341 } |
352 | 342 |
353 } | 343 public boolean isDupEnabled() { |
354 | 344 return (ffw1 & 0x10) == 0x10; |
355 public boolean isHiglightedEntry() { | 345 } |
356 | 346 |
357 return (fcw1 == 0x89); | 347 public boolean isContinued() { |
358 | 348 return (fcw1 & 0x86) == 0x86 && (fcw2 >= 1 && fcw2 <= 3) ; |
359 } | 349 } |
360 | 350 |
361 public boolean isAutoEnter() { | 351 public boolean isContinuedFirst() { |
362 | 352 return (fcw1 & 0x86) == 0x86 && (fcw2 == 1); |
363 return (ffw2 & 0x80) == 0x80; | 353 } |
364 | 354 |
365 } | 355 public boolean isContinuedMiddle() { |
366 | 356 return (fcw1 & 0x86) == 0x86 && (fcw2 == 3); |
367 public boolean isSignedNumeric () { | 357 } |
368 | 358 |
369 return (getFieldShift() == 7); | 359 public boolean isContinuedLast() { |
370 | 360 return (fcw1 & 0x86) == 0x86 && (fcw2 == 2); |
371 } | 361 } |
372 | 362 |
373 public boolean isRightToLeft() { | 363 protected boolean isCanSend() { |
374 return (getFieldShift() == 0x04); | 364 int adj = getAdjustment(); |
375 } | 365 |
376 | 366 // here we need to check the Field Exit Required value first before checking |
377 public boolean isNumeric () { | 367 // the adjustments. If the last character has been entered and we are |
378 | 368 // now setting past the last position then we are allowed to process the |
379 return (getFieldShift() == 3); | 369 // the field without continuing. |
380 | 370 if (isFER() && cursorPos > endPos) { |
381 } | |
382 | |
383 public boolean isDupEnabled() { | |
384 | |
385 return (ffw1 & 0x10) == 0x10; | |
386 | |
387 } | |
388 | |
389 public boolean isContinued() { | |
390 | |
391 return (fcw1 & 0x86) == 0x86 && (fcw2 >= 1 && fcw2 <= 3) ; | |
392 | |
393 } | |
394 | |
395 public boolean isContinuedFirst() { | |
396 | |
397 return (fcw1 & 0x86) == 0x86 && (fcw2 == 1); | |
398 | |
399 } | |
400 | |
401 public boolean isContinuedMiddle() { | |
402 | |
403 return (fcw1 & 0x86) == 0x86 && (fcw2 == 3); | |
404 | |
405 } | |
406 | |
407 public boolean isContinuedLast() { | |
408 | |
409 return (fcw1 & 0x86) == 0x86 && (fcw2 == 2); | |
410 | |
411 } | |
412 | |
413 protected boolean isCanSend() { | |
414 | |
415 int adj = getAdjustment(); | |
416 | |
417 // here we need to check the Field Exit Required value first before checking | |
418 // the adjustments. If the last character has been entered and we are | |
419 // now setting past the last position then we are allowed to process the | |
420 // the field without continuing. | |
421 if (isFER() && cursorPos > endPos) { | |
422 return true; | |
423 } | |
424 | |
425 // signed numeric fields need to be checked as well. | |
426 if (isSignedNumeric() && cursorPos < endPos - 1) { | |
427 return false; | |
428 } | |
429 | |
430 if (adj > 0) { | |
431 | |
432 switch (adj) { | |
433 | |
434 case 5: | |
435 case 6: | |
436 return rightAdjd; | |
437 case 7: | |
438 return manditoried; | |
439 default: | |
440 return true; | |
441 } | |
442 | |
443 } | |
444 return true; | |
445 } | |
446 | |
447 public boolean isSelectionField() { | |
448 | |
449 return isSelectionField; | |
450 | |
451 } | |
452 | |
453 public void setSelectionFieldInfo(int type, int index, int position) { | |
454 | |
455 selectionFieldType = type; | |
456 selectionIndex = index; | |
457 selectionPos = position; | |
458 isSelectionField = true; | |
459 | |
460 } | |
461 | |
462 protected int getKeyPos(int row1, int col1) { | |
463 | |
464 int x = ((row1 * s.getColumns()) + col1); | |
465 int y = x - startPos(); | |
466 cursorPos = x; | |
467 | |
468 return y; | |
469 } | |
470 | |
471 protected int getKeyPos(int pos) { | |
472 | |
473 int y = pos - startPos(); | |
474 cursorPos = pos; | |
475 | |
476 return y; | |
477 } | |
478 | |
479 public int getCurrentPos() { | |
480 | |
481 return cursorPos; | |
482 } | |
483 | |
484 public boolean withinField (int pos) { | |
485 | |
486 if (pos >= startPos && pos <= endPos) | |
487 return true; | 371 return true; |
488 return false; | 372 } |
489 | 373 |
490 } | 374 // signed numeric fields need to be checked as well. |
491 | 375 if (isSignedNumeric() && cursorPos < endPos - 1) { |
492 public int startPos() { | 376 return false; |
493 | 377 } |
494 return startPos; | 378 |
495 } | 379 if (adj > 0) { |
496 | 380 switch (adj) { |
497 /** | 381 case 5: |
498 * Get the starting row of the field. Offset is 0 so row 6 returned | 382 case 6: |
499 * is row 7 mapped to screen | 383 return rightAdjd; |
500 * @return int starting row of the field offset 0 | 384 |
501 */ | 385 case 7: |
502 public int startRow() { | 386 return manditoried; |
503 | 387 |
504 return startPos / s.getColumns(); | 388 default: |
505 | 389 return true; |
506 } | 390 } |
507 | 391 } |
508 /** | 392 |
509 * Get the starting column of the field. Offset is 0 so column 6 returned | 393 return true; |
510 * is column 7 mapped to screen | 394 } |
511 * @return int starting column of the field offset 0 | 395 |
512 */ | 396 public boolean isSelectionField() { |
513 public int startCol() { | 397 return isSelectionField; |
514 | 398 } |
515 return startPos % s.getColumns(); | 399 |
516 | 400 public void setSelectionFieldInfo(int type, int index, int position) { |
517 } | 401 selectionFieldType = type; |
518 | 402 selectionIndex = index; |
519 public int endPos() { | 403 selectionPos = position; |
520 | 404 isSelectionField = true; |
521 return endPos; | 405 } |
522 | 406 |
523 } | 407 protected int getKeyPos(int row1, int col1) { |
524 | 408 int x = ((row1 * s.getColumns()) + col1); |
525 /** | 409 int y = x - startPos(); |
526 * Sets the field's text plane to the specified string. If the string is | 410 cursorPos = x; |
527 * shorter than the length of the field, the rest of the field is cleared. | 411 return y; |
528 * If the string is longer than the field, the text is truncated. A subsequent | 412 } |
529 * call to getText on this field will not show the changed text. To see the | 413 |
530 * changed text, do a refresh on the iOhioFields collection and retrieve the | 414 protected int getKeyPos(int pos) { |
531 * refreshed field object. | 415 int y = pos - startPos(); |
532 * | 416 cursorPos = pos; |
533 * @param text - The text to be placed in the field's text plane. | 417 return y; |
534 */ | 418 } |
535 public void setString(String text) { | 419 |
536 | 420 public int getCurrentPos() { |
537 int y = length; | 421 return cursorPos; |
538 cursorPos = startPos; | 422 } |
539 int len = text.length(); | 423 |
540 char[] c = text.toCharArray(); | 424 public boolean withinField(int pos) { |
541 char tc = ' '; | 425 if (pos >= startPos && pos <= endPos) |
542 | 426 return true; |
543 for (int x = 0; x < y; x++) { | 427 |
544 tc = ' '; | 428 return false; |
545 if (x < len) { | 429 } |
546 tc = c[x]; | 430 |
547 } | 431 public int startPos() { |
548 s.getPlanes().setChar(cursorPos,tc); | 432 return startPos; |
549 changePos(1); | 433 } |
550 } | 434 |
551 setMDT(); | 435 /** |
552 s.getScreenFields().setMasterMDT(); | 436 * Get the starting row of the field. Offset is 0 so row 6 returned |
553 } | 437 * is row 7 mapped to screen |
554 | 438 * @return int starting row of the field offset 0 |
555 public String toString() { | 439 */ |
556 int fcw = (fcw1 & 0xff) << 8 | fcw2 & 0xff; | 440 public int startRow() { |
557 return "startRow = " + startRow() + " startCol = " + startCol() + | 441 return startPos / s.getColumns(); |
558 " length = " + length + " ffw1 = (0x" + Integer.toHexString(ffw1) + | 442 } |
559 ") ffw2 = (0x" + Integer.toHexString(ffw2) + | 443 |
560 ") fcw1 = (0x" + Integer.toHexString(fcw1) + | 444 /** |
561 ") fcw2 = (0x" + Integer.toHexString(fcw2) + | 445 * Get the starting column of the field. Offset is 0 so column 6 returned |
562 ") fcw = (" + Integer.toBinaryString(fcw) + | 446 * is column 7 mapped to screen |
563 ") fcw hex = (0x" + Integer.toHexString(fcw) + | 447 * @return int starting column of the field offset 0 |
564 ") is bypass field = " + isBypassField() + | 448 */ |
565 ") is autoenter = " + isAutoEnter() + | 449 public int startCol() { |
566 ") is manditoryenter = " + isMandatoryEnter() + | 450 return startPos % s.getColumns(); |
567 ") is field exit required = " + isFER() + | 451 } |
568 ") is Numeric = " + isNumeric() + | 452 |
569 ") is Signed Numeric = " + isSignedNumeric() + | 453 public int endPos() { |
570 ") is cursor progression = " + (fcw1 == 0x88) + | 454 return endPos; |
571 ") next progression field = " + fcw2 + | 455 } |
572 ") field id " + fieldId + | 456 |
573 " continued edit field = " + isContinued() + | 457 /** |
574 " first continued edit field = " + isContinuedFirst() + | 458 * Sets the field's text plane to the specified string. If the string is |
575 " middle continued edit field = " + isContinuedMiddle() + | 459 * shorter than the length of the field, the rest of the field is cleared. |
576 " last continued edit field = " + isContinuedLast() + | 460 * If the string is longer than the field, the text is truncated. A subsequent |
577 " mdt = " + mdt; | 461 * call to getText on this field will not show the changed text. To see the |
578 } | 462 * changed text, do a refresh on the iOhioFields collection and retrieve the |
463 * refreshed field object. | |
464 * | |
465 * @param text - The text to be placed in the field's text plane. | |
466 */ | |
467 public void setString(String text) { | |
468 int y = length; | |
469 cursorPos = startPos; | |
470 int len = text.length(); | |
471 char[] c = text.toCharArray(); | |
472 char tc = ' '; | |
473 | |
474 for (int x = 0; x < y; x++) { | |
475 tc = ' '; | |
476 | |
477 if (x < len) { | |
478 tc = c[x]; | |
479 } | |
480 | |
481 s.getPlanes().setChar(cursorPos, tc); | |
482 changePos(1); | |
483 } | |
484 | |
485 setMDT(); | |
486 s.getScreenFields().setMasterMDT(); | |
487 } | |
488 | |
489 public String toString() { | |
490 int fcw = (fcw1 & 0xff) << 8 | fcw2 & 0xff; | |
491 return "startRow = " + startRow() + " startCol = " + startCol() + | |
492 " length = " + length + " ffw1 = (0x" + Integer.toHexString(ffw1) + | |
493 ") ffw2 = (0x" + Integer.toHexString(ffw2) + | |
494 ") fcw1 = (0x" + Integer.toHexString(fcw1) + | |
495 ") fcw2 = (0x" + Integer.toHexString(fcw2) + | |
496 ") fcw = (" + Integer.toBinaryString(fcw) + | |
497 ") fcw hex = (0x" + Integer.toHexString(fcw) + | |
498 ") is bypass field = " + isBypassField() + | |
499 ") is autoenter = " + isAutoEnter() + | |
500 ") is manditoryenter = " + isMandatoryEnter() + | |
501 ") is field exit required = " + isFER() + | |
502 ") is Numeric = " + isNumeric() + | |
503 ") is Signed Numeric = " + isSignedNumeric() + | |
504 ") is cursor progression = " + (fcw1 == 0x88) + | |
505 ") next progression field = " + fcw2 + | |
506 ") field id " + fieldId + | |
507 " continued edit field = " + isContinued() + | |
508 " first continued edit field = " + isContinuedFirst() + | |
509 " middle continued edit field = " + isContinuedMiddle() + | |
510 " last continued edit field = " + isContinuedLast() + | |
511 " mdt = " + mdt; | |
512 } | |
579 | 513 |
580 public int getStartPos() { | 514 public int getStartPos() { |
581 return startPos; | 515 return startPos; |
582 } | 516 } |
583 | 517 |
584 int startPos = 0; | 518 int startPos = 0; |
585 int endPos = 0; | 519 int endPos = 0; |
586 boolean mdt = false; | 520 boolean mdt = false; |
587 protected boolean checkCanSend; | 521 protected boolean checkCanSend; |
588 protected boolean rightAdjd; | 522 protected boolean rightAdjd; |
589 protected boolean manditoried; | 523 protected boolean manditoried; |
590 boolean canSend = true; | 524 boolean canSend = true; |
591 int attr = 0; | 525 int attr = 0; |
592 int length = 0; | 526 int length = 0; |
593 int ffw1 = 0; | 527 int ffw1 = 0; |
594 int ffw2 = 0; | 528 int ffw2 = 0; |
595 int fcw1 = 0; | 529 int fcw1 = 0; |
596 int fcw2 = 0; | 530 int fcw2 = 0; |
597 int cursorPos = 0; | 531 int cursorPos = 0; |
598 Screen5250 s; | 532 Screen5250 s; |
599 int cursorProg = 0; | 533 int cursorProg = 0; |
600 int fieldId = 0; | 534 int fieldId = 0; |
601 ScreenField next = null; | 535 ScreenField next = null; |
602 ScreenField prev = null; | 536 ScreenField prev = null; |
603 boolean isSelectionField; | 537 boolean isSelectionField; |
604 int selectionFieldType; | 538 int selectionFieldType; |
605 int selectionIndex; | 539 int selectionIndex; |
606 int selectionPos; | 540 int selectionPos; |
607 } | 541 } |