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