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