Author: christian.bauer(a)jboss.com
Date: 2008-04-09 13:12:30 -0400 (Wed, 09 Apr 2008)
New Revision: 7888
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/exception/InvalidWikiConfigurationException.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/TemplateRegistry.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentEditorTemplate.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentTemplate.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogEntryDefaults.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionDefaults.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicDefaults.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicListDefaults.java
Modified:
trunk/examples/wiki/src/etc/META-INF/seam-deployment.properties
trunk/examples/wiki/src/etc/WEB-INF/pages.xml
trunk/examples/wiki/src/etc/i18n/messages_blogDirectory_en.properties
trunk/examples/wiki/src/etc/i18n/messages_en.properties
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentDefaults.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java
trunk/examples/wiki/view/dirDisplay_d.xhtml
trunk/examples/wiki/view/docDisplay_d.xhtml
trunk/examples/wiki/view/includes/directoryBrowserIconMenu.xhtml
trunk/examples/wiki/view/includes/userControl.xhtml
trunk/examples/wiki/view/includes/wikiTextEditor.xhtml
trunk/examples/wiki/view/themes/default/css/faqBrowser.css
trunk/examples/wiki/view/themes/default/css/template.css
trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css
trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css
Log:
JBSEAM-2646, templates for document creation (only BlogEntry for now)
Modified: trunk/examples/wiki/src/etc/META-INF/seam-deployment.properties
===================================================================
--- trunk/examples/wiki/src/etc/META-INF/seam-deployment.properties 2008-04-09 12:38:39
UTC (rev 7887)
+++ trunk/examples/wiki/src/etc/META-INF/seam-deployment.properties 2008-04-09 17:12:30
UTC (rev 7888)
@@ -1 +1 @@
-org.jboss.seam.deployment.annotationTypes=org.jboss.seam.wiki.preferences.annotations.Preferences
\ No newline at end of file
+org.jboss.seam.deployment.annotationTypes=org.jboss.seam.wiki.preferences.annotations.Preferences:org.jboss.seam.wiki.core.template.WikiDocumentTemplate
\ No newline at end of file
Modified: trunk/examples/wiki/src/etc/WEB-INF/pages.xml
===================================================================
--- trunk/examples/wiki/src/etc/WEB-INF/pages.xml 2008-04-09 12:38:39 UTC (rev 7887)
+++ trunk/examples/wiki/src/etc/WEB-INF/pages.xml 2008-04-09 17:12:30 UTC (rev 7888)
@@ -66,6 +66,7 @@
<page view-id="/docEdit*"
no-conversation-view-id="/wiki.xhtml">
<param name="documentId"
value="#{documentHome.nodeId}"/>
<param name="parentDirectoryId"
value="#{documentHome.parentNodeId}"/>
+ <param name="templateType"
value="#{documentHome.templateType}"/>
<action execute="#{documentHome.initEditor}"/>
<begin-conversation flush-mode="MANUAL" join="true"/>
Modified: trunk/examples/wiki/src/etc/i18n/messages_blogDirectory_en.properties
===================================================================
--- trunk/examples/wiki/src/etc/i18n/messages_blogDirectory_en.properties 2008-04-09
12:38:39 UTC (rev 7887)
+++ trunk/examples/wiki/src/etc/i18n/messages_blogDirectory_en.properties 2008-04-09
17:12:30 UTC (rev 7888)
@@ -15,4 +15,7 @@
blogDirectory.label.Tagged=tagged
blogDirectory.label.NoBlogEntriesFound=No blog entries found.
blogDirectory.label.Tag=Tag
-blogDirectory.label.Tags=Tags
\ No newline at end of file
+blogDirectory.label.Tags=Tags
+
+blogDirectory.label.template.BlogEntry=Weblog Entry
+blogDirectory.label.template.NewBlogEntryTitle=My weblog entry title...
Modified: trunk/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- trunk/examples/wiki/src/etc/i18n/messages_en.properties 2008-04-09 12:38:39 UTC (rev
7887)
+++ trunk/examples/wiki/src/etc/i18n/messages_en.properties 2008-04-09 17:12:30 UTC (rev
7888)
@@ -720,3 +720,7 @@
lacewiki.preferences.comments.EnableByDefault=Enable comments by default for new
documents
lacewiki.preferences.comments.Threaded=Threaded comment display (or flat)
+
+# Templates
+
+lacewiki.label.template.RegularWikiDocument=Regular Document
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2008-04-09
12:38:39 UTC (rev 7887)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -21,6 +21,10 @@
import org.jboss.seam.wiki.core.engine.WikiLinkResolver;
import org.jboss.seam.wiki.core.renderer.MacroWikiTextRenderer;
import org.jboss.seam.wiki.core.model.*;
+import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
+import org.jboss.seam.wiki.core.template.TemplateRegistry;
+import org.jboss.seam.wiki.core.template.WikiDocumentTemplate;
+import org.jboss.seam.wiki.core.template.WikiDocumentEditorTemplate;
import org.jboss.seam.wiki.preferences.Preferences;
import org.hibernate.validator.Length;
@@ -52,6 +56,7 @@
private boolean isOnSiteFeed = false;
private List<WikiFile> historicalFiles;
private Long numOfHistoricalFiles = 0l;
+ private String templateType;
/* -------------------------- Basic Overrides ------------------------------ */
@@ -77,6 +82,36 @@
tagEditor.setTags(doc.getTags());
outjectDocumentAndDirectory(doc, getParentNode());
+
+ if (templateType != null &&
!templateType.equals(WikiDocumentDefaults.class.getName())) {
+ getLog().debug("using custom template class for WikiDocument defaults:
" + templateType);
+ WikiDocumentDefaults defaults;
+ try {
+ Class<?> tplClass = Class.forName(templateType);
+
+ if (!TemplateRegistry.instance().getTemplateTypes().contains(tplClass))
{
+ throw new InvalidWikiRequestException("Invalid templateType:
" + templateType);
+ }
+
+ if
(tplClass.getAnnotation(WikiDocumentTemplate.class).requiresTemplateInstance()) {
+ getLog().debug("instantiating template " +
tplClass.getName() + " with current document instance");
+ defaults =
(WikiDocumentDefaults)tplClass.getConstructor(WikiDocument.class).newInstance(doc);
+ } else {
+ getLog().debug("instantiating template " +
tplClass.getName() + " with no-arg constructor");
+ defaults = (WikiDocumentDefaults)tplClass.newInstance();
+ }
+
+ if (WikiDocumentEditorTemplate.class.isAssignableFrom(tplClass)) {
+ getLog().debug("letting template set editor defaults");
+ ((WikiDocumentEditorTemplate)defaults).setEditorDefaults(this);
+ }
+
+ } catch (Exception ex) {
+ throw new InvalidWikiRequestException("Invalid templateType: "
+ templateType);
+ }
+ doc.setDefaults(defaults);
+ }
+
return doc;
}
@@ -405,4 +440,12 @@
public TagEditor getTagEditor() {
return tagEditor;
}
+
+ public String getTemplateType() {
+ return templateType;
+ }
+
+ public void setTemplateType(String templateType) {
+ this.templateType = templateType;
+ }
}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/exception/InvalidWikiConfigurationException.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/exception/InvalidWikiConfigurationException.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/exception/InvalidWikiConfigurationException.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.core.exception;
+
+/**
+ * @author Christian Bauer
+ */
+public class InvalidWikiConfigurationException extends RuntimeException {
+
+ public InvalidWikiConfigurationException() {
+ super();
+ }
+
+ public InvalidWikiConfigurationException(String s) {
+ super(s);
+ }
+
+ public InvalidWikiConfigurationException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public InvalidWikiConfigurationException(Throwable throwable) {
+ super(throwable);
+ }
+}
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentDefaults.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentDefaults.java 2008-04-09
12:38:39 UTC (rev 7887)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentDefaults.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -6,6 +6,22 @@
public class WikiDocumentDefaults {
+ WikiDocument template;
+
+ public WikiDocumentDefaults() {}
+
+ public WikiDocumentDefaults(WikiDocument template) {
+ this.template = template;
+ }
+
+ public WikiDocument getTemplate() {
+ return template;
+ }
+
+ public void setTemplate(WikiDocument template) {
+ this.template = template;
+ }
+
public String getName() {
return "New Document";
}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/TemplateRegistry.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/TemplateRegistry.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/TemplateRegistry.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.core.template;
+
+import org.jboss.seam.annotations.*;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.Component;
+import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+import org.jboss.seam.wiki.core.exception.InvalidWikiConfigurationException;
+import org.jboss.seam.core.Interpolator;
+
+import java.util.*;
+
+/**
+ * @author Christian Bauer
+ */
+@Name("templateRegistry")
+(a)Scope(ScopeType.APPLICATION)
+public class TemplateRegistry {
+
+ @Logger
+ static Log log;
+
+ @In(
+
value="#{deploymentStrategy.annotatedClasses['org.jboss.seam.wiki.core.template.WikiDocumentTemplate']}",
+ required = false
+ )
+ Set<Class> templateClasses;
+
+ Map<Class, String> templates = new HashMap<Class, String>();
+ List<Class> templateTypes = new ArrayList<Class>();
+
+ @Observer("Wiki.started")
+ public void create() {
+ log.debug("initializing template registry");
+
+ for (Class<?> templateClass : templateClasses) {
+
+ String templateName =
interpolate(templateClass.getAnnotation(WikiDocumentTemplate.class).value());
+
+ if (!WikiDocumentDefaults.class.isAssignableFrom(templateClass)) {
+ throw new InvalidWikiConfigurationException("Annotated
@WikiDocumentTemplate class '"
+ + templateClass
+ + "' does not
implement WikiDocumentDefaults interface");
+ }
+
+ log.debug("adding template class " + templateClass.getName() +
" as '" + templateName + "'");
+ templates.put(templateClass, templateName);
+ templateTypes.add(templateClass);
+ }
+ }
+
+ private String interpolate(String s) {
+ return Interpolator.instance().interpolate(s);
+ }
+
+ public Map<Class, String> getTemplates() {
+ return templates;
+ }
+
+ public List<Class> getTemplateTypes() {
+ return templateTypes;
+ }
+
+ public static TemplateRegistry instance() {
+ return (TemplateRegistry)Component.getInstance(TemplateRegistry.class);
+ }
+}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentEditorTemplate.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentEditorTemplate.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentEditorTemplate.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.core.template;
+
+import org.jboss.seam.wiki.core.action.DocumentHome;
+
+/**
+ * @author Christian Bauer
+ */
+public interface WikiDocumentEditorTemplate {
+
+ public void setEditorDefaults(DocumentHome editor);
+}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentTemplate.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentTemplate.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/template/WikiDocumentTemplate.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.core.template;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author Christian Bauer
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface WikiDocumentTemplate {
+ String value();
+ boolean requiresTemplateInstance() default false;
+}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogEntryDefaults.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogEntryDefaults.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogEntryDefaults.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.plugin.blogdirectory;
+
+import org.jboss.seam.wiki.core.template.WikiDocumentTemplate;
+import org.jboss.seam.wiki.core.template.WikiDocumentEditorTemplate;
+import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+import org.jboss.seam.wiki.core.action.DocumentHome;
+import org.jboss.seam.international.Messages;
+
+/**
+ * @author Christian Bauer
+ */
+(a)WikiDocumentTemplate("#{messages['blogDirectory.label.template.BlogEntry']}")
+public class BlogEntryDefaults extends WikiDocumentDefaults implements
WikiDocumentEditorTemplate {
+
+ @Override
+ public String getName() {
+ return
Messages.instance().get("blogDirectory.label.template.NewBlogEntryTitle");
+ }
+
+ @Override
+ public String[] getHeaderMacrosAsString() {
+ return new String[]{ "blogEntry" };
+ }
+
+ public void setEditorDefaults(DocumentHome editor) {
+ editor.setPushOnFeeds(true);
+ editor.setPushOnSiteFeed(true);
+ }
+}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionDefaults.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionDefaults.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionDefaults.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.plugin.faqBrowser;
+
+import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+import org.jboss.seam.wiki.core.model.WikiDocument;
+import org.jboss.seam.wiki.core.template.WikiDocumentTemplate;
+import org.jboss.seam.international.Messages;
+
+/**
+ * @author Christian Bauer
+ */
+public class FaqQuestionDefaults extends WikiDocumentDefaults {
+
+ public FaqQuestionDefaults() {
+ super();
+ }
+
+ @Override
+ public String getName() {
+ return Messages.instance().get("faqBrowser.label.NewQuestionTitle");
+ }
+
+ @Override
+ public String[] getHeaderMacrosAsString() {
+ return new String[]{"faqBrowser", "docPager"};
+ }
+
+ @Override
+ public String getContentText() {
+ return
Messages.instance().get("lacewiki.msg.wikiTextEditor.EditThisText");
+ }
+
+ @Override
+ public void setOptions(WikiDocument newQuestion) {
+ newQuestion.setNameAsTitle(true);
+ newQuestion.setEnableComments(true);
+ newQuestion.setEnableCommentForm(true);
+ newQuestion.setEnableCommentsOnFeeds(false);
+ }
+
+}
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java 2008-04-09
12:38:39 UTC (rev 7887)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -4,10 +4,8 @@
import org.jboss.seam.annotations.*;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Events;
-import org.jboss.seam.international.Messages;
import org.jboss.seam.wiki.core.action.DocumentHome;
import org.jboss.seam.wiki.core.model.WikiDocument;
-import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
import static javax.faces.application.FacesMessage.SEVERITY_INFO;
@@ -41,31 +39,7 @@
@Override
public WikiDocument afterNodeCreated(WikiDocument doc) {
WikiDocument newQuestion = super.afterNodeCreated(doc);
-
- WikiDocumentDefaults newQuestionDefaults=
- new WikiDocumentDefaults() {
- @Override
- public String getName() {
- return
Messages.instance().get("faqBrowser.label.NewQuestionTitle");
- }
- @Override
- public String[] getHeaderMacrosAsString() {
- return new String[] { "faqBrowser",
"docPager" };
- }
- @Override
- public String getContentText() {
- return
Messages.instance().get("lacewiki.msg.wikiTextEditor.EditThisText");
- }
- @Override
- public void setOptions(WikiDocument newQuestion) {
- newQuestion.setNameAsTitle(true);
- newQuestion.setEnableComments(true);
- newQuestion.setEnableCommentForm(true);
- newQuestion.setEnableCommentsOnFeeds(false);
- }
- };
- newQuestion.setDefaults(newQuestionDefaults);
-
+ newQuestion.setDefaults(new FaqQuestionDefaults());
return newQuestion;
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java 2008-04-09
12:38:39 UTC (rev 7887)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -1,13 +1,11 @@
package org.jboss.seam.wiki.plugin.forum;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.international.Messages;
import org.jboss.seam.annotations.*;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Events;
import org.jboss.seam.wiki.core.model.*;
import org.jboss.seam.wiki.core.action.DirectoryHome;
-import org.jboss.seam.wiki.util.WikiUtil;
import javax.faces.application.FacesMessage;
import static javax.faces.application.FacesMessage.SEVERITY_INFO;
@@ -68,40 +66,12 @@
getEntityManager().persist(newMenuItem);
// Default document is topic list
- WikiDocumentDefaults topicListDefaults =
- new WikiDocumentDefaults() {
- @Override
- public String getName() {
- return getInstance().getName() + " " +
Messages.instance().get("forum.label.Forum");
- }
- @Override
- public String[] getHeaderMacrosAsString() {
- return new String[] {"clearBackground",
"hideControls", "hideComments", "hideTags",
"hideCreatorHistory"};
- }
- @Override
- public String[] getContentMacrosAsString() {
- return new String[] {"forumTopics"};
- }
- @Override
- public String getContentText() {
- return "";
- }
- @Override
- public void setOptions(WikiDocument document) {
- document.setAreaNumber(getInstance().getAreaNumber());
-
document.setWikiname(WikiUtil.convertToWikiName(document.getName()));
- document.setNameAsTitle(true);
- document.setReadAccessLevel(getInstance().getReadAccessLevel());
-
document.setWriteAccessLevel(org.jboss.seam.wiki.core.model.Role.ADMINROLE_ACCESSLEVEL);
- document.setEnableComments(false);
- document.setEnableCommentForm(false);
- document.setEnableCommentsOnFeeds(false);
- document.setCreatedBy(getCurrentUser());
- }
- };
-
- WikiDocument topicList = new WikiDocument(topicListDefaults);
-
+ WikiDocument topicListTemplate = new WikiDocument();
+ topicListTemplate.setName(getInstance().getName());
+ topicListTemplate.setCreatedBy(currentUser);
+ topicListTemplate.setAreaNumber(getInstance().getAreaNumber());
+ topicListTemplate.setReadAccessLevel(getInstance().getReadAccessLevel());
+ WikiDocument topicList = new WikiDocument(new
TopicListDefaults(topicListTemplate));
topicList.setParent(getInstance());
getInstance().setDefaultFile(topicList);
Added: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicDefaults.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicDefaults.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicDefaults.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.plugin.forum;
+
+import org.jboss.seam.international.Messages;
+import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+import org.jboss.seam.wiki.core.model.WikiDocument;
+
+/**
+ * @author Christian Bauer
+ */
+public class TopicDefaults extends WikiDocumentDefaults {
+
+ public TopicDefaults() {
+ super();
+ }
+
+ @Override
+ public String getName() {
+ return Messages.instance().get("forum.label.NewTopic");
+ }
+
+ @Override
+ public String[] getHeaderMacrosAsString() {
+ return new String[] { "clearBackground", "hideControls",
"hideComments",
+ "hideTags", "hideCreatorHistory",
"disableContentMacros", "forumPosting" };
+ }
+
+ @Override
+ public String getContentText() {
+ return
Messages.instance().get("lacewiki.msg.wikiTextEditor.EditThisText");
+ }
+
+ @Override
+ public String[] getFooterMacrosAsString() {
+ return new String[] { "forumReplies" };
+ }
+
+ @Override
+ public void setOptions(WikiDocument newTopic) {
+ newTopic.setNameAsTitle(false);
+ newTopic.setEnableComments(true);
+ newTopic.setEnableCommentForm(true);
+ newTopic.setEnableCommentsOnFeeds(true);
+ }
+}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java 2008-04-09
12:38:39 UTC (rev 7887)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -1,23 +1,21 @@
package org.jboss.seam.wiki.plugin.forum;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.faces.Renderer;
-import org.jboss.seam.ui.validator.FormattedTextValidator;
import org.jboss.seam.annotations.*;
import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Events;
-import org.jboss.seam.international.Messages;
+import org.jboss.seam.faces.Renderer;
+import org.jboss.seam.ui.validator.FormattedTextValidator;
import org.jboss.seam.wiki.core.action.DocumentHome;
import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
+import org.jboss.seam.wiki.core.engine.WikiMacro;
import org.jboss.seam.wiki.core.model.WikiDirectory;
import org.jboss.seam.wiki.core.model.WikiDocument;
-import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
-import org.jboss.seam.wiki.core.engine.WikiMacro;
import org.jboss.seam.wiki.preferences.Preferences;
-import static javax.faces.application.FacesMessage.SEVERITY_INFO;
import javax.faces.application.FacesMessage;
+import static javax.faces.application.FacesMessage.SEVERITY_INFO;
import javax.faces.validator.ValidatorException;
@Name("topicHome")
@@ -60,38 +58,8 @@
@Override
public WikiDocument afterNodeCreated(WikiDocument doc) {
WikiDocument newTopic = super.afterNodeCreated(doc);
-
- WikiDocumentDefaults newTopicDefaults =
- new WikiDocumentDefaults() {
- @Override
- public String getName() {
- return
Messages.instance().get("forum.label.NewTopic");
- }
- @Override
- public String[] getHeaderMacrosAsString() {
- return new String[] { "clearBackground",
"hideControls", "hideComments",
- "hideTags",
"hideCreatorHistory", "disableContentMacros", "forumPosting"
};
- }
- @Override
- public String getContentText() {
- return
Messages.instance().get("lacewiki.msg.wikiTextEditor.EditThisText");
- }
- @Override
- public String[] getFooterMacrosAsString() {
- return new String[] { "forumReplies" };
- }
- @Override
- public void setOptions(WikiDocument newTopic) {
- newTopic.setNameAsTitle(false);
- newTopic.setEnableComments(true);
- newTopic.setEnableCommentForm(true);
- newTopic.setEnableCommentsOnFeeds(true);
- }
- };
- newTopic.setDefaults(newTopicDefaults);
-
+ newTopic.setDefaults(new TopicDefaults());
setPushOnFeeds(true);
-
return newTopic;
}
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicListDefaults.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicListDefaults.java
(rev 0)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicListDefaults.java 2008-04-09
17:12:30 UTC (rev 7888)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.seam.wiki.plugin.forum;
+
+import org.jboss.seam.international.Messages;
+import org.jboss.seam.wiki.util.WikiUtil;
+import org.jboss.seam.wiki.core.model.WikiDocument;
+import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+
+/**
+ * @author Christian Bauer
+ */
+public class TopicListDefaults extends WikiDocumentDefaults {
+
+ public TopicListDefaults(WikiDocument template) {
+ super(template);
+ }
+
+ @Override
+ public String getName() {
+ return getTemplate().getName() + " " +
Messages.instance().get("forum.label.Forum");
+ }
+
+ @Override
+ public String[] getHeaderMacrosAsString() {
+ return new String[]{"clearBackground", "hideControls",
"hideComments", "hideTags", "hideCreatorHistory"};
+ }
+
+ @Override
+ public String[] getContentMacrosAsString() {
+ return new String[]{"forumTopics"};
+ }
+
+ @Override
+ public String getContentText() {
+ return "";
+ }
+
+ @Override
+ public void setOptions(WikiDocument document) {
+ document.setAreaNumber(getTemplate().getAreaNumber());
+ document.setWikiname(WikiUtil.convertToWikiName(document.getName()));
+ document.setNameAsTitle(true);
+ document.setReadAccessLevel(getTemplate().getReadAccessLevel());
+
document.setWriteAccessLevel(org.jboss.seam.wiki.core.model.Role.ADMINROLE_ACCESSLEVEL);
+ document.setEnableComments(false);
+ document.setEnableCommentForm(false);
+ document.setEnableCommentsOnFeeds(false);
+ document.setCreatedBy(getTemplate().getCreatedBy());
+ }
+}
Modified: trunk/examples/wiki/view/dirDisplay_d.xhtml
===================================================================
--- trunk/examples/wiki/view/dirDisplay_d.xhtml 2008-04-09 12:38:39 UTC (rev 7887)
+++ trunk/examples/wiki/view/dirDisplay_d.xhtml 2008-04-09 17:12:30 UTC (rev 7888)
@@ -31,14 +31,32 @@
<h:outputText escape="false"
value="#{messages['lacewiki.button.EditDirectory']}"/>
</s:link>
- <s:link id="createDoc" styleClass="linkNavigation"
-
accesskey="#{messages['lacewiki.button.NewDocument.accesskey']}"
- view="/docEdit_#{skin}.xhtml" propagation="none"
- rendered="#{s:hasPermission('Node', 'create',
directoryBrowser.instance)}">
- <h:outputText escape="false"
value="#{messages['lacewiki.button.NewDocument']}"/>
- <f:param name="documentId"/>
- <f:param name="parentDirectoryId"
value="#{directoryBrowser.instance.id}"/>
- </s:link>
+ <s:div id="createDoc" styleClass="linkNavigationMenu"
+ rendered="#{s:hasPermission('Node', 'create',
directoryBrowser.instance)}">
+ <h:outputLink value="javascript://no-op"
+ onmouseover="jQuery(this).parent().menu();"
+
accesskey="#{messages['lacewiki.button.NewDocument.accesskey']}">
+ <h:outputText escape="false"
value="#{messages['lacewiki.button.NewDocument']}"/>
+ </h:outputLink><ul class="contextMenuItems">
+ <li>
+ <s:link view="/docEdit_#{skin}.xhtml"
propagation="none">
+ <h:outputText escape="false"
value="#{messages['lacewiki.label.template.RegularWikiDocument']}"/>
+ <f:param name="documentId" value=""/>
+ <f:param name="parentDirectoryId"
value="#{directoryBrowser.instance.id}"/>
+ </s:link>
+ </li>
+ <ui:repeat var="templateType"
value="#{templateRegistry.templateTypes}">
+ <li>
+ <s:link view="/docEdit_#{skin}.xhtml"
propagation="none">
+ <h:outputText escape="false"
value="#{templateRegistry.templates[templateType]}"/>
+ <f:param name="documentId"
value=""/>
+ <f:param name="parentDirectoryId"
value="#{directoryBrowser.instance.id}"/>
+ <f:param name="templateType"
value="#{templateType.name}"/>
+ </s:link>
+ </li>
+ </ui:repeat>
+ </ul>
+ </s:div>
<s:link id="uploadFile" styleClass="linkNavigation"
accesskey="#{messages['lacewiki.button.UploadFile.accesskey']}"
Modified: trunk/examples/wiki/view/docDisplay_d.xhtml
===================================================================
--- trunk/examples/wiki/view/docDisplay_d.xhtml 2008-04-09 12:38:39 UTC (rev 7887)
+++ trunk/examples/wiki/view/docDisplay_d.xhtml 2008-04-09 17:12:30 UTC (rev 7888)
@@ -27,14 +27,32 @@
<s:fragment rendered="#{not
documentHome.instance.macroPresent('hideControls') or
s:hasPermission('User', 'isAdmin', currentUser)}">
- <s:link id="createDoc" styleClass="linkNavigation"
-
accesskey="#{messages['lacewiki.button.CreateDocument.accesskey']}"
- view="/docEdit_#{skin}.xhtml" propagation="none"
- rendered="#{s:hasPermission('Node', 'create',
documentHome.instance.parent)}">
- <h:outputText escape="false"
value="#{messages['lacewiki.button.CreateDocument']}"/>
- <f:param name="documentId" value=""/>
- <f:param name="parentDirectoryId"
value="#{documentHome.instance.parent.id}"/>
- </s:link>
+ <s:div id="createDoc" styleClass="linkNavigationMenu"
+ rendered="#{s:hasPermission('Node', 'create',
documentHome.instance.parent)}">
+ <h:outputLink value="javascript://no-op"
+ onmouseover="jQuery(this).parent().menu();"
+
accesskey="#{messages['lacewiki.button.CreateDocument.accesskey']}">
+ <h:outputText escape="false"
value="#{messages['lacewiki.button.CreateDocument']}"/>
+ </h:outputLink><ul
+ class="contextMenuItems">
+ <li>
+ <s:link view="/docEdit_#{skin}.xhtml"
propagation="none">
+ <h:outputText escape="false"
value="#{messages['lacewiki.label.template.RegularWikiDocument']}"/>
+ <f:param name="documentId" value=""/>
+ <f:param name="parentDirectoryId"
value="#{documentHome.instance.parent.id}"/>
+ </s:link>
+ </li>
+ <ui:repeat var="templateType"
value="#{templateRegistry.templateTypes}">
+ <li>
+ <s:link view="/docEdit_#{skin}.xhtml"
propagation="none">
+ <h:outputText escape="false"
value="#{templateRegistry.templates[templateType]}"/>
+ <f:param name="documentId"
value=""/>
+ <f:param name="parentDirectoryId"
value="#{documentHome.instance.parent.id}"/>
+ <f:param name="templateType"
value="#{templateType.name}"/>
+ </s:link>
+ </li>
+ </ui:repeat>
+ </ul></s:div>
<s:link id="editDoc" styleClass="linkNavigation"
accesskey="#{messages['lacewiki.button.EditDocument.accesskey']}"
Modified: trunk/examples/wiki/view/includes/directoryBrowserIconMenu.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/directoryBrowserIconMenu.xhtml 2008-04-09 12:38:39
UTC (rev 7887)
+++ trunk/examples/wiki/view/includes/directoryBrowserIconMenu.xhtml 2008-04-09 17:12:30
UTC (rev 7888)
@@ -4,7 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:s="http://jboss.com/products/seam/taglib">
- <h:outputLink value="#" tabindex="1"
+ <h:outputLink value="javascript://no-op" tabindex="1"
onmouseover="jQuery(this).children('.dirItemIcon').attr('src','#{themePath}/img/menu_down.gif').toggleClass('mouseOver');
jQuery(this).parent('.contextMenu').menu();
jQuery(this).children('.contextMenuItems').show();"
onmouseout="jQuery(this).children('.dirItemIcon').attr('src','#{icon}').toggleClass('mouseOver')">
Modified: trunk/examples/wiki/view/includes/userControl.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/userControl.xhtml 2008-04-09 12:38:39 UTC (rev
7887)
+++ trunk/examples/wiki/view/includes/userControl.xhtml 2008-04-09 17:12:30 UTC (rev
7888)
@@ -97,7 +97,7 @@
<s:span styleClass="label">
<h:outputText
value="#{messages['lacewiki.label.userControl.Password']} "/>
- <h:outputLink value="#"
id="openPasswordResetPopup" tabindex="51">
+ <h:outputLink value="javascript://no-op"
id="openPasswordResetPopup" tabindex="51">
<h:outputText styleClass="linkText"
escape="false"
value="(#{messages['lacewiki.button.userControl.ResetPassword']})"/>
</h:outputLink>
<h:outputText value=":"/>
Modified: trunk/examples/wiki/view/includes/wikiTextEditor.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/wikiTextEditor.xhtml 2008-04-09 12:38:39 UTC (rev
7887)
+++ trunk/examples/wiki/view/includes/wikiTextEditor.xhtml 2008-04-09 17:12:30 UTC (rev
7888)
@@ -116,7 +116,7 @@
<s:fragment>
<s:fragment rendered="#{not empty
textPreviewId}">
- <h:outputLink value="#"
+ <h:outputLink value="javascript://no-op"
tabindex="1"
styleClass="buttonNonpersistent noWrapWhitespace"
accesskey="#{messages['lacewiki.button.wikiTextEditor.UpdatePreview.accesskey']}"
onclick="rememberCursorPosition('##{namingContainer}\\\\:#{textEditorId}TextArea');
#{textEditorId}UpdatePreview(); return false;">
Modified: trunk/examples/wiki/view/themes/default/css/faqBrowser.css
===================================================================
--- trunk/examples/wiki/view/themes/default/css/faqBrowser.css 2008-04-09 12:38:39 UTC
(rev 7887)
+++ trunk/examples/wiki/view/themes/default/css/faqBrowser.css 2008-04-09 17:12:30 UTC
(rev 7888)
@@ -60,6 +60,7 @@
}
.faqQuestionList {
+ width: 100%;
}
.faqQuestionList .rowOdd {
Modified: trunk/examples/wiki/view/themes/default/css/template.css
===================================================================
--- trunk/examples/wiki/view/themes/default/css/template.css 2008-04-09 12:38:39 UTC (rev
7887)
+++ trunk/examples/wiki/view/themes/default/css/template.css 2008-04-09 17:12:30 UTC (rev
7888)
@@ -473,6 +473,17 @@
margin: 0 5px 0 5px;
}
+.linkNavigationMenu {
+ display: inline;
+ text-decoration:none;
+ font-size: 85%;
+ font-weight: bold;
+ background: #5a4d46 url(../img/menu.bg.gif) 0 0 repeat-x;
+ border: 1px solid #fff;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.linkTab {
text-decoration:none;
font-weight: bold;
@@ -506,6 +517,11 @@
.linkNavigation:hover {color: #ccc}
.linkNavigation:active {color: #aaa}
+.linkNavigationMenu a:link {color: #fff}
+.linkNavigationMenu a:visited {color: #fff}
+.linkNavigationMenu a:hover {color: #ccc}
+.linkNavigationMenu a:active {color: #aaa}
+
.feeds {
padding: 5px;
}
Modified: trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css
===================================================================
--- trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2008-04-09 12:38:39
UTC (rev 7887)
+++ trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2008-04-09 17:12:30
UTC (rev 7888)
@@ -493,6 +493,18 @@
margin: 0 5px 0 5px;
}
+.linkNavigationMenu {
+ display: inline;
+ text-decoration:none;
+ font-size: 85%;
+ font-weight: bold;
+ background-color: #d55121;
+ border: 1px solid #f3f4e4;
+ border-bottom: 1px solid #f3f4e4;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.linkTab {
text-decoration:none;
font-weight: bold;
@@ -526,6 +538,11 @@
.linkNavigation:hover {color: #ccc}
.linkNavigation:active {color: #aaa}
+.linkNavigationMenu a:link {color: #fff}
+.linkNavigationMenu a:visited {color: #fff}
+.linkNavigationMenu a:hover {color: #ccc}
+.linkNavigationMenu a:active {color: #aaa}
+
.feeds {
padding: 5px;
}
Modified: trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css
===================================================================
--- trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2008-04-09 12:38:39 UTC (rev
7887)
+++ trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2008-04-09 17:12:30 UTC (rev
7888)
@@ -250,6 +250,12 @@
margin: 0 5px 0 5px;
}
+.linkNavigationMenu {
+ display: block;
+ padding: 2px 5px 2px 5px;
+ margin: 0 5px 0 5px;
+}
+
.linkNavigation:visited {color: #576c74}
.workspaceSwitcherContainer {
@@ -1481,7 +1487,6 @@
}
.activetarget {
- font-weight: bold;
cursor: pointer;
}