From e7fd217d2304bc11716525992ec6c8f22ae54914 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Nov 2008 02:03:17 +0100 Subject: [PATCH] Implement InsertListener interface in CoreImpl. Add InsertManager instance to CoreImpl. Ceate InsertManager in Main and hand it in to CoreImpl. --- src/net/pterodactylus/jsite/core/Core.java | 10 ++++ src/net/pterodactylus/jsite/core/CoreImpl.java | 69 +++++++++++++++++++++++++- src/net/pterodactylus/jsite/main/Main.java | 5 ++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/net/pterodactylus/jsite/core/Core.java b/src/net/pterodactylus/jsite/core/Core.java index 53cd6b7..27d87d9 100644 --- a/src/net/pterodactylus/jsite/core/Core.java +++ b/src/net/pterodactylus/jsite/core/Core.java @@ -128,6 +128,16 @@ public interface Core { public void createProject() throws IOException, JSiteException; /** + * Inserts the given project on the given node. + * + * @param node + * The node to use for the insert + * @param project + * The project to insert + */ + public void insertProject(Node node, Project project); + + /** * Clones the given project. {@link CoreListener}s will be notified of the * new clone via the {@link CoreListener#projectCloned(Project, Project)} * event. diff --git a/src/net/pterodactylus/jsite/core/CoreImpl.java b/src/net/pterodactylus/jsite/core/CoreImpl.java index 1e52659..6e61709 100644 --- a/src/net/pterodactylus/jsite/core/CoreImpl.java +++ b/src/net/pterodactylus/jsite/core/CoreImpl.java @@ -34,7 +34,7 @@ import net.pterodactylus.util.logging.Logging; * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ -public class CoreImpl implements Core, NodeListener, RequestListener { +public class CoreImpl implements Core, NodeListener, RequestListener, InsertListener { /** The logger. */ private static final Logger logger = Logging.getLogger(CoreImpl.class.getName()); @@ -56,6 +56,9 @@ public class CoreImpl implements Core, NodeListener, RequestListener { @SuppressWarnings("unused") private RequestManager requestManager; + /** The insert manager. */ + private InsertManager insertManager; + // // LISTENER MANAGEMENT // @@ -136,6 +139,16 @@ public class CoreImpl implements Core, NodeListener, RequestListener { } /** + * Sets the insert manager to use. + * + * @param insertManager + * The insert manager to use + */ + public void setInsertManager(InsertManager insertManager) { + this.insertManager = insertManager; + } + + /** * {@inheritDoc} */ public List getNodes() { @@ -245,6 +258,14 @@ public class CoreImpl implements Core, NodeListener, RequestListener { /** * {@inheritDoc} */ + public void insertProject(Node node, Project project) { + logger.log(Level.FINEST, "insertProject(node=" + node + ", project=" + project + ")"); + insertManager.insertProject(project, node); + } + + /** + * {@inheritDoc} + */ public void cloneProject(Project project) { logger.log(Level.FINEST, "cloneProject(project=" + project + ")"); Project projectClone = projectManager.cloneProject(project); @@ -361,4 +382,50 @@ public class CoreImpl implements Core, NodeListener, RequestListener { /* TODO - find project and process request */ } + // + // INTERFACE InsertListener + // + + /** + * {@inheritDoc} + */ + public void insertAdded(Insert insert) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void insertRemoved(Insert insert) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void insertStarted(Insert insert) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void insertProgressed(Insert insert) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void insertGeneratedURI(Insert insert, String uri) { + /* TODO */ + } + + /** + * {@inheritDoc} + */ + public void insertFinished(Insert insert) { + /* TODO */ + } + } diff --git a/src/net/pterodactylus/jsite/main/Main.java b/src/net/pterodactylus/jsite/main/Main.java index e7c1d39..cf31c07 100644 --- a/src/net/pterodactylus/jsite/main/Main.java +++ b/src/net/pterodactylus/jsite/main/Main.java @@ -28,6 +28,7 @@ import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import net.pterodactylus.jsite.core.CoreImpl; +import net.pterodactylus.jsite.core.InsertManager; import net.pterodactylus.jsite.core.NodeManager; import net.pterodactylus.jsite.core.ProjectManager; import net.pterodactylus.jsite.core.RequestManager; @@ -69,6 +70,10 @@ public class Main { core.setProjectManager(projectManager); projectManager.setNodeManager(nodeManager); + InsertManager insertManager = new InsertManager(); + core.setInsertManager(insertManager); + insertManager.addInsertListener(core); + RequestManager requestManager = new RequestManager(); core.setRequestManager(requestManager); nodeManager.addNodeListener(requestManager); -- 2.7.4