Mercurial > projects > dwt-mac
comparison dwt/browser/Browser.d @ 125:5583f8eeee6c
Synced mozilla with dwt-linux
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 16 Jan 2009 12:49:08 +0100 |
parents | d8635bb48c7c |
children |
comparison
equal
deleted
inserted
replaced
124:540fa4e9974a | 125:5583f8eeee6c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2003, 2008 IBM Corporation and others. | 2 * Copyright (c) 2003, 2007 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | |
11 * Port to the D programming language: | 10 * Port to the D programming language: |
12 * Jacob Carlborg <doob@me.com> | 11 * John Reimer <terminal.node@gmail.com> |
13 *******************************************************************************/ | 12 *******************************************************************************/ |
14 module dwt.browser.Browser; | 13 module dwt.browser.Browser; |
15 | 14 |
15 import dwt.dwthelper.utils; | |
16 | |
16 import tango.core.Thread; | 17 import tango.core.Thread; |
18 import tango.io.Stdout; | |
17 | 19 |
18 import dwt.DWT; | 20 import dwt.DWT; |
19 import dwt.DWTError; | 21 import dwt.DWTError; |
20 import dwt.DWTException; | 22 import dwt.DWTException; |
21 import dwt.widgets.Composite; | 23 import dwt.widgets.Composite; |
22 import dwt.widgets.Display; | 24 import dwt.widgets.Display; |
23 import dwt.widgets.Widget; | 25 import dwt.widgets.Widget; |
24 | 26 |
25 import dwt.browser.LocationListener; | 27 import dwt.browser.Mozilla; |
26 import dwt.browser.WebBrowser; | 28 import dwt.browser.WebBrowser; |
27 import dwt.browser.CloseWindowListener; | 29 import dwt.browser.CloseWindowListener; |
30 import dwt.browser.LocationListener; | |
28 import dwt.browser.OpenWindowListener; | 31 import dwt.browser.OpenWindowListener; |
29 import dwt.browser.ProgressListener; | 32 import dwt.browser.ProgressListener; |
30 import dwt.browser.StatusTextListener; | 33 import dwt.browser.StatusTextListener; |
31 import dwt.browser.TitleListener; | 34 import dwt.browser.TitleListener; |
32 import dwt.browser.VisibilityWindowListener; | 35 import dwt.browser.VisibilityWindowListener; |
33 | |
34 import dwt.dwthelper.utils; | |
35 | |
36 /** | 36 /** |
37 * Instances of this class implement the browser user interface | 37 * Instances of this class implement the browser user interface |
38 * metaphor. It allows the user to visualize and navigate through | 38 * metaphor. It allows the user to visualize and navigate through |
39 * HTML documents. | 39 * HTML documents. |
40 * <p> | 40 * <p> |
49 * </dl> | 49 * </dl> |
50 * <p> | 50 * <p> |
51 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | 51 * IMPORTANT: This class is <em>not</em> intended to be subclassed. |
52 * </p> | 52 * </p> |
53 * | 53 * |
54 * @see <a href="http://www.eclipse.org/swt/snippets/#browser">Browser snippets</a> | |
55 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Examples: ControlExample, BrowserExample</a> | |
56 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
57 * | |
58 * @since 3.0 | 54 * @since 3.0 |
59 */ | 55 */ |
60 | 56 |
61 public class Browser : Composite { | 57 public class Browser : Composite { |
62 WebBrowser webBrowser; | 58 WebBrowser webBrowser; |
63 int userStyle; | 59 int userStyle; |
64 | 60 |
65 static final String PACKAGE_PREFIX = "dwt.browser."; //$NON-NLS-1$ | 61 static final String PACKAGE_PREFIX = "dwt.browser."; //$NON-NLS-1$ |
66 static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ | 62 static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ |
67 | 63 |
68 /** | 64 /** |
69 * Constructs a new instance of this class given its parent | 65 * Constructs a new instance of this class given its parent |
70 * and a style value describing its behavior and appearance. | 66 * and a style value describing its behavior and appearance. |
71 * <p> | 67 * <p> |
72 * The style value is either one of the style constants defined in | 68 * The style value is either one of the style constants defined in |
73 * class <code>DWT</code> which is applicable to instances of this | 69 * class <code>DWT</code> which is applicable to instances of this |
74 * class, or must be built by <em>bitwise OR</em>'ing together | 70 * class, or must be built by <em>bitwise OR</em>'ing together |
75 * (that is, using the <code>int</code> "|" operator) two or more | 71 * (that is, using the <code>int</code> "|" operator) two or more |
76 * of those <code>DWT</code> style constants. The class description | 72 * of those <code>DWT</code> style constants. The class description |
77 * lists the style constants that are applicable to the class. | 73 * lists the style constants that are applicable to the class. |
78 * Style bits are also inherited from superclasses. | 74 * Style bits are also inherited from superclasses. |
79 * </p> | 75 * </p> |
80 * | 76 * |
81 * @param parent a widget which will be the parent of the new instance (cannot be null) | 77 * @param parent a widget which will be the parent of the new instance (cannot be null) |
82 * @param style the style of widget to construct | 78 * @param style the style of widget to construct |
83 * | 79 * |
84 * @exception IllegalArgumentException <ul> | 80 * @exception IllegalArgumentException <ul> |
85 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | 81 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> |
86 * </ul> | 82 * </ul> |
87 * @exception DWTException <ul> | 83 * @exception DWTException <ul> |
88 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | 84 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
89 * </ul> | 85 * </ul> |
90 * @exception DWTError <ul> | 86 * @exception DWTError <ul> |
91 * <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li> | 87 * <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li> |
92 * </ul> | 88 * </ul> |
93 * | 89 * |
94 * @see Widget#getStyle | 90 * @see Widget#getStyle |
95 * | 91 * |
96 * @since 3.0 | 92 * @since 3.0 |
97 */ | 93 */ |
98 public this (Composite parent, int style) { | 94 public this (Composite parent, int style) { |
99 super(checkParent(parent), checkStyle(style)); | 95 super (checkParent (parent), checkStyle (style)); |
100 userStyle = style; | 96 userStyle = style; |
101 | 97 |
102 String platform = DWT.getPlatform(); | 98 String platform = DWT.getPlatform (); |
103 Display display = parent.getDisplay(); | 99 Display display = parent.getDisplay (); |
104 if ("gtk".opEquals(platform)) | 100 if ("gtk" == platform) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$ |
105 display.setData(NO_INPUT_METHOD, null); //$NON-NLS-1$ | 101 /* |
106 String className = null; | 102 String className = null; |
107 if ((style & DWT.MOZILLA) !is 0) { | 103 if ((style & DWT.MOZILLA) !is 0) { |
108 className = "dwt.browser.Mozilla"; //$NON-NLS-1$ | 104 className = "dwt.browser.Mozilla"; //$NON-NLS-1$ |
109 } | 105 } else { |
110 else { | 106 dispose(); |
111 if ("win32".opEquals(platform) || "wpf".opEquals(platform)) { //$NON-NLS-1$ $NON-NLS-2$ | 107 DWT.error(DWT.ERROR_NO_HANDLES); |
112 className = "dwt.browser.IE"; //$NON-NLS-1$ | 108 } |
113 } | 109 */ |
114 else if ("motif".opEquals(platform)) { //$NON-NLS-1$ | 110 webBrowser = new Mozilla; |
115 className = "dwt.browser.Mozilla"; //$NON-NLS-1$ | 111 if (webBrowser is null) { |
116 } | 112 dispose (); |
117 else if ("gtk".opEquals(platform)) { //$NON-NLS-1$ | 113 DWT.error (DWT.ERROR_NO_HANDLES); |
118 className = "dwt.browser.Mozilla"; //$NON-NLS-1$ | 114 } |
119 } | 115 |
120 else if ("carbon".opEquals(platform) || "cocoa".opEquals(platform)) { //$NON-NLS-1$ | 116 webBrowser.setBrowser (this); |
121 className = "dwt.browser.Safari"; //$NON-NLS-1$ | 117 webBrowser.create (parent, style); |
122 } | 118 } |
123 else if ("photon".opEquals(platform)) { //$NON-NLS-1$ | 119 |
124 className = "dwt.browser.Voyager"; //$NON-NLS-1$ | 120 static Composite checkParent (Composite parent) { |
125 } | 121 String platform = DWT.getPlatform (); |
126 else { | 122 if (!("gtk" == platform)) return parent; //$NON-NLS-1$ |
127 dispose(); | 123 |
128 DWT.error(DWT.ERROR_NO_HANDLES); | 124 /* |
125 * Note. Mozilla provides all IM support needed for text input in web pages. | |
126 * If DWT creates another input method context for the widget it will cause | |
127 * indeterminate results to happen (hangs and crashes). The fix is to prevent | |
128 * DWT from creating an input method context for the Browser widget. | |
129 */ | |
130 if (parent !is null && !parent.isDisposed ()) { | |
131 Display display = parent.getDisplay (); | |
132 if (display !is null) { | |
133 if (display.getThread () is Thread.getThis ()) { | |
134 display.setData (NO_INPUT_METHOD, stringcast("true")); //$NON-NLS-1$ | |
129 } | 135 } |
130 } | 136 } |
131 | |
132 try { | |
133 Class clazz = Class.forName(className); | |
134 webBrowser = cast(WebBrowser) clazz.newInstance(); | |
135 } | |
136 catch (ClassNotFoundException e) { | |
137 } catch (IllegalAccessException e) { | |
138 } catch (InstantiationException e) { | |
139 } | |
140 if (webBrowser is null) { | |
141 dispose(); | |
142 DWT.error(DWT.ERROR_NO_HANDLES); | |
143 } | |
144 | |
145 webBrowser.setBrowser(this); | |
146 webBrowser.create(parent, style); | |
147 } | 137 } |
148 | 138 return parent; |
149 static Composite checkParent (Composite parent) { | 139 } |
150 String platform = DWT.getPlatform(); | 140 |
151 if (!"gtk".opEquals(platform)) | 141 static int checkStyle(int style) { |
152 return parent; //$NON-NLS-1$ | 142 String platform = DWT.getPlatform (); |
153 | 143 if ((style & DWT.MOZILLA) !is 0) { |
154 /* | 144 if ("carbon" == platform) return style | DWT.EMBEDDED; //$NON-NLS-1$ |
155 * Note. Mozilla provides all IM support needed for text input in web pages. | 145 if ("motif" == platform) return style | DWT.EMBEDDED; //$NON-NLS-1$ |
156 * If DWT creates another input method context for the widget it will cause | |
157 * indeterminate results to happen (hangs and crashes). The fix is to prevent | |
158 * DWT from creating an input method context for the Browser widget. | |
159 */ | |
160 if (parent !is null && !parent.isDisposed()) { | |
161 Display display = parent.getDisplay(); | |
162 if (display !is null) { | |
163 if (display.getThread() is Thread.currentThread()) { | |
164 display.setData(NO_INPUT_METHOD, "true"); //$NON-NLS-1$ | |
165 } | |
166 } | |
167 } | |
168 return parent; | |
169 } | |
170 | |
171 static int checkStyle (int style) { | |
172 String platform = DWT.getPlatform(); | |
173 if ((style & DWT.MOZILLA) !is 0) { | |
174 if ("carbon".opEquals(platform)) | |
175 return style | DWT.EMBEDDED; //$NON-NLS-1$ | |
176 if ("motif".opEquals(platform)) | |
177 return style | DWT.EMBEDDED; //$NON-NLS-1$ | |
178 return style; | |
179 } | |
180 | |
181 if ("win32".opEquals(platform)) { //$NON-NLS-1$ | |
182 /* | |
183 * For IE on win32 the border is supplied by the embedded browser, so remove | |
184 * the style so that the parent Composite will not draw a second border. | |
185 */ | |
186 return style & ~DWT.BORDER; | |
187 } | |
188 else if ("motif".opEquals(platform)) { //$NON-NLS-1$ | |
189 return style | DWT.EMBEDDED; | |
190 } | |
191 return style; | 146 return style; |
192 } | 147 } |
193 | 148 |
194 /** | 149 if ("win32" == platform) { //$NON-NLS-1$ |
195 * Clears all session cookies from all current Browser instances. | 150 /* |
196 * | 151 * For IE on win32 the border is supplied by the embedded browser, so remove |
197 * @since 3.2 | 152 * the style so that the parent Composite will not draw a second border. |
198 */ | 153 */ |
199 public static void clearSessions () { | 154 return style & ~DWT.BORDER; |
200 WebBrowser.clearSessions(); | 155 } else if ("motif" == platform) { //$NON-NLS-1$ |
156 return style | DWT.EMBEDDED; | |
201 } | 157 } |
202 | 158 return style; |
203 /** | 159 } |
204 * Adds the listener to the collection of listeners who will be | 160 |
205 * notified when the window hosting the receiver should be closed. | 161 /** |
206 * <p> | 162 * Clears all session cookies from all current Browser instances. |
207 * This notification occurs when a javascript command such as | 163 * |
208 * <code>window.close</code> gets executed by a <code>Browser</code>. | 164 * @since 3.2 |
209 * </p> | 165 */ |
210 * | 166 public static void clearSessions () { |
211 * @param listener the listener which should be notified | 167 WebBrowser.clearSessions (); |
212 * | 168 } |
213 * @exception IllegalArgumentException <ul> | 169 |
214 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 170 /** |
215 * </ul> | 171 * Adds the listener to the collection of listeners who will be |
216 * | 172 * notified when the window hosting the receiver should be closed. |
217 * @exception DWTException <ul> | 173 * <p> |
218 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 174 * This notification occurs when a javascript command such as |
219 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 175 * <code>window.close</code> gets executed by a <code>Browser</code>. |
220 * </ul> | 176 * </p> |
221 * | 177 * |
222 * @since 3.0 | 178 * @param listener the listener which should be notified |
223 */ | 179 * |
224 public void addCloseWindowListener (CloseWindowListener listener) { | 180 * @exception IllegalArgumentException <ul> |
225 checkWidget(); | 181 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
226 if (listener is null) | 182 * </ul> |
227 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 183 * |
228 webBrowser.addCloseWindowListener(listener); | 184 * @exception DWTException <ul> |
185 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
186 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
187 * </ul> | |
188 * | |
189 * @since 3.0 | |
190 */ | |
191 public void addCloseWindowListener (CloseWindowListener listener) { | |
192 checkWidget(); | |
193 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
194 webBrowser.addCloseWindowListener (listener); | |
195 } | |
196 | |
197 /** | |
198 * Adds the listener to the collection of listeners who will be | |
199 * notified when the current location has changed or is about to change. | |
200 * <p> | |
201 * This notification typically occurs when the application navigates | |
202 * to a new location with {@link #setUrl(String)} or when the user | |
203 * activates a hyperlink. | |
204 * </p> | |
205 * | |
206 * @param listener the listener which should be notified | |
207 * | |
208 * @exception IllegalArgumentException <ul> | |
209 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
210 * </ul> | |
211 * | |
212 * @exception DWTException <ul> | |
213 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
214 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
215 * </ul> | |
216 * | |
217 * @since 3.0 | |
218 */ | |
219 public void addLocationListener (LocationListener listener) { | |
220 checkWidget(); | |
221 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
222 webBrowser.addLocationListener (listener); | |
223 } | |
224 | |
225 /** | |
226 * Adds the listener to the collection of listeners who will be | |
227 * notified when a new window needs to be created. | |
228 * <p> | |
229 * This notification occurs when a javascript command such as | |
230 * <code>window.open</code> gets executed by a <code>Browser</code>. | |
231 * </p> | |
232 * | |
233 * @param listener the listener which should be notified | |
234 * | |
235 * @exception IllegalArgumentException <ul> | |
236 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
237 * </ul> | |
238 * | |
239 * @exception DWTException <ul> | |
240 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
241 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
242 * </ul> | |
243 * | |
244 * @since 3.0 | |
245 */ | |
246 public void addOpenWindowListener (OpenWindowListener listener) { | |
247 checkWidget(); | |
248 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
249 webBrowser.addOpenWindowListener (listener); | |
250 } | |
251 | |
252 /** | |
253 * Adds the listener to the collection of listeners who will be | |
254 * notified when a progress is made during the loading of the current | |
255 * URL or when the loading of the current URL has been completed. | |
256 * | |
257 * @param listener the listener which should be notified | |
258 * | |
259 * @exception IllegalArgumentException <ul> | |
260 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
261 * </ul> | |
262 * | |
263 * @exception DWTException <ul> | |
264 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
265 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
266 * </ul> | |
267 * | |
268 * @since 3.0 | |
269 */ | |
270 public void addProgressListener (ProgressListener listener) { | |
271 checkWidget(); | |
272 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
273 webBrowser.addProgressListener (listener); | |
274 } | |
275 | |
276 /** | |
277 * Adds the listener to the collection of listeners who will be | |
278 * notified when the status text is changed. | |
279 * <p> | |
280 * The status text is typically displayed in the status bar of | |
281 * a browser application. | |
282 * </p> | |
283 * | |
284 * @param listener the listener which should be notified | |
285 * | |
286 * @exception IllegalArgumentException <ul> | |
287 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
288 * </ul> | |
289 * | |
290 * @exception DWTException <ul> | |
291 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
292 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
293 * </ul> | |
294 * | |
295 * @since 3.0 | |
296 */ | |
297 public void addStatusTextListener (StatusTextListener listener) { | |
298 checkWidget(); | |
299 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
300 webBrowser.addStatusTextListener (listener); | |
301 } | |
302 | |
303 /** | |
304 * Adds the listener to the collection of listeners who will be | |
305 * notified when the title of the current document is available | |
306 * or has changed. | |
307 * | |
308 * @param listener the listener which should be notified | |
309 * | |
310 * @exception IllegalArgumentException <ul> | |
311 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
312 * </ul> | |
313 * | |
314 * @exception DWTException <ul> | |
315 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
316 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
317 * </ul> | |
318 * | |
319 * @since 3.0 | |
320 */ | |
321 public void addTitleListener (TitleListener listener) { | |
322 checkWidget(); | |
323 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
324 webBrowser.addTitleListener (listener); | |
325 } | |
326 | |
327 /** | |
328 * Adds the listener to the collection of listeners who will be | |
329 * notified when a window hosting the receiver needs to be displayed | |
330 * or hidden. | |
331 * | |
332 * @param listener the listener which should be notified | |
333 * | |
334 * @exception IllegalArgumentException <ul> | |
335 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
336 * </ul> | |
337 * | |
338 * @exception DWTException <ul> | |
339 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
340 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
341 * </ul> | |
342 * | |
343 * @since 3.0 | |
344 */ | |
345 public void addVisibilityWindowListener (VisibilityWindowListener listener) { | |
346 checkWidget(); | |
347 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
348 webBrowser.addVisibilityWindowListener (listener); | |
349 } | |
350 | |
351 /** | |
352 * Navigate to the previous session history item. | |
353 * | |
354 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise | |
355 * | |
356 * @exception DWTException <ul> | |
357 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
358 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
359 * </ul> | |
360 * | |
361 * @see #forward | |
362 * | |
363 * @since 3.0 | |
364 */ | |
365 public bool back () { | |
366 checkWidget(); | |
367 return webBrowser.back (); | |
368 } | |
369 | |
370 protected void checkSubclass () { | |
371 String name = this.classinfo.name; | |
372 name = name.substring(0, name.lastIndexOf('.')); | |
373 int index = name.lastIndexOf('.'); | |
374 if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) { | |
375 Stdout ("name: ")(name.substring(0, index + 1))(" == " )(PACKAGE_PREFIX).newline; | |
376 DWT.error (DWT.ERROR_INVALID_SUBCLASS); | |
229 } | 377 } |
230 | 378 } |
231 /** | 379 |
232 * Adds the listener to the collection of listeners who will be | 380 /** |
233 * notified when the current location has changed or is about to change. | 381 * Execute the specified script. |
234 * <p> | 382 * |
235 * This notification typically occurs when the application navigates | 383 * <p> |
236 * to a new location with {@link #setUrl(String)} or when the user | 384 * Execute a script containing javascript commands in the context of the current document. |
237 * activates a hyperlink. | 385 * |
238 * </p> | 386 * @param script the script with javascript commands |
239 * | 387 * |
240 * @param listener the listener which should be notified | 388 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise |
241 * | 389 * |
242 * @exception IllegalArgumentException <ul> | 390 * @exception IllegalArgumentException <ul> |
243 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 391 * <li>ERROR_NULL_ARGUMENT - if the script is null</li> |
244 * </ul> | 392 * </ul> |
245 * | 393 * |
246 * @exception DWTException <ul> | 394 * @exception DWTException <ul> |
247 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 395 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
248 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 396 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
249 * </ul> | 397 * </ul> |
250 * | 398 * |
251 * @since 3.0 | 399 * @since 3.1 |
252 */ | 400 */ |
253 public void addLocationListener (LocationListener listener) { | 401 public bool execute (String script) { |
254 checkWidget(); | 402 checkWidget(); |
255 if (listener is null) | 403 if (script is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
256 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 404 return webBrowser.execute (script); |
257 webBrowser.addLocationListener(listener); | 405 } |
258 } | 406 |
259 | 407 /** |
260 /** | 408 * Navigate to the next session history item. |
261 * Adds the listener to the collection of listeners who will be | 409 * |
262 * notified when a new window needs to be created. | 410 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise |
263 * <p> | 411 * |
264 * This notification occurs when a javascript command such as | 412 * @exception DWTException <ul> |
265 * <code>window.open</code> gets executed by a <code>Browser</code>. | 413 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
266 * </p> | 414 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
267 * | 415 * </ul> |
268 * @param listener the listener which should be notified | 416 * |
269 * | 417 * @see #back |
270 * @exception IllegalArgumentException <ul> | 418 * |
271 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 419 * @since 3.0 |
272 * </ul> | 420 */ |
273 * | 421 public bool forward () { |
274 * @exception DWTException <ul> | 422 checkWidget(); |
275 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 423 return webBrowser.forward (); |
276 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 424 } |
277 * </ul> | 425 |
278 * | 426 public int getStyle () { |
279 * @since 3.0 | 427 /* |
280 */ | 428 * If DWT.BORDER was specified at creation time then getStyle() should answer |
281 public void addOpenWindowListener (OpenWindowListener listener) { | 429 * it even though it is removed for IE on win32 in checkStyle(). |
282 checkWidget(); | 430 */ |
283 if (listener is null) | 431 return super.getStyle () | (userStyle & DWT.BORDER); |
284 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 432 } |
285 webBrowser.addOpenWindowListener(listener); | 433 |
286 } | 434 /** |
287 | 435 * Returns a string with HTML that represents the content of the current page. |
288 /** | 436 * |
289 * Adds the listener to the collection of listeners who will be | 437 * @return HTML representing the current page or an empty <code>String</code> |
290 * notified when a progress is made during the loading of the current | 438 * if this is empty |
291 * URL or when the loading of the current URL has been completed. | 439 * |
292 * | 440 * @exception DWTException <ul> |
293 * @param listener the listener which should be notified | 441 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
294 * | 442 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
295 * @exception IllegalArgumentException <ul> | 443 * </ul> |
296 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 444 * |
297 * </ul> | 445 * @since 3.4 |
298 * | 446 */ |
299 * @exception DWTException <ul> | 447 public String getText () { |
300 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 448 checkWidget(); |
301 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 449 return webBrowser.getText (); |
302 * </ul> | 450 } |
303 * | 451 |
304 * @since 3.0 | 452 /** |
305 */ | 453 * Returns the current URL. |
306 public void addProgressListener (ProgressListener listener) { | 454 * |
307 checkWidget(); | 455 * @return the current URL or an empty <code>String</code> if there is no current URL |
308 if (listener is null) | 456 * |
309 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 457 * @exception DWTException <ul> |
310 webBrowser.addProgressListener(listener); | 458 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
311 } | 459 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
312 | 460 * </ul> |
313 /** | 461 * |
314 * Adds the listener to the collection of listeners who will be | 462 * @see #setUrl |
315 * notified when the status text is changed. | 463 * |
316 * <p> | 464 * @since 3.0 |
317 * The status text is typically displayed in the status bar of | 465 */ |
318 * a browser application. | 466 public String getUrl () { |
319 * </p> | 467 checkWidget(); |
320 * | 468 return webBrowser.getUrl (); |
321 * @param listener the listener which should be notified | 469 } |
322 * | 470 |
323 * @exception IllegalArgumentException <ul> | 471 /** |
324 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 472 * Returns the JavaXPCOM <code>nsIWebBrowser</code> for the receiver, or <code>null</code> |
325 * </ul> | 473 * if it is not available. In order for an <code>nsIWebBrowser</code> to be returned all |
326 * | 474 * of the following must be true: <ul> |
327 * @exception DWTException <ul> | 475 * <li>the receiver's style must be <code>DWT.MOZILLA</code></li> |
328 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 476 * <li>the classes from JavaXPCOM >= 1.8.1.2 must be resolvable at runtime</li> |
329 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 477 * <li>the version of the underlying XULRunner must be >= 1.8.1.2</li> |
330 * </ul> | 478 * </ul> |
331 * | 479 * |
332 * @since 3.0 | 480 * @return the receiver's JavaXPCOM <code>nsIWebBrowser</code> or <code>null</code> |
333 */ | 481 * |
334 public void addStatusTextListener (StatusTextListener listener) { | 482 * @since 3.3 |
335 checkWidget(); | 483 */ |
336 if (listener is null) | 484 public Object getWebBrowser () { |
337 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 485 checkWidget(); |
338 webBrowser.addStatusTextListener(listener); | 486 return webBrowser.getWebBrowser (); |
339 } | 487 } |
340 | 488 |
341 /** | 489 /** |
342 * Adds the listener to the collection of listeners who will be | 490 * Returns <code>true</code> if the receiver can navigate to the |
343 * notified when the title of the current document is available | 491 * previous session history item, and <code>false</code> otherwise. |
344 * or has changed. | 492 * |
345 * | 493 * @return the receiver's back command enabled state |
346 * @param listener the listener which should be notified | 494 * |
347 * | 495 * @exception DWTException <ul> |
348 * @exception IllegalArgumentException <ul> | 496 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
349 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 497 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
350 * </ul> | 498 * </ul> |
351 * | 499 * |
352 * @exception DWTException <ul> | 500 * @see #back |
353 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 501 */ |
354 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 502 public bool isBackEnabled () { |
355 * </ul> | 503 checkWidget(); |
356 * | 504 return webBrowser.isBackEnabled (); |
357 * @since 3.0 | 505 } |
358 */ | 506 |
359 public void addTitleListener (TitleListener listener) { | 507 public bool isFocusControl () { |
360 checkWidget(); | 508 checkWidget(); |
361 if (listener is null) | 509 if (webBrowser.isFocusControl ()) return true; |
362 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 510 return super.isFocusControl (); |
363 webBrowser.addTitleListener(listener); | 511 } |
364 } | 512 |
365 | 513 /** |
366 /** | 514 * Returns <code>true</code> if the receiver can navigate to the |
367 * Adds the listener to the collection of listeners who will be | 515 * next session history item, and <code>false</code> otherwise. |
368 * notified when a window hosting the receiver needs to be displayed | 516 * |
369 * or hidden. | 517 * @return the receiver's forward command enabled state |
370 * | 518 * |
371 * @param listener the listener which should be notified | 519 * @exception DWTException <ul> |
372 * | 520 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
373 * @exception IllegalArgumentException <ul> | 521 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
374 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 522 * </ul> |
375 * </ul> | 523 * |
376 * | 524 * @see #forward |
377 * @exception DWTException <ul> | 525 */ |
378 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 526 public bool isForwardEnabled () { |
379 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 527 checkWidget(); |
380 * </ul> | 528 return webBrowser.isForwardEnabled (); |
381 * | 529 } |
382 * @since 3.0 | 530 |
383 */ | 531 /** |
384 public void addVisibilityWindowListener (VisibilityWindowListener listener) { | 532 * Refresh the current page. |
385 checkWidget(); | 533 * |
386 if (listener is null) | 534 * @exception DWTException <ul> |
387 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 535 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
388 webBrowser.addVisibilityWindowListener(listener); | 536 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
389 } | 537 * </ul> |
390 | 538 * |
391 /** | 539 * @since 3.0 |
392 * Navigate to the previous session history item. | 540 */ |
393 * | 541 public void refresh () { |
394 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise | 542 checkWidget(); |
395 * | 543 webBrowser.refresh (); |
396 * @exception DWTException <ul> | 544 } |
397 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 545 |
398 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 546 /** |
399 * </ul> | 547 * Removes the listener from the collection of listeners who will |
400 * | 548 * be notified when the window hosting the receiver should be closed. |
401 * @see #forward | 549 * |
402 * | 550 * @param listener the listener which should no longer be notified |
403 * @since 3.0 | 551 * |
404 */ | 552 * @exception IllegalArgumentException <ul> |
405 public bool back () { | 553 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
406 checkWidget(); | 554 * </ul> |
407 return webBrowser.back(); | 555 * |
408 } | 556 * @exception DWTException <ul> |
409 | 557 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
410 protected void checkSubclass () { | 558 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
411 String name = getClass().getName(); | 559 * </ul> |
412 int index = name.lastIndexOf('.'); | 560 * |
413 if (!name.substring(0, index + 1).opEquals(PACKAGE_PREFIX)) { | 561 * @since 3.0 |
414 DWT.error(DWT.ERROR_INVALID_SUBCLASS); | 562 */ |
415 } | 563 public void removeCloseWindowListener (CloseWindowListener listener) { |
416 } | 564 checkWidget(); |
417 | 565 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
418 /** | 566 webBrowser.removeCloseWindowListener (listener); |
419 * Execute the specified script. | 567 } |
420 * | 568 |
421 * <p> | 569 /** |
422 * Execute a script containing javascript commands in the context of the current document. | 570 * Removes the listener from the collection of listeners who will |
423 * | 571 * be notified when the current location is changed or about to be changed. |
424 * @param script the script with javascript commands | 572 * |
425 * | 573 * @param listener the listener which should no longer be notified |
426 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise | 574 * |
427 * | 575 * @exception IllegalArgumentException <ul> |
428 * @exception IllegalArgumentException <ul> | 576 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
429 * <li>ERROR_NULL_ARGUMENT - if the script is null</li> | 577 * </ul> |
430 * </ul> | 578 * |
431 * | 579 * @exception DWTException <ul> |
432 * @exception DWTException <ul> | 580 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
433 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 581 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
434 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 582 * </ul> |
435 * </ul> | 583 * |
436 * | 584 * @since 3.0 |
437 * @since 3.1 | 585 */ |
438 */ | 586 public void removeLocationListener (LocationListener listener) { |
439 public bool execute (String script) { | 587 checkWidget(); |
440 checkWidget(); | 588 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
441 if (script is null) | 589 webBrowser.removeLocationListener (listener); |
442 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 590 } |
443 return webBrowser.execute(script); | 591 |
444 } | 592 /** |
445 | 593 * Removes the listener from the collection of listeners who will |
446 /** | 594 * be notified when a new window needs to be created. |
447 * Navigate to the next session history item. | 595 * |
448 * | 596 * @param listener the listener which should no longer be notified |
449 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise | 597 * |
450 * | 598 * @exception IllegalArgumentException <ul> |
451 * @exception DWTException <ul> | 599 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
452 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 600 * </ul> |
453 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 601 * |
454 * </ul> | 602 * @exception DWTException <ul> |
455 * | 603 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
456 * @see #back | 604 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
457 * | 605 * </ul> |
458 * @since 3.0 | 606 * |
459 */ | 607 * @since 3.0 |
460 public bool forward () { | 608 */ |
461 checkWidget(); | 609 public void removeOpenWindowListener (OpenWindowListener listener) { |
462 return webBrowser.forward(); | 610 checkWidget(); |
463 } | 611 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
464 | 612 webBrowser.removeOpenWindowListener (listener); |
465 /** | 613 } |
466 * Returns the type of native browser being used by this instance. | 614 |
467 * Examples: "mozilla", "ie", "safari", "voyager" | 615 /** |
468 * | 616 * Removes the listener from the collection of listeners who will |
469 * @return the type of the native browser | 617 * be notified when a progress is made during the loading of the current |
470 * | 618 * URL or when the loading of the current URL has been completed. |
471 * @since 3.5 | 619 * |
472 */ | 620 * @param listener the listener which should no longer be notified |
473 public String getBrowserType () { | 621 * |
474 checkWidget(); | 622 * @exception IllegalArgumentException <ul> |
475 return webBrowser.getBrowserType (); | 623 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
476 } | 624 * </ul> |
477 | 625 * |
478 public int getStyle () { | 626 * @exception DWTException <ul> |
479 /* | 627 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
480 * If DWT.BORDER was specified at creation time then getStyle() should answer | 628 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
481 * it even though it is removed for IE on win32 in checkStyle(). | 629 * </ul> |
482 */ | 630 * |
483 return super.getStyle() | (userStyle & DWT.BORDER); | 631 * @since 3.0 |
484 } | 632 */ |
485 | 633 public void removeProgressListener (ProgressListener listener) { |
486 /** | 634 checkWidget(); |
487 * Returns a String with HTML that represents the content of the current page. | 635 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
488 * | 636 webBrowser.removeProgressListener (listener); |
489 * @return HTML representing the current page or an empty <code>String</code> | 637 } |
490 * if this is empty | 638 |
491 * | 639 /** |
492 * @exception DWTException <ul> | 640 * Removes the listener from the collection of listeners who will |
493 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 641 * be notified when the status text is changed. |
494 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 642 * |
495 * </ul> | 643 * @param listener the listener which should no longer be notified |
496 * | 644 * |
497 * @since 3.4 | 645 * @exception IllegalArgumentException <ul> |
498 */ | 646 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
499 public String getText () { | 647 * </ul> |
500 checkWidget(); | 648 * |
501 return webBrowser.getText(); | 649 * @exception DWTException <ul> |
502 } | 650 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
503 | 651 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
504 /** | 652 * </ul> |
505 * Returns the current URL. | 653 * |
506 * | 654 * @since 3.0 |
507 * @return the current URL or an empty <code>String</code> if there is no current URL | 655 */ |
508 * | 656 public void removeStatusTextListener (StatusTextListener listener) { |
509 * @exception DWTException <ul> | 657 checkWidget(); |
510 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 658 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
511 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 659 webBrowser.removeStatusTextListener (listener); |
512 * </ul> | 660 } |
513 * | 661 |
514 * @see #setUrl | 662 /** |
515 * | 663 * Removes the listener from the collection of listeners who will |
516 * @since 3.0 | 664 * be notified when the title of the current document is available |
517 */ | 665 * or has changed. |
518 public String getUrl () { | 666 * |
519 checkWidget(); | 667 * @param listener the listener which should no longer be notified |
520 return webBrowser.getUrl(); | 668 * |
521 } | 669 * @exception IllegalArgumentException <ul> |
522 | 670 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
523 /** | 671 * </ul> |
524 * Returns the JavaXPCOM <code>nsIWebBrowser</code> for the receiver, or <code>null</code> | 672 * |
525 * if it is not available. In order for an <code>nsIWebBrowser</code> to be returned all | 673 * @exception DWTException <ul> |
526 * of the following must be true: <ul> | 674 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
527 * <li>the receiver's style must be <code>DWT.MOZILLA</code></li> | 675 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
528 * <li>the classes from JavaXPCOM >= 1.8.1.2 must be resolvable at runtime</li> | 676 * </ul> |
529 * <li>the version of the underlying XULRunner must be >= 1.8.1.2</li> | 677 * |
530 * </ul> | 678 * @since 3.0 |
531 * | 679 */ |
532 * @return the receiver's JavaXPCOM <code>nsIWebBrowser</code> or <code>null</code> | 680 public void removeTitleListener (TitleListener listener) { |
533 * | 681 checkWidget(); |
534 * @since 3.3 | 682 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
535 */ | 683 webBrowser.removeTitleListener (listener); |
536 public Object getWebBrowser () { | 684 } |
537 checkWidget(); | 685 |
538 return webBrowser.getWebBrowser(); | 686 /** |
539 } | 687 * Removes the listener from the collection of listeners who will |
540 | 688 * be notified when a window hosting the receiver needs to be displayed |
541 /** | 689 * or hidden. |
542 * Returns <code>true</code> if the receiver can navigate to the | 690 * |
543 * previous session history item, and <code>false</code> otherwise. | 691 * @param listener the listener which should no longer be notified |
544 * | 692 * |
545 * @return the receiver's back command enabled state | 693 * @exception IllegalArgumentException <ul> |
546 * | 694 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
547 * @exception DWTException <ul> | 695 * </ul> |
548 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 696 * |
549 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 697 * @exception DWTException <ul> |
550 * </ul> | 698 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
551 * | 699 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
552 * @see #back | 700 * </ul> |
553 */ | 701 * |
554 public bool isBackEnabled () { | 702 * @since 3.0 |
555 checkWidget(); | 703 */ |
556 return webBrowser.isBackEnabled(); | 704 public void removeVisibilityWindowListener (VisibilityWindowListener listener) { |
557 } | 705 checkWidget(); |
558 | 706 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
559 public bool isFocusControl () { | 707 webBrowser.removeVisibilityWindowListener (listener); |
560 checkWidget(); | 708 } |
561 if (webBrowser.isFocusControl()) | 709 |
562 return true; | 710 /** |
563 return super.isFocusControl(); | 711 * Renders HTML. |
564 } | 712 * |
565 | 713 * <p> |
566 /** | 714 * The html parameter is Unicode encoded since it is a java <code>String</code>. |
567 * Returns <code>true</code> if the receiver can navigate to the | 715 * As a result, the HTML meta tag charset should not be set. The charset is implied |
568 * next session history item, and <code>false</code> otherwise. | 716 * by the <code>String</code> itself. |
569 * | 717 * |
570 * @return the receiver's forward command enabled state | 718 * @param html the HTML content to be rendered |
571 * | 719 * |
572 * @exception DWTException <ul> | 720 * @return true if the operation was successful and false otherwise. |
573 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 721 * |
574 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 722 * @exception IllegalArgumentException <ul> |
575 * </ul> | 723 * <li>ERROR_NULL_ARGUMENT - if the html is null</li> |
576 * | 724 * </ul> |
577 * @see #forward | 725 * |
578 */ | 726 * @exception DWTException <ul> |
579 public bool isForwardEnabled () { | 727 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
580 checkWidget(); | 728 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
581 return webBrowser.isForwardEnabled(); | 729 * </ul> |
582 } | 730 * |
583 | 731 * @see #setUrl |
584 /** | 732 * |
585 * Refresh the current page. | 733 * @since 3.0 |
586 * | 734 */ |
587 * @exception DWTException <ul> | 735 public bool setText (String html) { |
588 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 736 checkWidget(); |
589 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 737 if (html is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
590 * </ul> | 738 return webBrowser.setText (html); |
591 * | 739 } |
592 * @since 3.0 | 740 |
593 */ | 741 /** |
594 public void refresh () { | 742 * Loads a URL. |
595 checkWidget(); | 743 * |
596 webBrowser.refresh(); | 744 * @param url the URL to be loaded |
597 } | 745 * |
598 | 746 * @return true if the operation was successful and false otherwise. |
599 /** | 747 * |
600 * Removes the listener from the collection of listeners who will | 748 * @exception IllegalArgumentException <ul> |
601 * be notified when the window hosting the receiver should be closed. | 749 * <li>ERROR_NULL_ARGUMENT - if the url is null</li> |
602 * | 750 * </ul> |
603 * @param listener the listener which should no longer be notified | 751 * |
604 * | 752 * @exception DWTException <ul> |
605 * @exception IllegalArgumentException <ul> | 753 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
606 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 754 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
607 * </ul> | 755 * </ul> |
608 * | 756 * |
609 * @exception DWTException <ul> | 757 * @see #getUrl |
610 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 758 * |
611 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 759 * @since 3.0 |
612 * </ul> | 760 */ |
613 * | 761 public bool setUrl (String url) { |
614 * @since 3.0 | 762 checkWidget(); |
615 */ | 763 if (url is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
616 public void removeCloseWindowListener (CloseWindowListener listener) { | 764 return webBrowser.setUrl (url); |
617 checkWidget(); | 765 } |
618 if (listener is null) | 766 |
619 DWT.error(DWT.ERROR_NULL_ARGUMENT); | 767 /** |
620 webBrowser.removeCloseWindowListener(listener); | 768 * Stop any loading and rendering activity. |
621 } | 769 * |
622 | 770 * @exception DWTException <ul> |
623 /** | 771 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
624 * Removes the listener from the collection of listeners who will | 772 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
625 * be notified when the current location is changed or about to be changed. | 773 * </ul> |
626 * | 774 * |
627 * @param listener the listener which should no longer be notified | 775 * @since 3.0 |
628 * | 776 */ |
629 * @exception IllegalArgumentException <ul> | 777 public void stop () { |
630 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | 778 checkWidget(); |
631 * </ul> | 779 webBrowser.stop (); |
632 * | 780 } |
633 * @exception DWTException <ul> | 781 } |
634 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
635 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
636 * </ul> | |
637 * | |
638 * @since 3.0 | |
639 */ | |
640 public void removeLocationListener (LocationListener listener) { | |
641 checkWidget(); | |
642 if (listener is null) | |
643 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
644 webBrowser.removeLocationListener(listener); | |
645 } | |
646 | |
647 /** | |
648 * Removes the listener from the collection of listeners who will | |
649 * be notified when a new window needs to be created. | |
650 * | |
651 * @param listener the listener which should no longer be notified | |
652 * | |
653 * @exception IllegalArgumentException <ul> | |
654 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
655 * </ul> | |
656 * | |
657 * @exception DWTException <ul> | |
658 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
659 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
660 * </ul> | |
661 * | |
662 * @since 3.0 | |
663 */ | |
664 public void removeOpenWindowListener (OpenWindowListener listener) { | |
665 checkWidget(); | |
666 if (listener is null) | |
667 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
668 webBrowser.removeOpenWindowListener(listener); | |
669 } | |
670 | |
671 /** | |
672 * Removes the listener from the collection of listeners who will | |
673 * be notified when a progress is made during the loading of the current | |
674 * URL or when the loading of the current URL has been completed. | |
675 * | |
676 * @param listener the listener which should no longer be notified | |
677 * | |
678 * @exception IllegalArgumentException <ul> | |
679 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
680 * </ul> | |
681 * | |
682 * @exception DWTException <ul> | |
683 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
684 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
685 * </ul> | |
686 * | |
687 * @since 3.0 | |
688 */ | |
689 public void removeProgressListener (ProgressListener listener) { | |
690 checkWidget(); | |
691 if (listener is null) | |
692 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
693 webBrowser.removeProgressListener(listener); | |
694 } | |
695 | |
696 /** | |
697 * Removes the listener from the collection of listeners who will | |
698 * be notified when the status text is changed. | |
699 * | |
700 * @param listener the listener which should no longer be notified | |
701 * | |
702 * @exception IllegalArgumentException <ul> | |
703 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
704 * </ul> | |
705 * | |
706 * @exception DWTException <ul> | |
707 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
708 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
709 * </ul> | |
710 * | |
711 * @since 3.0 | |
712 */ | |
713 public void removeStatusTextListener (StatusTextListener listener) { | |
714 checkWidget(); | |
715 if (listener is null) | |
716 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
717 webBrowser.removeStatusTextListener(listener); | |
718 } | |
719 | |
720 /** | |
721 * Removes the listener from the collection of listeners who will | |
722 * be notified when the title of the current document is available | |
723 * or has changed. | |
724 * | |
725 * @param listener the listener which should no longer be notified | |
726 * | |
727 * @exception IllegalArgumentException <ul> | |
728 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
729 * </ul> | |
730 * | |
731 * @exception DWTException <ul> | |
732 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
733 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
734 * </ul> | |
735 * | |
736 * @since 3.0 | |
737 */ | |
738 public void removeTitleListener (TitleListener listener) { | |
739 checkWidget(); | |
740 if (listener is null) | |
741 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
742 webBrowser.removeTitleListener(listener); | |
743 } | |
744 | |
745 /** | |
746 * Removes the listener from the collection of listeners who will | |
747 * be notified when a window hosting the receiver needs to be displayed | |
748 * or hidden. | |
749 * | |
750 * @param listener the listener which should no longer be notified | |
751 * | |
752 * @exception IllegalArgumentException <ul> | |
753 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
754 * </ul> | |
755 * | |
756 * @exception DWTException <ul> | |
757 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
758 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
759 * </ul> | |
760 * | |
761 * @since 3.0 | |
762 */ | |
763 public void removeVisibilityWindowListener (VisibilityWindowListener listener) { | |
764 checkWidget(); | |
765 if (listener is null) | |
766 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
767 webBrowser.removeVisibilityWindowListener(listener); | |
768 } | |
769 | |
770 /** | |
771 * Renders HTML. | |
772 * | |
773 * <p> | |
774 * The html parameter is Unicode encoded since it is a java <code>String</code>. | |
775 * As a result, the HTML meta tag charset should not be set. The charset is implied | |
776 * by the <code>String</code> itself. | |
777 * | |
778 * @param html the HTML content to be rendered | |
779 * | |
780 * @return true if the operation was successful and false otherwise. | |
781 * | |
782 * @exception IllegalArgumentException <ul> | |
783 * <li>ERROR_NULL_ARGUMENT - if the html is null</li> | |
784 * </ul> | |
785 * | |
786 * @exception DWTException <ul> | |
787 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
788 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
789 * </ul> | |
790 * | |
791 * @see #setUrl | |
792 * | |
793 * @since 3.0 | |
794 */ | |
795 public bool setText (String html) { | |
796 checkWidget(); | |
797 if (html is null) | |
798 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
799 return webBrowser.setText(html); | |
800 } | |
801 | |
802 /** | |
803 * Loads a URL. | |
804 * | |
805 * @param url the URL to be loaded | |
806 * | |
807 * @return true if the operation was successful and false otherwise. | |
808 * | |
809 * @exception IllegalArgumentException <ul> | |
810 * <li>ERROR_NULL_ARGUMENT - if the url is null</li> | |
811 * </ul> | |
812 * | |
813 * @exception DWTException <ul> | |
814 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
815 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
816 * </ul> | |
817 * | |
818 * @see #getUrl | |
819 * | |
820 * @since 3.0 | |
821 */ | |
822 public bool setUrl (String url) { | |
823 checkWidget(); | |
824 if (url is null) | |
825 DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
826 return webBrowser.setUrl(url); | |
827 } | |
828 | |
829 /** | |
830 * Stop any loading and rendering activity. | |
831 * | |
832 * @exception DWTException <ul> | |
833 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | |
834 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | |
835 * </ul> | |
836 * | |
837 * @since 3.0 | |
838 */ | |
839 public void stop () { | |
840 checkWidget(); | |
841 webBrowser.stop(); | |
842 } | |
843 } |