001 package data.events;
002
003 import util.SerializableListener;
004 import data.CatalogItem;
005
006 /**
007 * An <i>abstract</i> adapter class for receiving catalog change events. The methods in this class are empty.
008 * This class exists as convenience for creating listener objects.
009 *
010 * <p>Extend this class to create a CatalogChangeEvent listener and override the methods for the events of
011 * interest. (If you implement the CatalogChangeListener interface, you have to define all of the methods in
012 * it. This abstract class defines empty method bodies for them all, so you can concentrate on defining
013 * methods only for events you care about.)</p>
014 *
015 * <p>Create a listener object using the extended class and then register it with a ListenableCatalog using
016 * the Catalog's {@link data.ListenableCatalog#addCatalogChangeListener} method. When the Catalog's contents
017 * change, the relevant method in the listener object is invoked, and a {@link CatalogChangeEvent} is passed
018 * to it.</p>
019 *
020 * @author Steffen Zschaler
021 * @version 2.0 19/08/1999
022 * @since v2.0
023 */
024 public abstract class CatalogChangeAdapter<T extends CatalogItem> extends Object
025 implements CatalogChangeListener<T>,
026 SerializableListener {
027
028 /**
029 * Called whenever a CatalogItem was added to the Catalog.
030 *
031 * @override Sometimes
032 *
033 * @param e an event object describing the event.
034 */
035 public void addedCatalogItem(CatalogChangeEvent<T> e) {}
036
037 /**
038 * Called whenever the adding of a CatalogItem was commited.
039 *
040 * @override Sometimes
041 *
042 * @param e an event object describing the event.
043 */
044 public void commitedAddCatalogItem(CatalogChangeEvent<T> e) {}
045
046 /**
047 * Called whenever the adding of a CatalogItem was rolled back.
048 *
049 * @override Sometimes
050 *
051 * @param e an event object describing the event.
052 */
053 public void rolledbackAddCatalogItem(CatalogChangeEvent<T> e) {}
054
055 /**
056 * Called to ask whether a CatalogItem may be removed. If one of the listeners vetos the removal, all
057 * listeners that had already been asked will receive a {@link #noRemoveCatalogItem noRemoveCatalogItem}
058 * event.
059 *
060 * @override Sometimes
061 *
062 * @param e an event object describing the event.
063 *
064 * @exception VetoException if the listener wants to veto the removal.
065 */
066 public void canRemoveCatalogItem(CatalogChangeEvent<T> e) throws VetoException {}
067
068 /**
069 * Called for each listener that already agreed with a removal that was then rejected by another listener.
070 *
071 * @override Sometimes
072 *
073 * @param e an event object describing the event.
074 */
075 public void noRemoveCatalogItem(CatalogChangeEvent<T> e) {}
076
077 /**
078 * Called whenever a CatalogItem was removed from the Catalog.
079 *
080 * @override Sometimes
081 *
082 * @param e an event object describing the event.
083 */
084 public void removedCatalogItem(CatalogChangeEvent<T> e) {}
085
086 /**
087 * Called whenever the removal of a CatalogItem was commited.
088 *
089 * @override Sometimes
090 *
091 * @param e an event object describing the event.
092 */
093 public void commitedRemoveCatalogItem(CatalogChangeEvent<T> e) {}
094
095 /**
096 * Called whenever the removal of a CatalogItem was rolled back.
097 *
098 * @override Sometimes
099 *
100 * @param e an event object describing the event.
101 */
102 public void rolledbackRemoveCatalogItem(CatalogChangeEvent<T> e) {}
103
104 /**
105 * Called to ask whether a CatalogItem may be edited. If one of the listeners vetos the editing, all
106 * steners that had already been asked will receive a {@link #noEditCatalogItem noEditCatalogItem} event.
107 *
108 * @override Sometimes
109 *
110 * @param e an event object describing the event.
111 *
112 * @exception VetoException if the listener wants to veto the editing.
113 */
114 public void canEditCatalogItem(CatalogChangeEvent<T> e) throws VetoException {}
115
116 /**
117 * Called for each listener that already agreed with an editing that was then rejected by another listener.
118 *
119 * @override Sometimes
120 *
121 * @param e an event object describing the event.
122 */
123 public void noEditCatalogItem(CatalogChangeEvent<T> e) {}
124
125 /**
126 * Called whenever editing a CatalogItem was started. This event may be accompanied by a
127 * <code>removedCatalogItem</code> and a <code>addedCatalogItem</code> event, but this is implementation
128 * specific.
129 *
130 * @override Sometimes
131 *
132 * @param e an event object describing the event.
133 */
134 public void editingCatalogItem(CatalogChangeEvent<T> e) {}
135
136 /**
137 * Called whenever editing a CatalogItem was commited.
138 *
139 * @override Sometimes
140 *
141 * @param e an event object describing the event.
142 */
143 public void commitEditCatalogItem(CatalogChangeEvent<T> e) {}
144
145 /**
146 * Called whenever editing a CatalogItem was rolled back.
147 *
148 * @override Sometimes
149 *
150 * @param e an event object describing the event.
151 */
152 public void rollbackEditCatalogItem(CatalogChangeEvent<T> e) {}
153 }