001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.event;
017:
018: /**
019: * Captures changes to Style.
020: *
021: * <p>
022: * The "delta" acts as a series of bread crumbs allowing you the listener to
023: * figure out what changed where. The <b>Type</b> answers that other peskey
024: * question: when.
025: * </p>
026: *
027: * <p>
028: * You should be warned that deltas may also be "saved up" for a rainy day,
029: * this keeps user interfaces from being flooded with a cascade of events. The
030: * best example is a "macro" that makes a series of changes and only reports
031: * back a compound change resulting from the batch opperation.
032: * </p>
033: *
034: * @author Jody Garnett, Refractions Research
035: *
036: * @since 2.2.M2
037: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/api/src/main/java/org/geotools/event/GTEvent.java $
038: */
039: public interface GTEvent {
040: /**
041: * Returns a delta, from the root, describing the set of changes that
042: * happened.
043: * <p>
044: * May be <code>null</code> if not applicable, available
045: * to this type of event.
046: *
047: * @return the style delta, or <code>null</code> if not applicable
048: */
049: public GTDelta getDelta();
050:
051: /**
052: * Root construct issuing the event.
053: * <p>
054: * Handy if you are listening to several things at once.
055: * </p>
056: * @return Root construct issuing event
057: */
058: public Object getSource();
059:
060: /**
061: * Returns the type of event being reported.
062: *
063: * @return one of the event type constants
064: *
065: * @see #POST_CHANGE
066: * @see #PRE_DELETE
067: */
068: public Type getType();
069:
070: /**
071: * Constants used to indicate the type of StyleChangedEvent
072: */
073: public class Type {
074: /**
075: * Event type indicating an after-the-fact report
076: * of creations, deletions, and modifications to one or more
077: * constructs expressed as a hierarchical delta as returned by
078: * <code>getDelta</code>.
079: *
080: * @see #getType()
081: */
082: public static final Type POST_CHANGE = new Type();
083:
084: /**
085: * Event type indicating a before-the-fact report
086: * of the impending deletion of a single construct.
087: * <p>
088: * The data is being removed, if you were keeping any
089: * metadata about this information it is time to throw
090: * away.
091: * </p>
092: * @see #getType()
093: */
094: public static final Type PRE_DELETE = new Type();
095:
096: /**
097: * Event type indicating a before-the-fact report
098: * of the impending closure of a single construct.
099: * <p>
100: * This is applicable when manging system resources,
101: * such as network connections and icons.
102: * </p>
103: * <p>
104: * We are simply tearing dow the data structure because
105: * the system is shutting down, you can keep metadata
106: * but be sure to return any resources you were using!
107: * </p>
108: * @see #getType()
109: */
110: public static final Type PRE_CLOSE = new Type();
111:
112: private Type() {
113: }
114: }
115: }
|