| 1 | /* JEditorPane.java --
|
|---|
| 2 | Copyright (C) 2002 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 6 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307 USA.
|
|---|
| 20 |
|
|---|
| 21 | Linking this library statically or dynamically with other modules is
|
|---|
| 22 | making a combined work based on this library. Thus, the terms and
|
|---|
| 23 | conditions of the GNU General Public License cover the whole
|
|---|
| 24 | combination.
|
|---|
| 25 |
|
|---|
| 26 | As a special exception, the copyright holders of this library give you
|
|---|
| 27 | permission to link this library with independent modules to produce an
|
|---|
| 28 | executable, regardless of the license terms of these independent
|
|---|
| 29 | modules, and to copy and distribute the resulting executable under
|
|---|
| 30 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 31 | independent module, the terms and conditions of the license of that
|
|---|
| 32 | module. An independent module is a module which is not derived from
|
|---|
| 33 | or based on this library. If you modify this library, you may extend
|
|---|
| 34 | this exception to your version of the library, but you are not
|
|---|
| 35 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 36 | exception statement from your version. */
|
|---|
| 37 |
|
|---|
| 38 | package javax.swing;
|
|---|
| 39 |
|
|---|
| 40 | import java.io.*;
|
|---|
| 41 | import java.net.*;
|
|---|
| 42 | import javax.swing.text.*;
|
|---|
| 43 | import javax.swing.event.*;
|
|---|
| 44 | import java.awt.event.*;
|
|---|
| 45 | import java.awt.*;
|
|---|
| 46 | import javax.accessibility.*;
|
|---|
| 47 |
|
|---|
| 48 | public class JEditorPane extends JTextComponent
|
|---|
| 49 | {
|
|---|
| 50 | URL page_url;
|
|---|
| 51 | EditorKit kit;
|
|---|
| 52 | String ctype = "text/plain";
|
|---|
| 53 | boolean focus_root;
|
|---|
| 54 | boolean manages_focus;
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | public JEditorPane()
|
|---|
| 58 | {
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | public JEditorPane(String url)
|
|---|
| 62 | {
|
|---|
| 63 | this();
|
|---|
| 64 | setPage(url);
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | public JEditorPane(String type, String text)
|
|---|
| 68 | {
|
|---|
| 69 | ctype = text;
|
|---|
| 70 | setText(text);
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | public JEditorPane(URL url)
|
|---|
| 74 | {
|
|---|
| 75 | setPage(url);
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | void addHyperlinkListener(HyperlinkListener listener)
|
|---|
| 79 | { }
|
|---|
| 80 |
|
|---|
| 81 | protected EditorKit createDefaultEditorKit()
|
|---|
| 82 | { return new PlainEditorKit(); }
|
|---|
| 83 |
|
|---|
| 84 | static EditorKit createEditorKitForContentType(String type)
|
|---|
| 85 | { return new PlainEditorKit(); }
|
|---|
| 86 |
|
|---|
| 87 | void fireHyperlinkUpdate(HyperlinkEvent e)
|
|---|
| 88 | {
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | public AccessibleContext getAccessibleContext()
|
|---|
| 92 | { return null; }
|
|---|
| 93 |
|
|---|
| 94 | String getContentType()
|
|---|
| 95 | { return ctype; }
|
|---|
| 96 |
|
|---|
| 97 | EditorKit getEditorKit()
|
|---|
| 98 | { return kit; }
|
|---|
| 99 |
|
|---|
| 100 | static String getEditorKitClassNameForContentType(String type)
|
|---|
| 101 | { return "text/plain"; }
|
|---|
| 102 |
|
|---|
| 103 | EditorKit getEditorKitForContentType(String type)
|
|---|
| 104 | { return kit; }
|
|---|
| 105 |
|
|---|
| 106 | public Dimension getPreferredSize()
|
|---|
| 107 | {
|
|---|
| 108 | //Returns the preferred size for the JEditorPane.
|
|---|
| 109 | return super.getPreferredSize();
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | public boolean getScrollableTracksViewportHeight()
|
|---|
| 113 | { return false; }
|
|---|
| 114 | public boolean getScrollableTracksViewportWidth()
|
|---|
| 115 | { return false; }
|
|---|
| 116 |
|
|---|
| 117 | URL getPage()
|
|---|
| 118 | { return page_url; }
|
|---|
| 119 |
|
|---|
| 120 | protected InputStream getStream(URL page)
|
|---|
| 121 | {
|
|---|
| 122 | try {
|
|---|
| 123 | return page.openStream();
|
|---|
| 124 | } catch (Exception e) {
|
|---|
| 125 | System.out.println("Hhmmm, failed to open stream: " + e);
|
|---|
| 126 | }
|
|---|
| 127 | return null;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | public String getText()
|
|---|
| 131 | { return super.getText(); }
|
|---|
| 132 |
|
|---|
| 133 | public String getUIClassID()
|
|---|
| 134 | { return "JEditorPane"; }
|
|---|
| 135 |
|
|---|
| 136 | public boolean isFocusCycleRoot()
|
|---|
| 137 | { return focus_root; }
|
|---|
| 138 |
|
|---|
| 139 | public boolean isManagingFocus()
|
|---|
| 140 | { return manages_focus; }
|
|---|
| 141 |
|
|---|
| 142 | protected String paramString()
|
|---|
| 143 | { return "JEditorPane"; }
|
|---|
| 144 |
|
|---|
| 145 | protected void processComponentKeyEvent(KeyEvent e)
|
|---|
| 146 | {
|
|---|
| 147 | //Overridden to handle processing of tab/shift tab.
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | protected void processKeyEvent(KeyEvent e)
|
|---|
| 151 | {
|
|---|
| 152 | //Make sure that TAB and Shift-TAB events get consumed, so that awt doesn't attempt focus traversal.
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | void read(InputStream in, Object desc)
|
|---|
| 156 | {
|
|---|
| 157 | //This method initializes from a stream.
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | static void registerEditorKitForContentType(String type, String classname)
|
|---|
| 161 | {
|
|---|
| 162 | //Establishes the default bindings of type to classname.
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | static void registerEditorKitForContentType(String type, String classname, ClassLoader loader)
|
|---|
| 166 | {
|
|---|
| 167 | //Establishes the default bindings of type to classname.
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | void removeHyperlinkListener(HyperlinkListener listener)
|
|---|
| 171 | {
|
|---|
| 172 | //Removes a hyperlink listener.
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | void replaceSelection(String content)
|
|---|
| 176 | {
|
|---|
| 177 | //Replaces the currently selected content with new content represented by the given string.
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | protected void scrollToReference(String reference)
|
|---|
| 181 | {
|
|---|
| 182 | //Scrolls the view to the given reference location (that is, the value returned by the UL.getRef method for the URL being displayed).
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | void setContentType(String type)
|
|---|
| 186 | {
|
|---|
| 187 | ctype = type;
|
|---|
| 188 | invalidate();
|
|---|
| 189 | repaint();
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | void setEditorKit(EditorKit kit)
|
|---|
| 193 | {
|
|---|
| 194 | this.kit = kit;
|
|---|
| 195 | invalidate();
|
|---|
| 196 | repaint();
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | void setEditorKitForContentType(String type, EditorKit k)
|
|---|
| 200 | {
|
|---|
| 201 | ctype = type;
|
|---|
| 202 | setEditorKit(k);
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | void setPage(String url)
|
|---|
| 206 | {
|
|---|
| 207 | // Sets the current URL being displayed.
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | void setPage(URL page)
|
|---|
| 211 | {
|
|---|
| 212 | // Sets the current URL being displayed.
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | public void setText(String t)
|
|---|
| 216 | {
|
|---|
| 217 | super.setText(t);
|
|---|
| 218 | }
|
|---|
| 219 | } // class JEditorPane
|
|---|