Emit upload-finished event when the first message from the node arrives.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 1 Jun 2009 14:12:06 +0000 (16:12 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 1 Jun 2009 14:12:06 +0000 (16:12 +0200)
src/de/todesbaum/jsite/application/ProjectInserter.java

index 7256bbe..46cdbd4 100644 (file)
@@ -125,6 +125,17 @@ public class ProjectInserter implements FileScannerListener, Runnable {
        /**
         * Notifies all listeners that the insert has made some progress.
         *
+        * @see InsertListener#projectUploadFinished(Project)
+        */
+       protected void fireProjectUploadFinished() {
+               for (InsertListener insertListener : insertListeners) {
+                       insertListener.projectUploadFinished(project);
+               }
+       }
+
+       /**
+        * Notifies all listeners that the insert has made some progress.
+        *
         * @see InsertListener#projectInsertProgress(Project, int, int, int, int,
         *      boolean)
         * @param succeeded
@@ -416,6 +427,7 @@ public class ProjectInserter implements FileScannerListener, Runnable {
 
                /* parse progress and success messages */
                String finalURI = null;
+               boolean firstMessage = true;
                boolean success = false;
                boolean finished = false;
                boolean disconnected = false;
@@ -425,6 +437,10 @@ public class ProjectInserter implements FileScannerListener, Runnable {
                        if (debug) {
                                System.out.println(message);
                        }
+                       if (firstMessage) {
+                               fireProjectUploadFinished();
+                               firstMessage = false;
+                       }
                        if (!finished) {
                                @SuppressWarnings("null")
                                String messageName = message.getName();