projects
/
jSite2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e858fb8
)
add default content type notion
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 28 May 2008 06:59:37 +0000
(08:59 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 28 May 2008 06:59:37 +0000
(08:59 +0200)
src/net/pterodactylus/jsite/project/AbstractEntry.java
patch
|
blob
|
history
src/net/pterodactylus/jsite/project/Entry.java
patch
|
blob
|
history
src/net/pterodactylus/jsite/project/Project.java
patch
|
blob
|
history
diff --git
a/src/net/pterodactylus/jsite/project/AbstractEntry.java
b/src/net/pterodactylus/jsite/project/AbstractEntry.java
index
41449b0
..
6e0c9d4
100644
(file)
--- a/
src/net/pterodactylus/jsite/project/AbstractEntry.java
+++ b/
src/net/pterodactylus/jsite/project/AbstractEntry.java
@@
-51,6
+51,9
@@
public abstract class AbstractEntry extends AbstractBean implements Entry {
/** Whether to insert the file. */
private boolean insert;
/** Whether to insert the file. */
private boolean insert;
+ /** The default content type of this entry. */
+ private String defaultContentType;
+
/** The content type of the file. */
private String contentType;
/** The content type of the file. */
private String contentType;
@@
-76,7
+79,14
@@
public abstract class AbstractEntry extends AbstractBean implements Entry {
* {@inheritDoc}
*/
public boolean isDefault() {
* {@inheritDoc}
*/
public boolean isDefault() {
- return (insert == defaultInsert) && (contentType == null);
+ return (insert == defaultInsert) && isDefaultContentType();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDefaultContentType() {
+ return ((defaultContentType != null) ? defaultContentType.equals(contentType) : (contentType == null));
}
/**
}
/**
@@
-139,4
+149,15
@@
public abstract class AbstractEntry extends AbstractBean implements Entry {
fireIfPropertyChanged(PROPERTY_CONTENT_TYPE, oldContentType, contentType);
}
fireIfPropertyChanged(PROPERTY_CONTENT_TYPE, oldContentType, contentType);
}
+ /**
+ * Sets the default content type of the entry. The default content type is
+ * derived from its extension.
+ *
+ * @param defaultContentType
+ * The default content type
+ */
+ void setDefaultContentType(String defaultContentType) {
+ this.defaultContentType = defaultContentType;
+ }
+
}
}
diff --git
a/src/net/pterodactylus/jsite/project/Entry.java
b/src/net/pterodactylus/jsite/project/Entry.java
index
8f3783b
..
86b5904
100644
(file)
--- a/
src/net/pterodactylus/jsite/project/Entry.java
+++ b/
src/net/pterodactylus/jsite/project/Entry.java
@@
-47,6
+47,14
@@
public interface Entry {
public boolean isDefault();
/**
public boolean isDefault();
/**
+ * Returns whether the content type setting is still the default.
+ *
+ * @return <code>true</code> if the content type has not been changed by
+ * the user, <code>false</code> otherwise
+ */
+ public boolean isDefaultContentType();
+
+ /**
* 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.
* 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
5c58763
..
36a27f9
100644
(file)
--- a/
src/net/pterodactylus/jsite/project/Project.java
+++ b/
src/net/pterodactylus/jsite/project/Project.java
@@
-25,6
+25,7
@@
import java.util.ArrayList;
import java.util.List;
import net.pterodactylus.util.beans.AbstractBean;
import java.util.List;
import net.pterodactylus.util.beans.AbstractBean;
+import net.pterodactylus.util.io.MimeTypes;
/**
* Container for project information. A Project is capable of notifying
/**
* Container for project information. A Project is capable of notifying
@@
-299,6
+300,12
@@
public class Project extends AbstractBean {
entry.setPath(file.getPath());
entry.setDefaultInsert(!file.isHidden());
entry.setInsert(!file.isHidden());
entry.setPath(file.getPath());
entry.setDefaultInsert(!file.isHidden());
entry.setInsert(!file.isHidden());
+ String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
+ List<String> mimeTypes = MimeTypes.getMimeTypes(extension);
+ if (!mimeTypes.isEmpty()) {
+ entry.setDefaultContentType(mimeTypes.get(0));
+ entry.setContentType(mimeTypes.get(0));
+ }
entries.add(entry);
}
}
entries.add(entry);
}
}