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.PostReply;
22 import net.pterodactylus.sone.data.Sone;
23 import net.pterodactylus.util.event.AbstractListenerManager;
24 import net.pterodactylus.util.version.Version;
27 * Manager for {@link CoreListener}s.
29 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
34 * Creates a new core listener manager.
39 public CoreListenerManager(Core source) {
48 * Notifies all listener that the given reply was removed.
50 * @see CoreListener#replyRemoved(PostReply)
54 void fireReplyRemoved(PostReply reply) {
55 for (CoreListener coreListener : getListeners()) {
56 coreListener.replyRemoved(reply);
61 * Notifies all listeners that the given Sone was locked.
63 * @see CoreListener#soneLocked(Sone)
65 * The Sone that was locked
67 void fireSoneLocked(Sone sone) {
68 for (CoreListener coreListener : getListeners()) {
69 coreListener.soneLocked(sone);
74 * Notifies all listeners that the given Sone was unlocked.
76 * @see CoreListener#soneUnlocked(Sone)
78 * The Sone that was unlocked
80 void fireSoneUnlocked(Sone sone) {
81 for (CoreListener coreListener : getListeners()) {
82 coreListener.soneUnlocked(sone);
87 * Notifies all listeners that the insert of the given Sone has started.
89 * @see SoneInsertListener#insertStarted(Sone)
91 * The Sone being inserted
93 void fireSoneInserting(Sone sone) {
94 for (CoreListener coreListener : getListeners()) {
95 coreListener.soneInserting(sone);
100 * Notifies all listeners that the insert of the given Sone has finished
103 * @see SoneInsertListener#insertFinished(Sone, long)
105 * The Sone that was inserted
106 * @param insertDuration
107 * The insert duration (in milliseconds)
109 void fireSoneInserted(Sone sone, long insertDuration) {
110 for (CoreListener coreListener : getListeners()) {
111 coreListener.soneInserted(sone, insertDuration);
116 * Notifies all listeners that the insert of the given Sone was aborted.
118 * @see SoneInsertListener#insertStarted(Sone)
120 * The Sone being inserted
122 * The cause for the abortion (may be {@code null}
124 void fireSoneInsertAborted(Sone sone, Throwable cause) {
125 for (CoreListener coreListener : getListeners()) {
126 coreListener.soneInsertAborted(sone, cause);
131 * Notifies all listeners that a new version was found.
133 * @see CoreListener#updateFound(Version, long, long)
137 * The release time of the new version
138 * @param latestEdition
139 * The latest edition of the Sone homepage
141 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
142 for (CoreListener coreListener : getListeners()) {
143 coreListener.updateFound(version, releaseTime, latestEdition);
148 * Notifies all listeners that an image has started being inserted.
150 * @see CoreListener#imageInsertStarted(Image)
152 * The image that is now inserted
154 void fireImageInsertStarted(Image image) {
155 for (CoreListener coreListener : getListeners()) {
156 coreListener.imageInsertStarted(image);
161 * Notifies all listeners that an image insert was aborted by the user.
163 * @see CoreListener#imageInsertAborted(Image)
165 * The image that is not inserted anymore
167 void fireImageInsertAborted(Image image) {
168 for (CoreListener coreListener : getListeners()) {
169 coreListener.imageInsertAborted(image);
174 * Notifies all listeners that an image was successfully inserted.
176 * @see CoreListener#imageInsertFinished(Image)
178 * The image that was inserted
180 void fireImageInsertFinished(Image image) {
181 for (CoreListener coreListener : getListeners()) {
182 coreListener.imageInsertFinished(image);
187 * Notifies all listeners that an image failed to be inserted.
189 * @see CoreListener#imageInsertFailed(Image, Throwable)
191 * The image that could not be inserted
193 * The cause of the failure
195 void fireImageInsertFailed(Image image, Throwable cause) {
196 for (CoreListener coreListener : getListeners()) {
197 coreListener.imageInsertFailed(image, cause);