From: David ‘Bombe’ Roden Date: Wed, 12 Nov 2008 21:38:07 +0000 (+0100) Subject: Add InsertListener support. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4b349422dc962a0c8e573d8d4714b5af2486cf69;p=jSite2.git Add InsertListener support. --- diff --git a/src/net/pterodactylus/jsite/core/InsertListenerSupport.java b/src/net/pterodactylus/jsite/core/InsertListenerSupport.java new file mode 100644 index 0000000..52ce219 --- /dev/null +++ b/src/net/pterodactylus/jsite/core/InsertListenerSupport.java @@ -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 <bombe@freenetproject.org> + */ +public class InsertListenerSupport extends ListenerSupport { + + /** + * 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()); + } + } + +}