Author: alevkovsky
Date: 2008-09-24 08:32:06 -0400 (Wed, 24 Sep 2008)
New Revision: 10545
Modified:
trunk/sandbox/samples/editor-sample/
trunk/sandbox/samples/editor-sample/src/main/java/org/richfaces/EditorBean.java
trunk/sandbox/samples/editor-sample/src/main/webapp/pages/editor.jsp
trunk/sandbox/ui/editor/
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:
Developing Editor component
Property changes on: trunk/sandbox/samples/editor-sample
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
+ target
.classpath
.project
copy-web-pages.bat
.settings
.classpath
.project
Modified: trunk/sandbox/samples/editor-sample/src/main/java/org/richfaces/EditorBean.java
===================================================================
---
trunk/sandbox/samples/editor-sample/src/main/java/org/richfaces/EditorBean.java 2008-09-23
17:16:55 UTC (rev 10544)
+++
trunk/sandbox/samples/editor-sample/src/main/java/org/richfaces/EditorBean.java 2008-09-24
12:32:06 UTC (rev 10545)
@@ -3,23 +3,22 @@
import java.util.HashMap;
import java.util.Map;
+import org.richfaces.component.UIEditor;
+
public class EditorBean {
private String value = "Some value....";
+ private UIEditor editor;
+ private boolean rendered = true;
+ private Map<String, Object> dataMap;
- private Map<String, Object> dataMap;
public EditorBean () {
dataMap = new HashMap<String, Object>();
dataMap.put("name1", "value1");
dataMap.put("name2", false);
}
- public Map<String, Object> getDataMap() {
- return dataMap;
- }
- public void setDataMap(Map<String, Object> dataMap) {
- this.dataMap = dataMap;
- }
+
public String getValue() {
return value;
}
@@ -31,4 +30,43 @@
value += "1";
return null;
}
+
+ public String action2(){
+ editor.setValue(editor.getValue() + "1");
+ return null;
+ }
+
+ public String changeRendered(){
+ if(rendered) {
+ rendered = false;
+ }else{
+ rendered = true;
+ }
+ return null;
+ }
+
+ public Map<String, Object> getDataMap() {
+ return dataMap;
+ }
+ public void setDataMap(Map<String, Object> dataMap) {
+ this.dataMap = dataMap;
+ }
+
+ public UIEditor getEditor() {
+ return editor;
+ }
+
+ public void setEditor(UIEditor editor) {
+ this.editor = editor;
+ }
+
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
+
+
}
Modified: trunk/sandbox/samples/editor-sample/src/main/webapp/pages/editor.jsp
===================================================================
--- trunk/sandbox/samples/editor-sample/src/main/webapp/pages/editor.jsp 2008-09-23
17:16:55 UTC (rev 10544)
+++ trunk/sandbox/samples/editor-sample/src/main/webapp/pages/editor.jsp 2008-09-24
12:32:06 UTC (rev 10545)
@@ -5,22 +5,79 @@
<html>
<head>
<title></title>
+ <style>
+ .editor-new{
+ font-size: 20;
+ }
+ </style>
+ <script type="text/javascript">
+ <!--
+ function testEvent(element, event){
+ element = document.getElementById(element.id + '_' + event)
+ element.innerHTML = '+';
+ }
+ </script>
</head>
<body>
<f:view >
- <h:form>
- <h:panelGroup>
- <ed:editor id="editorId" value="#{editorBean.value}"
width="100" height="100">
- <f:param name="mode" value="textareas"/>
- <f:param name="theme" value="advanced"/>
- </ed:editor>
-
- </h:panelGroup>
-
+ <h:form id="formId">
+
+ <ed:editor id="editorId"
+ styleClass="editor-new"
+ style="color: red"
+ value="#{editorBean.value}"
+ width="300"
+ height="175"
+ rendered="#{editorBean.rendered}"
+ binding="#{editorBean.editor}"
+ theme="advanced"
+ onclick="testEvent(this, 'onclick')"
+ ondblclick="testEvent(this, 'ondblclick')"
+ onkeydown="testEvent(this, 'onkeydown')"
+ onkeypress="testEvent(this, 'onkeypress')"
+ onkeyup="testEvent(this, 'onkeyup')"
+ onmousedown="testEvent(this, 'onmousedown')"
+ onmousemove="testEvent(this, 'onmousemove')"
+ onmouseout="testEvent(this, 'onmouseout')"
+ onmouseover="testEvent(this, 'onmouseover')"
+ onmouseup="testEvent(this, 'onmouseup')"/>
+
+
+ <h:outputText value="Editor value: #{editorBean.value}" />
<br/>
+ <h:panelGrid columns="10" border="1">
+ <h:outputText value="onclick"/>
+ <h:outputText value="ondblclick"/>
+ <h:outputText value="onmouseup"/>
+ <h:outputText value="onmousedown"/>
+ <h:outputText value="onmousemove"/>
+ <h:outputText value="onmouseover"/>
+ <h:outputText value="onmouseout"/>
+ <h:outputText value="onkeydown"/>
+ <h:outputText value="onkeypress"/>
+ <h:outputText value="onkeyup"/>
+ <h:outputText id="editorId_onclick" value="-"/>
+ <h:outputText id="editorId_ondblclick" value="-"/>
+ <h:outputText id="editorId_onmouseup" value="-"/>
+ <h:outputText id="editorId_onmousedown" value="-"/>
+ <h:outputText id="editorId_onmousemove" value="-"/>
+ <h:outputText id="editorId_onmouseover" value="-"/>
+ <h:outputText id="editorId_onmouseout" value="-"/>
+ <h:outputText id="editorId_onkeydown" value="-"/>
+ <h:outputText id="editorId_onkeypress" value="-"/>
+ <h:outputText id="editorId_onkeyup" value="-"/>
+ </h:panelGrid>
+ <br/>
<h:commandButton value="h:commandButton"
action="#{editorBean.action1}"/>
<a4j:commandButton value="a4j:commandButton"
action="#{editorBean.action1}"
- reRender="editorId"/>
+ reRender="editorId"/>
+ <br/>
+ <h:commandButton value="h:commandButton2"
action="#{editorBean.action2}"/>
+ <a4j:commandButton value="a4j:commandButton2"
action="#{editorBean.action2}"
+ reRender="editorId"/>
+
+ <br/>
+ <h:commandButton value="change rendered"
action="#{editorBean.changeRendered}"/>
</h:form>
</f:view>
</body>
Property changes on: trunk/sandbox/ui/editor
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Modified: trunk/sandbox/ui/editor/src/main/config/component/editor.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-09-23 17:16:55 UTC
(rev 10544)
+++ trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-09-24 12:32:06 UTC
(rev 10545)
@@ -50,5 +50,21 @@
</description>
<defaultvalue>200</defaultvalue>
</property>
+ <property>
+ <name>theme</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Attribute defines Editor theme
+ </description>
+ <defaultvalue>"simple"</defaultvalue>
+ </property>
+ <property hidden="true">
+ <name>mode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Attribute defines Editor mode
+ </description>
+ <defaultvalue>"textareas"</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-09-23
17:16:55 UTC (rev 10544)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java 2008-09-24
12:32:06 UTC (rev 10545)
@@ -30,7 +30,15 @@
public abstract int getHeight();
public abstract void setHeight(int height);
+
+ public abstract void setTheme(String theme);
+ public abstract String getTheme();
+
+ public abstract void setMode(String mode);
+
+ public abstract String getMode();
+
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-09-23
17:16:55 UTC (rev 10544)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-09-24
12:32:06 UTC (rev 10545)
@@ -60,11 +60,9 @@
}
if (component.getType() != null
&& component.getType().equalsIgnoreCase("TinyMCE")) {
- writer.writeText("//<![CDATA[ \n", null);
writer.writeText("tinyMCE.init(", null);
writer.writeText(ScriptUtils.toScript(params), null);
writer.writeText(");", null);
- writer.writeText("\n //]]>", null);
} else {
// TODO add supporting for other types
}
Modified: trunk/sandbox/ui/editor/src/main/templates/editor.jspx
===================================================================
--- trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-09-23 17:16:55 UTC (rev
10544)
+++ trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-09-24 12:32:06 UTC (rev
10545)
@@ -14,7 +14,17 @@
<h:styles>css/editor.xcss</h:styles>
<h:scripts>scripts/tiny_mce/tiny_mce_src.js,
scripts/editor.js</h:scripts>
<div id="#{clientId}"
x:passThruWithExclusions="id,value,styleClass,class"
- class="rich-editor #{component.attributes['styleClass']}">
+ class="rich-editor #{component.attributes['styleClass']}"
+ onclick="#{component.attributes['onclick']}"
+ ondblclick="#{component.attributes['ondblclick']}"
+ onmouseup="#{component.attributes['onmouseup']}"
+ onmousedown="#{component.attributes['onmousedown']}"
+ onmousemove="#{component.attributes['onmousemove']}"
+ onmouseover="#{component.attributes['onmouseover']}"
+ onmouseout="#{component.attributes['onmouseout']}"
+ onkeydown="#{component.attributes['onkeydown']}"
+ onkeypress="#{component.attributes['onkeypress']}"
+ onkeyup="#{component.attributes['onkeyup']}">
<textarea id="#{clientId}TextArea" name='#{clientId}'
style="width: #{component.attributes['width']}px; height:
#{component.attributes['height']}px;">
@@ -31,7 +41,10 @@
</textarea>
<script type="text/javascript">
- <f:call name="writeEditorScriptParameters" />
+ tinyMCE.init({
+ mode: '#{component.attributes['mode']}',
+ theme: '#{component.attributes['theme']}'
+ });
</script>
</div>
</f:root>