2 * Sone - CoreListenerManager.java - Copyright © 2010–2012 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.core;
20 import net.pterodactylus.sone.data.Image;
21 import net.pterodactylus.sone.data.Post;
22 import net.pterodactylus.sone.data.PostReply;
23 import net.pterodactylus.sone.data.Sone;
24 import net.pterodactylus.util.event.AbstractListenerManager;
25 import net.pterodactylus.util.version.Version;
28 * Manager for {@link CoreListener}s.
30 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
32 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
35 * Creates a new core listener manager.
40 public CoreListenerManager(Core source) {
49 * Notifies all listener that the given Sone was removed.
51 * @see CoreListener#soneRemoved(Sone)
55 void fireSoneRemoved(Sone sone) {
56 for (CoreListener coreListener : getListeners()) {
57 coreListener.soneRemoved(sone);
62 * Notifies all listener that the given post was removed.
64 * @see CoreListener#postRemoved(Post)
68 void firePostRemoved(Post post) {
69 for (CoreListener coreListener : getListeners()) {
70 coreListener.postRemoved(post);
75 * Notifies all listener that the given reply was removed.
77 * @see CoreListener#replyRemoved(PostReply)
81 void fireReplyRemoved(PostReply reply) {
82 for (CoreListener coreListener : getListeners()) {
83 coreListener.replyRemoved(reply);
88 * Notifies all listeners that the given Sone was locked.
90 * @see CoreListener#soneLocked(Sone)
92 * The Sone that was locked
94 void fireSoneLocked(Sone sone) {
95 for (CoreListener coreListener : getListeners()) {
96 coreListener.soneLocked(sone);
101 * Notifies all listeners that the given Sone was unlocked.
103 * @see CoreListener#soneUnlocked(Sone)
105 * The Sone that was unlocked
107 void fireSoneUnlocked(Sone sone) {
108 for (CoreListener coreListener : getListeners()) {
109 coreListener.soneUnlocked(sone);
114 * Notifies all listeners that the insert of the given Sone has started.
116 * @see SoneInsertListener#insertStarted(Sone)
118 * The Sone being inserted
120 void fireSoneInserting(Sone sone) {
121 for (CoreListener coreListener : getListeners()) {
122 coreListener.soneInserting(sone);
127 * Notifies all listeners that the insert of the given Sone has finished
130 * @see SoneInsertListener#insertFinished(Sone, long)
132 * The Sone that was inserted
133 * @param insertDuration
134 * The insert duration (in milliseconds)
136 void fireSoneInserted(Sone sone, long insertDuration) {
137 for (CoreListener coreListener : getListeners()) {
138 coreListener.soneInserted(sone, insertDuration);
143 * Notifies all listeners that the insert of the given Sone was aborted.
145 * @see SoneInsertListener#insertStarted(Sone)
147 * The Sone being inserted
149 * The cause for the abortion (may be {@code null}
151 void fireSoneInsertAborted(Sone sone, Throwable cause) {
152 for (CoreListener coreListener : getListeners()) {
153 coreListener.soneInsertAborted(sone, cause);
158 * Notifies all listeners that a new version was found.
160 * @see CoreListener#updateFound(Version, long, long)
164 * The release time of the new version
165 * @param latestEdition
166 * The latest edition of the Sone homepage
168 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
169 for (CoreListener coreListener : getListeners()) {
170 coreListener.updateFound(version, releaseTime, latestEdition);
175 * Notifies all listeners that an image has started being inserted.
177 * @see CoreListener#imageInsertStarted(Image)
179 * The image that is now inserted
181 void fireImageInsertStarted(Image image) {
182 for (CoreListener coreListener : getListeners()) {
183 coreListener.imageInsertStarted(image);
188 * Notifies all listeners that an image insert was aborted by the user.
190 * @see CoreListener#imageInsertAborted(Image)
192 * The image that is not inserted anymore
194 void fireImageInsertAborted(Image image) {
195 for (CoreListener coreListener : getListeners()) {
196 coreListener.imageInsertAborted(image);
201 * Notifies all listeners that an image was successfully inserted.
203 * @see CoreListener#imageInsertFinished(Image)
205 * The image that was inserted
207 void fireImageInsertFinished(Image image) {
208 for (CoreListener coreListener : getListeners()) {
209 coreListener.imageInsertFinished(image);
214 * Notifies all listeners that an image failed to be inserted.
216 * @see CoreListener#imageInsertFailed(Image, Throwable)
218 * The image that could not be inserted
220 * The cause of the failure
222 void fireImageInsertFailed(Image image, Throwable cause) {
223 for (CoreListener coreListener : getListeners()) {
224 coreListener.imageInsertFailed(image, cause);