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.Sone;
22 import net.pterodactylus.util.event.AbstractListenerManager;
23 import net.pterodactylus.util.version.Version;
26 * Manager for {@link CoreListener}s.
28 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
33 * Creates a new core listener manager.
38 public CoreListenerManager(Core source) {
47 * Notifies all listeners that the given Sone was unlocked.
49 * @see CoreListener#soneUnlocked(Sone)
51 * The Sone that was unlocked
53 void fireSoneUnlocked(Sone sone) {
54 for (CoreListener coreListener : getListeners()) {
55 coreListener.soneUnlocked(sone);
60 * Notifies all listeners that the insert of the given Sone has started.
62 * @see SoneInsertListener#insertStarted(Sone)
64 * The Sone being inserted
66 void fireSoneInserting(Sone sone) {
67 for (CoreListener coreListener : getListeners()) {
68 coreListener.soneInserting(sone);
73 * Notifies all listeners that the insert of the given Sone has finished
76 * @see SoneInsertListener#insertFinished(Sone, long)
78 * The Sone that was inserted
79 * @param insertDuration
80 * The insert duration (in milliseconds)
82 void fireSoneInserted(Sone sone, long insertDuration) {
83 for (CoreListener coreListener : getListeners()) {
84 coreListener.soneInserted(sone, insertDuration);
89 * Notifies all listeners that the insert of the given Sone was aborted.
91 * @see SoneInsertListener#insertStarted(Sone)
93 * The Sone being inserted
95 * The cause for the abortion (may be {@code null}
97 void fireSoneInsertAborted(Sone sone, Throwable cause) {
98 for (CoreListener coreListener : getListeners()) {
99 coreListener.soneInsertAborted(sone, cause);
104 * Notifies all listeners that a new version was found.
106 * @see CoreListener#updateFound(Version, long, long)
110 * The release time of the new version
111 * @param latestEdition
112 * The latest edition of the Sone homepage
114 void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
115 for (CoreListener coreListener : getListeners()) {
116 coreListener.updateFound(version, releaseTime, latestEdition);
121 * Notifies all listeners that an image has started being inserted.
123 * @see CoreListener#imageInsertStarted(Image)
125 * The image that is now inserted
127 void fireImageInsertStarted(Image image) {
128 for (CoreListener coreListener : getListeners()) {
129 coreListener.imageInsertStarted(image);
134 * Notifies all listeners that an image insert was aborted by the user.
136 * @see CoreListener#imageInsertAborted(Image)
138 * The image that is not inserted anymore
140 void fireImageInsertAborted(Image image) {
141 for (CoreListener coreListener : getListeners()) {
142 coreListener.imageInsertAborted(image);
147 * Notifies all listeners that an image was successfully inserted.
149 * @see CoreListener#imageInsertFinished(Image)
151 * The image that was inserted
153 void fireImageInsertFinished(Image image) {
154 for (CoreListener coreListener : getListeners()) {
155 coreListener.imageInsertFinished(image);
160 * Notifies all listeners that an image failed to be inserted.
162 * @see CoreListener#imageInsertFailed(Image, Throwable)
164 * The image that could not be inserted
166 * The cause of the failure
168 void fireImageInsertFailed(Image image, Throwable cause) {
169 for (CoreListener coreListener : getListeners()) {
170 coreListener.imageInsertFailed(image, cause);