8e5ee9103c660b8237da4a5c12880995bd340a71
[jalviewjs.git] / site / swingjs / j2s / javax / swing / text / AbstractDocument.js
1 Clazz.declarePackage ("javax.swing.text");
2 Clazz.load (["javax.swing.event.DocumentEvent", "javax.swing.text.DocumentFilter", "$.Element", "$.JSMinimalAbstractDocument", "$.MutableAttributeSet", "javax.swing.tree.TreeNode", "javax.swing.undo.AbstractUndoableEdit", "$.CompoundEdit", "javax.swing.event.EventListenerList"], "javax.swing.text.AbstractDocument", ["java.lang.Boolean", "java.util.Hashtable", "$.Vector", "javax.swing.UIManager", "javax.swing.event.DocumentEvent.ElementChange", "javax.swing.event.DocumentListener", "$.UndoableEditEvent", "$.UndoableEditListener", "javax.swing.text.BadLocationException", "$.SegmentCache", "$.StateInvariantError", "$.StyleConstants", "$.StyleContext", "$.Utilities"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.documentProperties = null;
5 this.listenerList = null;
6 this.data = null;
7 this.context = null;
8 this.bidiRoot = null;
9 this.documentFilter = null;
10 this.filterBypass = null;
11 if (!Clazz.isClassDefined ("javax.swing.text.AbstractDocument.AbstractElement")) {
12 javax.swing.text.AbstractDocument.$AbstractDocument$AbstractElement$ ();
13 }
14 if (!Clazz.isClassDefined ("javax.swing.text.AbstractDocument.BranchElement")) {
15 javax.swing.text.AbstractDocument.$AbstractDocument$BranchElement$ ();
16 }
17 if (!Clazz.isClassDefined ("javax.swing.text.AbstractDocument.LeafElement")) {
18 javax.swing.text.AbstractDocument.$AbstractDocument$LeafElement$ ();
19 }
20 if (!Clazz.isClassDefined ("javax.swing.text.AbstractDocument.DefaultDocumentEvent")) {
21 javax.swing.text.AbstractDocument.$AbstractDocument$DefaultDocumentEvent$ ();
22 }
23 if (!Clazz.isClassDefined ("javax.swing.text.AbstractDocument.UndoRedoDocumentEvent")) {
24 javax.swing.text.AbstractDocument.$AbstractDocument$UndoRedoDocumentEvent$ ();
25 }
26 if (!Clazz.isClassDefined ("javax.swing.text.AbstractDocument.DefaultFilterBypass")) {
27 javax.swing.text.AbstractDocument.$AbstractDocument$DefaultFilterBypass$ ();
28 }
29 Clazz.instantialize (this, arguments);
30 }, javax.swing.text, "AbstractDocument", null, javax.swing.text.JSMinimalAbstractDocument);
31 Clazz.prepareFields (c$, function () {
32 this.listenerList =  new javax.swing.event.EventListenerList ();
33 });
34 Clazz.makeConstructor (c$, 
35 function (data) {
36 this.construct (data, javax.swing.text.StyleContext.getDefaultStyleContext ());
37 }, "javax.swing.text.AbstractDocument.Content");
38 Clazz.makeConstructor (c$, 
39 function (data, context) {
40 this.data = data;
41 this.context = context;
42 }, "javax.swing.text.AbstractDocument.Content,javax.swing.text.AbstractDocument.AttributeContext");
43 Clazz.defineMethod (c$, "getDocumentProperties", 
44 function () {
45 if (this.documentProperties == null) {
46 this.documentProperties =  new java.util.Hashtable (2);
47 }return this.documentProperties;
48 });
49 Clazz.defineMethod (c$, "setDocumentProperties", 
50 function (x) {
51 this.documentProperties = x;
52 }, "java.util.Dictionary");
53 Clazz.defineMethod (c$, "fireInsertUpdate", 
54 function (e) {
55 try {
56 var listeners = this.listenerList.getListenerList ();
57 for (var i = listeners.length - 2; i >= 0; i -= 2) {
58 if (listeners[i] === javax.swing.event.DocumentListener) {
59 (listeners[i + 1]).insertUpdate (e);
60 }}
61 } finally {
62 }
63 }, "javax.swing.event.DocumentEvent");
64 Clazz.defineMethod (c$, "fireChangedUpdate", 
65 function (e) {
66 try {
67 var listeners = this.listenerList.getListenerList ();
68 for (var i = listeners.length - 2; i >= 0; i -= 2) {
69 if (listeners[i] === javax.swing.event.DocumentListener) {
70 (listeners[i + 1]).changedUpdate (e);
71 }}
72 } finally {
73 }
74 }, "javax.swing.event.DocumentEvent");
75 Clazz.defineMethod (c$, "fireRemoveUpdate", 
76 function (e) {
77 try {
78 var listeners = this.listenerList.getListenerList ();
79 for (var i = listeners.length - 2; i >= 0; i -= 2) {
80 if (listeners[i] === javax.swing.event.DocumentListener) {
81 (listeners[i + 1]).removeUpdate (e);
82 }}
83 } finally {
84 }
85 }, "javax.swing.event.DocumentEvent");
86 Clazz.defineMethod (c$, "fireUndoableEditUpdate", 
87 function (e) {
88 var listeners = this.listenerList.getListenerList ();
89 for (var i = listeners.length - 2; i >= 0; i -= 2) {
90 if (listeners[i] === javax.swing.event.UndoableEditListener) {
91 (listeners[i + 1]).undoableEditHappened (e);
92 }}
93 }, "javax.swing.event.UndoableEditEvent");
94 Clazz.defineMethod (c$, "getListeners", 
95 function (listenerType) {
96 return this.listenerList.getListeners (listenerType);
97 }, "Class");
98 Clazz.overrideMethod (c$, "getAsynchronousLoadPriority", 
99 function () {
100 var loadPriority = this.getProperty ("load priority");
101 if (loadPriority != null) {
102 return loadPriority.intValue ();
103 }return -1;
104 });
105 Clazz.defineMethod (c$, "setAsynchronousLoadPriority", 
106 function (p) {
107 var loadPriority = (p >= 0) ?  new Integer (p) : null;
108 this.putProperty ("load priority", loadPriority);
109 }, "~N");
110 Clazz.overrideMethod (c$, "setDocumentFilter", 
111 function (filter) {
112 this.documentFilter = filter;
113 }, "javax.swing.text.DocumentFilter");
114 Clazz.defineMethod (c$, "getDocumentFilter", 
115 function () {
116 return this.documentFilter;
117 });
118 Clazz.overrideMethod (c$, "getLength", 
119 function () {
120 return this.data.length () - 1;
121 });
122 Clazz.overrideMethod (c$, "addDocumentListener", 
123 function (listener) {
124 this.listenerList.add (javax.swing.event.DocumentListener, listener);
125 }, "javax.swing.event.DocumentListener");
126 Clazz.overrideMethod (c$, "removeDocumentListener", 
127 function (listener) {
128 this.listenerList.remove (javax.swing.event.DocumentListener, listener);
129 }, "javax.swing.event.DocumentListener");
130 Clazz.defineMethod (c$, "getDocumentListeners", 
131 function () {
132 return this.listenerList.getListeners (javax.swing.event.DocumentListener);
133 });
134 Clazz.overrideMethod (c$, "addUndoableEditListener", 
135 function (listener) {
136 this.listenerList.add (javax.swing.event.UndoableEditListener, listener);
137 }, "javax.swing.event.UndoableEditListener");
138 Clazz.overrideMethod (c$, "removeUndoableEditListener", 
139 function (listener) {
140 this.listenerList.remove (javax.swing.event.UndoableEditListener, listener);
141 }, "javax.swing.event.UndoableEditListener");
142 Clazz.defineMethod (c$, "getUndoableEditListeners", 
143 function () {
144 return this.listenerList.getListeners (javax.swing.event.UndoableEditListener);
145 });
146 Clazz.overrideMethod (c$, "getProperty", 
147 function (key) {
148 return this.getDocumentProperties ().get (key);
149 }, "~O");
150 Clazz.overrideMethod (c$, "putProperty", 
151 function (key, value) {
152 if (value != null) {
153 this.getDocumentProperties ().put (key, value);
154 } else {
155 this.getDocumentProperties ().remove (key);
156 }}, "~O,~O");
157 Clazz.overrideMethod (c$, "remove", 
158 function (offs, len) {
159 var filter = this.getDocumentFilter ();
160 this.writeLock ();
161 try {
162 if (filter != null) {
163 filter.remove (this.getFilterBypass (), offs, len);
164 } else {
165 this.handleRemove (offs, len);
166 }} finally {
167 this.writeUnlock ();
168 }
169 }, "~N,~N");
170 Clazz.defineMethod (c$, "handleRemove", 
171 function (offs, len) {
172 if (len > 0) {
173 if (offs < 0 || (offs + len) > this.getLength ()) {
174 throw  new javax.swing.text.BadLocationException ("Invalid remove", this.getLength () + 1);
175 }var chng = Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.DefaultDocumentEvent, this, null, offs, len, javax.swing.event.DocumentEvent.EventType.REMOVE);
176 var isComposedTextElement = false;
177 isComposedTextElement = javax.swing.text.Utilities.isComposedTextElement (this, offs);
178 this.removeUpdate (chng);
179 var u = this.data.remove (offs, len);
180 if (u != null) {
181 chng.addEdit (u);
182 }this.postRemoveUpdate (chng);
183 chng.end ();
184 this.fireRemoveUpdate (chng);
185 if ((u != null) && !isComposedTextElement) {
186 this.fireUndoableEditUpdate ( new javax.swing.event.UndoableEditEvent (this, chng));
187 }}}, "~N,~N");
188 Clazz.overrideMethod (c$, "replace", 
189 function (offset, length, text, attrs) {
190 if (length == 0 && (text == null || text.length == 0)) {
191 return;
192 }var filter = this.getDocumentFilter ();
193 this.writeLock ();
194 try {
195 if (filter != null) {
196 filter.replace (this.getFilterBypass (), offset, length, text, attrs);
197 } else {
198 if (length > 0) {
199 this.remove (offset, length);
200 }if (text != null && text.length > 0) {
201 this.insertString (offset, text, attrs);
202 }}} finally {
203 this.writeUnlock ();
204 }
205 }, "~N,~N,~S,javax.swing.text.AttributeSet");
206 Clazz.overrideMethod (c$, "insertString", 
207 function (offs, str, a) {
208 if ((str == null) || (str.length == 0)) {
209 return;
210 }var filter = this.getDocumentFilter ();
211 this.writeLock ();
212 try {
213 if (filter != null) {
214 filter.insertString (this.getFilterBypass (), offs, str, a);
215 } else {
216 this.handleInsertString (offs, str, a);
217 }} finally {
218 this.writeUnlock ();
219 }
220 }, "~N,~S,javax.swing.text.AttributeSet");
221 Clazz.defineMethod (c$, "handleInsertString", 
222 function (offs, str, a) {
223 if ((str == null) || (str.length == 0)) {
224 return;
225 }var u = this.data.insertString (offs, str);
226 var e = Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.DefaultDocumentEvent, this, null, offs, str.length, javax.swing.event.DocumentEvent.EventType.INSERT);
227 if (u != null) {
228 e.addEdit (u);
229 }if (this.getProperty ("i18n").equals (Boolean.FALSE)) {
230 }this.insertUpdate (e, a);
231 e.end ();
232 this.fireInsertUpdate (e);
233 if (u != null && (a == null || !a.isDefined (javax.swing.text.StyleConstants.ComposedTextAttribute))) {
234 this.fireUndoableEditUpdate ( new javax.swing.event.UndoableEditEvent (this, e));
235 }}, "~N,~S,javax.swing.text.AttributeSet");
236 Clazz.defineMethod (c$, "getText", 
237 function (offset, length) {
238 if (length < 0) {
239 throw  new javax.swing.text.BadLocationException ("Length must be positive", length);
240 }var str = this.data.getString (offset, length);
241 return str;
242 }, "~N,~N");
243 Clazz.defineMethod (c$, "getText", 
244 function (offset, length, txt) {
245 if (length < 0) {
246 throw  new javax.swing.text.BadLocationException ("Length must be positive", length);
247 }this.data.getChars (offset, length, txt);
248 }, "~N,~N,javax.swing.text.Segment");
249 Clazz.overrideMethod (c$, "createPosition", 
250 function (offs) {
251 return this.data.createPosition (offs);
252 }, "~N");
253 Clazz.overrideMethod (c$, "getStartPosition", 
254 function () {
255 var p;
256 try {
257 p = this.createPosition (0);
258 } catch (bl) {
259 if (Clazz.exceptionOf (bl, javax.swing.text.BadLocationException)) {
260 p = null;
261 } else {
262 throw bl;
263 }
264 }
265 return p;
266 });
267 Clazz.overrideMethod (c$, "getEndPosition", 
268 function () {
269 var p;
270 try {
271 p = this.createPosition (this.data.length ());
272 } catch (bl) {
273 if (Clazz.exceptionOf (bl, javax.swing.text.BadLocationException)) {
274 p = null;
275 } else {
276 throw bl;
277 }
278 }
279 return p;
280 });
281 Clazz.overrideMethod (c$, "getRootElements", 
282 function () {
283 var elems =  new Array (2);
284 elems[0] = this.getDefaultRootElement ();
285 elems[1] = this.getBidiRootElement ();
286 return elems;
287 });
288 Clazz.defineMethod (c$, "getFilterBypass", 
289  function () {
290 if (this.filterBypass == null) {
291 this.filterBypass = Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.DefaultFilterBypass, this, null);
292 }return this.filterBypass;
293 });
294 Clazz.defineMethod (c$, "getBidiRootElement", 
295 function () {
296 return this.bidiRoot;
297 });
298 Clazz.defineMethod (c$, "isLeftToRight", 
299 function (p0, p1) {
300 if (!this.getProperty ("i18n").equals (Boolean.TRUE)) {
301 return true;
302 }var bidiRoot = this.getBidiRootElement ();
303 var index = bidiRoot.getElementIndex (p0);
304 var bidiElem = bidiRoot.getElement (index);
305 if (bidiElem.getEndOffset () >= p1) {
306 var bidiAttrs = bidiElem.getAttributes ();
307 return ((javax.swing.text.StyleConstants.getBidiLevel (bidiAttrs) % 2) == 0);
308 }return true;
309 }, "~N,~N");
310 Clazz.defineMethod (c$, "getAttributeContext", 
311 function () {
312 return this.context;
313 });
314 Clazz.defineMethod (c$, "insertUpdate", 
315 function (chng, attr) {
316 if (chng.type === javax.swing.event.DocumentEvent.EventType.INSERT && chng.getLength () > 0 && !Boolean.TRUE.equals (this.getProperty (javax.swing.text.AbstractDocument.MultiByteProperty))) {
317 var segment = javax.swing.text.SegmentCache.getSharedSegment ();
318 try {
319 this.getText (chng.getOffset (), chng.getLength (), segment);
320 segment.first ();
321 do {
322 if ((segment.current ()).charCodeAt (0) > 255) {
323 this.putProperty (javax.swing.text.AbstractDocument.MultiByteProperty, Boolean.TRUE);
324 break;
325 }} while (segment.next () != '\uffff');
326 } catch (ble) {
327 if (Clazz.exceptionOf (ble, javax.swing.text.BadLocationException)) {
328 } else {
329 throw ble;
330 }
331 }
332 javax.swing.text.SegmentCache.releaseSharedSegment (segment);
333 }}, "javax.swing.text.AbstractDocument.DefaultDocumentEvent,javax.swing.text.AttributeSet");
334 Clazz.defineMethod (c$, "removeUpdate", 
335 function (chng) {
336 }, "javax.swing.text.AbstractDocument.DefaultDocumentEvent");
337 Clazz.defineMethod (c$, "postRemoveUpdate", 
338 function (chng) {
339 }, "javax.swing.text.AbstractDocument.DefaultDocumentEvent");
340 Clazz.defineMethod (c$, "getContent", 
341 function () {
342 return this.data;
343 });
344 Clazz.defineMethod (c$, "createLeafElement", 
345 function (parent, a, p0, p1) {
346 return Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.LeafElement, this, null, parent, a, p0, p1);
347 }, "javax.swing.text.Element,javax.swing.text.AttributeSet,~N,~N");
348 Clazz.defineMethod (c$, "createBranchElement", 
349 function (parent, a) {
350 return Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.BranchElement, this, null, parent, a);
351 }, "javax.swing.text.Element,javax.swing.text.AttributeSet");
352 Clazz.defineMethod (c$, "writeLock", 
353 function () {
354 });
355 Clazz.defineMethod (c$, "writeUnlock", 
356 function () {
357 });
358 Clazz.defineMethod (c$, "readLock", 
359 function () {
360 });
361 Clazz.defineMethod (c$, "readUnlock", 
362 function () {
363 });
364 c$.$AbstractDocument$AbstractElement$ = function () {
365 Clazz.pu$h(self.c$);
366 c$ = Clazz.decorateAsClass (function () {
367 Clazz.prepareCallback (this, arguments);
368 this.parent = null;
369 this.attributes = null;
370 Clazz.instantialize (this, arguments);
371 }, javax.swing.text.AbstractDocument, "AbstractElement", null, [javax.swing.text.Element, javax.swing.text.MutableAttributeSet, javax.swing.tree.TreeNode]);
372 Clazz.makeConstructor (c$, 
373 function (a, b) {
374 this.parent = a;
375 this.attributes = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ().getEmptySet ();
376 if (b != null) {
377 this.addAttributes (b);
378 }}, "javax.swing.text.Element,javax.swing.text.AttributeSet");
379 Clazz.defineMethod (c$, "getAttributeCount", 
380 function () {
381 return this.attributes.getAttributeCount ();
382 });
383 Clazz.defineMethod (c$, "isDefined", 
384 function (a) {
385 return this.attributes.isDefined (a);
386 }, "~O");
387 Clazz.defineMethod (c$, "isEqual", 
388 function (a) {
389 return this.attributes.isEqual (a);
390 }, "javax.swing.text.AttributeSet");
391 Clazz.defineMethod (c$, "copyAttributes", 
392 function () {
393 return this.attributes.copyAttributes ();
394 });
395 Clazz.defineMethod (c$, "getAttribute", 
396 function (a) {
397 var b = this.attributes.getAttribute (a);
398 if (b == null) {
399 var c = (this.parent != null) ? this.parent.getAttributes () : null;
400 if (c != null) {
401 b = c.getAttribute (a);
402 }}return b;
403 }, "~O");
404 Clazz.defineMethod (c$, "getAttributeNames", 
405 function () {
406 return this.attributes.getAttributeNames ();
407 });
408 Clazz.defineMethod (c$, "containsAttribute", 
409 function (a, b) {
410 return this.attributes.containsAttribute (a, b);
411 }, "~O,~O");
412 Clazz.defineMethod (c$, "containsAttributes", 
413 function (a) {
414 return this.attributes.containsAttributes (a);
415 }, "javax.swing.text.AttributeSet");
416 Clazz.defineMethod (c$, "getResolveParent", 
417 function () {
418 var a = this.attributes.getResolveParent ();
419 if ((a == null) && (this.parent != null)) {
420 a = this.parent.getAttributes ();
421 }return a;
422 });
423 Clazz.overrideMethod (c$, "addAttribute", 
424 function (a, b) {
425 this.checkForIllegalCast ();
426 var c = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ();
427 this.attributes = c.addAttribute (this.attributes, a, b);
428 }, "~O,~O");
429 Clazz.overrideMethod (c$, "addAttributes", 
430 function (a) {
431 this.checkForIllegalCast ();
432 var b = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ();
433 this.attributes = b.addAttributes (this.attributes, a);
434 }, "javax.swing.text.AttributeSet");
435 Clazz.overrideMethod (c$, "removeAttribute", 
436 function (a) {
437 this.checkForIllegalCast ();
438 var b = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ();
439 this.attributes = b.removeAttribute (this.attributes, a);
440 }, "~O");
441 Clazz.defineMethod (c$, "removeAttributes", 
442 function (a) {
443 this.checkForIllegalCast ();
444 var b = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ();
445 this.attributes = b.removeAttributes (this.attributes, a);
446 }, "java.util.Enumeration");
447 Clazz.defineMethod (c$, "removeAttributes", 
448 function (a) {
449 this.checkForIllegalCast ();
450 var b = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ();
451 if (a === this) {
452 this.attributes = b.getEmptySet ();
453 } else {
454 this.attributes = b.removeAttributes (this.attributes, a);
455 }}, "javax.swing.text.AttributeSet");
456 Clazz.overrideMethod (c$, "setResolveParent", 
457 function (a) {
458 this.checkForIllegalCast ();
459 var b = this.b$["javax.swing.text.AbstractDocument"].getAttributeContext ();
460 if (a != null) {
461 this.attributes = b.addAttribute (this.attributes, javax.swing.text.StyleConstants.ResolveAttribute, a);
462 } else {
463 this.attributes = b.removeAttribute (this.attributes, javax.swing.text.StyleConstants.ResolveAttribute);
464 }}, "javax.swing.text.AttributeSet");
465 Clazz.defineMethod (c$, "checkForIllegalCast", 
466  function () {
467 });
468 Clazz.overrideMethod (c$, "getDocument", 
469 function () {
470 return this.b$["javax.swing.text.AbstractDocument"];
471 });
472 Clazz.overrideMethod (c$, "getParentElement", 
473 function () {
474 return this.parent;
475 });
476 Clazz.defineMethod (c$, "getAttributes", 
477 function () {
478 return this;
479 });
480 Clazz.overrideMethod (c$, "getName", 
481 function () {
482 if (this.attributes.isDefined ("$ename")) {
483 return this.attributes.getAttribute ("$ename");
484 }return null;
485 });
486 Clazz.overrideMethod (c$, "getChildAt", 
487 function (a) {
488 return this.getElement (a);
489 }, "~N");
490 Clazz.overrideMethod (c$, "getChildCount", 
491 function () {
492 return this.getElementCount ();
493 });
494 Clazz.overrideMethod (c$, "getParent", 
495 function () {
496 return this.getParentElement ();
497 });
498 Clazz.overrideMethod (c$, "getIndex", 
499 function (a) {
500 for (var b = this.getChildCount () - 1; b >= 0; b--) if (this.getChildAt (b) === a) return b;
501
502 return -1;
503 }, "javax.swing.tree.TreeNode");
504 c$ = Clazz.p0p ();
505 };
506 c$.$AbstractDocument$BranchElement$ = function () {
507 Clazz.pu$h(self.c$);
508 c$ = Clazz.decorateAsClass (function () {
509 Clazz.prepareCallback (this, arguments);
510 this.$children = null;
511 this.nchildren = 0;
512 this.lastIndex = 0;
513 Clazz.instantialize (this, arguments);
514 }, javax.swing.text.AbstractDocument, "BranchElement", javax.swing.text.AbstractDocument.AbstractElement, null, Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.AbstractElement, this, null, Clazz.inheritArgs));
515 Clazz.makeConstructor (c$, 
516 function (a, b) {
517 Clazz.superConstructor (this, javax.swing.text.AbstractDocument.BranchElement, [a, b]);
518 this.$children =  new Array (1);
519 this.nchildren = 0;
520 this.lastIndex = -1;
521 }, "javax.swing.text.Element,javax.swing.text.AttributeSet");
522 Clazz.defineMethod (c$, "positionToElement", 
523 function (a) {
524 var b = this.getElementIndex (a);
525 var c = this.$children[b];
526 var d = c.getStartOffset ();
527 var e = c.getEndOffset ();
528 if ((a >= d) && (a < e)) {
529 return c;
530 }return null;
531 }, "~N");
532 Clazz.defineMethod (c$, "replace", 
533 function (a, b, c) {
534 var d = c.length - b;
535 var e = a + b;
536 var f = this.nchildren - e;
537 var g = e + d;
538 if ((this.nchildren + d) >= this.$children.length) {
539 var h = Math.max (2 * this.$children.length, this.nchildren + d);
540 var i =  new Array (h);
541 System.arraycopy (this.$children, 0, i, 0, a);
542 System.arraycopy (c, 0, i, a, c.length);
543 System.arraycopy (this.$children, e, i, g, f);
544 this.$children = i;
545 } else {
546 System.arraycopy (this.$children, e, this.$children, g, f);
547 System.arraycopy (c, 0, this.$children, a, c.length);
548 }this.nchildren = this.nchildren + d;
549 }, "~N,~N,~A");
550 Clazz.overrideMethod (c$, "toString", 
551 function () {
552 return "BranchElement(" + this.getName () + ") " + this.getStartOffset () + "," + this.getEndOffset () + "\n";
553 });
554 Clazz.defineMethod (c$, "getName", 
555 function () {
556 var a = Clazz.superCall (this, javax.swing.text.AbstractDocument.BranchElement, "getName", []);
557 if (a == null) {
558 a = "paragraph";
559 }return a;
560 });
561 Clazz.defineMethod (c$, "getStartOffset", 
562 function () {
563 return this.$children[0].getStartOffset ();
564 });
565 Clazz.overrideMethod (c$, "getEndOffset", 
566 function () {
567 var a = (this.nchildren > 0) ? this.$children[this.nchildren - 1] : this.$children[0];
568 return a.getEndOffset ();
569 });
570 Clazz.overrideMethod (c$, "getElement", 
571 function (a) {
572 if (a < this.nchildren) {
573 return this.$children[a];
574 }return null;
575 }, "~N");
576 Clazz.overrideMethod (c$, "getElementCount", 
577 function () {
578 return this.nchildren;
579 });
580 Clazz.overrideMethod (c$, "getElementIndex", 
581 function (a) {
582 var b;
583 var c = 0;
584 var d = this.nchildren - 1;
585 var e = 0;
586 var f = this.getStartOffset ();
587 var g;
588 if (this.nchildren == 0) {
589 return 0;
590 }if (a >= this.getEndOffset ()) {
591 return this.nchildren - 1;
592 }if ((this.lastIndex >= c) && (this.lastIndex <= d)) {
593 var h = this.$children[this.lastIndex];
594 f = h.getStartOffset ();
595 g = h.getEndOffset ();
596 if ((a >= f) && (a < g)) {
597 return this.lastIndex;
598 }if (a < f) {
599 d = this.lastIndex;
600 } else {
601 c = this.lastIndex;
602 }}while (c <= d) {
603 e = c + (Clazz.doubleToInt ((d - c) / 2));
604 var h = this.$children[e];
605 f = h.getStartOffset ();
606 g = h.getEndOffset ();
607 if ((a >= f) && (a < g)) {
608 b = e;
609 this.lastIndex = b;
610 return b;
611 } else if (a < f) {
612 d = e - 1;
613 } else {
614 c = e + 1;
615 }}
616 if (a < f) {
617 b = e;
618 } else {
619 b = e + 1;
620 }this.lastIndex = b;
621 return b;
622 }, "~N");
623 Clazz.overrideMethod (c$, "isLeaf", 
624 function () {
625 return false;
626 });
627 Clazz.overrideMethod (c$, "getAllowsChildren", 
628 function () {
629 return true;
630 });
631 Clazz.overrideMethod (c$, "children", 
632 function () {
633 if (this.nchildren == 0) return null;
634 var a =  new java.util.Vector (this.nchildren);
635 for (var b = 0; b < this.nchildren; b++) a.addElement (this.$children[b]);
636
637 return a.elements ();
638 });
639 c$ = Clazz.p0p ();
640 };
641 c$.$AbstractDocument$LeafElement$ = function () {
642 Clazz.pu$h(self.c$);
643 c$ = Clazz.decorateAsClass (function () {
644 Clazz.prepareCallback (this, arguments);
645 this.p0 = null;
646 this.p1 = null;
647 Clazz.instantialize (this, arguments);
648 }, javax.swing.text.AbstractDocument, "LeafElement", javax.swing.text.AbstractDocument.AbstractElement, null, Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.AbstractElement, this, null, Clazz.inheritArgs));
649 Clazz.makeConstructor (c$, 
650 function (a, b, c, d) {
651 Clazz.superConstructor (this, javax.swing.text.AbstractDocument.LeafElement, [a, b]);
652 try {
653 this.p0 = this.b$["javax.swing.text.AbstractDocument"].createPosition (c);
654 this.p1 = this.b$["javax.swing.text.AbstractDocument"].createPosition (d);
655 } catch (e) {
656 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
657 this.p0 = null;
658 this.p1 = null;
659 throw  new javax.swing.text.StateInvariantError ("Can't create Position references");
660 } else {
661 throw e;
662 }
663 }
664 }, "javax.swing.text.Element,javax.swing.text.AttributeSet,~N,~N");
665 Clazz.overrideMethod (c$, "toString", 
666 function () {
667 return "LeafElement(" + this.getName () + ") " + this.p0 + "," + this.p1 + "\n";
668 });
669 Clazz.overrideMethod (c$, "getStartOffset", 
670 function () {
671 return this.p0.getOffset ();
672 });
673 Clazz.overrideMethod (c$, "getEndOffset", 
674 function () {
675 return this.p1.getOffset ();
676 });
677 Clazz.defineMethod (c$, "getName", 
678 function () {
679 var a = Clazz.superCall (this, javax.swing.text.AbstractDocument.LeafElement, "getName", []);
680 if (a == null) {
681 a = "content";
682 }return a;
683 });
684 Clazz.overrideMethod (c$, "getElementIndex", 
685 function (a) {
686 return -1;
687 }, "~N");
688 Clazz.overrideMethod (c$, "getElement", 
689 function (a) {
690 return null;
691 }, "~N");
692 Clazz.overrideMethod (c$, "getElementCount", 
693 function () {
694 return 0;
695 });
696 Clazz.overrideMethod (c$, "isLeaf", 
697 function () {
698 return true;
699 });
700 Clazz.overrideMethod (c$, "getAllowsChildren", 
701 function () {
702 return false;
703 });
704 Clazz.overrideMethod (c$, "children", 
705 function () {
706 return null;
707 });
708 c$ = Clazz.p0p ();
709 };
710 c$.$AbstractDocument$DefaultDocumentEvent$ = function () {
711 Clazz.pu$h(self.c$);
712 c$ = Clazz.decorateAsClass (function () {
713 Clazz.prepareCallback (this, arguments);
714 this.offset = 0;
715 this.length = 0;
716 this.changeLookup = null;
717 this.type = null;
718 Clazz.instantialize (this, arguments);
719 }, javax.swing.text.AbstractDocument, "DefaultDocumentEvent", javax.swing.undo.CompoundEdit, javax.swing.event.DocumentEvent);
720 Clazz.makeConstructor (c$, 
721 function (a, b, c) {
722 Clazz.superConstructor (this, javax.swing.text.AbstractDocument.DefaultDocumentEvent);
723 this.offset = a;
724 this.length = b;
725 this.type = c;
726 }, "~N,~N,javax.swing.event.DocumentEvent.EventType");
727 Clazz.overrideMethod (c$, "toString", 
728 function () {
729 return this.edits.toString ();
730 });
731 Clazz.defineMethod (c$, "addEdit", 
732 function (a) {
733 if ((this.changeLookup == null) && (this.edits.size () > 10)) {
734 this.changeLookup =  new java.util.Hashtable ();
735 var b = this.edits.size ();
736 for (var c = 0; c < b; c++) {
737 var d = this.edits.elementAt (c);
738 if (Clazz.instanceOf (d, javax.swing.event.DocumentEvent.ElementChange)) {
739 var e = d;
740 this.changeLookup.put (e.getElement (), e);
741 }}
742 }if ((this.changeLookup != null) && (Clazz.instanceOf (a, javax.swing.event.DocumentEvent.ElementChange))) {
743 var b = a;
744 this.changeLookup.put (b.getElement (), b);
745 }return Clazz.superCall (this, javax.swing.text.AbstractDocument.DefaultDocumentEvent, "addEdit", [a]);
746 }, "javax.swing.undo.UndoableEdit");
747 Clazz.defineMethod (c$, "redo", 
748 function () {
749 this.b$["javax.swing.text.AbstractDocument"].writeLock ();
750 try {
751 Clazz.superCall (this, javax.swing.text.AbstractDocument.DefaultDocumentEvent, "redo", []);
752 var a = Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.UndoRedoDocumentEvent, this, null, this, false);
753 if (this.type === javax.swing.event.DocumentEvent.EventType.INSERT) {
754 this.b$["javax.swing.text.AbstractDocument"].fireInsertUpdate (a);
755 } else if (this.type === javax.swing.event.DocumentEvent.EventType.REMOVE) {
756 this.b$["javax.swing.text.AbstractDocument"].fireRemoveUpdate (a);
757 } else {
758 this.b$["javax.swing.text.AbstractDocument"].fireChangedUpdate (a);
759 }} finally {
760 this.b$["javax.swing.text.AbstractDocument"].writeUnlock ();
761 }
762 });
763 Clazz.defineMethod (c$, "undo", 
764 function () {
765 this.b$["javax.swing.text.AbstractDocument"].writeLock ();
766 try {
767 Clazz.superCall (this, javax.swing.text.AbstractDocument.DefaultDocumentEvent, "undo", []);
768 var a = Clazz.innerTypeInstance (javax.swing.text.AbstractDocument.UndoRedoDocumentEvent, this, null, this, true);
769 if (this.type === javax.swing.event.DocumentEvent.EventType.REMOVE) {
770 this.b$["javax.swing.text.AbstractDocument"].fireInsertUpdate (a);
771 } else if (this.type === javax.swing.event.DocumentEvent.EventType.INSERT) {
772 this.b$["javax.swing.text.AbstractDocument"].fireRemoveUpdate (a);
773 } else {
774 this.b$["javax.swing.text.AbstractDocument"].fireChangedUpdate (a);
775 }} finally {
776 this.b$["javax.swing.text.AbstractDocument"].writeUnlock ();
777 }
778 });
779 Clazz.overrideMethod (c$, "isSignificant", 
780 function () {
781 return true;
782 });
783 Clazz.overrideMethod (c$, "getPresentationName", 
784 function () {
785 var a = this.getType ();
786 if (a === javax.swing.event.DocumentEvent.EventType.INSERT) return javax.swing.UIManager.getString ("AbstractDocument.additionText");
787 if (a === javax.swing.event.DocumentEvent.EventType.REMOVE) return javax.swing.UIManager.getString ("AbstractDocument.deletionText");
788 return javax.swing.UIManager.getString ("AbstractDocument.styleChangeText");
789 });
790 Clazz.overrideMethod (c$, "getUndoPresentationName", 
791 function () {
792 return javax.swing.UIManager.getString ("AbstractDocument.undoText") + " " + this.getPresentationName ();
793 });
794 Clazz.overrideMethod (c$, "getRedoPresentationName", 
795 function () {
796 return javax.swing.UIManager.getString ("AbstractDocument.redoText") + " " + this.getPresentationName ();
797 });
798 Clazz.overrideMethod (c$, "getType", 
799 function () {
800 return this.type;
801 });
802 Clazz.overrideMethod (c$, "getOffset", 
803 function () {
804 return this.offset;
805 });
806 Clazz.overrideMethod (c$, "getLength", 
807 function () {
808 return this.length;
809 });
810 Clazz.overrideMethod (c$, "getDocument", 
811 function () {
812 return this.b$["javax.swing.text.AbstractDocument"];
813 });
814 Clazz.overrideMethod (c$, "getChange", 
815 function (a) {
816 if (this.changeLookup != null) {
817 return this.changeLookup.get (a);
818 }var b = this.edits.size ();
819 for (var c = 0; c < b; c++) {
820 var d = this.edits.elementAt (c);
821 if (Clazz.instanceOf (d, javax.swing.event.DocumentEvent.ElementChange)) {
822 var e = d;
823 if (a.equals (e.getElement ())) {
824 return e;
825 }}}
826 return null;
827 }, "javax.swing.text.Element");
828 c$ = Clazz.p0p ();
829 };
830 c$.$AbstractDocument$UndoRedoDocumentEvent$ = function () {
831 Clazz.pu$h(self.c$);
832 c$ = Clazz.decorateAsClass (function () {
833 Clazz.prepareCallback (this, arguments);
834 this.src = null;
835 this.type = null;
836 Clazz.instantialize (this, arguments);
837 }, javax.swing.text.AbstractDocument, "UndoRedoDocumentEvent", null, javax.swing.event.DocumentEvent);
838 Clazz.makeConstructor (c$, 
839 function (a, b) {
840 this.src = a;
841 if (b) {
842 if (a.getType ().equals (javax.swing.event.DocumentEvent.EventType.INSERT)) {
843 this.type = javax.swing.event.DocumentEvent.EventType.REMOVE;
844 } else if (a.getType ().equals (javax.swing.event.DocumentEvent.EventType.REMOVE)) {
845 this.type = javax.swing.event.DocumentEvent.EventType.INSERT;
846 } else {
847 this.type = a.getType ();
848 }} else {
849 this.type = a.getType ();
850 }}, "javax.swing.text.AbstractDocument.DefaultDocumentEvent,~B");
851 Clazz.defineMethod (c$, "getSource", 
852 function () {
853 return this.src;
854 });
855 Clazz.overrideMethod (c$, "getOffset", 
856 function () {
857 return this.src.getOffset ();
858 });
859 Clazz.overrideMethod (c$, "getLength", 
860 function () {
861 return this.src.getLength ();
862 });
863 Clazz.overrideMethod (c$, "getDocument", 
864 function () {
865 return this.src.getDocument ();
866 });
867 Clazz.overrideMethod (c$, "getType", 
868 function () {
869 return this.type;
870 });
871 Clazz.overrideMethod (c$, "getChange", 
872 function (a) {
873 return this.src.getChange (a);
874 }, "javax.swing.text.Element");
875 c$ = Clazz.p0p ();
876 };
877 c$.$AbstractDocument$DefaultFilterBypass$ = function () {
878 Clazz.pu$h(self.c$);
879 c$ = Clazz.decorateAsClass (function () {
880 Clazz.prepareCallback (this, arguments);
881 Clazz.instantialize (this, arguments);
882 }, javax.swing.text.AbstractDocument, "DefaultFilterBypass", javax.swing.text.DocumentFilter.FilterBypass);
883 Clazz.overrideMethod (c$, "getDocument", 
884 function () {
885 return this.b$["javax.swing.text.AbstractDocument"];
886 });
887 Clazz.overrideMethod (c$, "remove", 
888 function (a, b) {
889 this.b$["javax.swing.text.AbstractDocument"].handleRemove (a, b);
890 }, "~N,~N");
891 Clazz.overrideMethod (c$, "insertString", 
892 function (a, b, c) {
893 this.b$["javax.swing.text.AbstractDocument"].handleInsertString (a, b, c);
894 }, "~N,~S,javax.swing.text.AttributeSet");
895 Clazz.overrideMethod (c$, "replace", 
896 function (a, b, c, d) {
897 this.b$["javax.swing.text.AbstractDocument"].handleRemove (a, b);
898 this.b$["javax.swing.text.AbstractDocument"].handleInsertString (a, c, d);
899 }, "~N,~N,~S,javax.swing.text.AttributeSet");
900 c$ = Clazz.p0p ();
901 };
902 Clazz.declareInterface (javax.swing.text.AbstractDocument, "Content");
903 Clazz.declareInterface (javax.swing.text.AbstractDocument, "AttributeContext");
904 Clazz.pu$h(self.c$);
905 c$ = Clazz.decorateAsClass (function () {
906 this.e = null;
907 this.index = 0;
908 this.removed = null;
909 this.added = null;
910 Clazz.instantialize (this, arguments);
911 }, javax.swing.text.AbstractDocument, "ElementEdit", javax.swing.undo.AbstractUndoableEdit, javax.swing.event.DocumentEvent.ElementChange);
912 Clazz.makeConstructor (c$, 
913 function (a, b, c, d) {
914 Clazz.superConstructor (this, javax.swing.text.AbstractDocument.ElementEdit);
915 this.e = a;
916 this.index = b;
917 this.removed = c;
918 this.added = d;
919 }, "javax.swing.text.Element,~N,~A,~A");
920 Clazz.overrideMethod (c$, "getElement", 
921 function () {
922 return this.e;
923 });
924 Clazz.overrideMethod (c$, "getIndex", 
925 function () {
926 return this.index;
927 });
928 Clazz.overrideMethod (c$, "getChildrenRemoved", 
929 function () {
930 return this.removed;
931 });
932 Clazz.overrideMethod (c$, "getChildrenAdded", 
933 function () {
934 return this.added;
935 });
936 Clazz.defineMethod (c$, "redo", 
937 function () {
938 Clazz.superCall (this, javax.swing.text.AbstractDocument.ElementEdit, "redo", []);
939 var a = this.removed;
940 this.removed = this.added;
941 this.added = a;
942 (this.e).replace (this.index, this.removed.length, this.added);
943 });
944 Clazz.defineMethod (c$, "undo", 
945 function () {
946 Clazz.superCall (this, javax.swing.text.AbstractDocument.ElementEdit, "undo", []);
947 (this.e).replace (this.index, this.added.length, this.removed);
948 var a = this.removed;
949 this.removed = this.added;
950 this.added = a;
951 });
952 c$ = Clazz.p0p ();
953 Clazz.defineStatics (c$,
954 "BAD_LOCATION", "document location failure",
955 "ParagraphElementName", "paragraph",
956 "ContentElementName", "content",
957 "SectionElementName", "section",
958 "BidiElementName", "bidi level",
959 "ElementNameAttribute", "$ename",
960 "I18NProperty", "i18n",
961 "MultiByteProperty", "multiByte",
962 "AsyncLoadPriority", "load priority");
963 });