Add method that signals when a Sone is marked as known.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Nov 2010 19:44:05 +0000 (20:44 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Nov 2010 19:44:05 +0000 (20:44 +0100)
src/main/java/net/pterodactylus/sone/core/CoreListener.java
src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java

index 2547e63..f8278ed 100644 (file)
@@ -55,4 +55,12 @@ public interface CoreListener extends EventListener {
         */
        public void newReplyFound(Reply reply);
 
+       /**
+        * Notifies a listener that the given Sone is now marked as known.
+        *
+        * @param sone
+        *            The known Sone
+        */
+       public void markSoneKnown(Sone sone);
+
 }
index 84dc5f0..f226723 100644 (file)
@@ -82,4 +82,17 @@ public class CoreListenerManager extends AbstractListenerManager<Core, CoreListe
                }
        }
 
+       /**
+        * Notifies all listeners that the given Sone is now marked as known.
+        *
+        * @see CoreListener#markSoneKnown(Sone)
+        * @param sone
+        *            The known Sone
+        */
+       void fireMarkSoneKnown(Sone sone) {
+               for (CoreListener coreListener : getListeners()) {
+                       coreListener.markSoneKnown(sone);
+               }
+       }
+
 }
index 9e92c1d..5b9efb2 100644 (file)
@@ -371,6 +371,17 @@ public class WebInterface implements CoreListener {
        }
 
        /**
+        * {@inheritDoc}
+        */
+       @Override
+       public void markSoneKnown(Sone sone) {
+               newSoneNotification.removeSone(sone);
+               if (newSoneNotification.isEmpty()) {
+                       newSoneNotification.dismiss();
+               }
+       }
+
+       /**
         * Template provider implementation that uses
         * {@link WebInterface#createReader(String)} to load templates for
         * inclusion.