From f9ef6f2eb051a0e2e6cd99302502aa13c6562804 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Nov 2008 00:43:28 +0100 Subject: [PATCH] Use new InsertListenerSupport. --- .../pterodactylus/jsite/core/InsertManager.java | 107 +-------------------- 1 file changed, 5 insertions(+), 102 deletions(-) diff --git a/src/net/pterodactylus/jsite/core/InsertManager.java b/src/net/pterodactylus/jsite/core/InsertManager.java index bdd02a1..2c4f97b 100644 --- a/src/net/pterodactylus/jsite/core/InsertManager.java +++ b/src/net/pterodactylus/jsite/core/InsertManager.java @@ -18,9 +18,7 @@ package net.pterodactylus.jsite.core; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -37,8 +35,8 @@ public class InsertManager { /** Logger. */ private static final Logger logger = Logging.getLogger(InsertManager.class.getName()); - /** The insert listeners. */ - private final List insertListeners = new ArrayList(); + /** The insert listener support. */ + private final InsertListenerSupport insertListenerSupport = new InsertListenerSupport(); /** Mapping from insert IDs to inserts. */ private final Map inserts = new HashMap(); @@ -55,9 +53,7 @@ public class InsertManager { */ public void addInsertListener(InsertListener insertListener) { logger.log(Level.FINEST, "addInsertListener(insertListener=" + insertListener + ")"); - synchronized (insertListeners) { - insertListeners.add(insertListener); - } + insertListenerSupport.addListener(insertListener); } /** @@ -68,100 +64,7 @@ public class InsertManager { */ public void removeInsertListener(InsertListener insertListener) { logger.log(Level.FINEST, "removeInsertListener(insertListener=" + insertListener + ")"); - synchronized (insertListeners) { - insertListeners.remove(insertListener); - } - } - - /** - * Notifies all listeners that an insert was added. - * - * @param insert - * The insert that was added - */ - private void fireInsertAdded(Insert insert) { - synchronized (insertListeners) { - for (InsertListener insertListener : insertListeners) { - insertListener.insertAdded(insert); - } - } - } - - /** - * Notifies all listeners that an insert was removed. - * - * @param insert - * The insert that was removes - */ - @SuppressWarnings("unused") - private void fireInsertRemoved(Insert insert) { - synchronized (insertListeners) { - for (InsertListener insertListener : insertListeners) { - insertListener.insertRemoved(insert); - } - } - } - - /** - * Notifies all listeners that an insert was started. - * - * @param insert - * The insert that was started - */ - @SuppressWarnings("unused") - private void fireInsertStarted(Insert insert) { - synchronized (insertListeners) { - for (InsertListener insertListener : insertListeners) { - insertListener.insertStarted(insert); - } - } - } - - /** - * Notifies all listeners that an insert made some progress - * - * @param insert - * The insert that made some progress - */ - @SuppressWarnings("unused") - private void fireInsertProgressed(Insert insert) { - synchronized (insertListeners) { - for (InsertListener insertListener : insertListeners) { - insertListener.insertProgressed(insert); - } - } - } - - /** - * Notifies all listeners that an insert generated a URI. - * - * @param insert - * The insert that generated a URI - * @param uri - * The generated URI - */ - @SuppressWarnings("unused") - private void fireInsertGeneratedURI(Insert insert, String uri) { - synchronized (insertListeners) { - for (InsertListener insertListener : insertListeners) { - insertListener.insertGeneratedURI(insert, uri); - } - } - } - - /** - * Notifies all listeners that an insert has finished. - * - * @param insert - * The insert that has finished - */ - @SuppressWarnings("unused") - private void fireInsertFinished(Insert insert) { - synchronized (insertListeners) { - for (InsertListener insertListener : insertListeners) { - insertListener.insertFinished(insert); - } - } + insertListenerSupport.removeListener(insertListener); } // @@ -192,7 +95,7 @@ public class InsertManager { Insert newInsert = new Insert(project, insertNode, insertId); inserts.put(insertId, newInsert); saveConfiguration(); - fireInsertAdded(newInsert); + insertListenerSupport.fireInsertAdded(newInsert); /* TODO - start insert */ } -- 2.7.4