From: David ‘Bombe’ Roden Date: Wed, 14 May 2008 13:38:58 +0000 (+0000) Subject: remove requests from table when node disconnects X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=196231f83b4fd9c8c5710b722ff27595f8644734;p=jSite2.git remove requests from table when node disconnects git-svn-id: http://trooper/svn/projects/jSite/trunk@880 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/core/CoreImpl.java b/src/net/pterodactylus/jsite/core/CoreImpl.java index 73039f4..d2fa1ac 100644 --- a/src/net/pterodactylus/jsite/core/CoreImpl.java +++ b/src/net/pterodactylus/jsite/core/CoreImpl.java @@ -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); } } diff --git a/src/net/pterodactylus/jsite/core/CoreListener.java b/src/net/pterodactylus/jsite/core/CoreListener.java index 96fcd9d..d5d8cdc 100644 --- a/src/net/pterodactylus/jsite/core/CoreListener.java +++ b/src/net/pterodactylus/jsite/core/CoreListener.java @@ -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); + } diff --git a/src/net/pterodactylus/jsite/core/RequestManager.java b/src/net/pterodactylus/jsite/core/RequestManager.java index 618dbf1..4efd9d9 100644 --- a/src/net/pterodactylus/jsite/core/RequestManager.java +++ b/src/net/pterodactylus/jsite/core/RequestManager.java @@ -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 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(); } // diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index 4d83851..65fcebe 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -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 //