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