From e858fb8e714fdb9f07c9172869caab47bfc7945e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 28 May 2008 08:53:08 +0200 Subject: [PATCH] add default insert flag --- .../pterodactylus/jsite/project/AbstractEntry.java | 24 ++++++++++++++++++++++ src/net/pterodactylus/jsite/project/Entry.java | 8 ++++++++ src/net/pterodactylus/jsite/project/Project.java | 1 + 3 files changed, 33 insertions(+) diff --git a/src/net/pterodactylus/jsite/project/AbstractEntry.java b/src/net/pterodactylus/jsite/project/AbstractEntry.java index 4f6e6ed..41449b0 100644 --- a/src/net/pterodactylus/jsite/project/AbstractEntry.java +++ b/src/net/pterodactylus/jsite/project/AbstractEntry.java @@ -19,6 +19,8 @@ package net.pterodactylus.jsite.project; +import java.io.File; + import net.pterodactylus.util.beans.AbstractBean; /** @@ -43,6 +45,9 @@ public abstract class AbstractEntry extends AbstractBean implements Entry { /** The name of the file. */ private String name; + /** The default insert flag for this entry. */ + private boolean defaultInsert; + /** Whether to insert the file. */ private boolean insert; @@ -70,6 +75,25 @@ public abstract class AbstractEntry extends AbstractBean implements Entry { /** * {@inheritDoc} */ + public boolean isDefault() { + return (insert == defaultInsert) && (contentType == null); + } + + /** + * Sets the default insert flag for this entry. The default insert flag is + * derived from {@link File#isHidden()}. + * + * @param defaultInsert + * true if the default for this entry is to insert + * it, false otherwise + */ + void setDefaultInsert(boolean defaultInsert) { + this.defaultInsert = defaultInsert; + } + + /** + * {@inheritDoc} + */ public String getName() { return name; } diff --git a/src/net/pterodactylus/jsite/project/Entry.java b/src/net/pterodactylus/jsite/project/Entry.java index 9b3c521..8f3783b 100644 --- a/src/net/pterodactylus/jsite/project/Entry.java +++ b/src/net/pterodactylus/jsite/project/Entry.java @@ -39,6 +39,14 @@ public interface Entry { public boolean isVirtual(); /** + * Returns whether this entry still has its default settings. + * + * @return true if this entry has not been changed by the + * user, false otherwise + */ + public boolean isDefault(); + + /** * Returns the name of the file. The name can contain multiple path * components, separated by the platform’s {@link File#separatorChar}. It * will never start with a separator, though. diff --git a/src/net/pterodactylus/jsite/project/Project.java b/src/net/pterodactylus/jsite/project/Project.java index c54f211..5c58763 100644 --- a/src/net/pterodactylus/jsite/project/Project.java +++ b/src/net/pterodactylus/jsite/project/Project.java @@ -297,6 +297,7 @@ public class Project extends AbstractBean { PhysicalEntry entry = new PhysicalEntry(); entry.setName(fileName); entry.setPath(file.getPath()); + entry.setDefaultInsert(!file.isHidden()); entry.setInsert(!file.isHidden()); entries.add(entry); } -- 2.7.4