[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui ...
Christian Bauer
christian at hibernate.org
Mon Sep 24 04:23:20 EDT 2007
User: cbauer
Date: 07/09/24 04:23:20
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/ui
UIWikiFormattedText.java
WikiFormattedTextHandler.java Converters.java
Added: examples/wiki/src/main/org/jboss/seam/wiki/core/ui
SeamTextValidator.java WikiTextEditor.java
Log:
New help system and improved wiki text editor
Revision Changes Path
1.28 +25 -5 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/UIWikiFormattedText.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIWikiFormattedText.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/UIWikiFormattedText.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- UIWikiFormattedText.java 25 Aug 2007 17:59:25 -0000 1.27
+++ UIWikiFormattedText.java 24 Sep 2007 08:23:20 -0000 1.28
@@ -36,6 +36,9 @@
public static final String ATTR_ATTACHMENT_LINK_STYLE_CLASS = "attachmentLinkStyleClass";
public static final String ATTR_THUMBNAIL_LINK_STYLE_CLASS = "thumbnailLinkStyleClass";
public static final String ATTR_UPDATE_RESOLVED_LINKS = "updateResolvedLinks";
+ public static final String ATTR_PLAIN_VIEW = "plainView";
+ public static final String ATTR_INTERNAL_TARGET_FRAME = "internalTargetFrame";
+ public static final String ATTR_EXTERNAL_TARGET_FRAME = "externalTargetFrame";
public static final String ATTR_RENDER_BASE_DOCUMENT = "renderBaseDocument";
public static final String ATTR_RENDER_BASE_DIRECTORY = "renderBaseDirectory";
public static final String ATTR_ENABLE_PLUGINS = "enablePlugins";
@@ -86,7 +89,15 @@
public String renderInlineLink(WikiLink inlineLink) {
return "<a href=\""
- + (inlineLink.isBroken() ? inlineLink.getUrl() : WikiUtil.renderURL(inlineLink.getNode()))
+ + (
+ inlineLink.isBroken()
+ ? inlineLink.getUrl()
+ : "true".equals(getAttributes().get(ATTR_PLAIN_VIEW))
+ ? WikiUtil.renderPlainURL(inlineLink.getNode())
+ : WikiUtil.renderURL(inlineLink.getNode())
+ )
+ + "\" target=\""
+ + (getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) : "")
+ "\" class=\""
+ (inlineLink.isBroken() ? getAttributes().get(ATTR_BROKEN_LINK_STYLE_CLASS)
: getAttributes().get(ATTR_LINK_STYLE_CLASS)) + "\">"
@@ -96,6 +107,8 @@
public String renderExternalLink(WikiLink externalLink) {
return "<a href=\""
+ WikiUtil.escapeEmailURL(externalLink.getUrl())
+ + "\" target=\""
+ + (getAttributes().get(ATTR_EXTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_EXTERNAL_TARGET_FRAME) : "")
+ "\" class=\""
+ (externalLink.isBroken() ? getAttributes().get(ATTR_BROKEN_LINK_STYLE_CLASS)
: getAttributes().get(ATTR_LINK_STYLE_CLASS)) + "\">"
@@ -104,8 +117,13 @@
public String renderFileAttachmentLink(int attachmentNumber, WikiLink attachmentLink) {
return "<a href=\""
- + WikiUtil.renderURL(baseDocument)
- + "#attachment" + attachmentNumber + "\" class=\""
+ + ("true".equals(getAttributes().get(ATTR_PLAIN_VIEW))
+ ? WikiUtil.renderPlainURL(baseDocument)
+ : WikiUtil.renderURL(baseDocument))
+ + "#attachment" + attachmentNumber
+ + "\" target=\""
+ + (getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) : "")
+ + "\" class=\""
+ getAttributes().get(ATTR_ATTACHMENT_LINK_STYLE_CLASS) + "\">"
+ attachmentLink.getDescription() + "[" + attachmentNumber + "]" + "</a>";
}
@@ -129,8 +147,10 @@
String thumbnailUrl = WikiUtil.renderURL(inlineLink.getNode()) + "&thumbnail=true&cid=" + Conversation.instance().getId();
return "<a href=\""
- + (inlineLink.isBroken() ? inlineLink.getUrl() : WikiUtil.renderURL(inlineLink
- .getNode())) + "\" class=\""
+ + (inlineLink.isBroken() ? inlineLink.getUrl() : WikiUtil.renderURL(inlineLink.getNode()))
+ + "\" target=\""
+ + (getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) : "")
+ + "\" class=\""
+ getAttributes().get(ATTR_THUMBNAIL_LINK_STYLE_CLASS) + "\"><img src=\""
+ thumbnailUrl + "\"/></a>";
1.14 +3 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiFormattedTextHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiFormattedTextHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiFormattedTextHandler.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- WikiFormattedTextHandler.java 2 Sep 2007 14:54:30 -0000 1.13
+++ WikiFormattedTextHandler.java 24 Sep 2007 08:23:20 -0000 1.14
@@ -91,6 +91,9 @@
setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_ATTACHMENT_LINK_STYLE_CLASS);
setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_THUMBNAIL_LINK_STYLE_CLASS);
setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_UPDATE_RESOLVED_LINKS);
+ setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_PLAIN_VIEW);
+ setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_INTERNAL_TARGET_FRAME);
+ setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_EXTERNAL_TARGET_FRAME);
setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_RENDER_BASE_DOCUMENT);
setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_RENDER_BASE_DIRECTORY);
setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_ENABLE_PLUGINS);
1.12 +0 -3 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/Converters.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Converters.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/Converters.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- Converters.java 30 Aug 2007 16:50:59 -0000 1.11
+++ Converters.java 24 Sep 2007 08:23:20 -0000 1.12
@@ -38,7 +38,6 @@
@org.jboss.seam.annotations.faces.Converter(forClass = Importer.class)
public static class ImporterConverter implements Converter, Serializable {
- @Transactional
public Object getAsObject(FacesContext arg0,
UIComponent arg1,
String arg2) throws ConverterException {
@@ -60,7 +59,6 @@
@org.jboss.seam.annotations.faces.Converter(forClass = SearchableEntity.class)
public static class SearchableEntityConverter implements Converter, Serializable {
- @Transactional
public Object getAsObject(FacesContext arg0,
UIComponent arg1,
String arg2) throws ConverterException {
@@ -82,7 +80,6 @@
@org.jboss.seam.annotations.faces.Converter(forClass = Role.AccessLevel.class)
public static class AccessLevelConverter implements Converter, Serializable {
- @Transactional
public Object getAsObject(FacesContext arg0,
UIComponent arg1,
String arg2) throws ConverterException {
1.1 date: 2007/09/24 08:23:20; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/SeamTextValidator.java
Index: SeamTextValidator.java
===================================================================
package org.jboss.seam.wiki.core.ui;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringReader;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.faces.Validator;
import org.jboss.seam.text.SeamTextLexer;
import org.jboss.seam.text.SeamTextParser;
import antlr.ANTLRException;
import antlr.RecognitionException;
/**
* Seam Text validator
* @author matthew.drees
*
*/
@Validator
@Name("seamTextValidator")
public class SeamTextValidator implements javax.faces.validator.Validator, Serializable {
private static final long serialVersionUID = 1L;
String firstError;
/**
* Validate the given value as well-formed Seam Text. If there are parse errors, throw a ValidatorException
* including the first parse error.
*/
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
firstError = null;
if (value == null) {
return;
}
if (!(value instanceof String)){
throw new IllegalArgumentException("Value is not a string: " + value);
}
String text = (String) value;
Reader r = new StringReader(text);
SeamTextLexer lexer = new SeamTextLexer(r);
SeamTextParser parser = new SeamTextParser(lexer) {
@Override
public void reportError(RecognitionException re) {
if (firstError == null) {
firstError = re.getMessage();
}
}
};
try {
parser.startRule();
}
catch (ANTLRException re) {
throw new RuntimeException("Can't parse text", re);
}
if (firstError != null) {
firstError = firstError.replace("\uFFFF", "[END OF TEXT]");
throw new ValidatorException(new FacesMessage("Invalid text: " + firstError));
}
}
}
1.1 date: 2007/09/24 08:23:20; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiTextEditor.java
Index: WikiTextEditor.java
===================================================================
package org.jboss.seam.wiki.core.ui;
import org.jboss.seam.annotations.remoting.WebRemote;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.ScopeType;
import java.util.Map;
import java.util.HashMap;
/**
* Store UI status of wiki text editor.
* <p>
* This is called via Javascript when the user changes some visual properties of the wiki text editor,
* atm this is only resizing of the text area. We need to store the UI properties so that we can restore
* the UI when the user exits the page and comes back later in the conversation. Or, when we reRender the
* wiki text editor we need to apply these properties so it looks the same as before the reRender.
*
* @author Christian Bauer
*/
@Name("wikiTextEditor")
@Scope(ScopeType.CONVERSATION) // TODO: Should be PAGE but doesn't work with Seam remoting!
public class WikiTextEditor {
private Map<String, String> textAreaRows = new HashMap<String, String>();
@WebRemote
public void setTextAreaRows(String editorId, String textAreaRows) {
this.textAreaRows.put(editorId, textAreaRows);
}
public String getTextAreaRows(String editorId) {
return textAreaRows.get(editorId);
}
}
More information about the jboss-cvs-commits
mailing list