1 Clazz.declarePackage ("javax.swing.text");
\r
2 Clazz.load (["javax.swing.AbstractAction", "javax.swing.text.DefaultFormatter"], "javax.swing.text.InternationalFormatter", ["java.lang.StringBuffer", "java.util.ArrayList", "$.BitSet", "java.text.AttributedCharacterIterator.Attribute", "java.text.ParseException"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
7 this.literalMask = null;
\r
8 this.iterator = null;
\r
9 this.validMask = false;
\r
11 this.ignoreDocumentMutate = false;
\r
12 if (!Clazz.isClassDefined ("javax.swing.text.InternationalFormatter.IncrementAction")) {
\r
13 javax.swing.text.InternationalFormatter.$InternationalFormatter$IncrementAction$ ();
\r
15 Clazz.instantialize (this, arguments);
\r
16 }, javax.swing.text, "InternationalFormatter", javax.swing.text.DefaultFormatter);
\r
17 Clazz.makeConstructor (c$,
\r
19 Clazz.superConstructor (this, javax.swing.text.InternationalFormatter, []);
\r
20 this.setOverwriteMode (false);
\r
22 Clazz.makeConstructor (c$,
\r
25 this.setFormat (format);
\r
26 }, "java.text.Format");
\r
27 Clazz.defineMethod (c$, "setFormat",
\r
29 this.format = format;
\r
30 }, "java.text.Format");
\r
31 Clazz.defineMethod (c$, "getFormat",
\r
35 Clazz.defineMethod (c$, "setMinimum",
\r
36 function (minimum) {
\r
37 if (this.getValueClass () == null && minimum != null) {
\r
38 this.setValueClass (minimum.getClass ());
\r
39 }this.min = minimum;
\r
41 Clazz.defineMethod (c$, "getMinimum",
\r
45 Clazz.defineMethod (c$, "setMaximum",
\r
47 if (this.getValueClass () == null && max != null) {
\r
48 this.setValueClass (max.getClass ());
\r
51 Clazz.defineMethod (c$, "getMaximum",
\r
55 Clazz.defineMethod (c$, "install",
\r
57 Clazz.superCall (this, javax.swing.text.InternationalFormatter, "install", [ftf]);
\r
58 this.updateMaskIfNecessary ();
\r
59 this.positionCursorAtInitialLocation ();
\r
60 }, "javax.swing.JFormattedTextField");
\r
61 Clazz.overrideMethod (c$, "valueToString",
\r
63 if (value == null) {
\r
65 }var f = this.getFormat ();
\r
67 return value.toString ();
\r
68 }return f.format (value);
\r
70 Clazz.defineMethod (c$, "stringToValue",
\r
72 var value = this.stringToValueParse (text, this.getFormat ());
\r
73 if (value != null && this.getValueClass () != null && !this.getValueClass ().isInstance (value)) {
\r
74 value = Clazz.superCall (this, javax.swing.text.InternationalFormatter, "stringToValue", [value.toString ()]);
\r
76 if (!this.isValidValue (value, true)) {
\r
77 throw new java.text.ParseException ("Value not within min/max range", 0);
\r
79 if (Clazz.exceptionOf (cce, ClassCastException)) {
\r
80 throw new java.text.ParseException ("Class cast exception comparing values: " + cce, 0);
\r
87 Clazz.defineMethod (c$, "getFields",
\r
89 if (this.getAllowsInvalid ()) {
\r
91 }var attrs = this.getAttributes (offset);
\r
92 if (attrs != null && attrs.size () > 0) {
\r
93 var al = new java.util.ArrayList ();
\r
94 al.addAll (attrs.keySet ());
\r
95 return al.toArray (javax.swing.text.InternationalFormatter.EMPTY_FIELD_ARRAY);
\r
96 }return javax.swing.text.InternationalFormatter.EMPTY_FIELD_ARRAY;
\r
98 Clazz.defineMethod (c$, "clone",
\r
100 var formatter = Clazz.superCall (this, javax.swing.text.InternationalFormatter, "clone", []);
\r
101 formatter.literalMask = null;
\r
102 formatter.iterator = null;
\r
103 formatter.validMask = false;
\r
104 formatter.string = null;
\r
107 Clazz.overrideMethod (c$, "getActions",
\r
109 if (this.getSupportsIncrement ()) {
\r
110 return Clazz.newArray (-1, [Clazz.innerTypeInstance (javax.swing.text.InternationalFormatter.IncrementAction, this, null, "increment", 1), Clazz.innerTypeInstance (javax.swing.text.InternationalFormatter.IncrementAction, this, null, "decrement", -1)]);
\r
113 Clazz.defineMethod (c$, "stringToValueParse",
\r
114 function (text, f) {
\r
117 }return f.parseObject (text);
\r
118 }, "~S,java.text.Format");
\r
119 Clazz.defineMethod (c$, "isValidValue",
\r
120 function (value, wantsCCE) {
\r
121 var min = this.getMinimum ();
\r
123 if (min != null && min.compareTo (value) > 0) {
\r
126 if (Clazz.exceptionOf (cce, ClassCastException)) {
\r
134 var max = this.getMaximum ();
\r
136 if (max != null && max.compareTo (value) < 0) {
\r
139 if (Clazz.exceptionOf (cce, ClassCastException)) {
\r
149 Clazz.defineMethod (c$, "getAttributes",
\r
151 if (this.isValidMask ()) {
\r
152 var iterator = this.getIterator ();
\r
153 if (index >= 0 && index <= iterator.getEndIndex ()) {
\r
154 iterator.setIndex (index);
\r
155 return iterator.getAttributes ();
\r
158 Clazz.defineMethod (c$, "getAttributeStart",
\r
160 if (this.isValidMask ()) {
\r
161 var iterator = this.getIterator ();
\r
163 while (iterator.current () != '\uffff') {
\r
164 if (iterator.getAttribute (id) != null) {
\r
165 return iterator.getIndex ();
\r
169 }, "java.text.AttributedCharacterIterator.Attribute");
\r
170 Clazz.defineMethod (c$, "getIterator",
\r
172 return this.iterator;
\r
174 Clazz.defineMethod (c$, "updateMaskIfNecessary",
\r
176 if (!this.getAllowsInvalid () && (this.getFormat () != null)) {
\r
177 if (!this.isValidMask ()) {
\r
178 this.updateMask ();
\r
180 var newString = this.getFormattedTextField ().getText ();
\r
181 if (!newString.equals (this.string)) {
\r
182 this.updateMask ();
\r
184 Clazz.defineMethod (c$, "updateMask",
\r
186 if (this.getFormat () != null) {
\r
187 var doc = this.getFormattedTextField ().getDocument ();
\r
188 this.validMask = false;
\r
191 this.string = doc.getText (0, doc.getLength ());
\r
193 if (Clazz.exceptionOf (ble, javax.swing.text.BadLocationException)) {
\r
194 this.string = null;
\r
199 if (this.string != null) {
\r
201 var value = this.stringToValue (this.string);
\r
202 var iterator = this.getFormat ().formatToCharacterIterator (value);
\r
203 this.updateMask (iterator);
\r
205 if (Clazz.exceptionOf (e$$, java.text.ParseException)) {
\r
209 } else if (Clazz.exceptionOf (e$$, IllegalArgumentException)) {
\r
213 } else if (Clazz.exceptionOf (e$$, NullPointerException)) {
\r
222 Clazz.defineMethod (c$, "getLiteralCountTo",
\r
225 for (var counter = 0; counter < index; counter++) {
\r
226 if (this.isLiteral (counter)) {
\r
231 Clazz.defineMethod (c$, "isLiteral",
\r
233 if (this.isValidMask () && index < this.string.length) {
\r
234 return this.literalMask.get (index);
\r
237 Clazz.defineMethod (c$, "getLiteral",
\r
239 if (this.isValidMask () && this.string != null && index < this.string.length) {
\r
240 return this.string.charAt (index);
\r
241 }return String.fromCharCode (0);
\r
243 Clazz.overrideMethod (c$, "isNavigatable",
\r
244 function (offset) {
\r
245 return !this.isLiteral (offset);
\r
247 Clazz.defineMethod (c$, "updateValue",
\r
249 Clazz.superCall (this, javax.swing.text.InternationalFormatter, "updateValue", [value]);
\r
250 this.updateMaskIfNecessary ();
\r
252 Clazz.defineMethod (c$, "replace",
\r
253 function (fb, offset, length, text, attrs) {
\r
254 if (this.ignoreDocumentMutate) {
\r
255 fb.replace (offset, length, text, attrs);
\r
257 }Clazz.superCall (this, javax.swing.text.InternationalFormatter, "replace", [fb, offset, length, text, attrs]);
\r
258 }, "javax.swing.text.DocumentFilter.FilterBypass,~N,~N,~S,javax.swing.text.AttributeSet");
\r
259 Clazz.defineMethod (c$, "getNextNonliteralIndex",
\r
260 function (index, direction) {
\r
261 var max = this.getFormattedTextField ().getDocument ().getLength ();
\r
262 while (index >= 0 && index < max) {
\r
263 if (this.isLiteral (index)) {
\r
264 index += direction;
\r
268 return (direction == -1) ? 0 : max;
\r
270 Clazz.defineMethod (c$, "canReplace",
\r
272 if (!this.getAllowsInvalid ()) {
\r
273 var text = rh.text;
\r
274 var tl = (text != null) ? text.length : 0;
\r
275 if (tl == 0 && rh.length == 1 && this.getFormattedTextField ().getSelectionStart () != rh.offset) {
\r
276 rh.offset = this.getNextNonliteralIndex (rh.offset, -1);
\r
277 }if (this.getOverwriteMode ()) {
\r
278 var replace = null;
\r
279 for (var counter = 0, textIndex = 0, max = Math.max (tl, rh.length); counter < max; counter++) {
\r
280 if (this.isLiteral (rh.offset + counter)) {
\r
281 if (replace != null) {
\r
282 replace.append (this.getLiteral (rh.offset + counter));
\r
283 }if (textIndex < tl && text.charAt (textIndex) == this.getLiteral (rh.offset + counter)) {
\r
285 } else if (textIndex == 0) {
\r
290 } else if (replace == null) {
\r
291 replace = new StringBuffer (max);
\r
292 replace.append (text.substring (0, textIndex));
\r
293 replace.append (this.getLiteral (rh.offset + counter));
\r
294 }} else if (textIndex < tl) {
\r
295 if (replace != null) {
\r
296 replace.append (text.charAt (textIndex));
\r
299 if (replace == null) {
\r
300 replace = new StringBuffer (max);
\r
301 if (textIndex > 0) {
\r
302 replace.append (text.substring (0, textIndex));
\r
303 }}if (replace != null) {
\r
304 replace.append (' ');
\r
306 if (replace != null) {
\r
307 rh.text = replace.toString ();
\r
308 }} else if (tl > 0) {
\r
309 rh.offset = this.getNextNonliteralIndex (rh.offset, 1);
\r
311 rh.offset = this.getNextNonliteralIndex (rh.offset, -1);
\r
312 }(rh).endOffset = rh.offset;
\r
313 (rh).endTextLength = (rh.text != null) ? rh.text.length : 0;
\r
315 (rh).endOffset = rh.offset;
\r
316 (rh).endTextLength = (rh.text != null) ? rh.text.length : 0;
\r
317 }var can = Clazz.superCall (this, javax.swing.text.InternationalFormatter, "canReplace", [rh]);
\r
318 if (can && !this.getAllowsInvalid ()) {
\r
319 (rh).resetFromValue (this);
\r
321 }, "javax.swing.text.DefaultFormatter.ReplaceHolder");
\r
322 Clazz.defineMethod (c$, "replace",
\r
326 var literalCount = -1;
\r
327 if (rh.length > 0 && (rh.text == null || rh.text.length == 0) && (this.getFormattedTextField ().getSelectionStart () != rh.offset || rh.length > 1)) {
\r
329 }if (!this.getAllowsInvalid ()) {
\r
330 if ((rh.text == null || rh.text.length == 0) && rh.length > 0) {
\r
331 start = this.getFormattedTextField ().getSelectionStart ();
\r
334 }literalCount = this.getLiteralCountTo (start);
\r
335 }if (Clazz.superCall (this, javax.swing.text.InternationalFormatter, "replace", [rh])) {
\r
337 var end = (rh).endOffset;
\r
338 end += (rh).endTextLength;
\r
339 this.repositionCursor (literalCount, end, direction);
\r
341 start = (rh).endOffset;
\r
342 if (direction == 1) {
\r
343 start += (rh).endTextLength;
\r
344 }this.repositionCursor (start, direction);
\r
347 }, "javax.swing.text.DefaultFormatter.ReplaceHolder");
\r
348 Clazz.defineMethod (c$, "repositionCursor",
\r
349 function (startLiteralCount, end, direction) {
\r
350 var endLiteralCount = this.getLiteralCountTo (end);
\r
351 if (endLiteralCount != end) {
\r
352 end -= startLiteralCount;
\r
353 for (var counter = 0; counter < end; counter++) {
\r
354 if (this.isLiteral (counter)) {
\r
357 }this.repositionCursor (end, 1);
\r
359 Clazz.defineMethod (c$, "getBufferedChar",
\r
361 if (this.isValidMask ()) {
\r
362 if (this.string != null && index < this.string.length) {
\r
363 return this.string.charAt (index);
\r
364 }}return String.fromCharCode (0);
\r
366 Clazz.defineMethod (c$, "isValidMask",
\r
368 return this.validMask;
\r
370 Clazz.defineMethod (c$, "isLiteral",
\r
371 function (attributes) {
\r
372 return ((attributes == null) || attributes.size () == 0);
\r
373 }, "java.util.Map");
\r
374 Clazz.defineMethod (c$, "updateMask",
\r
375 function (iterator) {
\r
376 if (iterator != null) {
\r
377 this.validMask = true;
\r
378 this.iterator = iterator;
\r
379 if (this.literalMask == null) {
\r
380 this.literalMask = new java.util.BitSet ();
\r
382 for (var counter = this.literalMask.length () - 1; counter >= 0; counter--) {
\r
383 this.literalMask.clear (counter);
\r
385 }iterator.first ();
\r
386 while (iterator.current () != '\uffff') {
\r
387 var attributes = iterator.getAttributes ();
\r
388 var set = this.isLiteral (attributes);
\r
389 var start = iterator.getIndex ();
\r
390 var end = iterator.getRunLimit ();
\r
391 while (start < end) {
\r
393 this.literalMask.set (start);
\r
395 this.literalMask.clear (start);
\r
398 iterator.setIndex (start);
\r
400 }}, "java.text.AttributedCharacterIterator");
\r
401 Clazz.defineMethod (c$, "canIncrement",
\r
402 function (field, cursorPosition) {
\r
403 return (field != null);
\r
405 Clazz.defineMethod (c$, "selectField",
\r
406 function (f, count) {
\r
407 var iterator = this.getIterator ();
\r
408 if (iterator != null && (Clazz.instanceOf (f, java.text.AttributedCharacterIterator.Attribute))) {
\r
411 while (iterator.current () != '\uffff') {
\r
412 while (iterator.getAttribute (field) == null && iterator.next () != '\uffff') ;
\r
413 if (iterator.current () != '\uffff') {
\r
414 var limit = iterator.getRunLimit (field);
\r
415 if (--count <= 0) {
\r
416 this.getFormattedTextField ().select (iterator.getIndex (), limit);
\r
418 }iterator.setIndex (limit);
\r
422 Clazz.defineMethod (c$, "getAdjustField",
\r
423 function (start, attributes) {
\r
425 }, "~N,java.util.Map");
\r
426 Clazz.defineMethod (c$, "getFieldTypeCountTo",
\r
427 function (f, start) {
\r
428 var iterator = this.getIterator ();
\r
430 if (iterator != null && (Clazz.instanceOf (f, java.text.AttributedCharacterIterator.Attribute))) {
\r
434 while (iterator.getIndex () < start) {
\r
435 while (iterator.getAttribute (field) == null && iterator.next () != '\uffff') ;
\r
436 if (iterator.current () != '\uffff') {
\r
437 iterator.setIndex (iterator.getRunLimit (field));
\r
445 Clazz.defineMethod (c$, "adjustValue",
\r
446 function (value, attributes, field, direction) {
\r
448 }, "~O,java.util.Map,~O,~N");
\r
449 Clazz.defineMethod (c$, "getSupportsIncrement",
\r
453 Clazz.defineMethod (c$, "resetValue",
\r
455 var doc = this.getFormattedTextField ().getDocument ();
\r
456 var string = this.valueToString (value);
\r
458 this.ignoreDocumentMutate = true;
\r
459 doc.remove (0, doc.getLength ());
\r
460 doc.insertString (0, string, null);
\r
462 this.ignoreDocumentMutate = false;
\r
464 this.updateValue (value);
\r
466 Clazz.defineMethod (c$, "getReplaceHolder",
\r
467 function (fb, offset, length, text, attrs) {
\r
468 if (this.replaceHolder == null) {
\r
469 this.replaceHolder = new javax.swing.text.InternationalFormatter.ExtendedReplaceHolder ();
\r
470 }return Clazz.superCall (this, javax.swing.text.InternationalFormatter, "getReplaceHolder", [fb, offset, length, text, attrs]);
\r
471 }, "javax.swing.text.DocumentFilter.FilterBypass,~N,~N,~S,javax.swing.text.AttributeSet");
\r
472 c$.$InternationalFormatter$IncrementAction$ = function () {
\r
473 Clazz.pu$h(self.c$);
\r
474 c$ = Clazz.decorateAsClass (function () {
\r
475 Clazz.prepareCallback (this, arguments);
\r
476 this.direction = 0;
\r
477 Clazz.instantialize (this, arguments);
\r
478 }, javax.swing.text.InternationalFormatter, "IncrementAction", javax.swing.AbstractAction);
\r
479 Clazz.makeConstructor (c$,
\r
481 Clazz.superConstructor (this, javax.swing.text.InternationalFormatter.IncrementAction, [a]);
\r
482 this.direction = b;
\r
484 Clazz.overrideMethod (c$, "actionPerformed",
\r
486 if (this.b$["javax.swing.text.InternationalFormatter"].getFormattedTextField ().isEditable ()) {
\r
487 if (this.b$["javax.swing.text.InternationalFormatter"].getAllowsInvalid ()) {
\r
488 this.b$["javax.swing.text.InternationalFormatter"].updateMask ();
\r
490 if (this.b$["javax.swing.text.InternationalFormatter"].isValidMask ()) {
\r
491 var c = this.b$["javax.swing.text.InternationalFormatter"].getFormattedTextField ().getSelectionStart ();
\r
493 var d = this.b$["javax.swing.text.InternationalFormatter"].getIterator ();
\r
495 var e = d.getAttributes ();
\r
496 var f = this.b$["javax.swing.text.InternationalFormatter"].getAdjustField (c, e);
\r
497 if (this.b$["javax.swing.text.InternationalFormatter"].canIncrement (f, c)) {
\r
499 var g = this.b$["javax.swing.text.InternationalFormatter"].stringToValue (this.b$["javax.swing.text.InternationalFormatter"].getFormattedTextField ().getText ());
\r
500 var h = this.b$["javax.swing.text.InternationalFormatter"].getFieldTypeCountTo (f, c);
\r
501 g = this.b$["javax.swing.text.InternationalFormatter"].adjustValue (g, e, f, this.direction);
\r
502 if (g != null && this.b$["javax.swing.text.InternationalFormatter"].isValidValue (g, false)) {
\r
503 this.b$["javax.swing.text.InternationalFormatter"].resetValue (g);
\r
504 this.b$["javax.swing.text.InternationalFormatter"].updateMask ();
\r
505 if (this.b$["javax.swing.text.InternationalFormatter"].isValidMask ()) {
\r
506 this.b$["javax.swing.text.InternationalFormatter"].selectField (f, h);
\r
509 if (Clazz.exceptionOf (e$$, java.text.ParseException)) {
\r
513 } else if (Clazz.exceptionOf (e$$, javax.swing.text.BadLocationException)) {
\r
522 this.b$["javax.swing.text.InternationalFormatter"].invalidEdit ();
\r
523 }}}, "java.awt.event.ActionEvent");
\r
526 Clazz.pu$h(self.c$);
\r
527 c$ = Clazz.decorateAsClass (function () {
\r
528 this.endOffset = 0;
\r
529 this.endTextLength = 0;
\r
530 Clazz.instantialize (this, arguments);
\r
531 }, javax.swing.text.InternationalFormatter, "ExtendedReplaceHolder", javax.swing.text.DefaultFormatter.ReplaceHolder);
\r
532 Clazz.defineMethod (c$, "resetFromValue",
\r
536 this.text = a.valueToString (this.value);
\r
538 if (Clazz.exceptionOf (pe, java.text.ParseException)) {
\r
544 this.length = this.fb.getDocument ().getLength ();
\r
545 }, "javax.swing.text.InternationalFormatter");
\r
547 c$.EMPTY_FIELD_ARRAY = c$.prototype.EMPTY_FIELD_ARRAY = new Array (0);
\r