1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
5 | * library suite from the New Zealand Digital Library Project at the
|
---|
6 | * University of Waikato, New Zealand.
|
---|
7 | *
|
---|
8 | * <BR><BR>
|
---|
9 | *
|
---|
10 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
11 | *
|
---|
12 | * <BR><BR>
|
---|
13 | *
|
---|
14 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
15 | *
|
---|
16 | * <BR><BR>
|
---|
17 | *
|
---|
18 | * This program is free software; you can redistribute it and/or modify
|
---|
19 | * it under the terms of the GNU General Public License as published by
|
---|
20 | * the Free Software Foundation; either version 2 of the License, or
|
---|
21 | * (at your option) any later version.
|
---|
22 | *
|
---|
23 | * <BR><BR>
|
---|
24 | *
|
---|
25 | * This program is distributed in the hope that it will be useful,
|
---|
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
28 | * GNU General Public License for more details.
|
---|
29 | *
|
---|
30 | * <BR><BR>
|
---|
31 | *
|
---|
32 | * You should have received a copy of the GNU General Public License
|
---|
33 | * along with this program; if not, write to the Free Software
|
---|
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
35 | *########################################################################
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | package org.greenstone.gatherer.gui.browser;
|
---|
44 |
|
---|
45 | import java.awt.AWTEvent;
|
---|
46 | import javax.swing.JProgressBar;
|
---|
47 | import org.greenstone.gatherer.util.GURL;
|
---|
48 |
|
---|
49 | /** A GBrowserEvent is an event fired by one of Gatherers HTMLViewPane browser
|
---|
50 | * implementations. They come in two flavours; GURL events contain a url
|
---|
51 | * which the message is about and may have an associated message String, while
|
---|
52 | * pure message events contain only a String.
|
---|
53 | */
|
---|
54 | public class GBrowserEvent
|
---|
55 | extends AWTEvent {
|
---|
56 |
|
---|
57 | /** The url payload of this event. */
|
---|
58 | private GURL url = null;
|
---|
59 |
|
---|
60 | private JProgressBar progress = null;
|
---|
61 |
|
---|
62 | /** The message payload of this event. */
|
---|
63 | private String message = null;
|
---|
64 |
|
---|
65 | /** This contructor is used to pass events about GURLs out to its
|
---|
66 | * listeners. The source and id are needed by the super class of AWTEvents
|
---|
67 | * but the url is specific to this class.
|
---|
68 | * @param source the class Object that fired this event.
|
---|
69 | * @param id a numeric identifier for this event.
|
---|
70 | * @param url the GURL about which this event is concerned.
|
---|
71 | */
|
---|
72 | public GBrowserEvent(Object source, int id, GURL url) {
|
---|
73 | super(source, id);
|
---|
74 | this.url = url;
|
---|
75 | }
|
---|
76 |
|
---|
77 | /** This contructor is used to pass events about GURLs out to its
|
---|
78 | * listeners. The source and id are needed by the super class of AWTEvents
|
---|
79 | * but the url and message are specific to this class.
|
---|
80 | * @param source the class Object that fired this event.
|
---|
81 | * @param id a numeric identifier for this event.
|
---|
82 | * @param url the GURL about which this event is concerned.
|
---|
83 | * @param message a message String, the reason for this event.
|
---|
84 | */
|
---|
85 | public GBrowserEvent(Object source, int id, GURL url, String message) {
|
---|
86 | super(source, id);
|
---|
87 | this.url = url;
|
---|
88 | }
|
---|
89 |
|
---|
90 | /** This constructor is used to pass message events out to its listeners.
|
---|
91 | * It is much the same as the first constructor, however instead of a
|
---|
92 | * GURL as payload, we instead have a message String.
|
---|
93 | * @param source the class Object that fired this event.
|
---|
94 | * @param id a numeric identifier for this event.
|
---|
95 | * @param message a message String, the reason for this event.
|
---|
96 | */
|
---|
97 | public GBrowserEvent(Object source, int id, String message) {
|
---|
98 | super(source, id);
|
---|
99 | this.message = message;
|
---|
100 | }
|
---|
101 |
|
---|
102 | /** Used to get the GURL contained within this event.
|
---|
103 | * @return a GURL specifying the url this event is concerned with, or null
|
---|
104 | * if this is a message type event.
|
---|
105 | */
|
---|
106 | public GURL getURL() {
|
---|
107 | return url;
|
---|
108 | }
|
---|
109 |
|
---|
110 | /** Used to get the String message contained within this event.
|
---|
111 | * @return a String containing the message for this event, or null if this
|
---|
112 | * is a GURL type event.
|
---|
113 | */
|
---|
114 | public String getMessage() {
|
---|
115 | return message;
|
---|
116 | }
|
---|
117 |
|
---|
118 | /** Returns a boolean showing whether it is legal to request this GURLs
|
---|
119 | * progress bar. All GURLs have progress bars, but only those spawned in
|
---|
120 | * GHTMLPanes etc will actually have their progress bars updated. Webclient
|
---|
121 | * does not yet support this functionality but will eventually via the
|
---|
122 | * DocumentProgressEvent.
|
---|
123 | * @return A boolean specifying whether this GURL supports ProgressBar
|
---|
124 | * requests.
|
---|
125 | */
|
---|
126 | public boolean hasProgress() {
|
---|
127 | if(progress != null) {
|
---|
128 | return true;
|
---|
129 | }
|
---|
130 | return false;
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|