Author: alevkovsky
Date: 2008-11-13 11:39:24 -0500 (Thu, 13 Nov 2008)
New Revision: 11151
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
trunk/sandbox/ui/editor/src/main/templates/editor.jspx
Log:
Editor: implement view mode attribute
Modified: trunk/sandbox/ui/editor/src/main/config/component/editor.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-13 16:20:27 UTC
(rev 11150)
+++ trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-13 16:39:24 UTC
(rev 11151)
@@ -50,14 +50,14 @@
</property>
<property>
<name>width</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
<description>
Attribute defines width of component.
</description>
</property>
<property>
<name>height</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
<description>
Attribute defines height of component.
</description>
@@ -165,5 +165,13 @@
Attribute defines Editor skin
</description>
</property>
+ <property>
+ <name>viewMode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Attribute defines if tinyMCE WYSIWYG should be disabled
+ </description>
+ <defaultvalue>"visual"</defaultvalue>
+ </property>
</component>
</components>
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-13
16:20:27 UTC (rev 11150)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java 2008-11-13
16:39:24 UTC (rev 11151)
@@ -49,13 +49,13 @@
public abstract String getType();
- public abstract int getWidth();
+ public abstract Integer getWidth();
- public abstract void setWidth(int width);
+ public abstract void setWidth(Integer width);
- public abstract int getHeight();
+ public abstract Integer getHeight();
- public abstract void setHeight(int height);
+ public abstract void setHeight(Integer height);
public abstract void setTheme(String theme);
@@ -108,7 +108,11 @@
public abstract void setSkin(String skin);
public abstract String getSkin();
+
+ public abstract void setViewMode(String viewMode);
+ public abstract String getViewMode();
+
public boolean getRendersChildren() {
return true;
}
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-13
16:20:27 UTC (rev 11150)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-11-13
16:39:24 UTC (rev 11151)
@@ -48,7 +48,9 @@
private final static String SPECIFIC_SCRIPT_RESOURCE_NAME =
"org/richfaces/renderkit/html/1$1.js";
private final static String SPECIFIC_XCSS_RESOURCE_NAME =
"org/richfaces/renderkit/html/1$1.xcss";
-
+
+ private final static String TINY_MCE_DISABLED_MODE = "source";
+
@Override
protected Class<? extends UIComponent> getComponentClass() {
return UIEditor.class;
@@ -185,11 +187,11 @@
+ ScriptUtils.toScript(component.getPlugins()) + ";\n",
null);
}
- if (component.getWidth() != 0) {
+ if (component.getWidth() != null) {
writer.writeText("tinyMceParams.width = "
+ ScriptUtils.toScript(component.getWidth()) + ";\n", null);
}
- if (component.getHeight() != 0) {
+ if (component.getHeight() != null) {
writer
.writeText("tinyMceParams.height = "
+ ScriptUtils.toScript(component.getHeight())
@@ -245,4 +247,27 @@
}
}
}
+
+ public boolean shouldRenderTinyMCE(UIEditor component) {
+ if (component.getViewMode() != null
+ && component.getViewMode().equalsIgnoreCase(
+ TINY_MCE_DISABLED_MODE)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public String getTextAreaStyle(UIEditor component) {
+ StringBuilder b = new StringBuilder();
+ if (component.getWidth() != null) {
+ b.append("width: " + component.getWidth() + "px;");
+ }
+ if (component.getHeight() != null) {
+ b.append("height: " + component.getHeight() + "px;");
+ }
+ return b.toString();
+ }
+
+
}
Modified: trunk/sandbox/ui/editor/src/main/templates/editor.jspx
===================================================================
--- trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-11-13 16:20:27 UTC (rev
11150)
+++ trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-11-13 16:39:24 UTC (rev
11151)
@@ -13,22 +13,18 @@
<f:clientid var="clientId"/>
<h:styles>css/editor.xcss</h:styles>
<h:scripts>new org.ajax4jsf.javascript.AjaxScript(), new
org.ajax4jsf.javascript.PrototypeScript(), scripts/tiny_mce/tiny_mce_src.js,
scripts/editor.js</h:scripts>
+ <jsp:scriptlet>
+ <![CDATA[
+ if(shouldRenderTinyMCE(component)) {
+ ]]>
+ </jsp:scriptlet>
<div id="#{clientId}"
x:passThruWithExclusions="id,value,styleClass,class"
class="rich-editor #{component.attributes['styleClass']}"
style="#{component.attributes['style']}">
- <textarea id="#{clientId}TextArea" name='#{clientId}TextArea'
+ <textarea id="#{clientId}TextArea" name="#{clientId}TextArea"
style="visibility: hidden">
#{this:getFormattedComponentStringValue(context, component)}
</textarea>
- <jsp:scriptlet>
- <![CDATA[
- String onsetup = null;
- if (component.getAttributes().get("onsetup") != null) {
- onsetup = (String) component.getAttributes().get("onsetup");
- }
- variables.setVariable("onsetup", onsetup);
- ]]>
- </jsp:scriptlet>
<script type="text/javascript">
<f:call name="writeEditorConfigurationParameters" />
@@ -41,4 +37,20 @@
new RichEditor('#{clientId}', richParams, tinyMceParams);
</script>
</div>
+ <jsp:scriptlet>
+ <![CDATA[
+ } else {
+ ]]>
+ </jsp:scriptlet>
+ <div id="#{clientId}"
x:passThruWithExclusions="id,value,styleClass,class"
+ class="rich-editor #{component.attributes['styleClass']}"
style="#{component.attributes['style']}">
+ <textarea id="#{clientId}TextArea" name="#{clientId}TextArea"
style="#{this:getTextAreaStyle(component)}">
+ #{this:getFormattedComponentStringValue(context, component)}
+ </textarea>
+ </div>
+ <jsp:scriptlet>
+ <![CDATA[
+ }
+ ]]>
+ </jsp:scriptlet>
</f:root>
Show replies by date