2 * Sone - CoreListenerManager.java - Copyright © 2010 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.Reply;
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 listeners that the given Sone is now being rescued.
51 * @see CoreListener#rescuingSone(Sone)
53 * The Sone that is being rescued
55 void fireRescuingSone(Sone sone) {
56 for (CoreListener coreListener : getListeners()) {
57 coreListener.rescuingSone(sone);
62 * Notifies all listeners that the given Sone was rescued.
64 * @see CoreListener#rescuedSone(Sone)
66 * The Sone that was rescued
68 void fireRescuedSone(Sone sone) {
69 for (CoreListener coreListener : getListeners()) {
70 coreListener.rescuedSone(sone);
75 * Notifies all listeners that a new Sone has been discovered.
77 * @see CoreListener#newSoneFound(Sone)
81 void fireNewSoneFound(Sone sone) {
82 for (CoreListener coreListener : getListeners()) {
83 coreListener.newSoneFound(sone);
88 * Notifies all listeners that a new post has been found.
90 * @see CoreListener#newPostFound(Post)
94 void fireNewPostFound(Post post) {
95 for (CoreListener coreListener : getListeners()) {
96 coreListener.newPostFound(post);
101 * Notifies all listeners that a new reply has been found.
103 * @see CoreListener#newReplyFound(Reply)
107 void fireNewReplyFound(Reply reply) {
108 for (CoreListener coreListener : getListeners()) {
109 coreListener.newReplyFound(reply);
114 * Notifies all listeners that the given Sone is now marked as known.
116 * @see CoreListener#markSoneKnown(Sone)
120 void fireMarkSoneKnown(Sone sone) {
121 for (CoreListener coreListener : getListeners()) {
122 coreListener.markSoneKnown(sone);
127 * Notifies all listeners that the given post is now marked as known.
132 void fireMarkPostKnown(Post post) {
133 for (CoreListener coreListener : getListeners()) {
134 coreListener.markPostKnown(post);
139 * Notifies all listeners that the given reply is now marked as known.
144 void fireMarkReplyKnown(Reply reply) {
145 for (CoreListener coreListener : getListeners()) {
146 coreListener.markReplyKnown(reply);
151 * Notifies all listener that the given post was removed.
153 * @see CoreListener#postRemoved(Post)
157 void firePostRemoved(Post post) {
158 for (CoreListener coreListener : getListeners()) {
159 coreListener.postRemoved(post);
164 * Notifies all listener that the given reply was removed.
166 * @see CoreListener#replyRemoved(Reply)
170 void fireReplyRemoved(Reply reply) {
171 for (CoreListener coreListener : getListeners()) {
172 coreListener.replyRemoved(reply);
177 * Notifies all listeners that the given Sone was locked.
179 * @see CoreListener#soneLocked(Sone)
181 * The Sone that was locked
183 void fireSoneLocked(Sone sone) {
184 for (CoreListener coreListener : getListeners()) {
185 coreListener.soneLocked(sone);
190 * Notifies all listeners that the given Sone was unlocked.
192 * @see CoreListener#soneUnlocked(Sone)
194 * The Sone that was unlocked
196 void fireSoneUnlocked(Sone sone) {
197 for (CoreListener coreListener : getListeners()) {
198 coreListener.soneUnlocked(sone);
203 * Notifies all listeners that a new version was found.
205 * @see CoreListener#updateFound(Version, long, long)
209 * The release time of the new version
210 * @param latestEdition
211 * The latest edition of the Sone homepage
213 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
214 for (CoreListener coreListener : getListeners()) {
215 coreListener.updateFound(version, releaseTime, latestEdition);
220 * Notifies all listeners that an image has started being inserted.
222 * @see CoreListener#imageInsertStarted(Image)
224 * The image that is now inserted
226 void fireImageInsertStarted(Image image) {
227 for (CoreListener coreListener : getListeners()) {
228 coreListener.imageInsertStarted(image);
233 * Notifies all listeners that an image insert was aborted by the user.
235 * @see CoreListener#imageInsertAborted(Image)
237 * The image that is not inserted anymore
239 void fireImageInsertAborted(Image image) {
240 for (CoreListener coreListener : getListeners()) {
241 coreListener.imageInsertAborted(image);
246 * Notifies all listeners that an image was successfully inserted.
248 * @see CoreListener#imageInsertFinished(Image)
250 * The image that was inserted
252 void fireImageInsertFinished(Image image) {
253 for (CoreListener coreListener : getListeners()) {
254 coreListener.imageInsertFinished(image);
259 * Notifies all listeners that an image failed to be inserted.
261 * @see CoreListener#imageInsertFailed(Image, Throwable)
263 * The image that could not be inserted
265 * The cause of the failure
267 void fireImageInsertFailed(Image image, Throwable cause) {
268 for (CoreListener coreListener : getListeners()) {
269 coreListener.imageInsertFailed(image, cause);