698131b5aa9a93906d5ddbdc305ba2631ca6f01c
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JEditorPane.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.io.FilterInputStream", "java.lang.Thread", "javax.swing.text.CompositeView", "$.DefaultEditorKit", "$.JTextComponent", "$.ParagraphView", "$.ViewFactory", "java.lang.Error", "java.util.HashMap", "javax.swing.JTextArea"], "javax.swing.JEditorPane", ["java.io.BufferedInputStream", "$.DataOutputStream", "$.IOException", "$.InputStreamReader", "$.StringReader", "java.lang.Boolean", "$.RuntimeException", "java.net.HttpURLConnection", "$.URL", "java.util.Hashtable", "java.awt.Dimension", "$.Rectangle", "javax.swing.JViewport", "$.SwingUtilities", "$.UIManager", "javax.swing.event.HyperlinkListener", "javax.swing.text.BoxView", "$.JSMinimalAbstractDocument", "$.WrappedPlainView", "swingjs.api.Interface"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 if (!Clazz.isClassDefined ("javax.swing.JEditorPane.PageLoader")) {
5 javax.swing.JEditorPane.$JEditorPane$PageLoader$ ();
6 }
7 this.loading = null;
8 this.kit = null;
9 this.isUserSetEditorKit = false;
10 this.pageProperties = null;
11 this.typeHandlers = null;
12 Clazz.instantialize (this, arguments);
13 }, javax.swing, "JEditorPane", javax.swing.text.JTextComponent);
14 Clazz.makeConstructor (c$, 
15 function (initialPage) {
16 this.construct ();
17 this.setPage (initialPage);
18 }, "java.net.URL");
19 Clazz.makeConstructor (c$, 
20 function (url) {
21 this.construct ();
22 this.setPage (url);
23 }, "~S");
24 Clazz.makeConstructor (c$, 
25 function (type, text) {
26 this.construct ();
27 this.setContentType (type);
28 this.setText (text);
29 }, "~S,~S");
30 Clazz.defineMethod (c$, "addHyperlinkListener", 
31 function (listener) {
32 this.listenerList.add (javax.swing.event.HyperlinkListener, listener);
33 }, "javax.swing.event.HyperlinkListener");
34 Clazz.defineMethod (c$, "removeHyperlinkListener", 
35 function (listener) {
36 this.listenerList.remove (javax.swing.event.HyperlinkListener, listener);
37 }, "javax.swing.event.HyperlinkListener");
38 Clazz.defineMethod (c$, "getHyperlinkListeners", 
39 function () {
40 return this.listenerList.getListeners (javax.swing.event.HyperlinkListener);
41 });
42 Clazz.defineMethod (c$, "fireHyperlinkUpdate", 
43 function (e) {
44 var listeners = this.listenerList.getListenerList ();
45 for (var i = listeners.length - 2; i >= 0; i -= 2) {
46 if (listeners[i] === javax.swing.event.HyperlinkListener) {
47 (listeners[i + 1]).hyperlinkUpdate (e);
48 }}
49 }, "javax.swing.event.HyperlinkEvent");
50 Clazz.defineMethod (c$, "setPage", 
51 function (page) {
52 if (page == null) {
53 throw  new java.io.IOException ("invalid url");
54 }var loaded = this.getPage ();
55 if (!page.equals (loaded) && page.getRef () == null) {
56 this.scrollRectToVisible ( new java.awt.Rectangle (0, 0, 1, 1));
57 }var reloaded = false;
58 var postData = this.getPostData ();
59 if ((loaded == null) || !loaded.sameFile (page) || (postData != null)) {
60 var p = this.getAsynchronousLoadPriority (this.getDocument ());
61 if ((postData == null) || (p < 0)) {
62 var $in = this.getStream (page);
63 if (this.kit != null) {
64 var doc = this.initializeModel (this.kit, page);
65 {
66 if (this.loading != null) {
67 this.loading.cancel ();
68 this.loading = null;
69 }}p = this.getAsynchronousLoadPriority (doc);
70 if (p >= 0) {
71 this.setDocument (doc);
72 {
73 this.loading =  new javax.swing.JEditorPane.PageStream ($in);
74 var pl = Clazz.innerTypeInstance (javax.swing.JEditorPane.PageLoader, this, null, doc, this.loading, p, loaded, page);
75 pl.start ();
76 }return;
77 }this.read ($in, doc);
78 this.setDocument (doc);
79 reloaded = true;
80 }} else {
81 var pl = Clazz.innerTypeInstance (javax.swing.JEditorPane.PageLoader, this, null, null, null, p, loaded, page);
82 pl.start ();
83 return;
84 }}var reference = page.getRef ();
85 if (reference != null) {
86 if (!reloaded) {
87 this.scrollToReference (reference);
88 } else {
89 javax.swing.SwingUtilities.invokeLater (((Clazz.isClassDefined ("javax.swing.JEditorPane$1") ? 0 : javax.swing.JEditorPane.$JEditorPane$1$ ()), Clazz.innerTypeInstance (javax.swing.JEditorPane$1, this, Clazz.cloneFinals ("reference", reference))));
90 }this.getDocument ().putProperty ("stream", page);
91 }this.firePropertyChangeObject ("page", loaded, page);
92 }, "java.net.URL");
93 Clazz.defineMethod (c$, "initializeModel", 
94  function (kit, page) {
95 var doc = kit.createDefaultDocument ();
96 if (this.pageProperties != null) {
97 for (var e = this.pageProperties.keys (); e.hasMoreElements (); ) {
98 var key = e.nextElement ();
99 doc.putProperty (key, this.pageProperties.get (key));
100 }
101 this.pageProperties.clear ();
102 }if (doc.getProperty ("stream") == null) {
103 doc.putProperty ("stream", page);
104 }return doc;
105 }, "javax.swing.text.EditorKit,java.net.URL");
106 Clazz.defineMethod (c$, "getAsynchronousLoadPriority", 
107  function (doc) {
108 return (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument) ? (doc).getAsynchronousLoadPriority () : -1);
109 }, "javax.swing.text.Document");
110 Clazz.defineMethod (c$, "read", 
111 function ($in, desc) {
112 var charset = this.getClientProperty ("charset");
113 var r = (charset != null) ?  new java.io.InputStreamReader ($in, charset) :  new java.io.InputStreamReader ($in);
114 Clazz.superCall (this, javax.swing.JEditorPane, "read", [r, desc]);
115 }, "java.io.InputStream,~O");
116 Clazz.defineMethod (c$, "read", 
117 function ($in, doc) {
118 if (!Boolean.TRUE.equals (doc.getProperty ("IgnoreCharsetDirective"))) {
119 var READ_LIMIT = 10240;
120 $in =  new java.io.BufferedInputStream ($in, 10240);
121 $in.mark (10240);
122 }try {
123 var charset = this.getClientProperty ("charset");
124 var r = (charset != null) ?  new java.io.InputStreamReader ($in, charset) :  new java.io.InputStreamReader ($in);
125 this.kit.read (r, doc, 0);
126 } catch (e$$) {
127 if (Clazz.exceptionOf (e$$, javax.swing.text.BadLocationException)) {
128 var e = e$$;
129 {
130 throw  new java.io.IOException (e.getMessage ());
131 }
132 } else if (Clazz.exceptionOf (e$$, javax.swing.text.ChangedCharSetException)) {
133 var changedCharSetException = e$$;
134 {
135 var charSetSpec = changedCharSetException.getCharSetSpec ();
136 if (changedCharSetException.keyEqualsCharSet ()) {
137 this.putClientProperty ("charset", charSetSpec);
138 } else {
139 this.setCharsetFromContentTypeParameters (charSetSpec);
140 }try {
141 $in.reset ();
142 } catch (exception) {
143 if (Clazz.exceptionOf (exception, java.io.IOException)) {
144 $in.close ();
145 var url = doc.getProperty ("stream");
146 if (url != null) {
147 var conn = url.openConnection ();
148 $in = conn.getInputStream ();
149 } else {
150 throw changedCharSetException;
151 }} else {
152 throw exception;
153 }
154 }
155 try {
156 doc.remove (0, doc.getLength ());
157 } catch (e) {
158 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
159 } else {
160 throw e;
161 }
162 }
163 doc.putProperty ("IgnoreCharsetDirective", Boolean.$valueOf (true));
164 this.read ($in, doc);
165 }
166 } else {
167 throw e$$;
168 }
169 }
170 }, "java.io.InputStream,javax.swing.text.Document");
171 Clazz.defineMethod (c$, "getStream", 
172 function (page) {
173 var conn = page.openConnection ();
174 if (Clazz.instanceOf (conn, java.net.HttpURLConnection)) {
175 var hconn = conn;
176 hconn.setInstanceFollowRedirects (false);
177 var postData = this.getPostData ();
178 if (postData != null) {
179 this.handlePostData (hconn, postData);
180 }var response = hconn.getResponseCode ();
181 var redirect = (response >= 300 && response <= 399);
182 if (redirect) {
183 var loc = conn.getHeaderField ("Location");
184 if (loc.startsWith ("http", 0)) {
185 page =  new java.net.URL (loc);
186 } else {
187 page =  new java.net.URL (page, loc);
188 }return this.getStream (page);
189 }}if (javax.swing.SwingUtilities.isEventDispatchThread ()) {
190 this.handleConnectionProperties (conn);
191 } else {
192 try {
193 javax.swing.SwingUtilities.invokeAndWait (((Clazz.isClassDefined ("javax.swing.JEditorPane$2") ? 0 : javax.swing.JEditorPane.$JEditorPane$2$ ()), Clazz.innerTypeInstance (javax.swing.JEditorPane$2, this, Clazz.cloneFinals ("conn", conn))));
194 } catch (e$$) {
195 if (Clazz.exceptionOf (e$$, InterruptedException)) {
196 var e = e$$;
197 {
198 throw  new RuntimeException (e);
199 }
200 } else if (Clazz.exceptionOf (e$$, java.lang.reflect.InvocationTargetException)) {
201 var e = e$$;
202 {
203 throw  new RuntimeException (e);
204 }
205 } else {
206 throw e$$;
207 }
208 }
209 }return conn.getInputStream ();
210 }, "java.net.URL");
211 Clazz.defineMethod (c$, "handleConnectionProperties", 
212  function (conn) {
213 if (this.pageProperties == null) {
214 this.pageProperties =  new java.util.Hashtable ();
215 }var type = conn.getContentType ();
216 if (type != null) {
217 this.setContentType (type);
218 this.pageProperties.put ("content-type", type);
219 }this.pageProperties.put ("stream", conn.getURL ());
220 var enc = conn.getContentEncoding ();
221 if (enc != null) {
222 this.pageProperties.put ("content-encoding", enc);
223 }}, "java.net.URLConnection");
224 Clazz.defineMethod (c$, "getPostData", 
225  function () {
226 return this.getDocument ().getProperty ("javax.swing.JEditorPane.postdata");
227 });
228 Clazz.defineMethod (c$, "handlePostData", 
229  function (conn, postData) {
230 conn.setDoOutput (true);
231 var os = null;
232 try {
233 conn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
234 os =  new java.io.DataOutputStream (conn.getOutputStream ());
235 os.writeBytes (postData);
236 } finally {
237 if (os != null) {
238 os.close ();
239 }}
240 }, "java.net.HttpURLConnection,~O");
241 Clazz.defineMethod (c$, "scrollToReference", 
242 function (reference) {
243 }, "~S");
244 Clazz.defineMethod (c$, "getPage", 
245 function () {
246 return this.getDocument ().getProperty ("stream");
247 });
248 Clazz.defineMethod (c$, "setPage", 
249 function (url) {
250 if (url == null) {
251 throw  new java.io.IOException ("invalid url");
252 }var page =  new java.net.URL (url);
253 this.setPage (page);
254 }, "~S");
255 Clazz.overrideMethod (c$, "getUIClassID", 
256 function () {
257 return "EditorPaneUI";
258 });
259 Clazz.defineMethod (c$, "createDefaultEditorKit", 
260 function () {
261 return  new javax.swing.JEditorPane.PlainEditorKit ();
262 });
263 Clazz.defineMethod (c$, "getEditorKit", 
264 function () {
265 if (this.kit == null) {
266 this.kit = this.createDefaultEditorKit ();
267 this.isUserSetEditorKit = false;
268 }return this.kit;
269 });
270 Clazz.defineMethod (c$, "getContentType", 
271 function () {
272 return (this.kit != null) ? this.kit.getContentType () : null;
273 });
274 Clazz.defineMethod (c$, "setContentType", 
275 function (type) {
276 var parm = type.indexOf (";");
277 if (parm > -1) {
278 var paramList = type.substring (parm);
279 type = type.substring (0, parm).trim ();
280 if (type.toLowerCase ().startsWith ("text/")) {
281 this.setCharsetFromContentTypeParameters (paramList);
282 }}if ((this.kit == null) || (!type.equals (this.kit.getContentType ())) || !this.isUserSetEditorKit) {
283 var k = this.getEditorKitForContentType (type);
284 if (k != null && k !== this.kit) {
285 this.setEditorKit (k);
286 this.isUserSetEditorKit = false;
287 }}}, "~S");
288 Clazz.defineMethod (c$, "setCharsetFromContentTypeParameters", 
289  function (paramlist) {
290 var charset = null;
291 try {
292 var semi = paramlist.indexOf (';');
293 if (semi > -1 && semi < paramlist.length - 1) {
294 paramlist = paramlist.substring (semi + 1);
295 }if (paramlist.length > 0) {
296 var hdrParser =  new javax.swing.JEditorPane.HeaderParser (paramlist);
297 charset = hdrParser.findValue ("charset");
298 if (charset != null) {
299 this.putClientProperty ("charset", charset);
300 }}} catch (e$$) {
301 if (Clazz.exceptionOf (e$$, IndexOutOfBoundsException)) {
302 var e = e$$;
303 {
304 }
305 } else if (Clazz.exceptionOf (e$$, NullPointerException)) {
306 var e = e$$;
307 {
308 }
309 } else if (Clazz.exceptionOf (e$$, Exception)) {
310 var e = e$$;
311 {
312 System.err.println ("JEditorPane.getCharsetFromContentTypeParameters failed on: " + paramlist);
313 e.printStackTrace ();
314 }
315 } else {
316 throw e$$;
317 }
318 }
319 }, "~S");
320 Clazz.defineMethod (c$, "setEditorKit", 
321 function (kit) {
322 var old = this.kit;
323 this.isUserSetEditorKit = true;
324 if (old != null) {
325 old.deinstall (this);
326 }this.kit = kit;
327 if (this.kit != null) {
328 this.kit.install (this);
329 this.setDocument (this.kit.createDefaultDocument ());
330 }this.firePropertyChangeObject ("editorKit", old, kit);
331 }, "javax.swing.text.EditorKit");
332 Clazz.defineMethod (c$, "getEditorKitForContentType", 
333 function (type) {
334 if (this.typeHandlers == null) {
335 this.typeHandlers =  new java.util.Hashtable (3);
336 }var k = this.typeHandlers.get (type);
337 if (k == null) {
338 k = javax.swing.JEditorPane.createEditorKitForContentType (type);
339 if (k != null) {
340 this.setEditorKitForContentType (type, k);
341 }}if (k == null) {
342 k = this.createDefaultEditorKit ();
343 }return k;
344 }, "~S");
345 Clazz.defineMethod (c$, "setEditorKitForContentType", 
346 function (type, k) {
347 if (this.typeHandlers == null) {
348 this.typeHandlers =  new java.util.Hashtable (3);
349 }this.typeHandlers.put (type, k);
350 }, "~S,javax.swing.text.EditorKit");
351 Clazz.defineMethod (c$, "replaceSelection", 
352 function (content) {
353 if (!this.isEditable ()) {
354 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this);
355 return;
356 }var kit = this.getEditorKit ();
357 if (Clazz.instanceOf (kit, javax.swing.text.StyledEditorKit)) {
358 try {
359 var doc = this.getDocument ();
360 var caret = this.getCaret ();
361 var p0 = Math.min (caret.getDot (), caret.getMark ());
362 var p1 = Math.max (caret.getDot (), caret.getMark ());
363 if (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument)) {
364 (doc).replace (p0, p1 - p0, content, (kit).getInputAttributes ());
365 } else {
366 if (p0 != p1) {
367 doc.remove (p0, p1 - p0);
368 }if (content != null && content.length > 0) {
369 doc.insertString (p0, content, (kit).getInputAttributes ());
370 }}} catch (e) {
371 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
372 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this);
373 } else {
374 throw e;
375 }
376 }
377 } else {
378 Clazz.superCall (this, javax.swing.JEditorPane, "replaceSelection", [content]);
379 }}, "~S");
380 c$.createEditorKitForContentType = Clazz.defineMethod (c$, "createEditorKitForContentType", 
381 function (type) {
382 var k = null;
383 var kitRegistry = javax.swing.JEditorPane.getKitRegisty ();
384 k = kitRegistry.get (type);
385 if (k == null) {
386 var classname = javax.swing.JEditorPane.getKitTypeRegistry ().get (type);
387 try {
388 k = swingjs.api.Interface.getInstance (classname, false);
389 kitRegistry.put (type, k);
390 } catch (e) {
391 k = null;
392 }
393 }if (k != null) {
394 return k.clone ();
395 }return null;
396 }, "~S");
397 c$.registerEditorKitForContentType = Clazz.defineMethod (c$, "registerEditorKitForContentType", 
398 function (type, classname) {
399 javax.swing.JEditorPane.registerEditorKitForContentType (type, classname, null);
400 }, "~S,~S");
401 c$.registerEditorKitForContentType = Clazz.defineMethod (c$, "registerEditorKitForContentType", 
402 function (type, classname, loader) {
403 javax.swing.JEditorPane.getKitTypeRegistry ().put (type, classname);
404 javax.swing.JEditorPane.getKitRegisty ().remove (type);
405 }, "~S,~S,ClassLoader");
406 c$.getEditorKitClassNameForContentType = Clazz.defineMethod (c$, "getEditorKitClassNameForContentType", 
407 function (type) {
408 return javax.swing.JEditorPane.getKitTypeRegistry ().get (type);
409 }, "~S");
410 c$.getKitTypeRegistry = Clazz.defineMethod (c$, "getKitTypeRegistry", 
411  function () {
412 javax.swing.JEditorPane.loadDefaultKitsIfNecessary ();
413 return javax.swing.SwingUtilities.appContextGet (javax.swing.JEditorPane.kitTypeRegistryKey);
414 });
415 c$.getKitRegisty = Clazz.defineMethod (c$, "getKitRegisty", 
416  function () {
417 var ht = javax.swing.SwingUtilities.appContextGet (javax.swing.JEditorPane.kitRegistryKey);
418 if (ht == null) {
419 ht =  new java.util.Hashtable (3);
420 javax.swing.SwingUtilities.appContextPut (javax.swing.JEditorPane.kitRegistryKey, ht);
421 }return ht;
422 });
423 c$.loadDefaultKitsIfNecessary = Clazz.defineMethod (c$, "loadDefaultKitsIfNecessary", 
424  function () {
425 if (javax.swing.SwingUtilities.appContextGet (javax.swing.JEditorPane.kitTypeRegistryKey) == null) {
426 {
427 if (javax.swing.JEditorPane.defaultEditorKitMap.size () == 0) {
428 javax.swing.JEditorPane.defaultEditorKitMap.put ("text/plain", "javax.swing.JEditorPane$PlainEditorKit");
429 javax.swing.JEditorPane.defaultEditorKitMap.put ("text/html", "javax.swing.text.html.HTMLEditorKit");
430 javax.swing.JEditorPane.defaultEditorKitMap.put ("text/rtf", "javax.swing.text.rtf.RTFEditorKit");
431 javax.swing.JEditorPane.defaultEditorKitMap.put ("application/rtf", "javax.swing.text.rtf.RTFEditorKit");
432 }}var ht =  new java.util.Hashtable ();
433 javax.swing.SwingUtilities.appContextPut (javax.swing.JEditorPane.kitTypeRegistryKey, ht);
434 ht =  new java.util.Hashtable ();
435 javax.swing.SwingUtilities.appContextPut (javax.swing.JEditorPane.kitLoaderRegistryKey, ht);
436 for (var key, $key = javax.swing.JEditorPane.defaultEditorKitMap.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) {
437 javax.swing.JEditorPane.registerEditorKitForContentType (key, javax.swing.JEditorPane.defaultEditorKitMap.get (key));
438 }
439 }});
440 Clazz.overrideMethod (c$, "getPreferredSize", 
441 function () {
442 var d = this.getPrefSizeJComp ();
443 if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
444 var port = this.getParent ();
445 var ui = this.getUI ();
446 var prefWidth = d.width;
447 var prefHeight = d.height;
448 if (!this.getScrollableTracksViewportWidth ()) {
449 var w = port.getWidth ();
450 var min = ui.getMinimumSize (this);
451 if (w != 0 && w < min.width) {
452 prefWidth = min.width;
453 }}if (!this.getScrollableTracksViewportHeight ()) {
454 var h = port.getHeight ();
455 var min = ui.getMinimumSize (this);
456 if (h != 0 && h < min.height) {
457 prefHeight = min.height;
458 }}if (prefWidth != d.width || prefHeight != d.height) {
459 d =  new java.awt.Dimension (prefWidth, prefHeight);
460 }}return d;
461 });
462 Clazz.overrideMethod (c$, "setText", 
463 function (t) {
464 try {
465 var doc = this.getDocument ();
466 doc.remove (0, doc.getLength ());
467 if (t == null || t.equals ("")) {
468 return;
469 }var r =  new java.io.StringReader (t);
470 var kit = this.getEditorKit ();
471 kit.read (r, doc, 0);
472 } catch (e$$) {
473 if (Clazz.exceptionOf (e$$, java.io.IOException)) {
474 var ioe = e$$;
475 {
476 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this);
477 }
478 } else if (Clazz.exceptionOf (e$$, javax.swing.text.BadLocationException)) {
479 var ble = e$$;
480 {
481 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this);
482 }
483 } else {
484 throw e$$;
485 }
486 }
487 }, "~S");
488 Clazz.defineMethod (c$, "getText", 
489 function () {
490 var doc = this.getDocument ();
491 try {
492 return doc.getText (0, doc.getLength ());
493 } catch (e) {
494 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
495 return null;
496 } else {
497 throw e;
498 }
499 }
500 });
501 Clazz.overrideMethod (c$, "getScrollableTracksViewportWidth", 
502 function () {
503 if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
504 var port = this.getParent ();
505 var ui = this.getUI ();
506 var w = port.getWidth ();
507 var min = ui.getMinimumSize (this);
508 var max = ui.getMaximumSize (this);
509 if ((w >= min.width) && (w <= max.width)) {
510 return true;
511 }}return false;
512 });
513 Clazz.overrideMethod (c$, "getScrollableTracksViewportHeight", 
514 function () {
515 if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
516 var port = this.getParent ();
517 var ui = this.getUI ();
518 var h = port.getHeight ();
519 var min = ui.getMinimumSize (this);
520 if (h >= min.height) {
521 var max = ui.getMaximumSize (this);
522 if (h <= max.height) {
523 return true;
524 }}}return false;
525 });
526 Clazz.defineMethod (c$, "paramString", 
527 function () {
528 var kitString = (this.kit != null ? this.kit.toString () : "");
529 var typeHandlersString = (this.typeHandlers != null ? this.typeHandlers.toString () : "");
530 return Clazz.superCall (this, javax.swing.JEditorPane, "paramString", []) + ",kit=" + kitString + ",typeHandlers=" + typeHandlersString;
531 });
532 c$.$JEditorPane$PageLoader$ = function () {
533 Clazz.pu$h(self.c$);
534 c$ = Clazz.decorateAsClass (function () {
535 Clazz.prepareCallback (this, arguments);
536 this.pageLoaded = false;
537 this.$in = null;
538 this.old = null;
539 this.page = null;
540 this.doc = null;
541 Clazz.instantialize (this, arguments);
542 }, javax.swing.JEditorPane, "PageLoader", Thread);
543 Clazz.makeConstructor (c$, 
544 function (a, b, c, d, e) {
545 Clazz.superConstructor (this, javax.swing.JEditorPane.PageLoader, []);
546 this.setPriority (c);
547 this.$in = b;
548 this.old = d;
549 this.page = e;
550 this.doc = a;
551 }, "javax.swing.text.Document,java.io.InputStream,~N,java.net.URL,java.net.URL");
552 Clazz.overrideMethod (c$, "run", 
553 function () {
554 try {
555 if (this.$in == null) {
556 this.$in = this.b$["javax.swing.JEditorPane"].getStream (this.page);
557 if (this.b$["javax.swing.JEditorPane"].kit == null) {
558 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this.b$["javax.swing.JEditorPane"]);
559 return;
560 }{
561 this.$in = this.b$["javax.swing.JEditorPane"].loading =  new javax.swing.JEditorPane.PageStream (this.$in);
562 }}if (this.doc == null) {
563 try {
564 javax.swing.SwingUtilities.invokeAndWait (((Clazz.isClassDefined ("javax.swing.JEditorPane$PageLoader$2") ? 0 : javax.swing.JEditorPane.PageLoader.$JEditorPane$PageLoader$2$ ()), Clazz.innerTypeInstance (javax.swing.JEditorPane$PageLoader$2, this, null)));
565 } catch (e$$) {
566 if (Clazz.exceptionOf (e$$, java.lang.reflect.InvocationTargetException)) {
567 var ex = e$$;
568 {
569 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this.b$["javax.swing.JEditorPane"]);
570 return;
571 }
572 } else if (Clazz.exceptionOf (e$$, InterruptedException)) {
573 var ex = e$$;
574 {
575 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this.b$["javax.swing.JEditorPane"]);
576 return;
577 }
578 } else {
579 throw e$$;
580 }
581 }
582 }this.b$["javax.swing.JEditorPane"].read (this.$in, this.doc);
583 var a = this.doc.getProperty ("stream");
584 var b = a.getRef ();
585 if (b != null) {
586 var c = ((Clazz.isClassDefined ("javax.swing.JEditorPane$PageLoader$3") ? 0 : javax.swing.JEditorPane.PageLoader.$JEditorPane$PageLoader$3$ ()), Clazz.innerTypeInstance (javax.swing.JEditorPane$PageLoader$3, this, null));
587 javax.swing.SwingUtilities.invokeLater (c);
588 }this.pageLoaded = true;
589 } catch (ioe) {
590 if (Clazz.exceptionOf (ioe, java.io.IOException)) {
591 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this.b$["javax.swing.JEditorPane"]);
592 } else {
593 throw ioe;
594 }
595 } finally {
596 {
597 this.b$["javax.swing.JEditorPane"].loading = null;
598 }javax.swing.SwingUtilities.invokeLater (((Clazz.isClassDefined ("javax.swing.JEditorPane$PageLoader$1") ? 0 : javax.swing.JEditorPane.PageLoader.$JEditorPane$PageLoader$1$ ()), Clazz.innerTypeInstance (javax.swing.JEditorPane$PageLoader$1, this, null)));
599 }
600 });
601 c$.$JEditorPane$PageLoader$2$ = function () {
602 Clazz.pu$h(self.c$);
603 c$ = Clazz.declareAnonymous (javax.swing, "JEditorPane$PageLoader$2", null, Runnable);
604 Clazz.overrideMethod (c$, "run", 
605 function () {
606 this.b$["javax.swing.JEditorPane.PageLoader"].doc = this.b$["javax.swing.JEditorPane"].initializeModel (this.b$["javax.swing.JEditorPane"].kit, this.b$["javax.swing.JEditorPane.PageLoader"].page);
607 this.b$["javax.swing.JEditorPane"].setDocument (this.b$["javax.swing.JEditorPane.PageLoader"].doc);
608 });
609 c$ = Clazz.p0p ();
610 };
611 c$.$JEditorPane$PageLoader$3$ = function () {
612 Clazz.pu$h(self.c$);
613 c$ = Clazz.declareAnonymous (javax.swing, "JEditorPane$PageLoader$3", null, Runnable);
614 Clazz.overrideMethod (c$, "run", 
615 function () {
616 var a = this.b$["javax.swing.JEditorPane"].getDocument ().getProperty ("stream");
617 var b = a.getRef ();
618 this.b$["javax.swing.JEditorPane"].scrollToReference (b);
619 });
620 c$ = Clazz.p0p ();
621 };
622 c$.$JEditorPane$PageLoader$1$ = function () {
623 Clazz.pu$h(self.c$);
624 c$ = Clazz.declareAnonymous (javax.swing, "JEditorPane$PageLoader$1", null, Runnable);
625 Clazz.overrideMethod (c$, "run", 
626 function () {
627 if (this.b$["javax.swing.JEditorPane.PageLoader"].pageLoaded) {
628 this.b$["javax.swing.JEditorPane"].firePropertyChangeObject ("page", this.b$["javax.swing.JEditorPane.PageLoader"].old, this.b$["javax.swing.JEditorPane.PageLoader"].page);
629 }});
630 c$ = Clazz.p0p ();
631 };
632 c$ = Clazz.p0p ();
633 };
634 c$.$JEditorPane$1$ = function () {
635 Clazz.pu$h(self.c$);
636 c$ = Clazz.declareAnonymous (javax.swing, "JEditorPane$1", null, Runnable);
637 Clazz.overrideMethod (c$, "run", 
638 function () {
639 this.b$["javax.swing.JEditorPane"].scrollToReference (this.f$.reference);
640 });
641 c$ = Clazz.p0p ();
642 };
643 c$.$JEditorPane$2$ = function () {
644 Clazz.pu$h(self.c$);
645 c$ = Clazz.declareAnonymous (javax.swing, "JEditorPane$2", null, Runnable);
646 Clazz.overrideMethod (c$, "run", 
647 function () {
648 this.b$["javax.swing.JEditorPane"].handleConnectionProperties (this.f$.conn);
649 });
650 c$ = Clazz.p0p ();
651 };
652 Clazz.pu$h(self.c$);
653 c$ = Clazz.decorateAsClass (function () {
654 this.canceled = false;
655 Clazz.instantialize (this, arguments);
656 }, javax.swing.JEditorPane, "PageStream", java.io.FilterInputStream);
657 Clazz.makeConstructor (c$, 
658 function (a) {
659 Clazz.superConstructor (this, javax.swing.JEditorPane.PageStream, [a]);
660 this.canceled = false;
661 }, "java.io.InputStream");
662 Clazz.defineMethod (c$, "cancel", 
663 function () {
664 this.canceled = true;
665 });
666 Clazz.defineMethod (c$, "checkCanceled", 
667 function () {
668 if (this.canceled) {
669 throw  new java.io.IOException ("page canceled");
670 }});
671 Clazz.defineMethod (c$, "read", 
672 function () {
673 this.checkCanceled ();
674 return Clazz.superCall (this, javax.swing.JEditorPane.PageStream, "read", []);
675 });
676 Clazz.defineMethod (c$, "skip", 
677 function (a) {
678 this.checkCanceled ();
679 return Clazz.superCall (this, javax.swing.JEditorPane.PageStream, "skip", [a]);
680 }, "~N");
681 Clazz.defineMethod (c$, "available", 
682 function () {
683 this.checkCanceled ();
684 return Clazz.superCall (this, javax.swing.JEditorPane.PageStream, "available", []);
685 });
686 Clazz.defineMethod (c$, "reset", 
687 function () {
688 this.checkCanceled ();
689 Clazz.superCall (this, javax.swing.JEditorPane.PageStream, "reset", []);
690 });
691 c$ = Clazz.p0p ();
692 Clazz.pu$h(self.c$);
693 c$ = Clazz.declareType (javax.swing.JEditorPane, "PlainEditorKit", javax.swing.text.DefaultEditorKit, javax.swing.text.ViewFactory);
694 Clazz.overrideMethod (c$, "getViewFactory", 
695 function () {
696 return this;
697 });
698 Clazz.overrideMethod (c$, "create", 
699 function (a) {
700 return  new javax.swing.text.WrappedPlainView (a);
701 }, "javax.swing.text.Element");
702 Clazz.defineMethod (c$, "createI18N", 
703 function (a) {
704 var b = a.getName ();
705 if (b != null) {
706 if (b.equals ("content")) {
707 return  new javax.swing.JEditorPane.PlainEditorKit.PlainParagraph (a);
708 } else if (b.equals ("paragraph")) {
709 return  new javax.swing.text.BoxView (a, 1);
710 }}return null;
711 }, "javax.swing.text.Element");
712 Clazz.pu$h(self.c$);
713 c$ = Clazz.declareType (javax.swing.JEditorPane.PlainEditorKit, "PlainParagraph", javax.swing.text.ParagraphView);
714 Clazz.makeConstructor (c$, 
715 function (a) {
716 Clazz.superConstructor (this, javax.swing.JEditorPane.PlainEditorKit.PlainParagraph, [a]);
717 this.layoutPool =  new javax.swing.JEditorPane.PlainEditorKit.PlainParagraph.LogicalView (a);
718 this.layoutPool.setParent (this);
719 }, "javax.swing.text.Element");
720 Clazz.overrideMethod (c$, "setPropertiesFromAttributes", 
721 function () {
722 var a = this.getContainer ();
723 if ((a != null) && (!a.getComponentOrientation ().isLeftToRight ())) {
724 this.setJustification (2);
725 } else {
726 this.setJustification (0);
727 }});
728 Clazz.defineMethod (c$, "getFlowSpan", 
729 function (a) {
730 var b = this.getContainer ();
731 if (Clazz.instanceOf (b, javax.swing.JTextArea)) {
732 var c = b;
733 if (!c.getLineWrap ()) {
734 return 2147483647;
735 }}return Clazz.superCall (this, javax.swing.JEditorPane.PlainEditorKit.PlainParagraph, "getFlowSpan", [a]);
736 }, "~N");
737 Clazz.defineMethod (c$, "calculateMinorAxisRequirements", 
738 function (a, b) {
739 var c = Clazz.superCall (this, javax.swing.JEditorPane.PlainEditorKit.PlainParagraph, "calculateMinorAxisRequirements", [a, b]);
740 var d = this.getContainer ();
741 if (Clazz.instanceOf (d, javax.swing.JTextArea)) {
742 var e = d;
743 if (!e.getLineWrap ()) {
744 c.minimum = c.preferred;
745 }}return c;
746 }, "~N,javax.swing.SizeRequirements");
747 Clazz.pu$h(self.c$);
748 c$ = Clazz.declareType (javax.swing.JEditorPane.PlainEditorKit.PlainParagraph, "LogicalView", javax.swing.text.CompositeView);
749 Clazz.overrideMethod (c$, "getViewIndexAtPosition", 
750 function (a) {
751 var b = this.getElement ();
752 if (b.getElementCount () > 0) {
753 return b.getElementIndex (a);
754 }return 0;
755 }, "~N");
756 Clazz.overrideMethod (c$, "updateChildren", 
757 function (a, b, c) {
758 return false;
759 }, "javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,javax.swing.text.ViewFactory");
760 Clazz.overrideMethod (c$, "loadChildren", 
761 function (a) {
762 }, "javax.swing.text.ViewFactory");
763 Clazz.defineMethod (c$, "getPreferredSpan", 
764 function (a) {
765 if (this.getViewCount () != 1) throw  new Error ("One child view is assumed.");
766 var b = this.getView (0);
767 return b.getPreferredSpan (a);
768 }, "~N");
769 Clazz.defineMethod (c$, "forwardUpdateToView", 
770 function (a, b, c, d) {
771 a.setParent (this);
772 Clazz.superCall (this, javax.swing.JEditorPane.PlainEditorKit.PlainParagraph.LogicalView, "forwardUpdateToView", [a, b, c, d]);
773 }, "javax.swing.text.View,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
774 Clazz.overrideMethod (c$, "paint", 
775 function (a, b) {
776 }, "java.awt.Graphics,java.awt.Shape");
777 Clazz.overrideMethod (c$, "isBefore", 
778 function (a, b, c) {
779 return false;
780 }, "~N,~N,java.awt.Rectangle");
781 Clazz.overrideMethod (c$, "isAfter", 
782 function (a, b, c) {
783 return false;
784 }, "~N,~N,java.awt.Rectangle");
785 Clazz.overrideMethod (c$, "getViewAtPoint", 
786 function (a, b, c) {
787 return null;
788 }, "~N,~N,java.awt.Rectangle");
789 Clazz.overrideMethod (c$, "childAllocation", 
790 function (a, b) {
791 }, "~N,java.awt.Rectangle");
792 c$ = Clazz.p0p ();
793 c$ = Clazz.p0p ();
794 c$ = Clazz.p0p ();
795 Clazz.pu$h(self.c$);
796 c$ = Clazz.decorateAsClass (function () {
797 this.raw = null;
798 this.tab = null;
799 Clazz.instantialize (this, arguments);
800 }, javax.swing.JEditorPane, "HeaderParser");
801 Clazz.makeConstructor (c$, 
802 function (a) {
803 this.raw = a;
804 this.tab =  Clazz.newArray (10, 2, null);
805 this.parse ();
806 }, "~S");
807 Clazz.defineMethod (c$, "parse", 
808  function () {
809 if (this.raw != null) {
810 this.raw = this.raw.trim ();
811 var a = this.raw.toCharArray ();
812 var b = 0;
813 var c = 0;
814 var d = 0;
815 var e = true;
816 var f = false;
817 var g = a.length;
818 while (c < g) {
819 var h = a[c];
820 if (h == '=') {
821 this.tab[d][0] =  String.instantialize (a, b, c - b).toLowerCase ();
822 e = false;
823 c++;
824 b = c;
825 } else if (h == '\"') {
826 if (f) {
827 this.tab[d++][1] =  String.instantialize (a, b, c - b);
828 f = false;
829 do {
830 c++;
831 } while (c < g && (a[c] == ' ' || a[c] == ','));
832 e = true;
833 b = c;
834 } else {
835 f = true;
836 c++;
837 b = c;
838 }} else if (h == ' ' || h == ',') {
839 if (f) {
840 c++;
841 continue;
842 } else if (e) {
843 this.tab[d++][0] = ( String.instantialize (a, b, c - b)).toLowerCase ();
844 } else {
845 this.tab[d++][1] = ( String.instantialize (a, b, c - b));
846 }while (c < g && (a[c] == ' ' || a[c] == ',')) {
847 c++;
848 }
849 e = true;
850 b = c;
851 } else {
852 c++;
853 }}
854 if (--c > b) {
855 if (!e) {
856 if (a[c] == '\"') {
857 this.tab[d++][1] = ( String.instantialize (a, b, c - b));
858 } else {
859 this.tab[d++][1] = ( String.instantialize (a, b, c - b + 1));
860 }} else {
861 this.tab[d][0] = ( String.instantialize (a, b, c - b + 1)).toLowerCase ();
862 }} else if (c == b) {
863 if (!e) {
864 if (a[c] == '\"') {
865 this.tab[d++][1] = String.valueOf (a[c - 1]);
866 } else {
867 this.tab[d++][1] = String.valueOf (a[c]);
868 }} else {
869 this.tab[d][0] = String.valueOf (a[c]).toLowerCase ();
870 }}}});
871 Clazz.defineMethod (c$, "findKey", 
872 function (a) {
873 if (a < 0 || a > 10) return null;
874 return this.tab[a][0];
875 }, "~N");
876 Clazz.defineMethod (c$, "findValue", 
877 function (a) {
878 if (a < 0 || a > 10) return null;
879 return this.tab[a][1];
880 }, "~N");
881 Clazz.defineMethod (c$, "findValue", 
882 function (a) {
883 return this.findValue (a, null);
884 }, "~S");
885 Clazz.defineMethod (c$, "findValue", 
886 function (a, b) {
887 if (a == null) return b;
888 a = a.toLowerCase ();
889 for (var c = 0; c < 10; ++c) {
890 if (this.tab[c][0] == null) {
891 return b;
892 } else if (a.equals (this.tab[c][0])) {
893 return this.tab[c][1];
894 }}
895 return b;
896 }, "~S,~S");
897 Clazz.defineMethod (c$, "findInt", 
898 function (a, b) {
899 try {
900 return Integer.parseInt (this.findValue (a, String.valueOf (b)));
901 } catch (t) {
902 return b;
903 }
904 }, "~S,~N");
905 c$ = Clazz.p0p ();
906 Clazz.defineStatics (c$,
907 "PostDataProperty", "javax.swing.JEditorPane.postdata");
908 c$.kitRegistryKey = c$.prototype.kitRegistryKey =  new Clazz._O ();
909 c$.kitTypeRegistryKey = c$.prototype.kitTypeRegistryKey =  new Clazz._O ();
910 c$.kitLoaderRegistryKey = c$.prototype.kitLoaderRegistryKey =  new Clazz._O ();
911 Clazz.defineStatics (c$,
912 "$uiClassID", "EditorPaneUI",
913 "W3C_LENGTH_UNITS", "JEditorPane.w3cLengthUnits",
914 "HONOR_DISPLAY_PROPERTIES", "JEditorPane.honorDisplayProperties");
915 c$.defaultEditorKitMap = c$.prototype.defaultEditorKitMap =  new java.util.HashMap (0);
916 });