You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2004/12/03 22:59:09 UTC
cvs commit: incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/htmleditorexample EditorFace.java
svieujot 2004/12/03 13:59:09
Modified: src/components/org/apache/myfaces/custom/htmlEditor
HtmlEditorRenderer.java HtmlEditor.java
HtmlEditorTag.java
tlds myfaces_ext.tld
webapps/examples/web htmlEditor.jsp
webapps/examples/src/org/apache/myfaces/examples/htmleditorexample
EditorFace.java
Log:
Initial set of htmlEditor attributes.
Revision Changes Path
1.4 +33 -5 incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditorRenderer.java
Index: HtmlEditorRenderer.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditorRenderer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HtmlEditorRenderer.java 3 Dec 2004 12:55:30 -0000 1.3
+++ HtmlEditorRenderer.java 3 Dec 2004 21:59:09 -0000 1.4
@@ -33,6 +33,9 @@
* @author Sylvain Vieujot (latest modification by $Author$)
* @version $Revision$ $Date$
* $Log$
+ * Revision 1.4 2004/12/03 21:59:09 svieujot
+ * Initial set of htmlEditor attributes.
+ *
* Revision 1.3 2004/12/03 12:55:30 svieujot
* Get ride of the save button / process.
*
@@ -41,8 +44,6 @@
*
* Revision 1.1 2004/12/02 22:28:30 svieujot
* Add an x:htmlEditor based on the Kupu library.
- *
- *
*/
public class HtmlEditorRenderer extends Renderer {
@@ -50,6 +51,7 @@
RendererUtils.checkParamValidity(context, component, HtmlEditor.class);
HtmlEditor editor = (HtmlEditor) component;
String clientId = editor.getClientId(context);
+ String editorFrameId = clientId.replace(":","_")+"_kupu_editorframe"; // The : in the id breaks the inline css.
String formId;
{
UIComponent tmpComponent = editor.getParent();
@@ -295,7 +297,9 @@
writer.startElement(HTML.SPAN_ELEM,null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null);
- // TODO : No ID ?
+ if( ! editor.isAllowEditSource().booleanValue() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
writeButton(writer, "kupu-source", "Edit source", null);
writer.endElement(HTML.SPAN_ELEM);
@@ -559,11 +563,17 @@
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute("xmlns", "", null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolboxes", null);
+ if( ! editor.isShowAnyToolBox() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
// Properties tool box
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null);
writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-properties", null);
+ if( ! editor.isShowPropertiesToolBox().booleanValue() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
writer.startElement(HTML.H1_ELEM, null);
writer.write("Properties");
writer.endElement(HTML.H1_ELEM);
@@ -588,6 +598,9 @@
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null);
writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-links", null);
+ if( ! editor.isShowLinksToolBox().booleanValue() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
writer.startElement(HTML.H1_ELEM, null);
writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null);
writer.writeAttribute("i18n:translate", "links", null);
@@ -631,6 +644,9 @@
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null);
writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-images", null);
+ if( ! editor.isShowImagesToolBox().booleanValue() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
writer.startElement(HTML.H1_ELEM, null);
writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null);
writer.writeAttribute("i18n:translate", "images", null);
@@ -693,6 +709,9 @@
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null);
writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-tables", null);
+ if( ! editor.isShowTablesToolBox().booleanValue() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
writer.startElement(HTML.H1_ELEM, null);
writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null);
writer.writeAttribute("i18n:translate", "table-inspector", null);
@@ -785,6 +804,9 @@
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null);
writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-debug", null);
+ if( ! editor.isShowDebugToolBox().booleanValue() ){
+ writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
+ }
writer.startElement(HTML.H1_ELEM, null);
writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null);
writer.writeAttribute("i18n:translate", "debug-log", null);
@@ -810,6 +832,7 @@
// Edit space
writer.startElement(HTML.DIV_ELEM, null);
writer.writeAttribute(HTML.CLASS_ATTR, "kupu-editorframe", null);
+ writer.writeAttribute(HTML.ID_ATTR, editorFrameId, null);
writer.startElement(HTML.IFRAME_ELEM, null);
writer.writeAttribute(HTML.ID_ATTR, "kupu-editor", null);
writer.writeAttribute(HTML.FRAMEBORDER_ATTR, "0", null);
@@ -823,6 +846,11 @@
writer.endElement(HTML.DIV_ELEM);
writer.endElement(HTML.DIV_ELEM); // kupu-fulleditor
+
+ if( !editor.isShowAnyToolBox() ){
+ String largeEditorStyle = "#"+editorFrameId+"{margin-right: 0.3em;}";
+ AddResource.addInlineStyleToHeader(largeEditorStyle, context);
+ }
String text = (String) editor.getValue();
String encodedText = text == null ? "" : JavascriptUtils.encodeString( text );
1.2 +84 -3 incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditor.java
Index: HtmlEditor.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HtmlEditor.java 2 Dec 2004 22:28:30 -0000 1.1
+++ HtmlEditor.java 3 Dec 2004 21:59:09 -0000 1.2
@@ -17,6 +17,7 @@
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
/**
* HTML Editor using the kupu library.
@@ -25,6 +26,9 @@
* @author Sylvain Vieujot (latest modification by $Author$)
* @version $Revision$ $Date$
* $Log$
+ * Revision 1.2 2004/12/03 21:59:09 svieujot
+ * Initial set of htmlEditor attributes.
+ *
* Revision 1.1 2004/12/02 22:28:30 svieujot
* Add an x:htmlEditor based on the Kupu library.
*
@@ -34,6 +38,14 @@
public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlEditor";
private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlEditor";
+
+ private Boolean _allowEditSource;
+
+ private Boolean _showPropertiesToolBox;
+ private Boolean _showLinksToolBox;
+ private Boolean _showImagesToolBox;
+ private Boolean _showTablesToolBox;
+ private Boolean _showDebugToolBox;
public HtmlEditor() {
setRendererType(DEFAULT_RENDERER_TYPE);
@@ -44,13 +56,82 @@
}
public Object saveState(FacesContext context) {
- Object values[] = new Object[1];
+ Object values[] = new Object[3];
values[0] = super.saveState(context);
+
+ Boolean toolBarButtons[] = new Boolean[1];
+ toolBarButtons[0] = _allowEditSource;
+
+ values[1] = toolBarButtons;
+
+ Boolean toolBoxes[] = new Boolean[5];
+ toolBoxes[0] = _showPropertiesToolBox;
+ toolBoxes[1] = _showLinksToolBox;
+ toolBoxes[2] = _showImagesToolBox;
+ toolBoxes[3] = _showTablesToolBox;
+ toolBoxes[4] = _showDebugToolBox;
+
+ values[2] = toolBoxes;
+
return values;
}
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
+
+ Boolean[] toolBarButtons = (Boolean[]) values[1];
+ _allowEditSource = toolBarButtons[0];
+
+ Boolean[] toolBoxes = (Boolean[]) values[2];
+ _showPropertiesToolBox = toolBoxes[0];
+ _showLinksToolBox = toolBoxes[1];
+ _showImagesToolBox = toolBoxes[2];
+ _showTablesToolBox = toolBoxes[3];
+ _showDebugToolBox = toolBoxes[4];
+ }
+
+ public Boolean isAllowEditSource(){
+ if (_allowEditSource != null) return _allowEditSource;
+ ValueBinding vb = getValueBinding("allowEditSource");
+ return vb != null ? (Boolean)vb.getValue(getFacesContext()) : Boolean.TRUE;
+ }
+
+ public Boolean isShowPropertiesToolBox(){
+ if (_showPropertiesToolBox != null) return _showPropertiesToolBox;
+ ValueBinding vb = getValueBinding("showPropertiesToolBox");
+ return vb != null ? (Boolean)vb.getValue(getFacesContext()) : Boolean.TRUE;
+ }
+
+ public Boolean isShowLinksToolBox(){
+ if (_showLinksToolBox != null) return _showLinksToolBox;
+ ValueBinding vb = getValueBinding("showLinksToolBox");
+ return vb != null ? (Boolean)vb.getValue(getFacesContext()) : Boolean.TRUE;
+ }
+
+ public Boolean isShowImagesToolBox(){
+ if (_showImagesToolBox != null) return _showImagesToolBox;
+ ValueBinding vb = getValueBinding("showImagesToolBox");
+ return vb != null ? (Boolean)vb.getValue(getFacesContext()) : Boolean.TRUE;
+ }
+
+ public Boolean isShowTablesToolBox(){
+ if (_showTablesToolBox != null) return _showTablesToolBox;
+ ValueBinding vb = getValueBinding("showTablesToolBox");
+ return vb != null ? (Boolean)vb.getValue(getFacesContext()) : Boolean.TRUE;
+ }
+
+ public Boolean isShowDebugToolBox(){
+ if (_showDebugToolBox != null) return _showDebugToolBox;
+ ValueBinding vb = getValueBinding("showDebugToolBox");
+ return vb != null ? (Boolean)vb.getValue(getFacesContext()) : Boolean.FALSE;
+ }
+
+ public boolean isShowAnyToolBox(){
+ return isShowPropertiesToolBox().booleanValue()
+ || isShowLinksToolBox().booleanValue()
+ || isShowImagesToolBox().booleanValue()
+ || isShowTablesToolBox().booleanValue()
+ || isShowDebugToolBox().booleanValue();
}
}
1.2 +41 -6 incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditorTag.java
Index: HtmlEditorTag.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditorTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HtmlEditorTag.java 2 Dec 2004 22:28:30 -0000 1.1
+++ HtmlEditorTag.java 3 Dec 2004 21:59:09 -0000 1.2
@@ -23,6 +23,9 @@
* @author Sylvain Vieujot (latest modification by $Author$)
* @version $Revision$ $Date$
* $Log$
+ * Revision 1.2 2004/12/03 21:59:09 svieujot
+ * Initial set of htmlEditor attributes.
+ *
* Revision 1.1 2004/12/02 22:28:30 svieujot
* Add an x:htmlEditor based on the Kupu library.
*
@@ -30,12 +33,24 @@
*/
public class HtmlEditorTag extends UIComponentTagBase {
- private String _value;
+ private String allowEditSource;
+
+ private String showPropertiesToolBox;
+ private String showLinksToolBox;
+ private String showImagesToolBox;
+ private String showTablesToolBox;
+ private String showDebugToolBox;
protected void setProperties(UIComponent component) {
super.setProperties(component);
- setStringProperty(component, "value", _value);
+ setBooleanProperty(component, "allowEditSource", allowEditSource);
+
+ setBooleanProperty(component, "showPropertiesToolBox", showPropertiesToolBox);
+ setBooleanProperty(component, "showLinksToolBox", showLinksToolBox);
+ setBooleanProperty(component, "showImagesToolBox", showImagesToolBox);
+ setBooleanProperty(component, "showTablesToolBox", showTablesToolBox);
+ setBooleanProperty(component, "showDebugToolBox", showDebugToolBox);
}
public String getComponentType() {
@@ -45,8 +60,28 @@
public String getRendererType() {
return "org.apache.myfaces.HtmlEditor";
}
+
+ public void setAllowEditSource(String allowEditSource){
+ this.allowEditSource = allowEditSource;
+ }
+
+ public void setShowPropertiesToolBox(String showPropertiesToolBox){
+ this.showPropertiesToolBox = showPropertiesToolBox;
+ }
+
+ public void setShowLinksToolBox(String showLinksToolBox){
+ this.showLinksToolBox = showLinksToolBox;
+ }
+
+ public void setShowImagesToolBox(String showImagesToolBox){
+ this.showImagesToolBox = showImagesToolBox;
+ }
+
+ public void setShowTablesToolBox(String showTablesToolBox){
+ this.showTablesToolBox = showTablesToolBox;
+ }
- public void setValue(String value){
- _value = value;
+ public void setShowDebugToolBox(String showDebugToolBox){
+ this.showDebugToolBox = showDebugToolBox;
}
}
1.134 +30 -0 incubator-myfaces/tlds/myfaces_ext.tld
Index: myfaces_ext.tld
===================================================================
RCS file: /home/cvs/incubator-myfaces/tlds/myfaces_ext.tld,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -r1.133 -r1.134
--- myfaces_ext.tld 2 Dec 2004 22:28:31 -0000 1.133
+++ myfaces_ext.tld 3 Dec 2004 21:59:09 -0000 1.134
@@ -802,6 +802,36 @@
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
+ <attribute>
+ <name>allowEditSource</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>showPropertiesToolBox</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>showLinksToolBox</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>showImagesToolBox</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>showTablesToolBox</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>showDebugToolBox</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
</tag>
<!-- inputDate -->
1.3 +36 -5 incubator-myfaces/webapps/examples/web/htmlEditor.jsp
Index: htmlEditor.jsp
===================================================================
RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/htmlEditor.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- htmlEditor.jsp 3 Dec 2004 12:55:30 -0000 1.2
+++ htmlEditor.jsp 3 Dec 2004 21:59:09 -0000 1.3
@@ -52,13 +52,44 @@
<f:facet name="body">
<h:panelGroup id="body">
- <f:verbatim>
- Html Editor powered by the kupu library ( http://kupu.oscom.org ).
- </f:verbatim>
-
<h:form>
- <x:htmlEditor value="#{editor.text}"/>
+ <f:verbatim>
+ <h1>Html Editor powered by the Kupu library</h1>
+ See <a href="http://kupu.oscom.org">http://kupu.oscom.org</a>
+ </f:verbatim>
+
+ <x:htmlEditor value="#{editor.text}"
+ allowEditSource="#{editor.allowEditSource}"
+ showPropertiesToolBox="#{editor.showPropertiesToolBox}"
+ showLinksToolBox="#{editor.showLinksToolBox}"
+ showImagesToolBox="#{editor.showImagesToolBox}"
+ showTablesToolBox="#{editor.showTablesToolBox}"
+ showDebugToolBox="#{editor.showDebugToolBox}"/>
<h:commandButton value="Submit"/>
+
+ <f:verbatim>
+ <h2>Component Options</h2>
+ </f:verbatim>
+ <h:panelGrid columns="2">
+ <h:selectBooleanCheckbox value="#{editor.allowEditSource}" immediate="true"/>
+ <h:outputText value="Allow Edit Source"/>
+
+ <h:selectBooleanCheckbox value="#{editor.showPropertiesToolBox}" immediate="true"/>
+ <h:outputText value="Show Properties tool box"/>
+
+ <h:selectBooleanCheckbox value="#{editor.showLinksToolBox}" immediate="true"/>
+ <h:outputText value="Show Links tool box"/>
+
+ <h:selectBooleanCheckbox value="#{editor.showImagesToolBox}" immediate="true"/>
+ <h:outputText value="Show Images tool box"/>
+
+ <h:selectBooleanCheckbox value="#{editor.showTablesToolBox}" immediate="true"/>
+ <h:outputText value="Show Tables tool box"/>
+
+ <h:selectBooleanCheckbox value="#{editor.showDebugToolBox}" immediate="true"/>
+ <h:outputText value="Show Debug tool box"/>
+ </h:panelGrid>
+
</h:form>
</h:panelGroup>
1.2 +46 -1 incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/htmleditorexample/EditorFace.java
Index: EditorFace.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/htmleditorexample/EditorFace.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EditorFace.java 2 Dec 2004 22:28:30 -0000 1.1
+++ EditorFace.java 3 Dec 2004 21:59:09 -0000 1.2
@@ -22,6 +22,14 @@
public class EditorFace {
private String text ="default text";
+
+ // Options
+ private boolean allowEditSource = true;
+ private boolean showPropertiesToolBox = true;
+ private boolean showLinksToolBox = true;
+ private boolean showImagesToolBox = true;
+ private boolean showTablesToolBox = true;
+ private boolean showDebugToolBox = false;
public String getText() {
return text;
@@ -29,5 +37,42 @@
public void setText(String text) {
this.text = text;
+ }
+
+ public boolean isAllowEditSource() {
+ return allowEditSource;
+ }
+ public void setAllowEditSource(boolean allowEditSource) {
+ this.allowEditSource = allowEditSource;
+ }
+ public boolean isShowImagesToolBox() {
+ return showImagesToolBox;
+ }
+ public void setShowImagesToolBox(boolean showImagesToolBox) {
+ this.showImagesToolBox = showImagesToolBox;
+ }
+ public boolean isShowLinksToolBox() {
+ return showLinksToolBox;
+ }
+ public void setShowLinksToolBox(boolean showLinksToolBox) {
+ this.showLinksToolBox = showLinksToolBox;
+ }
+ public boolean isShowPropertiesToolBox() {
+ return showPropertiesToolBox;
+ }
+ public void setShowPropertiesToolBox(boolean showPropertiesToolBox) {
+ this.showPropertiesToolBox = showPropertiesToolBox;
+ }
+ public boolean isShowTablesToolBox(){
+ return showTablesToolBox;
+ }
+ public void setShowTablesToolBox(boolean showTablesToolBox){
+ this.showTablesToolBox = showTablesToolBox;
+ }
+ public boolean isShowDebugToolBox(){
+ return showDebugToolBox;
+ }
+ public void setShowDebugToolBox(boolean showDebugToolBox){
+ this.showDebugToolBox = showDebugToolBox;
}
}