remove requests from table when node disconnects
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 14 May 2008 13:38:58 +0000 (13:38 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 14 May 2008 13:38:58 +0000 (13:38 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@880 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/core/CoreImpl.java
src/net/pterodactylus/jsite/core/CoreListener.java
src/net/pterodactylus/jsite/core/RequestManager.java
src/net/pterodactylus/jsite/gui/SwingInterface.java

index 73039f4..d2fa1ac 100644 (file)
@@ -289,6 +289,18 @@ public class CoreImpl implements Core, NodeListener, RequestListener {
                }
        }
 
+       /**
+        * Notifies all listeners that a request was removed.
+        * 
+        * @param request
+        *            The request that was removed
+        */
+       private void fireRequestRemoved(Request request) {
+               for (CoreListener coreListener: coreListeners) {
+                       coreListener.requestRemoved(request);
+               }
+       }
+
        //
        // ACCESSORS
        //
@@ -507,7 +519,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener {
         * @see net.pterodactylus.jsite.core.RequestListener#requestRemoved(net.pterodactylus.jsite.core.Request)
         */
        public void requestRemoved(Request request) {
-               /* TODO */
+               fireRequestRemoved(request);
        }
 
 }
index 96fcd9d..d5d8cdc 100644 (file)
@@ -203,4 +203,12 @@ public interface CoreListener {
         */
        public void requestProgressed(Request request);
 
+       /**
+        * Notifies a listener that a request was removed.
+        * 
+        * @param request
+        *            The request that was removed
+        */
+       public void requestRemoved(Request request);
+
 }
index 618dbf1..4efd9d9 100644 (file)
@@ -109,7 +109,17 @@ public class RequestManager implements NodeListener, HighLevelProgressListener {
                }
        }
 
-       // TODO - fireRequestRemoved
+       /**
+        * Notifies all listeners that a request was removed.
+        * 
+        * @param request
+        *            The request that was removed
+        */
+       private void fireRequestRemoved(Request request) {
+               for (RequestListener requestListener: requestListeners) {
+                       requestListener.requestRemoved(request);
+               }
+       }
 
        //
        // ACCESSORS
@@ -228,11 +238,15 @@ public class RequestManager implements NodeListener, HighLevelProgressListener {
         * {@inheritDoc}
         */
        public void nodeDisconnected(Node node, Throwable throwable) {
-               HighLevelClient highLevelClient = nodeManager.getHighLevelClient(node);
-               if (highLevelClient == null) {
-                       logger.warning("got nodeDisconnected from node without high-level client: " + node);
+               Map<String, Request> identifierRequests = nodeRequests.get(node);
+               if (identifierRequests == null) {
+                       logger.warning("got node without request map: " + node);
                        return;
                }
+               for (Request request: identifierRequests.values()) {
+                       fireRequestRemoved(request);
+               }
+               identifierRequests.clear();
        }
 
        //
index 4d83851..65fcebe 100644 (file)
@@ -991,6 +991,13 @@ public class SwingInterface implements CoreListener, LoggingListener {
                /* TODO - update table model */
        }
 
+       /**
+        * @see net.pterodactylus.jsite.core.CoreListener#requestRemoved(net.pterodactylus.jsite.core.Request)
+        */
+       public void requestRemoved(Request request) {
+               requestTableModel.removeRequest(request);
+       }
+
        //
        // INTERFACE LoggingListener
        //