Author: dmorozov
Date: 2008-11-20 06:28:45 -0500 (Thu, 20 Nov 2008)
New Revision: 11261
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/seamtext/
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/seamtext/SeamTextConverter.java
Removed:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/SeamTextConverter.java
Modified:
trunk/sandbox/ui/editor/src/main/config/component/editor.xml
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
Log:
readonly, useSeamText, autoResize now boolean instead of Boolean, move SeamTextConverter
class ti the package org.richfaces.convert.seamtext, create SeamTextConverter instance
then HtmlEditor instance created
Modified: trunk/sandbox/ui/editor/src/main/config/component/editor.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-20 11:10:18 UTC
(rev 11260)
+++ trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-20 11:28:45 UTC
(rev 11261)
@@ -71,7 +71,7 @@
</property>
<property>
<name>useSeamText</name>
- <classname>java.lang.Boolean</classname>
+ <classname>boolean</classname>
<description>
Attribute defines if model value should be converted to Seam Text
</description>
@@ -87,7 +87,7 @@
</property>
<property>
<name>readonly</name>
- <classname>java.lang.Boolean</classname>
+ <classname>boolean</classname>
<description>
Attribute defines Editor is readonly
</description>
@@ -101,7 +101,7 @@
</property>
<property>
<name>autoResize</name>
- <classname>java.lang.Boolean</classname>
+ <classname>boolean</classname>
<description>
Attribute enables to get the Editor area to resize to the boundaries of the
contents.
</description>
Modified: trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java 2008-11-20
11:10:18 UTC (rev 11260)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java 2008-11-20
11:28:45 UTC (rev 11261)
@@ -30,7 +30,7 @@
import javax.faces.component.UIInput;
import javax.faces.convert.Converter;
-import org.richfaces.convert.SeamTextConverter;
+import org.richfaces.convert.seamtext.SeamTextConverter;
/**
* JSF component class
@@ -47,7 +47,9 @@
/** Id suffix of textarea which used as target element for tinyMCE scripts*/
public static final String EDITOR_TEXT_AREA_ID_SUFFIX = "TextArea";
-
+
+ private SeamTextConverter defaultSeamTextConverter = new SeamTextConverter();
+
public abstract void setType(String type);
public abstract String getType();
@@ -64,10 +66,10 @@
public abstract String getTheme();
- public abstract void setUseSeamText(Boolean useSeamText);
+ public abstract void setUseSeamText(boolean useSeamText);
- public abstract Boolean getUseSeamText();
-
+ public abstract boolean isUseSeamText();
+
public abstract void setPlugins(String plugins);
public abstract String getPlugins();
@@ -96,13 +98,13 @@
public abstract String getOnsetup();
- public abstract void setAutoResize(Boolean autoResize);
+ public abstract void setAutoResize(boolean autoResize);
- public abstract Boolean getAutoResize();
+ public abstract boolean isAutoResize();
- public abstract void setReadonly(Boolean readonly);
+ public abstract void setReadonly(boolean readonly);
- public abstract Boolean getReadonly();
+ public abstract boolean isReadonly();
public abstract void setConfiguration(String configuration);
@@ -137,11 +139,10 @@
@Override
public Converter getConverter() {
Converter converter = super.getConverter();
- if (getUseSeamText() && converter == null) {
- return new SeamTextConverter();
+ if(isUseSeamText() && converter == null) {
+ converter = defaultSeamTextConverter;
}
return converter;
}
-
}
Deleted:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/SeamTextConverter.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/SeamTextConverter.java 2008-11-20
11:10:18 UTC (rev 11260)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/SeamTextConverter.java 2008-11-20
11:28:45 UTC (rev 11261)
@@ -1,123 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * SeamTextConverter.java Date created: 26.09.2008
- * Last modified by: $Author$
- * $Revision$ $Date$
- */
-
-package org.richfaces.convert;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.lang.reflect.Constructor;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.seam.text.SeamTextLexer;
-import org.jboss.seam.text.SeamTextParser;
-import org.richfaces.antlr.HtmlSeamTextLexer;
-import org.richfaces.antlr.HtmlSeamTextParser;
-
-import antlr.ANTLRException;
-import antlr.RecognitionException;
-import antlr.TokenStream;
-
-/**
- * Seam Text Converter class. Provides converting html to seam text and vice versa.
- *
- * @author Alexandr Levkovsky
- *
- */
-public class SeamTextConverter implements Converter {
-
- /** log4j instance for converter class */
- private static final Log _log = LogFactory.getLog(SeamTextConverter.class);
-
- /** The converter id for this converter. */
- public static final String CONVERTER_ID = SeamTextConverter.class.getName();
-
- /* (non-Javadoc)
- * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
- */
- @SuppressWarnings("unchecked")
- public Object getAsObject(FacesContext context, UIComponent component,
- String value) {
- try {
- Reader r = new StringReader(value);
- HtmlSeamTextLexer lexer = new HtmlSeamTextLexer(r);
- HtmlSeamTextParser parser = new HtmlSeamTextParser(lexer);
- parser.startRule();
- return parser.toString();
- } catch (RecognitionException rex) {
- // Log a nice message for any lexer/parser errors, users can disable
- // this if they want to
- _log.warn("Seam Text parse error: " + rex.getMessage());
- } catch (ANTLRException ex) {
- // All other errors are fatal;
- throw new RuntimeException(ex);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
- */
- @SuppressWarnings("unchecked")
- public String getAsString(FacesContext context, UIComponent component,
- Object value) {
- if (value == null) {
- return "";
- }
-
- SeamTextParser parser = null;
-
- try {
-
- Reader r = new StringReader(value.toString());
- Class seamTextLexerClass =
Class.forName("org.jboss.seam.text.SeamTextLexer");
- Class seamTextParserClass =
Class.forName("org.jboss.seam.text.SeamTextParser");
- Constructor seamTextLexerConstructor =
seamTextLexerClass.getConstructor(Reader.class);
- SeamTextLexer lexer = (SeamTextLexer) seamTextLexerConstructor.newInstance(new
Object[] { r });
- Constructor seamTextParserConstructor =
seamTextParserClass.getConstructor(TokenStream.class);
- parser = (SeamTextParser) seamTextParserConstructor.newInstance(new Object[] { lexer
});
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- try {
- parser.startRule();
- } catch (RecognitionException rex) {
- // Log a nice message for any lexer/parser errors, users can disable
- // this if they want to
- _log.warn("Seam Text parse error: " + rex.getMessage());
- } catch (ANTLRException ex) {
- // All other errors are fatal;
- throw new RuntimeException(ex);
- }
- return parser.toString();
- }
-
-}
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/seamtext/SeamTextConverter.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/seamtext/SeamTextConverter.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/convert/seamtext/SeamTextConverter.java 2008-11-20
11:28:45 UTC (rev 11261)
@@ -0,0 +1,123 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * SeamTextConverter.java Date created: 26.09.2008
+ * Last modified by: $Author: alevkovsky $
+ * $Revision: 11244 $ $Date: 2008-11-19 18:45:36 +0200 (Wed, 19 Nov 2008) $
+ */
+
+package org.richfaces.convert.seamtext;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.lang.reflect.Constructor;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.seam.text.SeamTextLexer;
+import org.jboss.seam.text.SeamTextParser;
+import org.richfaces.antlr.HtmlSeamTextLexer;
+import org.richfaces.antlr.HtmlSeamTextParser;
+
+import antlr.ANTLRException;
+import antlr.RecognitionException;
+import antlr.TokenStream;
+
+/**
+ * Seam Text Converter class. Provides converting html to seam text and vice versa.
+ *
+ * @author Alexandr Levkovsky
+ *
+ */
+public class SeamTextConverter implements Converter {
+
+ /** log4j instance for converter class */
+ private static final Log _log = LogFactory.getLog(SeamTextConverter.class);
+
+ /** The converter id for this converter. */
+ public static final String CONVERTER_ID = SeamTextConverter.class.getName();
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
+ */
+ @SuppressWarnings("unchecked")
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ try {
+ Reader r = new StringReader(value);
+ HtmlSeamTextLexer lexer = new HtmlSeamTextLexer(r);
+ HtmlSeamTextParser parser = new HtmlSeamTextParser(lexer);
+ parser.startRule();
+ return parser.toString();
+ } catch (RecognitionException rex) {
+ // Log a nice message for any lexer/parser errors, users can disable
+ // this if they want to
+ _log.warn("Seam Text parse error: " + rex.getMessage());
+ } catch (ANTLRException ex) {
+ // All other errors are fatal;
+ throw new RuntimeException(ex);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ if (value == null) {
+ return "";
+ }
+
+ SeamTextParser parser = null;
+
+ try {
+
+ Reader r = new StringReader(value.toString());
+ Class seamTextLexerClass =
Class.forName("org.jboss.seam.text.SeamTextLexer");
+ Class seamTextParserClass =
Class.forName("org.jboss.seam.text.SeamTextParser");
+ Constructor seamTextLexerConstructor =
seamTextLexerClass.getConstructor(Reader.class);
+ SeamTextLexer lexer = (SeamTextLexer) seamTextLexerConstructor.newInstance(new
Object[] { r });
+ Constructor seamTextParserConstructor =
seamTextParserClass.getConstructor(TokenStream.class);
+ parser = (SeamTextParser) seamTextParserConstructor.newInstance(new Object[] { lexer
});
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ try {
+ parser.startRule();
+ } catch (RecognitionException rex) {
+ // Log a nice message for any lexer/parser errors, users can disable
+ // this if they want to
+ _log.warn("Seam Text parse error: " + rex.getMessage());
+ } catch (ANTLRException ex) {
+ // All other errors are fatal;
+ throw new RuntimeException(ex);
+ }
+ return parser.toString();
+ }
+
+}
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-11-20
11:10:18 UTC (rev 11260)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-11-20
11:28:45 UTC (rev 11261)
@@ -302,16 +302,13 @@
+ ScriptUtils.toScript(component.getLanguage()) + ";\n",
null);
}
- if (component.getAutoResize() != null) {
- writer.writeText("tinyMceParams.auto_resize = "
- + ScriptUtils.toScript(component.getAutoResize()) + ";\n",
- null);
- }
- if (component.getReadonly() != null) {
- writer.writeText("tinyMceParams.readonly = "
- + ScriptUtils.toScript(component.getReadonly()) + ";\n",
- null);
- }
+ writer.writeText("tinyMceParams.auto_resize = "
+ + ScriptUtils.toScript(component.isAutoResize()) + ";\n",
+ null);
+
+ writer.writeText("tinyMceParams.readonly = "
+ + ScriptUtils.toScript(component.isReadonly()) + ";\n",
+ null);
if (component.getPlugins() != null
&& component.getPlugins().length() > 0) {
writer.writeText("tinyMceParams.plugins = "