Add image insert notifications.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 12 Apr 2011 07:05:48 +0000 (09:05 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 13 Apr 2011 04:41:05 +0000 (06:41 +0200)
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/resources/i18n/sone.en.properties
src/main/resources/templates/notify/image-insert-failed-notification.html [new file with mode: 0644]
src/main/resources/templates/notify/inserted-images-notification.html [new file with mode: 0644]
src/main/resources/templates/notify/inserting-images-notification.html [new file with mode: 0644]

index ddca4d1..560b3c3 100644 (file)
@@ -37,6 +37,7 @@ import java.util.logging.Logger;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.core.CoreListener;
 import net.pterodactylus.sone.data.Album;
+import net.pterodactylus.sone.data.Image;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
@@ -173,6 +174,15 @@ public class WebInterface implements CoreListener {
        /** The “new version” notification. */
        private final TemplateNotification newVersionNotification;
 
+       /** The “inserting images” notification. */
+       private final ListNotification<Image> insertingImagesNotification;
+
+       /** The “inserted images” notification. */
+       private final ListNotification<Image> insertedImagesNotification;
+
+       /** The “image insert failed” notification. */
+       private final ListNotification<Image> imageInsertFailedNotification;
+
        /**
         * Creates a new web interface.
         *
@@ -235,6 +245,15 @@ public class WebInterface implements CoreListener {
 
                Template newVersionTemplate = TemplateParser.parse(createReader("/templates/notify/newVersionNotification.html"));
                newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate);
+
+               Template insertingImagesTemplate = TemplateParser.parse(createReader("/templates/notify/inserting-images-notification.html"));
+               insertingImagesNotification = new ListNotification<Image>("inserting-images-notification", "images", insertingImagesTemplate);
+
+               Template insertedImagesTemplate = TemplateParser.parse(createReader("/templates/notify/inserted-images-notification.html"));
+               insertedImagesNotification = new ListNotification<Image>("inserted-images-notification", "images", insertedImagesTemplate);
+
+               Template imageInsertFailedTemplate = TemplateParser.parse(createReader("/templates/notify/image-insert-failed-notification.html"));
+               imageInsertFailedNotification = new ListNotification<Image>("image-insert-failed-notification", "images", imageInsertFailedTemplate);
        }
 
        //
@@ -797,6 +816,8 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void imageInsertStarted(Image image) {
+               insertingImagesNotification.add(image);
+               notificationManager.addNotification(insertingImagesNotification);
        }
 
        /**
@@ -804,6 +825,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void imageInsertAborted(Image image) {
+               insertingImagesNotification.remove(image);
        }
 
        /**
@@ -811,6 +833,9 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void imageInsertFinished(Image image) {
+               insertingImagesNotification.remove(image);
+               insertedImagesNotification.add(image);
+               notificationManager.addNotification(insertedImagesNotification);
        }
 
        /**
@@ -818,6 +843,9 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void imageInsertFailed(Image image, Throwable cause) {
+               insertingImagesNotification.remove(image);
+               imageInsertFailedNotification.add(image);
+               notificationManager.addNotification(imageInsertFailedNotification);
        }
 
        /**
index b146e68..aa90d0b 100644 (file)
@@ -285,3 +285,6 @@ Notification.SoneRescued.Text=The following Sones have been rescued:
 Notification.SoneRescued.Text.RememberToUnlock=Please remember to control the posts and replies you have given and don’t forget to unlock your Sones!
 Notification.LockedSones.Text=The following Sones have been locked for more than 5 minutes. Please check if you really want to keep these Sones locked:
 Notification.NewVersion.Text=Version {version} of the Sone plugin was found. Download it from USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​!
+Notification.InsertingImages.Text=The following images are being inserted:
+Notification.InsertedImages.Text=The following images have been inserted:
+Notification.ImageInsertFailed.Text=The following images could not be inserted:
diff --git a/src/main/resources/templates/notify/image-insert-failed-notification.html b/src/main/resources/templates/notify/image-insert-failed-notification.html
new file mode 100644 (file)
index 0000000..c4b3c67
--- /dev/null
@@ -0,0 +1,6 @@
+<div class="text">
+       <%= Notification.ImageInsertFailed.Text|l10n|html>
+       <%foreach images image>
+               <a href="imageBrowser.html?image=<%image.id|html>" title="<%image.title|html>"><%image.title|html></a><%notlast>,<%/notlast><%last>.<%/last>
+       <%/foreach>
+</div>
diff --git a/src/main/resources/templates/notify/inserted-images-notification.html b/src/main/resources/templates/notify/inserted-images-notification.html
new file mode 100644 (file)
index 0000000..f388d59
--- /dev/null
@@ -0,0 +1,6 @@
+<div class="text">
+       <%= Notification.InsertedImages.Text|l10n|html>
+       <%foreach images image>
+               <a href="imageBrowser.html?image=<%image.id|html>" title="<%image.title|html>"><%image.title|html></a><%notlast>,<%/notlast><%last>.<%/last>
+       <%/foreach>
+</div>
diff --git a/src/main/resources/templates/notify/inserting-images-notification.html b/src/main/resources/templates/notify/inserting-images-notification.html
new file mode 100644 (file)
index 0000000..efe930d
--- /dev/null
@@ -0,0 +1,6 @@
+<div class="text">
+       <%= Notification.InsertingImages.Text|l10n|html>
+       <%foreach images image>
+               <a href="imageBrowser.html?image=<%image.id|html>" title="<%image.title|html>"><%image.title|html></a><%notlast>,<%/notlast><%last>.<%/last>
+       <%/foreach>
+</div>