Add InsertListener support.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 12 Nov 2008 21:38:07 +0000 (22:38 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 12 Nov 2008 21:38:07 +0000 (22:38 +0100)
src/net/pterodactylus/jsite/core/InsertListenerSupport.java [new file with mode: 0644]

diff --git a/src/net/pterodactylus/jsite/core/InsertListenerSupport.java b/src/net/pterodactylus/jsite/core/InsertListenerSupport.java
new file mode 100644 (file)
index 0000000..52ce219
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * jSite-next - InsertListenerSupport.java -
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package net.pterodactylus.jsite.core;
+
+import net.pterodactylus.util.event.ListenerSupport;
+
+/**
+ * Helper class that fires {@link InsertListener} events.
+ *
+ * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+ */
+public class InsertListenerSupport extends ListenerSupport<Insert, InsertListener> {
+
+       /**
+        * Creates a new insert listener support.
+        *
+        * @param insert
+        *            The source insert
+        */
+       public InsertListenerSupport(Insert insert) {
+               super(insert);
+       }
+
+       /**
+        * Notifies all listeners that the insert was added.
+        *
+        * @see InsertListener#insertAdded(Insert)
+        */
+       public void fireInsertAdded() {
+               for (InsertListener insertListener : getListeners()) {
+                       insertListener.insertAdded(getSource());
+               }
+       }
+
+       /**
+        * Notifies all listeners that the insert was removed.
+        *
+        * @see InsertListener#insertRemoved(Insert)
+        */
+       public void fireInsertRemoved() {
+               for (InsertListener insertListener : getListeners()) {
+                       insertListener.insertRemoved(getSource());
+               }
+       }
+
+       /**
+        * Notifies all listeners that the insert was started.
+        *
+        * @see InsertListener#insertStarted(Insert)
+        */
+       public void fireInsertStarted() {
+               for (InsertListener insertListener : getListeners()) {
+                       insertListener.insertStarted(getSource());
+               }
+       }
+
+       /**
+        * Notifies all listeners that the insert made progress.
+        *
+        * @see InsertListener#insertProgressed(Insert)
+        */
+       public void fireInsertProgressed() {
+               for (InsertListener insertListener : getListeners()) {
+                       insertListener.insertProgressed(getSource());
+               }
+       }
+
+       /**
+        * Notifies all listeners that the insert generated a URI.
+        *
+        * @see InsertListener#insertGeneratedURI(Insert, String)
+        * @param generatedUri
+        *            The URI that was generated
+        */
+       public void fireInsertGeneratedURI(String generatedUri) {
+               for (InsertListener insertListener : getListeners()) {
+                       insertListener.insertGeneratedURI(getSource(), generatedUri);
+               }
+       }
+
+       /**
+        * Notifies all listeners that the insert has finished.
+        *
+        * @see InsertListener#insertFinished(Insert)
+        */
+       public void fireInsertFinished() {
+               for (InsertListener insertListener : getListeners()) {
+                       insertListener.insertFinished(getSource());
+               }
+       }
+
+}