Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / swingjs / j2s / javax / swing / text / JTextComponent.js
1 Clazz.declarePackage ("javax.swing.text");
2 Clazz.load (["java.awt.event.FocusListener", "$.MouseListener", "javax.swing.ActionMap", "$.InputMap", "$.JComponent", "$.Scrollable", "javax.swing.event.CaretEvent", "$.ChangeListener", "javax.swing.text.Keymap", "javax.swing.DropMode"], "javax.swing.text.JTextComponent", ["java.io.IOException", "java.lang.Boolean", "$.Character", "$.IllegalArgumentException", "java.util.HashMap", "$.Hashtable", "$.Vector", "java.awt.Point", "javax.swing.Action", "$.JViewport", "$.UIManager", "javax.swing.event.CaretListener", "javax.swing.text.DefaultEditorKit", "$.JSMinimalAbstractDocument", "jssun.awt.AppContext", "swingjs.JSToolkit"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.model = null;
5 this.caret = null;
6 this.navigationFilter = null;
7 this.highlighter = null;
8 this.keymap = null;
9 this.caretEvent = null;
10 this.caretColor = null;
11 this.selectionColor = null;
12 this.selectedTextColor = null;
13 this.disabledTextColor = null;
14 this.editable = false;
15 this.margin = null;
16 this.focusAccelerator = '\0';
17 this.dragEnabled = false;
18 this.dropMode = null;
19 this.composedTextAttribute = null;
20 this.composedTextContent = null;
21 this.composedTextStart = null;
22 this.composedTextEnd = null;
23 Clazz.instantialize (this, arguments);
24 }, javax.swing.text, "JTextComponent", javax.swing.JComponent, javax.swing.Scrollable);
25 Clazz.prepareFields (c$, function () {
26 this.dropMode = javax.swing.DropMode.USE_SELECTION;
27 });
28 Clazz.makeConstructor (c$, 
29 function () {
30 Clazz.superConstructor (this, javax.swing.text.JTextComponent);
31 this.enableEvents (2056);
32 this.caretEvent =  new javax.swing.text.JTextComponent.MutableCaretEvent (this);
33 this.addMouseListener (this.caretEvent);
34 this.addFocusListener (this.caretEvent);
35 this.setEditable (true);
36 this.setDragEnabled (false);
37 this.setLayout (null);
38 this.updateUI ();
39 });
40 Clazz.overrideMethod (c$, "getUI", 
41 function () {
42 return this.ui;
43 });
44 Clazz.overrideMethod (c$, "updateUI", 
45 function () {
46 this.setUI (javax.swing.UIManager.getUI (this));
47 this.invalidate ();
48 });
49 Clazz.defineMethod (c$, "addCaretListener", 
50 function (listener) {
51 this.listenerList.add (javax.swing.event.CaretListener, listener);
52 }, "javax.swing.event.CaretListener");
53 Clazz.defineMethod (c$, "removeCaretListener", 
54 function (listener) {
55 this.listenerList.remove (javax.swing.event.CaretListener, listener);
56 }, "javax.swing.event.CaretListener");
57 Clazz.defineMethod (c$, "getCaretListeners", 
58 function () {
59 return this.listenerList.getListeners (javax.swing.event.CaretListener);
60 });
61 Clazz.defineMethod (c$, "fireCaretUpdate", 
62 function (e) {
63 var listeners = this.listenerList.getListenerList ();
64 for (var i = listeners.length - 2; i >= 0; i -= 2) {
65 if (listeners[i] === javax.swing.event.CaretListener) {
66 (listeners[i + 1]).caretUpdate (e);
67 }}
68 }, "javax.swing.event.CaretEvent");
69 Clazz.defineMethod (c$, "setDocument", 
70 function (doc) {
71 var old = this.model;
72 try {
73 this.model = doc;
74 this.firePropertyChangeObject ("document", old, doc);
75 } finally {
76 }
77 this.revalidate ();
78 this.repaint ();
79 }, "javax.swing.text.Document");
80 Clazz.defineMethod (c$, "getDocument", 
81 function () {
82 return this.model;
83 });
84 Clazz.defineMethod (c$, "getActions", 
85 function () {
86 if (this.getUI () == null) return null;
87 return this.getUI ().getEditorKit (this).getActions ();
88 });
89 Clazz.defineMethod (c$, "setMargin", 
90 function (m) {
91 var old = this.margin;
92 this.margin = m;
93 this.firePropertyChangeObject ("margin", old, m);
94 this.invalidate ();
95 }, "java.awt.Insets");
96 Clazz.defineMethod (c$, "getMargin", 
97 function () {
98 return this.margin;
99 });
100 Clazz.defineMethod (c$, "setNavigationFilter", 
101 function (filter) {
102 this.navigationFilter = filter;
103 }, "javax.swing.text.NavigationFilter");
104 Clazz.defineMethod (c$, "getNavigationFilter", 
105 function () {
106 return this.navigationFilter;
107 });
108 Clazz.defineMethod (c$, "getCaret", 
109 function () {
110 return this.caret;
111 });
112 Clazz.defineMethod (c$, "setCaret", 
113 function (c) {
114 if (this.caret != null) {
115 this.caret.removeChangeListener (this.caretEvent);
116 this.caret.deinstall (this);
117 }var old = this.caret;
118 this.caret = c;
119 if (this.caret != null) {
120 this.caret.install (this);
121 this.caret.addChangeListener (this.caretEvent);
122 }this.firePropertyChangeObject ("caret", old, this.caret);
123 }, "javax.swing.text.Caret");
124 Clazz.defineMethod (c$, "getHighlighter", 
125 function () {
126 return this.highlighter;
127 });
128 Clazz.defineMethod (c$, "setHighlighter", 
129 function (h) {
130 if (this.highlighter != null) {
131 this.highlighter.deinstall (this);
132 }var old = this.highlighter;
133 this.highlighter = h;
134 if (this.highlighter != null) {
135 this.highlighter.install (this);
136 }this.firePropertyChangeObject ("highlighter", old, h);
137 }, "javax.swing.text.Highlighter");
138 Clazz.defineMethod (c$, "setKeymap", 
139 function (map) {
140 var old = this.keymap;
141 this.keymap = map;
142 this.firePropertyChangeObject ("keymap", old, this.keymap);
143 this.updateInputMap (old, map);
144 }, "javax.swing.text.Keymap");
145 Clazz.defineMethod (c$, "setDragEnabled", 
146 function (b) {
147 this.dragEnabled = b;
148 }, "~B");
149 Clazz.defineMethod (c$, "getDragEnabled", 
150 function () {
151 return this.dragEnabled;
152 });
153 Clazz.defineMethod (c$, "setDropMode", 
154 function (dropMode) {
155 if (dropMode != null) {
156 switch (dropMode) {
157 case javax.swing.DropMode.USE_SELECTION:
158 case javax.swing.DropMode.INSERT:
159 this.dropMode = dropMode;
160 return;
161 }
162 }throw  new IllegalArgumentException (dropMode + ": Unsupported drop mode for text");
163 }, "javax.swing.DropMode");
164 Clazz.defineMethod (c$, "getDropMode", 
165 function () {
166 return this.dropMode;
167 });
168 Clazz.defineMethod (c$, "updateInputMap", 
169 function (oldKm, newKm) {
170 var km = this.getInputMap (0);
171 var last = km;
172 while (km != null && !(Clazz.instanceOf (km, javax.swing.text.JTextComponent.KeymapWrapper))) {
173 last = km;
174 km = km.getParent ();
175 }
176 if (km != null) {
177 if (newKm == null) {
178 if (last !== km) {
179 last.setParent (km.getParent ());
180 } else {
181 last.setParent (null);
182 }} else {
183 var newKM =  new javax.swing.text.JTextComponent.KeymapWrapper (newKm);
184 last.setParent (newKM);
185 if (last !== km) {
186 newKM.setParent (km.getParent ());
187 }}} else if (newKm != null) {
188 km = this.getInputMap (0);
189 if (km != null) {
190 var newKM =  new javax.swing.text.JTextComponent.KeymapWrapper (newKm);
191 newKM.setParent (km.getParent ());
192 km.setParent (newKM);
193 }}var am = this.getActionMap ();
194 var lastAM = am;
195 while (am != null && !(Clazz.instanceOf (am, javax.swing.text.JTextComponent.KeymapActionMap))) {
196 lastAM = am;
197 am = am.getParent ();
198 }
199 if (am != null) {
200 if (newKm == null) {
201 if (lastAM !== am) {
202 lastAM.setParent (am.getParent ());
203 } else {
204 lastAM.setParent (null);
205 }} else {
206 var newAM =  new javax.swing.text.JTextComponent.KeymapActionMap (newKm);
207 lastAM.setParent (newAM);
208 if (lastAM !== am) {
209 newAM.setParent (am.getParent ());
210 }}} else if (newKm != null) {
211 am = this.getActionMap ();
212 if (am != null) {
213 var newAM =  new javax.swing.text.JTextComponent.KeymapActionMap (newKm);
214 newAM.setParent (am.getParent ());
215 am.setParent (newAM);
216 }}}, "javax.swing.text.Keymap,javax.swing.text.Keymap");
217 Clazz.defineMethod (c$, "getKeymap", 
218 function () {
219 return this.keymap;
220 });
221 c$.addKeymap = Clazz.defineMethod (c$, "addKeymap", 
222 function (nm, parent) {
223 var map =  new javax.swing.text.JTextComponent.DefaultKeymap (nm, parent);
224 if (nm != null) {
225 javax.swing.text.JTextComponent.getKeymapTable ().put (nm, map);
226 }return map;
227 }, "~S,javax.swing.text.Keymap");
228 c$.removeKeymap = Clazz.defineMethod (c$, "removeKeymap", 
229 function (nm) {
230 return javax.swing.text.JTextComponent.getKeymapTable ().remove (nm);
231 }, "~S");
232 c$.getKeymap = Clazz.defineMethod (c$, "getKeymap", 
233 function (nm) {
234 return javax.swing.text.JTextComponent.getKeymapTable ().get (nm);
235 }, "~S");
236 c$.getKeymapTable = Clazz.defineMethod (c$, "getKeymapTable", 
237  function () {
238 {
239 var appContext = jssun.awt.AppContext.getAppContext ();
240 var keymapTable = appContext.get (javax.swing.text.JTextComponent.KEYMAP_TABLE);
241 if (keymapTable == null) {
242 keymapTable =  new java.util.HashMap (17);
243 appContext.put (javax.swing.text.JTextComponent.KEYMAP_TABLE, keymapTable);
244 var binding = javax.swing.text.JTextComponent.addKeymap ("default", null);
245 binding.setDefaultAction ( new javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction ());
246 }return keymapTable;
247 }});
248 c$.loadKeymap = Clazz.defineMethod (c$, "loadKeymap", 
249 function (map, bindings, actions) {
250 var h =  new java.util.Hashtable ();
251 for (var i = 0; i < actions.length; i++) {
252 var a = actions[i];
253 var value = a.getValue ("Name");
254 h.put ((value != null ? value : ""), a);
255 }
256 for (var i = 0; i < bindings.length; i++) {
257 var a = h.get (bindings[i].actionName);
258 if (a != null) {
259 map.addActionForKeyStroke (bindings[i].key, a);
260 }}
261 }, "javax.swing.text.Keymap,~A,~A");
262 Clazz.defineMethod (c$, "getCaretColor", 
263 function () {
264 return this.caretColor;
265 });
266 Clazz.defineMethod (c$, "setCaretColor", 
267 function (c) {
268 var old = this.caretColor;
269 this.caretColor = c;
270 this.firePropertyChangeObject ("caretColor", old, this.caretColor);
271 }, "java.awt.Color");
272 Clazz.defineMethod (c$, "getSelectionColor", 
273 function () {
274 return this.selectionColor;
275 });
276 Clazz.defineMethod (c$, "setSelectionColor", 
277 function (c) {
278 var old = this.selectionColor;
279 this.selectionColor = c;
280 this.firePropertyChangeObject ("selectionColor", old, this.selectionColor);
281 }, "java.awt.Color");
282 Clazz.defineMethod (c$, "getSelectedTextColor", 
283 function () {
284 return this.selectedTextColor;
285 });
286 Clazz.defineMethod (c$, "setSelectedTextColor", 
287 function (c) {
288 var old = this.selectedTextColor;
289 this.selectedTextColor = c;
290 this.firePropertyChangeObject ("selectedTextColor", old, this.selectedTextColor);
291 }, "java.awt.Color");
292 Clazz.defineMethod (c$, "getDisabledTextColor", 
293 function () {
294 return this.disabledTextColor;
295 });
296 Clazz.defineMethod (c$, "setDisabledTextColor", 
297 function (c) {
298 var old = this.disabledTextColor;
299 this.disabledTextColor = c;
300 this.firePropertyChangeObject ("disabledTextColor", old, this.disabledTextColor);
301 }, "java.awt.Color");
302 Clazz.defineMethod (c$, "replaceSelection", 
303 function (content) {
304 var doc = this.getDocument ();
305 if (doc != null) {
306 try {
307 var composedTextSaved = this.saveComposedText (this.caret.getDot ());
308 var p0 = Math.min (this.caret.getDot (), this.caret.getMark ());
309 var p1 = Math.max (this.caret.getDot (), this.caret.getMark ());
310 if (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument)) {
311 (doc).replace (p0, p1 - p0, content, null);
312 } else {
313 if (p0 != p1) {
314 doc.remove (p0, p1 - p0);
315 }if (content != null && content.length > 0) {
316 doc.insertString (p0, content, null);
317 }}if (composedTextSaved) {
318 this.restoreComposedText ();
319 }} catch (e) {
320 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
321 swingjs.JSToolkit.alert ("SWINGJS BAD LOCATION EXCEPTION (replace):" + e.getMessage () + swingjs.JSToolkit.getStackTrace (-10));
322 } else {
323 throw e;
324 }
325 }
326 }}, "~S");
327 Clazz.defineMethod (c$, "getText", 
328 function (offs, len) {
329 return this.getDocument ().getText (offs, len);
330 }, "~N,~N");
331 Clazz.defineMethod (c$, "modelToView", 
332 function (pos) {
333 return this.getUI ().modelToView (this, pos);
334 }, "~N");
335 Clazz.defineMethod (c$, "viewToModel", 
336 function (pt) {
337 return this.getUI ().viewToModel (this, pt);
338 }, "java.awt.Point");
339 Clazz.defineMethod (c$, "cut", 
340 function () {
341 });
342 Clazz.defineMethod (c$, "copy", 
343 function () {
344 });
345 Clazz.defineMethod (c$, "paste", 
346 function () {
347 });
348 Clazz.defineMethod (c$, "moveCaretPosition", 
349 function (pos) {
350 var doc = this.getDocument ();
351 if (doc != null) {
352 if (pos > doc.getLength () || pos < 0) {
353 throw  new IllegalArgumentException ("bad position: " + pos);
354 }this.caret.moveDot (pos);
355 }}, "~N");
356 Clazz.defineMethod (c$, "setFocusAccelerator", 
357 function (aKey) {
358 aKey = Character.toUpperCase (aKey);
359 var old = this.focusAccelerator;
360 this.focusAccelerator = aKey;
361 this.firePropertyChange ("focusAcceleratorKey", old, this.focusAccelerator);
362 this.firePropertyChange ("focusAccelerator", old, this.focusAccelerator);
363 }, "~S");
364 Clazz.defineMethod (c$, "getFocusAccelerator", 
365 function () {
366 return this.focusAccelerator;
367 });
368 Clazz.defineMethod (c$, "read", 
369 function ($in, desc) {
370 var kit = this.getUI ().getEditorKit (this);
371 var doc = kit.createDefaultDocument ();
372 if (desc != null) {
373 doc.putProperty ("stream", desc);
374 }try {
375 kit.read ($in, doc, 0);
376 this.setDocument (doc);
377 } catch (e) {
378 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
379 throw  new java.io.IOException (e.getMessage ());
380 } else {
381 throw e;
382 }
383 }
384 }, "java.io.Reader,~O");
385 Clazz.defineMethod (c$, "write", 
386 function (out) {
387 var doc = this.getDocument ();
388 try {
389 this.getUI ().getEditorKit (this).write (out, doc, 0, doc.getLength ());
390 } catch (e) {
391 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
392 throw  new java.io.IOException (e.getMessage ());
393 } else {
394 throw e;
395 }
396 }
397 }, "java.io.Writer");
398 Clazz.defineMethod (c$, "removeNotify", 
399 function () {
400 Clazz.superCall (this, javax.swing.text.JTextComponent, "removeNotify", []);
401 if (javax.swing.text.JTextComponent.getFocusedComponent () === this) {
402 jssun.awt.AppContext.getAppContext ().remove (javax.swing.text.JTextComponent.FOCUSED_COMPONENT);
403 }});
404 Clazz.defineMethod (c$, "setCaretPosition", 
405 function (position) {
406 var doc = this.getDocument ();
407 if (doc != null) {
408 if (position > doc.getLength () || position < 0) {
409 throw  new IllegalArgumentException ("bad position: " + position);
410 }this.caret.setDot (position);
411 }}, "~N");
412 Clazz.defineMethod (c$, "getCaretPosition", 
413 function () {
414 return this.caret.getDot ();
415 });
416 Clazz.defineMethod (c$, "setText", 
417 function (t) {
418 try {
419 var doc = this.getDocument ();
420 if (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument)) {
421 (doc).replace (0, doc.getLength (), t, null);
422 } else {
423 doc.remove (0, doc.getLength ());
424 doc.insertString (0, t, null);
425 }} catch (e) {
426 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
427 swingjs.JSToolkit.alert ("SWINGJS BAD LOCATION EXCEPTION (setText):" + e.getMessage () + swingjs.JSToolkit.getStackTrace (-10));
428 } else {
429 throw e;
430 }
431 }
432 }, "~S");
433 Clazz.defineMethod (c$, "getText", 
434 function () {
435 var doc = this.getDocument ();
436 var txt;
437 try {
438 txt = doc.getText (0, doc.getLength ());
439 } catch (e) {
440 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
441 txt = null;
442 } else {
443 throw e;
444 }
445 }
446 return txt;
447 });
448 Clazz.defineMethod (c$, "getSelectedText", 
449 function () {
450 var txt = null;
451 var p0 = Math.min (this.caret.getDot (), this.caret.getMark ());
452 var p1 = Math.max (this.caret.getDot (), this.caret.getMark ());
453 if (p0 != p1) {
454 try {
455 var doc = this.getDocument ();
456 txt = doc.getText (p0, p1 - p0);
457 } catch (e) {
458 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
459 throw  new IllegalArgumentException (e.getMessage ());
460 } else {
461 throw e;
462 }
463 }
464 }return txt;
465 });
466 Clazz.defineMethod (c$, "isEditable", 
467 function () {
468 return this.editable;
469 });
470 Clazz.defineMethod (c$, "setEditable", 
471 function (b) {
472 if (b != this.editable) {
473 var oldVal = this.editable;
474 this.editable = b;
475 this.firePropertyChangeObject ("editable", Boolean.$valueOf (oldVal), Boolean.$valueOf (this.editable));
476 this.repaint ();
477 }}, "~B");
478 Clazz.defineMethod (c$, "getSelectionStart", 
479 function () {
480 var start = Math.min (this.caret.getDot (), this.caret.getMark ());
481 return start;
482 });
483 Clazz.defineMethod (c$, "setSelectionStart", 
484 function (selectionStart) {
485 this.select (selectionStart, this.getSelectionEnd ());
486 }, "~N");
487 Clazz.defineMethod (c$, "getSelectionEnd", 
488 function () {
489 var end = Math.max (this.caret.getDot (), this.caret.getMark ());
490 return end;
491 });
492 Clazz.defineMethod (c$, "setSelectionEnd", 
493 function (selectionEnd) {
494 this.select (this.getSelectionStart (), selectionEnd);
495 }, "~N");
496 Clazz.defineMethod (c$, "select", 
497 function (selectionStart, selectionEnd) {
498 var docLength = this.getDocument ().getLength ();
499 if (selectionStart < 0) {
500 selectionStart = 0;
501 }if (selectionStart > docLength) {
502 selectionStart = docLength;
503 }if (selectionEnd > docLength) {
504 selectionEnd = docLength;
505 }if (selectionEnd < selectionStart) {
506 selectionEnd = selectionStart;
507 }this.setCaretPosition (selectionStart);
508 this.moveCaretPosition (selectionEnd);
509 }, "~N,~N");
510 Clazz.defineMethod (c$, "selectAll", 
511 function () {
512 var doc = this.getDocument ();
513 if (doc != null) {
514 this.setCaretPosition (0);
515 this.moveCaretPosition (doc.getLength ());
516 }});
517 Clazz.defineMethod (c$, "getToolTipText", 
518 function (event) {
519 var retValue = Clazz.superCall (this, javax.swing.text.JTextComponent, "getToolTipText", [event]);
520 if (retValue == null) {
521 var ui = this.getUI ();
522 if (ui != null) {
523 retValue = ui.getToolTipText (this,  new java.awt.Point (event.getX (), event.getY ()));
524 }}return retValue;
525 }, "java.awt.event.MouseEvent");
526 Clazz.overrideMethod (c$, "getPreferredScrollableViewportSize", 
527 function () {
528 return this.getPreferredSize ();
529 });
530 Clazz.overrideMethod (c$, "getScrollableUnitIncrement", 
531 function (visibleRect, orientation, direction) {
532 switch (orientation) {
533 case 1:
534 return Clazz.doubleToInt (visibleRect.height / 10);
535 case 0:
536 return Clazz.doubleToInt (visibleRect.width / 10);
537 default:
538 throw  new IllegalArgumentException ("Invalid orientation: " + orientation);
539 }
540 }, "java.awt.Rectangle,~N,~N");
541 Clazz.overrideMethod (c$, "getScrollableBlockIncrement", 
542 function (visibleRect, orientation, direction) {
543 switch (orientation) {
544 case 1:
545 return visibleRect.height;
546 case 0:
547 return visibleRect.width;
548 default:
549 throw  new IllegalArgumentException ("Invalid orientation: " + orientation);
550 }
551 }, "java.awt.Rectangle,~N,~N");
552 Clazz.overrideMethod (c$, "getScrollableTracksViewportWidth", 
553 function () {
554 if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
555 return ((this.getParent ()).getWidth () > this.getPreferredSize ().width);
556 }return false;
557 });
558 Clazz.overrideMethod (c$, "getScrollableTracksViewportHeight", 
559 function () {
560 if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
561 return ((this.getParent ()).getHeight () > this.getPreferredSize ().height);
562 }return false;
563 });
564 Clazz.defineMethod (c$, "paramString", 
565 function () {
566 var editableString = (this.editable ? "true" : "false");
567 var caretColorString = (this.caretColor != null ? this.caretColor.toString () : "");
568 var selectionColorString = (this.selectionColor != null ? this.selectionColor.toString () : "");
569 var selectedTextColorString = (this.selectedTextColor != null ? this.selectedTextColor.toString () : "");
570 var disabledTextColorString = (this.disabledTextColor != null ? this.disabledTextColor.toString () : "");
571 var marginString = (this.margin != null ? this.margin.toString () : "");
572 return Clazz.superCall (this, javax.swing.text.JTextComponent, "paramString", []) + ",caretColor=" + caretColorString + ",disabledTextColor=" + disabledTextColorString + ",editable=" + editableString + ",margin=" + marginString + ",selectedTextColor=" + selectedTextColorString + ",selectionColor=" + selectionColorString;
573 });
574 c$.getFocusedComponent = Clazz.defineMethod (c$, "getFocusedComponent", 
575 function () {
576 return jssun.awt.AppContext.getAppContext ().get (javax.swing.text.JTextComponent.FOCUSED_COMPONENT);
577 });
578 Clazz.defineMethod (c$, "addInputMethodListener", 
579 function (l) {
580 Clazz.superCall (this, javax.swing.text.JTextComponent, "addInputMethodListener", [l]);
581 if (l != null) {
582 }}, "java.awt.event.InputMethodListener");
583 Clazz.defineMethod (c$, "saveComposedText", 
584  function (pos) {
585 if (this.composedTextExists ()) {
586 var start = this.composedTextStart.getOffset ();
587 var len = this.composedTextEnd.getOffset () - this.composedTextStart.getOffset ();
588 if (pos >= start && pos <= start + len) {
589 try {
590 this.getDocument ().remove (start, len);
591 return true;
592 } catch (ble) {
593 if (Clazz.exceptionOf (ble, javax.swing.text.BadLocationException)) {
594 } else {
595 throw ble;
596 }
597 }
598 }}return false;
599 }, "~N");
600 Clazz.defineMethod (c$, "restoreComposedText", 
601  function () {
602 var doc = this.getDocument ();
603 try {
604 doc.insertString (this.caret.getDot (), this.composedTextContent, this.composedTextAttribute);
605 this.composedTextStart = doc.createPosition (this.caret.getDot () - this.composedTextContent.length);
606 this.composedTextEnd = doc.createPosition (this.caret.getDot ());
607 } catch (ble) {
608 if (Clazz.exceptionOf (ble, javax.swing.text.BadLocationException)) {
609 } else {
610 throw ble;
611 }
612 }
613 });
614 Clazz.defineMethod (c$, "composedTextExists", 
615 function () {
616 return (this.composedTextStart != null);
617 });
618 Clazz.pu$h(self.c$);
619 c$ = Clazz.decorateAsClass (function () {
620 this.key = null;
621 this.actionName = null;
622 Clazz.instantialize (this, arguments);
623 }, javax.swing.text.JTextComponent, "KeyBinding");
624 Clazz.makeConstructor (c$, 
625 function (a, b) {
626 this.key = a;
627 this.actionName = b;
628 }, "javax.swing.KeyStroke,~S");
629 c$ = Clazz.p0p ();
630 Clazz.pu$h(self.c$);
631 c$ = Clazz.decorateAsClass (function () {
632 this.nm = null;
633 this.parent = null;
634 this.bindings = null;
635 this.defaultAction = null;
636 Clazz.instantialize (this, arguments);
637 }, javax.swing.text.JTextComponent, "DefaultKeymap", null, javax.swing.text.Keymap);
638 Clazz.makeConstructor (c$, 
639 function (a, b) {
640 this.nm = a;
641 this.parent = b;
642 this.bindings =  new java.util.Hashtable ();
643 }, "~S,javax.swing.text.Keymap");
644 Clazz.defineMethod (c$, "getDefaultAction", 
645 function () {
646 if (this.defaultAction != null) {
647 return this.defaultAction;
648 }return (this.parent != null) ? this.parent.getDefaultAction () : null;
649 });
650 Clazz.overrideMethod (c$, "setDefaultAction", 
651 function (a) {
652 this.defaultAction = a;
653 }, "javax.swing.Action");
654 Clazz.overrideMethod (c$, "getName", 
655 function () {
656 return this.nm;
657 });
658 Clazz.defineMethod (c$, "getAction", 
659 function (a) {
660 var b = this.bindings.get (a);
661 if ((b == null) && (this.parent != null)) {
662 b = this.parent.getAction (a);
663 }return b;
664 }, "javax.swing.KeyStroke");
665 Clazz.overrideMethod (c$, "getBoundKeyStrokes", 
666 function () {
667 var a =  new Array (this.bindings.size ());
668 var b = 0;
669 for (var c = this.bindings.keys (); c.hasMoreElements (); ) {
670 a[b++] = c.nextElement ();
671 }
672 return a;
673 });
674 Clazz.overrideMethod (c$, "getBoundActions", 
675 function () {
676 var a =  new Array (this.bindings.size ());
677 var b = 0;
678 for (var c = this.bindings.elements (); c.hasMoreElements (); ) {
679 a[b++] = c.nextElement ();
680 }
681 return a;
682 });
683 Clazz.defineMethod (c$, "getKeyStrokesForAction", 
684 function (a) {
685 if (a == null) {
686 return null;
687 }var b = null;
688 var c = null;
689 for (var d = this.bindings.keys (); d.hasMoreElements (); ) {
690 var e = d.nextElement ();
691 if (this.bindings.get (e) === a) {
692 if (c == null) {
693 c =  new java.util.Vector ();
694 }c.addElement (e);
695 }}
696 if (this.parent != null) {
697 var e = this.parent.getKeyStrokesForAction (a);
698 if (e != null) {
699 var f = 0;
700 for (var g = e.length - 1; g >= 0; g--) {
701 if (this.isLocallyDefined (e[g])) {
702 e[g] = null;
703 f++;
704 }}
705 if (f > 0 && f < e.length) {
706 if (c == null) {
707 c =  new java.util.Vector ();
708 }for (var h = e.length - 1; h >= 0; h--) {
709 if (e[h] != null) {
710 c.addElement (e[h]);
711 }}
712 } else if (f == 0) {
713 if (c == null) {
714 b = e;
715 } else {
716 b =  new Array (c.size () + e.length);
717 c.copyInto (b);
718 System.arraycopy (e, 0, b, c.size (), e.length);
719 c = null;
720 }}}}if (c != null) {
721 b =  new Array (c.size ());
722 c.copyInto (b);
723 }return b;
724 }, "javax.swing.Action");
725 Clazz.overrideMethod (c$, "isLocallyDefined", 
726 function (a) {
727 return this.bindings.containsKey (a);
728 }, "javax.swing.KeyStroke");
729 Clazz.overrideMethod (c$, "addActionForKeyStroke", 
730 function (a, b) {
731 this.bindings.put (a, b);
732 }, "javax.swing.KeyStroke,javax.swing.Action");
733 Clazz.overrideMethod (c$, "removeKeyStrokeBinding", 
734 function (a) {
735 this.bindings.remove (a);
736 }, "javax.swing.KeyStroke");
737 Clazz.overrideMethod (c$, "removeBindings", 
738 function () {
739 this.bindings.clear ();
740 });
741 Clazz.overrideMethod (c$, "getResolveParent", 
742 function () {
743 return this.parent;
744 });
745 Clazz.overrideMethod (c$, "setResolveParent", 
746 function (a) {
747 this.parent = a;
748 }, "javax.swing.text.Keymap");
749 Clazz.overrideMethod (c$, "toString", 
750 function () {
751 return "Keymap[" + this.nm + "]" + this.bindings;
752 });
753 c$ = Clazz.p0p ();
754 Clazz.pu$h(self.c$);
755 c$ = Clazz.decorateAsClass (function () {
756 this.keymap = null;
757 Clazz.instantialize (this, arguments);
758 }, javax.swing.text.JTextComponent, "KeymapWrapper", javax.swing.InputMap);
759 Clazz.makeConstructor (c$, 
760 function (a) {
761 Clazz.superConstructor (this, javax.swing.text.JTextComponent.KeymapWrapper, []);
762 this.keymap = a;
763 }, "javax.swing.text.Keymap");
764 Clazz.defineMethod (c$, "keys", 
765 function () {
766 var a = Clazz.superCall (this, javax.swing.text.JTextComponent.KeymapWrapper, "keys", []);
767 var b = this.keymap.getBoundKeyStrokes ();
768 var c = (a == null) ? 0 : a.length;
769 var d = (b == null) ? 0 : b.length;
770 if (c == 0) {
771 return b;
772 }if (d == 0) {
773 return a;
774 }var e =  new Array (c + d);
775 System.arraycopy (a, 0, e, 0, c);
776 System.arraycopy (b, 0, e, c, d);
777 return e;
778 });
779 Clazz.defineMethod (c$, "size", 
780 function () {
781 var a = this.keymap.getBoundKeyStrokes ();
782 var b = (a == null) ? 0 : a.length;
783 return Clazz.superCall (this, javax.swing.text.JTextComponent.KeymapWrapper, "size", []) + b;
784 });
785 Clazz.defineMethod (c$, "get", 
786 function (a) {
787 var b = this.keymap.getAction (a);
788 if (b == null) {
789 b = Clazz.superCall (this, javax.swing.text.JTextComponent.KeymapWrapper, "get", [a]);
790 if (b == null && a.getKeyChar () != '\uffff' && this.keymap.getDefaultAction () != null) {
791 b = javax.swing.text.JTextComponent.KeymapWrapper.DefaultActionKey;
792 }}return b;
793 }, "javax.swing.KeyStroke");
794 c$.DefaultActionKey = c$.prototype.DefaultActionKey =  new Clazz._O ();
795 c$ = Clazz.p0p ();
796 Clazz.pu$h(self.c$);
797 c$ = Clazz.decorateAsClass (function () {
798 this.keymap = null;
799 Clazz.instantialize (this, arguments);
800 }, javax.swing.text.JTextComponent, "KeymapActionMap", javax.swing.ActionMap);
801 Clazz.makeConstructor (c$, 
802 function (a) {
803 Clazz.superConstructor (this, javax.swing.text.JTextComponent.KeymapActionMap, []);
804 this.keymap = a;
805 }, "javax.swing.text.Keymap");
806 Clazz.defineMethod (c$, "keys", 
807 function () {
808 var a = Clazz.superCall (this, javax.swing.text.JTextComponent.KeymapActionMap, "keys", []);
809 var b = this.keymap.getBoundActions ();
810 var c = (a == null) ? 0 : a.length;
811 var d = (b == null) ? 0 : b.length;
812 var e = (this.keymap.getDefaultAction () != null);
813 if (e) {
814 d++;
815 }if (c == 0) {
816 if (e) {
817 var f =  new Array (d);
818 if (d > 1) {
819 System.arraycopy (b, 0, f, 0, d - 1);
820 }f[d - 1] = javax.swing.text.JTextComponent.KeymapWrapper.DefaultActionKey;
821 return f;
822 }return b;
823 }if (d == 0) {
824 return a;
825 }var f =  new Array (c + d);
826 System.arraycopy (a, 0, f, 0, c);
827 if (e) {
828 if (d > 1) {
829 System.arraycopy (b, 0, f, c, d - 1);
830 }f[c + d - 1] = javax.swing.text.JTextComponent.KeymapWrapper.DefaultActionKey;
831 } else {
832 System.arraycopy (b, 0, f, c, d);
833 }return f;
834 });
835 Clazz.defineMethod (c$, "size", 
836 function () {
837 var a = this.keymap.getBoundActions ();
838 var b = (a == null) ? 0 : a.length;
839 if (this.keymap.getDefaultAction () != null) {
840 b++;
841 }return Clazz.superCall (this, javax.swing.text.JTextComponent.KeymapActionMap, "size", []) + b;
842 });
843 Clazz.defineMethod (c$, "get", 
844 function (a) {
845 var b = Clazz.superCall (this, javax.swing.text.JTextComponent.KeymapActionMap, "get", [a]);
846 if (b == null) {
847 if (a === javax.swing.text.JTextComponent.KeymapWrapper.DefaultActionKey) {
848 b = this.keymap.getDefaultAction ();
849 } else if (Clazz.instanceOf (a, javax.swing.Action)) {
850 b = a;
851 }}return b;
852 }, "~O");
853 c$ = Clazz.p0p ();
854 Clazz.pu$h(self.c$);
855 c$ = Clazz.decorateAsClass (function () {
856 this.dragActive = false;
857 this.dot = 0;
858 this.mark = 0;
859 Clazz.instantialize (this, arguments);
860 }, javax.swing.text.JTextComponent, "MutableCaretEvent", javax.swing.event.CaretEvent, [javax.swing.event.ChangeListener, java.awt.event.FocusListener, java.awt.event.MouseListener]);
861 Clazz.defineMethod (c$, "fire", 
862 function () {
863 var a = this.getSource ();
864 if (a != null) {
865 var b = a.getCaret ();
866 if (b != null) {
867 this.dot = b.getDot ();
868 this.mark = b.getMark ();
869 a.fireCaretUpdate (this);
870 }}});
871 Clazz.overrideMethod (c$, "toString", 
872 function () {
873 return "dot=" + this.dot + "," + "mark=" + this.mark;
874 });
875 Clazz.overrideMethod (c$, "getDot", 
876 function () {
877 return this.dot;
878 });
879 Clazz.overrideMethod (c$, "getMark", 
880 function () {
881 return this.mark;
882 });
883 Clazz.overrideMethod (c$, "stateChanged", 
884 function (a) {
885 if (!this.dragActive) {
886 this.fire ();
887 }}, "javax.swing.event.ChangeEvent");
888 Clazz.overrideMethod (c$, "focusGained", 
889 function (a) {
890 jssun.awt.AppContext.getAppContext ().put (javax.swing.text.JTextComponent.FOCUSED_COMPONENT, a.getSource ());
891 }, "java.awt.event.FocusEvent");
892 Clazz.overrideMethod (c$, "focusLost", 
893 function (a) {
894 }, "java.awt.event.FocusEvent");
895 Clazz.overrideMethod (c$, "mousePressed", 
896 function (a) {
897 this.dragActive = true;
898 }, "java.awt.event.MouseEvent");
899 Clazz.overrideMethod (c$, "mouseReleased", 
900 function (a) {
901 this.dragActive = false;
902 this.fire ();
903 }, "java.awt.event.MouseEvent");
904 Clazz.overrideMethod (c$, "mouseClicked", 
905 function (a) {
906 }, "java.awt.event.MouseEvent");
907 Clazz.overrideMethod (c$, "mouseEntered", 
908 function (a) {
909 }, "java.awt.event.MouseEvent");
910 Clazz.overrideMethod (c$, "mouseExited", 
911 function (a) {
912 }, "java.awt.event.MouseEvent");
913 c$ = Clazz.p0p ();
914 Clazz.defineStatics (c$,
915 "FOCUS_ACCELERATOR_KEY", "focusAcceleratorKey");
916 c$.KEYMAP_TABLE = c$.prototype.KEYMAP_TABLE =  new Clazz._O ();
917 c$.FOCUSED_COMPONENT = c$.prototype.FOCUSED_COMPONENT =  new Clazz._O ();
918 Clazz.defineStatics (c$,
919 "DEFAULT_KEYMAP", "default");
920 });