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 post was removed.
51 * @see CoreListener#postRemoved(Post)
55 void firePostRemoved(Post post) {
56 for (CoreListener coreListener : getListeners()) {
57 coreListener.postRemoved(post);
62 * Notifies all listener that the given reply was removed.
64 * @see CoreListener#replyRemoved(PostReply)
68 void fireReplyRemoved(PostReply reply) {
69 for (CoreListener coreListener : getListeners()) {
70 coreListener.replyRemoved(reply);
75 * Notifies all listeners that the given Sone was locked.
77 * @see CoreListener#soneLocked(Sone)
79 * The Sone that was locked
81 void fireSoneLocked(Sone sone) {
82 for (CoreListener coreListener : getListeners()) {
83 coreListener.soneLocked(sone);
88 * Notifies all listeners that the given Sone was unlocked.
90 * @see CoreListener#soneUnlocked(Sone)
92 * The Sone that was unlocked
94 void fireSoneUnlocked(Sone sone) {
95 for (CoreListener coreListener : getListeners()) {
96 coreListener.soneUnlocked(sone);
101 * Notifies all listeners that the insert of the given Sone has started.
103 * @see SoneInsertListener#insertStarted(Sone)
105 * The Sone being inserted
107 void fireSoneInserting(Sone sone) {
108 for (CoreListener coreListener : getListeners()) {
109 coreListener.soneInserting(sone);
114 * Notifies all listeners that the insert of the given Sone has finished
117 * @see SoneInsertListener#insertFinished(Sone, long)
119 * The Sone that was inserted
120 * @param insertDuration
121 * The insert duration (in milliseconds)
123 void fireSoneInserted(Sone sone, long insertDuration) {
124 for (CoreListener coreListener : getListeners()) {
125 coreListener.soneInserted(sone, insertDuration);
130 * Notifies all listeners that the insert of the given Sone was aborted.
132 * @see SoneInsertListener#insertStarted(Sone)
134 * The Sone being inserted
136 * The cause for the abortion (may be {@code null}
138 void fireSoneInsertAborted(Sone sone, Throwable cause) {
139 for (CoreListener coreListener : getListeners()) {
140 coreListener.soneInsertAborted(sone, cause);
145 * Notifies all listeners that a new version was found.
147 * @see CoreListener#updateFound(Version, long, long)
151 * The release time of the new version
152 * @param latestEdition
153 * The latest edition of the Sone homepage
155 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
156 for (CoreListener coreListener : getListeners()) {
157 coreListener.updateFound(version, releaseTime, latestEdition);
162 * Notifies all listeners that an image has started being inserted.
164 * @see CoreListener#imageInsertStarted(Image)
166 * The image that is now inserted
168 void fireImageInsertStarted(Image image) {
169 for (CoreListener coreListener : getListeners()) {
170 coreListener.imageInsertStarted(image);
175 * Notifies all listeners that an image insert was aborted by the user.
177 * @see CoreListener#imageInsertAborted(Image)
179 * The image that is not inserted anymore
181 void fireImageInsertAborted(Image image) {
182 for (CoreListener coreListener : getListeners()) {
183 coreListener.imageInsertAborted(image);
188 * Notifies all listeners that an image was successfully inserted.
190 * @see CoreListener#imageInsertFinished(Image)
192 * The image that was inserted
194 void fireImageInsertFinished(Image image) {
195 for (CoreListener coreListener : getListeners()) {
196 coreListener.imageInsertFinished(image);
201 * Notifies all listeners that an image failed to be inserted.
203 * @see CoreListener#imageInsertFailed(Image, Throwable)
205 * The image that could not be inserted
207 * The cause of the failure
209 void fireImageInsertFailed(Image image, Throwable cause) {
210 for (CoreListener coreListener : getListeners()) {
211 coreListener.imageInsertFailed(image, cause);