001: /* ====================================================================
002: * Copyright (c) 1998 - 2003 David F. Glasser. All rights
003: * reserved.
004: *
005: * This file is part of the QueryForm Database Tool.
006: *
007: * The QueryForm Database Tool is free software; you can redistribute it
008: * and/or modify it under the terms of the GNU General Public License as
009: * published by the Free Software Foundation; either version 2 of the
010: * License, or (at your option) any later version.
011: *
012: * The QueryForm Database Tool is distributed in the hope that it will
013: * be useful, but WITHOUT ANY WARRANTY; without even the implied
014: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
015: * See the GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with the QueryForm Database Tool; if not, write to:
019: *
020: * The Free Software Foundation, Inc.,
021: * 59 Temple Place, Suite 330
022: * Boston, MA 02111-1307 USA
023: *
024: * or visit http://www.gnu.org.
025: *
026: * ====================================================================
027: *
028: * This product includes software developed by the
029: * Apache Software Foundation (http://www.apache.org/).
030: *
031: * ====================================================================
032: *
033: * $Source: /cvsroot/qform/qform/src/org/glasser/qform/QueryPanelEvent.java,v $
034: * $Revision: 1.1 $
035: * $Author: dglasser $
036: * $Date: 2003/05/29 00:40:24 $
037: *
038: * --------------------------------------------------------------------
039: */
040: package org.glasser.qform;
041:
042: import java.util.*;
043: import org.glasser.util.*;
044:
045: /**
046: * This is a SmartEvent that is fired by a QueryPanel to notify listeners of
047: * various types of events.
048: *
049: * @author David F. Glasser
050: */
051: public final class QueryPanelEvent implements SmartEvent,
052: java.io.Serializable {
053:
054: public final static int STATE_CHANGED = 0;
055:
056: public final static int HORIZONTAL_SCROLLBAR_STATE_CHANGED = 1;
057:
058: private int type = STATE_CHANGED;
059:
060: private QueryPanel source = null;
061:
062: /**
063: * Constructs a QueryPanelEvent object.
064: *
065: * @param source the QueryPanel which originated this event.
066: * @param type an it indicating what type of event occurred. Currently the only
067: * type of event is STATE_CHANGED.
068: */
069: public QueryPanelEvent(QueryPanel source, int type) {
070: this .source = source;
071: this .type = type;
072: }
073:
074: /**
075: * Returns the Class for the interface that receives this type of event; in this
076: * particular case is is QueryPanelListener.class.
077: */
078: public Class getListenerClass() {
079: return QueryPanelListener.class;
080: }
081:
082: /**
083: * Returns an int indicating the type of event occurred. Currently the only
084: * type of event is STATE_CHANGED.
085: */
086: public int getType() {
087: return type;
088: }
089:
090: /**
091: * This method, specified by the org.glasser.util.SmartEventListener interface,
092: * is passed a reference to one of the listeners registered to receive this
093: * event. It then calls the appropriate method on the listener interface,
094: * notifying the object of the event.
095: */
096: public void notifyListener(EventListener listener) {
097:
098: QueryPanelListener panelListener = (QueryPanelListener) listener;
099:
100: switch (type) { // a switch is used in anticipation of adding more event types.
101: case STATE_CHANGED:
102: panelListener.queryPanelStateChanged(this );
103: break;
104: case HORIZONTAL_SCROLLBAR_STATE_CHANGED:
105: panelListener
106: .queryPanelHorizontalScrollbarStateChanged(this );
107: break;
108: default:
109: throw new RuntimeException(
110: "QueryPanelEvent: Invalid Type: " + type);
111: }
112: }
113: }
|