KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > browser > WebBrowserEvent


1 /*
2  * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is
3  * subject to license terms.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the Lesser GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  */

20
21 package org.jdesktop.jdic.browser;
22
23 import java.util.EventObject JavaDoc;
24
25 /**
26  * A <code>WebBrowserEvent</code> is dispatched by a <code>WebBrowser</code>
27  * object to indicate a defined WebBrowser event occured. The event is passed
28  * to every <code>WebBrowserListener</code> object that was registered to
29  * receive such events using WebBrowser's <code>addWebBrowserListener</code>
30  * method.
31  * <p>
32  * The object that implements the <code>WebBrowserListener</code> interface or
33  * inherits the <code>WebBrowserAdapter</code> class gets this
34  * <code>WebBrowserEvent</code> when the event occurs. The listener is
35  * therefore spared the details of processing individual WebBrowser events.
36  *
37  * @see WebBrowserListener
38  * @see WebBrowser
39  *
40  * @author Kyle Yuan
41  * @version 0.1, 03/07/17
42  */

43 public class WebBrowserEvent extends EventObject JavaDoc
44 {
45     private static final int WEBBROWSER_FIRST = 3000;
46     /**
47      * Event fired before a navigation occurs in the given object
48      * (on either a window or frameset element).
49      */

50     static final int WEBBROWSER_BEFORE_NAVIGATE
51         = 1 + WEBBROWSER_FIRST;
52
53     /**
54      * Event fired when a new window is to be created.
55      */

56     static final int WEBBROWSER_BEFORE_NEWWINDOW
57         = 2 + WEBBROWSER_FIRST;
58     
59     /**
60      * Event fired when a navigation operation is beginning.
61      */

62     public static final int WEBBROWSER_DOWNLOAD_STARTED
63         = 3 + WEBBROWSER_FIRST;
64     
65     /**
66      * Event fired when a navigation operation finishes, is halted, or fails.
67      * This may be fired multiple times if a document has pop-up windows
68      * or frames.
69      */

70     public static final int WEBBROWSER_DOWNLOAD_COMPLETED
71         = 4 + WEBBROWSER_FIRST;
72     
73     /**
74      * Event fired when the progress of a navigation operation is updated
75      * on the object.
76      */

77     public static final int WEBBROWSER_DOWNLOAD_PROGRESS
78         = 5 + WEBBROWSER_FIRST;
79     
80     /**
81      * Event fired when an error occurs during a navigation operation.
82      */

83     public static final int WEBBROWSER_DOWNLOAD_ERROR
84         = 6 + WEBBROWSER_FIRST;
85     
86     /**
87      * Event fired when the document has loaded completely.
88      *
89      * @since 0.9
90      */

91     public static final int WEBBROWSER_DOCUMENT_COMPLETED
92         = 7 + WEBBROWSER_FIRST;
93
94     /**
95      * Event fired when the current URL is requested by a <code>WebBrowser</code>
96      * object's <code>getURL</code> method.
97      */

98     static final int WEBBROWSER_RETURN_URL
99         = 21 + WEBBROWSER_FIRST;
100
101     /**
102      * Event fired when the enabled state of a command changes.
103      */

104     static final int WEBBROWSER_COMMAND_STATE_CHANGE
105         = 22 + WEBBROWSER_FIRST;
106     /**
107      * Event fired when the title of a document changes.
108      */

109     public static final int WEBBROWSER_TITLE_CHANGE
110         = 23 + WEBBROWSER_FIRST;
111     /**
112      * Event fired when the status bar text changes.
113      */

114     public static final int WEBBROWSER_STATUSTEXT_CHANGE
115         = 24 + WEBBROWSER_FIRST;
116
117     /**
118      * Event fired when the initialization of WebBrowser fails.
119      */

120     static final int WEBBROWSER_INIT_FAILED
121         = 41 + WEBBROWSER_FIRST;
122     /**
123      * Event fired when initialization of WebBrowser Window succeeds.
124      */

125     static final int WEBBROWSER_INIT_WINDOW_SUCC
126         = 42 + WEBBROWSER_FIRST;
127     /**
128      * Event fired when WebBrowser need to get Focus.
129      */

130     static final int WEBBROWSER_FOCUS_REQUEST
131         = 43 + WEBBROWSER_FIRST;
132     
133     /**
134      * Event fired when destroy of WebBrowser Window succeeds.
135      */

136     static final int WEBBROWSER_DESTROYWINDOW_SUCC
137         = 44 + WEBBROWSER_FIRST;
138
139     /**
140      * Event fired when the content of the currently loaded page is requested
141      * by a WebBrowser object's getContent method.
142      */

143     static final int WEBBROWSER_GETCONTENT
144         = 61 + WEBBROWSER_FIRST;
145     /**
146      * Event fired when the content of the currently loaded page is requested
147      * to be set by a WebBrowser object's setContent() method.
148      */

149     static final int WEBBROWSER_SETCONTENT
150         = 62 + WEBBROWSER_FIRST;
151     /**
152      * Event fired when a javascript string is requrested to be executed
153      * by a WebBrowser object's executeScript method.
154      */

155     static final int WEBBROWSER_EXECUTESCRIPT
156         = 63 + WEBBROWSER_FIRST;
157     
158     /**
159      * The event's id.
160      */

161     int id;
162     /**
163      * Content of the event
164      */

165     String JavaDoc data;
166
167     /**
168      * Constructs a <code>WebBrowserEvent</code> object with source and event id.
169      *
170      * @param source the WebBrowser which owns this event.
171      * @param id the id of the event.
172      */

173     public WebBrowserEvent(WebBrowser source, int id) {
174         this(source, id, null);
175     }
176
177     /**
178      * Constructs a <code>WebBrowserEvent</code> object with source, event id
179      * and event data.
180      *
181      * @param source the WebBrowser which owns this event.
182      * @param id the id of the event.
183      * @param data the data of the event.
184      */

185     public WebBrowserEvent(WebBrowser source, int id, String JavaDoc data) {
186         super(source);
187         this.id = id;
188         this.data = data;
189     }
190
191     /**
192      * Returns the event ID.
193      */

194     public int getID() {
195         return id;
196     }
197
198     /**
199      * Returns the event data.
200      */

201     public String JavaDoc getData() {
202         return data;
203     }
204 }
Popular Tags