/** *######################################################################### * * A component of the Gatherer application, part of the Greenstone digital * library suite from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * *

* * Author: John Thompson, Greenstone Digital Library, University of Waikato * *

* * Copyright (C) 1999 New Zealand Digital Library Project * *

* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * *

* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * *

* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *######################################################################## */ package org.greenstone.gatherer.gui.browser; import java.awt.AWTEvent; import javax.swing.JProgressBar; import org.greenstone.gatherer.util.GURL; /** A GBrowserEvent is an event fired by one of Gatherers HTMLViewPane browser * implementations. They come in two flavours; GURL events contain a url * which the message is about and may have an associated message String, while * pure message events contain only a String. */ public class GBrowserEvent extends AWTEvent { /** The url payload of this event. */ private GURL url = null; private JProgressBar progress = null; /** The message payload of this event. */ private String message = null; /** This contructor is used to pass events about GURLs out to its * listeners. The source and id are needed by the super class of AWTEvents * but the url is specific to this class. * @param source the class Object that fired this event. * @param id a numeric identifier for this event. * @param url the GURL about which this event is concerned. */ public GBrowserEvent(Object source, int id, GURL url) { super(source, id); this.url = url; } /** This contructor is used to pass events about GURLs out to its * listeners. The source and id are needed by the super class of AWTEvents * but the url and message are specific to this class. * @param source the class Object that fired this event. * @param id a numeric identifier for this event. * @param url the GURL about which this event is concerned. * @param message a message String, the reason for this event. */ public GBrowserEvent(Object source, int id, GURL url, String message) { super(source, id); this.url = url; } /** This constructor is used to pass message events out to its listeners. * It is much the same as the first constructor, however instead of a * GURL as payload, we instead have a message String. * @param source the class Object that fired this event. * @param id a numeric identifier for this event. * @param message a message String, the reason for this event. */ public GBrowserEvent(Object source, int id, String message) { super(source, id); this.message = message; } /** Used to get the GURL contained within this event. * @return a GURL specifying the url this event is concerned with, or null * if this is a message type event. */ public GURL getURL() { return url; } /** Used to get the String message contained within this event. * @return a String containing the message for this event, or null if this * is a GURL type event. */ public String getMessage() { return message; } /** Returns a boolean showing whether it is legal to request this GURLs * progress bar. All GURLs have progress bars, but only those spawned in * GHTMLPanes etc will actually have their progress bars updated. Webclient * does not yet support this functionality but will eventually via the * DocumentProgressEvent. * @return A boolean specifying whether this GURL supports ProgressBar * requests. */ public boolean hasProgress() { if(progress != null) { return true; } return false; } }