From e79c1f7e0e16d301a47e6483decf8d40175474a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 16 Jun 2008 01:23:42 +0200 Subject: [PATCH] add insertProject() --- .../pterodactylus/jsite/core/InsertManager.java | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/net/pterodactylus/jsite/core/InsertManager.java b/src/net/pterodactylus/jsite/core/InsertManager.java index be8cc5e..1a55798 100644 --- a/src/net/pterodactylus/jsite/core/InsertManager.java +++ b/src/net/pterodactylus/jsite/core/InsertManager.java @@ -15,11 +15,13 @@ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ + package net.pterodactylus.jsite.core; import java.util.ArrayList; -import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -38,6 +40,9 @@ public class InsertManager { /** The insert listeners. */ private final List insertListeners = new ArrayList(); + /** Mapping from insert IDs to inserts. */ + private final Map inserts = new HashMap(); + // // EVENT MANAGEMENT // @@ -157,6 +162,33 @@ public class InsertManager { // /** + * Starts to insert the given project. The insert will be made to the node + * stored in the project, and if no node is specified in the project, the + * given node will be used. + * + * @param project + * The project to insert + * @param node + * The node to insert the project to if the project does not + * specify a node + */ + public void insertProject(Project project, Node node) { + logger.log(Level.FINEST, "insertProject(project=" + project + ",node=" + node + ")"); + Node insertNode = project.getNode(); + if (insertNode == null) { + insertNode = node; + if (insertNode == null) { + throw new NullPointerException("node must not be null"); + } + } + String insertId = "insert-" + project.getId(); + Insert newInsert = new Insert(project, insertNode, insertId); + inserts.put(insertId, newInsert); + fireInsertAdded(newInsert); + /* TODO - start insert */ + } + + /** * Starts the insert manager. */ public void start() { -- 2.7.4