diff options
author | Mark Wielaard <mark@klomp.org> | 2006-12-03 16:41:55 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2006-12-03 16:41:55 +0000 |
commit | e38e788dd1d7e256ba6c041e238aab2217b13951 (patch) | |
tree | 0474be940dd847943cfea5864d9704407da43594 | |
parent | 46f024912047b0c71e31ad0e1e2901b50c707986 (diff) | |
download | classpath-e38e788dd1d7e256ba6c041e238aab2217b13951.tar.gz |
* javax/swing/JEditorPane.java (PageLoader.in): Made a PageStream.
(PageLoader.page): Made package local.
(PageLoader.run): Don't reset loader.
(PageLoader.cancel): New method.
(loading): Renamed to loader.
(getPage): Return loader.page.
(setPage): Always set loader. Never reset to null.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | javax/swing/JEditorPane.java | 47 |
2 files changed, 29 insertions, 28 deletions
@@ -1,5 +1,15 @@ 2006-12-03 Mark Wielaard <mark@klomp.org> + * javax/swing/JEditorPane.java (PageLoader.in): Made a PageStream. + (PageLoader.page): Made package local. + (PageLoader.run): Don't reset loader. + (PageLoader.cancel): New method. + (loading): Renamed to loader. + (getPage): Return loader.page. + (setPage): Always set loader. Never reset to null. + +2006-12-03 Mark Wielaard <mark@klomp.org> + * javax/swing/plaf/basic/BasicTreeUI.java (paint): Check whether path[k] is null. (isLastChild): Return false when path is null. diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java index 4007169bd..4f7ad7119 100644 --- a/javax/swing/JEditorPane.java +++ b/javax/swing/JEditorPane.java @@ -582,13 +582,13 @@ public class JEditorPane extends JTextComponent implements Runnable { private Document doc; - private InputStream in; + private PageStream in; private URL old; - private URL page; - PageLoader(Document doc, InputStream in, int prio, URL old, URL page) + URL page; + PageLoader(Document doc, InputStream in, URL old, URL page) { this.doc = doc; - this.in = in; + this.in = new PageStream(in); this.old = old; this.page = page; } @@ -598,10 +598,6 @@ public class JEditorPane extends JTextComponent try { read(in, doc); - synchronized (JEditorPane.this) - { - loading = null; - } } catch (IOException ex) { @@ -621,7 +617,12 @@ public class JEditorPane extends JTextComponent } }); } - } + } + } + + void cancel() + { + in.cancel(); } } @@ -640,7 +641,7 @@ public class JEditorPane extends JTextComponent /** * The currently loading stream, if any. */ - private PageStream loading; + private PageLoader loader; public JEditorPane() { @@ -885,7 +886,7 @@ public class JEditorPane extends JTextComponent public URL getPage() { - return (URL) getDocument().getProperty(Document.StreamDescriptionProperty); + return loader != null ? loader.page : null; } protected InputStream getStream(URL page) @@ -1075,15 +1076,10 @@ public class JEditorPane extends JTextComponent Document doc = editorKit.createDefaultDocument(); doc.putProperty(Document.StreamDescriptionProperty, page); - // Cancel loading stream, if there is any. - synchronized (this) - { - if (loading != null) - { - loading.cancel(); - loading = null; - } - } + if (loader != null) + loader.cancel(); + loader = new PageLoader(doc, in, old, page); + int prio = -1; if (doc instanceof AbstractDocument) { @@ -1094,20 +1090,15 @@ public class JEditorPane extends JTextComponent { // Load asynchronously. setDocument(doc); - synchronized (this) - { - loading = new PageStream(in); - } - PageLoader loader = new PageLoader(doc, loading, prio, old, - page); - Thread loadThread = new Thread(loader); + Thread loadThread = new Thread(loader, + "JEditorPane.PageLoader"); + loadThread.setDaemon(true); loadThread.setPriority(prio); loadThread.start(); } else { // Load synchronously. - PageLoader loader = new PageLoader(doc, in, prio, old, page); loader.run(); setDocument(doc); } |