import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.core.event.PostRemovedEvent;
import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
+import net.pterodactylus.sone.core.event.SoneInsertingEvent;
import net.pterodactylus.sone.core.event.SoneLockedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
*/
@Override
public void insertStarted(Sone sone) {
- coreListenerManager.fireSoneInserting(sone);
+ eventBus.post(new SoneInsertingEvent(sone));
}
/**
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that the insert of the given Sone has started.
- *
- * @see SoneInsertListener#insertStarted(Sone)
- * @param sone
- * The Sone that is being inserted
- */
- public void soneInserting(Sone sone);
-
- /**
* Notifies a listener that the insert of the given Sone has finished
* successfully.
*
//
/**
- * Notifies all listeners that the insert of the given Sone has started.
- *
- * @see SoneInsertListener#insertStarted(Sone)
- * @param sone
- * The Sone being inserted
- */
- void fireSoneInserting(Sone sone) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.soneInserting(sone);
- }
- }
-
- /**
* Notifies all listeners that the insert of the given Sone has finished
* successfully.
*
--- /dev/null
+/*
+ * Sone - SoneInsertingEvent.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.Sone;
+
+/**
+ * Event that signals that a {@link Sone} is now being inserted.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SoneInsertingEvent extends SoneEvent {
+
+ /**
+ * Creates a new “Sone is being inserted” event.
+ *
+ * @param sone
+ * The Sone that is being inserted
+ */
+ public SoneInsertingEvent(Sone sone) {
+ super(sone);
+ }
+
+}
import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.core.event.PostRemovedEvent;
import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
+import net.pterodactylus.sone.core.event.SoneInsertingEvent;
import net.pterodactylus.sone.core.event.SoneLockedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(soneUnlockedEvent.sone()));
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link Sone} is being inserted.
+ *
+ * @param soneInsertingEvent
+ * The event
*/
- @Override
- public void soneInserting(Sone sone) {
- TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ @Subscribe
+ public void soneInserting(SoneInsertingEvent soneInsertingEvent) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.sone());
soneInsertNotification.set("soneStatus", "inserting");
- if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ if (soneInsertingEvent.sone().getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
notificationManager.addNotification(soneInsertNotification);
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/