import net.pterodactylus.sone.core.Options.DefaultOption;
import net.pterodactylus.sone.core.Options.Option;
import net.pterodactylus.sone.core.Options.OptionWatcher;
+import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
@Override
public void imageInsertAborted(Image image) {
logger.log(Level.WARNING, String.format("Image insert aborted for %s.", image));
- coreListenerManager.fireImageInsertAborted(image);
+ eventBus.post(new ImageInsertAbortedEvent(image));
}
/**
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that an image insert was aborted by the user.
- *
- * @param image
- * The image that is not inserted anymore
- */
- public void imageInsertAborted(Image image);
-
- /**
* Notifies a listener that an image was successfully inserted.
*
* @param image
//
/**
- * Notifies all listeners that an image insert was aborted by the user.
- *
- * @see CoreListener#imageInsertAborted(Image)
- * @param image
- * The image that is not inserted anymore
- */
- void fireImageInsertAborted(Image image) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.imageInsertAborted(image);
- }
- }
-
- /**
* Notifies all listeners that an image was successfully inserted.
*
* @see CoreListener#imageInsertFinished(Image)
--- /dev/null
+/*
+ * Sone - ImageInsertAbortedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.core.event;
+
+import net.pterodactylus.sone.data.Image;
+
+/**
+ * Event that signals that an {@link Image} insert is aborted.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ImageInsertAbortedEvent extends ImageEvent {
+
+ /**
+ * Creates a new “image insert aborted” event.
+ *
+ * @param image
+ * The image whose insert aborted
+ */
+ public ImageInsertAbortedEvent(Image image) {
+ super(image);
+ }
+
+}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.CoreListener;
+import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
notificationManager.addNotification(insertingImagesNotification);
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that an {@link Image} insert was aborted.
+ *
+ * @param imageInsertAbortedEvent
+ * The event
*/
- @Override
- public void imageInsertAborted(Image image) {
- insertingImagesNotification.remove(image);
+ @Subscribe
+ public void imageInsertAborted(ImageInsertAbortedEvent imageInsertAbortedEvent) {
+ insertingImagesNotification.remove(imageInsertAbortedEvent.image());
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/