52ce219b081ccd8a51f7df325e2e96fa3ebcc7a8
[jSite2.git] / src / net / pterodactylus / jsite / core / InsertListenerSupport.java
1 /*
2  * jSite-next - InsertListenerSupport.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 import net.pterodactylus.util.event.ListenerSupport;
23
24 /**
25  * Helper class that fires {@link InsertListener} events.
26  *
27  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28  */
29 public class InsertListenerSupport extends ListenerSupport<Insert, InsertListener> {
30
31         /**
32          * Creates a new insert listener support.
33          *
34          * @param insert
35          *            The source insert
36          */
37         public InsertListenerSupport(Insert insert) {
38                 super(insert);
39         }
40
41         /**
42          * Notifies all listeners that the insert was added.
43          *
44          * @see InsertListener#insertAdded(Insert)
45          */
46         public void fireInsertAdded() {
47                 for (InsertListener insertListener : getListeners()) {
48                         insertListener.insertAdded(getSource());
49                 }
50         }
51
52         /**
53          * Notifies all listeners that the insert was removed.
54          *
55          * @see InsertListener#insertRemoved(Insert)
56          */
57         public void fireInsertRemoved() {
58                 for (InsertListener insertListener : getListeners()) {
59                         insertListener.insertRemoved(getSource());
60                 }
61         }
62
63         /**
64          * Notifies all listeners that the insert was started.
65          *
66          * @see InsertListener#insertStarted(Insert)
67          */
68         public void fireInsertStarted() {
69                 for (InsertListener insertListener : getListeners()) {
70                         insertListener.insertStarted(getSource());
71                 }
72         }
73
74         /**
75          * Notifies all listeners that the insert made progress.
76          *
77          * @see InsertListener#insertProgressed(Insert)
78          */
79         public void fireInsertProgressed() {
80                 for (InsertListener insertListener : getListeners()) {
81                         insertListener.insertProgressed(getSource());
82                 }
83         }
84
85         /**
86          * Notifies all listeners that the insert generated a URI.
87          *
88          * @see InsertListener#insertGeneratedURI(Insert, String)
89          * @param generatedUri
90          *            The URI that was generated
91          */
92         public void fireInsertGeneratedURI(String generatedUri) {
93                 for (InsertListener insertListener : getListeners()) {
94                         insertListener.insertGeneratedURI(getSource(), generatedUri);
95                 }
96         }
97
98         /**
99          * Notifies all listeners that the insert has finished.
100          *
101          * @see InsertListener#insertFinished(Insert)
102          */
103         public void fireInsertFinished() {
104                 for (InsertListener insertListener : getListeners()) {
105                         insertListener.insertFinished(getSource());
106                 }
107         }
108
109 }