KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > HtmlRendererContext


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 /*
22  * Created on Aug 28, 2005
23  */

24 package org.lobobrowser.html;
25
26 import java.net.URL JavaDoc;
27 import org.w3c.dom.html2.*;
28
29 /**
30  * The <code>HtmlRendererContext</code> interface must be implemented
31  * in order to use the Cobra HTML renderer. In many ways this
32  * interface parallers the Javascript <code>Window</code> class, which
33  * in reality represents a browser frame, not a window.
34  * @author J. H. S.
35  */

36 public interface HtmlRendererContext {
37     /**
38      * Performs a hyperlink click. Implementations should
39      * retrieve the URL content, parse it and render it.
40      * @param url The destination URL.
41      * @param target Same as the target attribute in the HTML anchor tag, i.e. _top, _blank, etc.
42      */

43     public void navigate(URL JavaDoc url, String JavaDoc target);
44     
45     /**
46      * Gets a collection of frames from the document
47      * currently in the context.
48      */

49     public HTMLCollection getFrames();
50     
51     /**
52      * Submits a HTML form. Note that when the the method is "GET", parameters
53      * are still expected to be part of <code>formInputs</code>.
54      * @param method The request method, GET or POST.
55      * @param action The destination URL.
56      * @param target Same as the target attribute in the FORM tag, i.e. _blank, _top, etc.
57      * @param enctype The encoding type.
58      * @param formInputs An array of {@link org.lobobrowser.html.FormInput} instances.
59      */

60     public void submitForm(String JavaDoc method, URL JavaDoc action, String JavaDoc target, String JavaDoc enctype, FormInput[] formInputs);
61
62     /**
63      * Creates a {@link org.lobobrowser.html.BrowserFrame} instance.
64      */

65     public BrowserFrame createBrowserFrame();
66     
67 // /**
68
// * Gets the parser context associated with this
69
// * renderer context.
70
// */
71
// public HtmlParserContext getHtmlParserContext();
72

73     /**
74      * Gets the browser context.
75      */

76     public UserAgentContext getUserAgentContext();
77     
78     /**
79      * Gets a <code>HtmlObject</code> instance that implements
80      * a OBJECT tag from HTML.
81      * @param element The DOM element for the object, which may
82      * either represent an OBJECT, EMBED or an APPLET tag.
83      * @return Implementations of this method must return <code>null</code>
84      * if they have any problems producing a <code>HtmlObject</code> instance.
85      * This is particularly true of OBJECT tags, where inner HTML of
86      * the tag must be rendered if the OBJECT content cannot be handled.
87      */

88     public HtmlObject getHtmlObject(org.w3c.dom.html2.HTMLElement element);
89
90     //------ Methods useful for Window implementation:
91

92     /**
93      * Opens an alert dialog.
94      * @param message Message shown by the dialog.
95      */

96     public void alert(String JavaDoc message);
97     
98     /**
99      * Goes to the previous page in the browser's history.
100      */

101     public void back();
102     
103     /**
104      * Relinquishes focus.
105      */

106     public void blur();
107     
108     /**
109      * Closes the browser window, provided this
110      * is allowed for the current context.
111      */

112     public void close();
113
114     /**
115      * Opens a confirmation dialog.
116      * @param message The message shown by the confirmation dialog.
117      * @return True if the user selects YES.
118      */

119     public boolean confirm(String JavaDoc message);
120
121     /**
122      * Requests focus for the current window.
123      */

124     public void focus();
125     
126     /**
127      * Opens a separate browser window and renders a URL.
128      * @param absoluteUrl The URL to be rendered.
129      * @param windowName The name of the new window.
130      * @param windowFeatures The features of the new window (same as in Javascript open method).
131      * @param replace
132      * @return A new {@link org.lobobrowser.html.HtmlRendererContext} instance.
133      * @deprecated Use {@link #open(URL, String, String, boolean)} instead.
134      */

135     public HtmlRendererContext open(String JavaDoc absoluteUrl, String JavaDoc windowName, String JavaDoc windowFeatures, boolean replace);
136     
137     /**
138      * Opens a separate browser window and renders a URL.
139      * @param url The URL to be rendered.
140      * @param windowName The name of the new window.
141      * @param windowFeatures The features of the new window (same as in Javascript open method).
142      * @param replace
143      * @return A new {@link org.lobobrowser.html.HtmlRendererContext} instance.
144      */

145     public HtmlRendererContext open(java.net.URL JavaDoc url, String JavaDoc windowName, String JavaDoc windowFeatures, boolean replace);
146
147     /**
148      * Shows a prompt dialog.
149      * @param message The message shown by the dialog.
150      * @param inputDefault The default input value.
151      * @return The user's input value.
152      */

153     public String JavaDoc prompt(String JavaDoc message, String JavaDoc inputDefault);
154     
155     /**
156      * Scrolls the client area.
157      * @param x Document's x coordinate.
158      * @param y Document's y coordinate.
159      */

160     public void scroll(int x, int y);
161     
162     /**
163      * Gets a value indicating if the window is closed.
164      */

165     public boolean isClosed();
166     
167     public String JavaDoc getDefaultStatus();
168     public void setDefaultStatus(String JavaDoc value);
169         
170     /**
171      * Gets the window name.
172      */

173     public String JavaDoc getName();
174     
175     /**
176      * Gets the parent of the window in the current context.
177      */

178     public HtmlRendererContext getParent();
179     
180     /**
181      * Gets the opener of the window in the current context.
182      */

183     public HtmlRendererContext getOpener();
184     
185     /**
186      * Sets the context that opened the window of the current one.
187      * @param opener A {@link org.lobobrowser.html.HtmlRendererContext}.
188      */

189     public void setOpener(HtmlRendererContext opener);
190     
191     /**
192      * Gets the window status text.
193      */

194     public String JavaDoc getStatus();
195     
196     /**
197      * Sets the window status text.
198      * @param message A string.
199      */

200     public void setStatus(String JavaDoc message);
201     
202     /**
203      * Gets the top-most browser window.
204      */

205     public HtmlRendererContext getTop();
206
207     /**
208      * It should return true if the link provided has been visited.
209      */

210     public boolean isVisitedLink(HTMLLinkElement link);
211     
212     /**
213      * Returns true if the current media matches the name provided.
214      * @param mediaName Media name, which
215      * may be screen, tty, etc. (See <a HREF="http://www.w3.org/TR/REC-html40/types.html#type-media-descriptors">HTML Specification</a>).
216      */

217     public boolean isMedia(String JavaDoc mediaName);
218     
219     /**
220      * Reloads the current document.
221      */

222     public void reload();
223 }
224
Popular Tags