X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FProject.java;h=9ddada5243f140df5fb774a6578c4270f41205c9;hb=62d8078eff84dd476c3cf7c6b95b47d1438a1360;hp=1edb93337b87e765fe27d394104726ca3968f900;hpb=dc37f1e959fe36099d157e6d09b5790d4e06897c;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/core/Project.java b/src/net/pterodactylus/jsite/core/Project.java index 1edb933..9ddada5 100644 --- a/src/net/pterodactylus/jsite/core/Project.java +++ b/src/net/pterodactylus/jsite/core/Project.java @@ -27,7 +27,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.pterodactylus.jsite.util.IdGenerator; import net.pterodactylus.util.beans.AbstractBean; +import net.pterodactylus.util.number.Hex; /** * Container for project information. A Project is capable of notifying @@ -55,6 +57,9 @@ public class Project extends AbstractBean { /** Name of the “default file” property. */ public static final String PROPERTY_DEFAULT_FILE = "defaultFile"; + /** Name of the “node” property. */ + public static final String PROPERTY_NODE = "node"; + /** Internal ID. */ private String id; @@ -79,6 +84,9 @@ public class Project extends AbstractBean { /** The overrides. */ private final Map fileOverrides = new HashMap(); + /** The default node to insert to. */ + private Node node; + /** The current root project file. */ private ProjectFileImpl rootProjectFile; @@ -86,7 +94,7 @@ public class Project extends AbstractBean { * Creates a new project. */ public Project() { - /* do nothing. */ + id = Hex.toHex(IdGenerator.generateId()); } /** @@ -95,6 +103,7 @@ public class Project extends AbstractBean { * @param project */ Project(Project project) { + this(); this.name = project.name; this.description = project.description; this.publicKey = project.publicKey; @@ -118,7 +127,11 @@ public class Project extends AbstractBean { * The internal ID */ void setId(String id) { - this.id = id; + if (id == null) { + this.id = Hex.toHex(IdGenerator.generateId()); + } else { + this.id = id; + } } /** @@ -369,6 +382,35 @@ public class Project extends AbstractBean { return currentProjectFile; } + /** + * Returns the default node to insert this project to. + * + * @return The node to insert this project to + */ + public Node getNode() { + return node; + } + + /** + * Sets the default node to insert this project to. + * + * @param node + * The node to insert this project to + */ + public void setNode(Node node) { + Node oldNode = this.node; + this.node = node; + fireIfPropertyChanged(PROPERTY_NODE, oldNode, node); + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return getClass().getName() + "[id=" + id + ",name=" + name + ",description=" + description + ",publicKey=" + publicKey + ",privateKey=" + privateKey + ",basePath=" + basePath + ",defaultFile=" + defaultFile + ",node=" + node + "]"; + } + // // PRIVATE METHODS //