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 listeners that the given Sone is now marked as known.
51 * @see CoreListener#markSoneKnown(Sone)
55 void fireMarkSoneKnown(Sone sone) {
56 for (CoreListener coreListener : getListeners()) {
57 coreListener.markSoneKnown(sone);
62 * Notifies all listeners that the given post is now marked as known.
67 void fireMarkPostKnown(Post post) {
68 for (CoreListener coreListener : getListeners()) {
69 coreListener.markPostKnown(post);
74 * Notifies all listeners that the given reply is now marked as known.
79 void fireMarkReplyKnown(PostReply reply) {
80 for (CoreListener coreListener : getListeners()) {
81 coreListener.markReplyKnown(reply);
86 * Notifies all listener that the given Sone was removed.
88 * @see CoreListener#soneRemoved(Sone)
92 void fireSoneRemoved(Sone sone) {
93 for (CoreListener coreListener : getListeners()) {
94 coreListener.soneRemoved(sone);
99 * Notifies all listener that the given post was removed.
101 * @see CoreListener#postRemoved(Post)
105 void firePostRemoved(Post post) {
106 for (CoreListener coreListener : getListeners()) {
107 coreListener.postRemoved(post);
112 * Notifies all listener that the given reply was removed.
114 * @see CoreListener#replyRemoved(PostReply)
118 void fireReplyRemoved(PostReply reply) {
119 for (CoreListener coreListener : getListeners()) {
120 coreListener.replyRemoved(reply);
125 * Notifies all listeners that the given Sone was locked.
127 * @see CoreListener#soneLocked(Sone)
129 * The Sone that was locked
131 void fireSoneLocked(Sone sone) {
132 for (CoreListener coreListener : getListeners()) {
133 coreListener.soneLocked(sone);
138 * Notifies all listeners that the given Sone was unlocked.
140 * @see CoreListener#soneUnlocked(Sone)
142 * The Sone that was unlocked
144 void fireSoneUnlocked(Sone sone) {
145 for (CoreListener coreListener : getListeners()) {
146 coreListener.soneUnlocked(sone);
151 * Notifies all listeners that the insert of the given Sone has started.
153 * @see SoneInsertListener#insertStarted(Sone)
155 * The Sone being inserted
157 void fireSoneInserting(Sone sone) {
158 for (CoreListener coreListener : getListeners()) {
159 coreListener.soneInserting(sone);
164 * Notifies all listeners that the insert of the given Sone has finished
167 * @see SoneInsertListener#insertFinished(Sone, long)
169 * The Sone that was inserted
170 * @param insertDuration
171 * The insert duration (in milliseconds)
173 void fireSoneInserted(Sone sone, long insertDuration) {
174 for (CoreListener coreListener : getListeners()) {
175 coreListener.soneInserted(sone, insertDuration);
180 * Notifies all listeners that the insert of the given Sone was aborted.
182 * @see SoneInsertListener#insertStarted(Sone)
184 * The Sone being inserted
186 * The cause for the abortion (may be {@code null}
188 void fireSoneInsertAborted(Sone sone, Throwable cause) {
189 for (CoreListener coreListener : getListeners()) {
190 coreListener.soneInsertAborted(sone, cause);
195 * Notifies all listeners that a new version was found.
197 * @see CoreListener#updateFound(Version, long, long)
201 * The release time of the new version
202 * @param latestEdition
203 * The latest edition of the Sone homepage
205 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
206 for (CoreListener coreListener : getListeners()) {
207 coreListener.updateFound(version, releaseTime, latestEdition);
212 * Notifies all listeners that an image has started being inserted.
214 * @see CoreListener#imageInsertStarted(Image)
216 * The image that is now inserted
218 void fireImageInsertStarted(Image image) {
219 for (CoreListener coreListener : getListeners()) {
220 coreListener.imageInsertStarted(image);
225 * Notifies all listeners that an image insert was aborted by the user.
227 * @see CoreListener#imageInsertAborted(Image)
229 * The image that is not inserted anymore
231 void fireImageInsertAborted(Image image) {
232 for (CoreListener coreListener : getListeners()) {
233 coreListener.imageInsertAborted(image);
238 * Notifies all listeners that an image was successfully inserted.
240 * @see CoreListener#imageInsertFinished(Image)
242 * The image that was inserted
244 void fireImageInsertFinished(Image image) {
245 for (CoreListener coreListener : getListeners()) {
246 coreListener.imageInsertFinished(image);
251 * Notifies all listeners that an image failed to be inserted.
253 * @see CoreListener#imageInsertFailed(Image, Throwable)
255 * The image that could not be inserted
257 * The cause of the failure
259 void fireImageInsertFailed(Image image, Throwable cause) {
260 for (CoreListener coreListener : getListeners()) {
261 coreListener.imageInsertFailed(image, cause);