From richfaces-svn-commits at lists.jboss.org Mon May 4 20:27:20 2009 Content-Type: multipart/mixed; boundary="===============3301970822937137207==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r14015 - in trunk: samples/layout-sample/src/main/webapp/pages and 5 other directories. Date: Mon, 04 May 2009 20:24:44 -0400 Message-ID: --===============3301970822937137207== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: alexsmirnov Date: 2009-05-04 20:24:43 -0400 (Mon, 04 May 2009) New Revision: 14015 Added: trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPane= lRenderer.java Modified: trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutBe= an.java trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml trunk/ui/layout/src/main/config/component/layoutPanel.xml trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRend= erer.java trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx Log: Start moving layout panels from CSS to style attributes. Modified: trunk/samples/layout-sample/src/main/java/org/richfaces/samples/L= ayoutBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutB= ean.java 2009-05-04 22:02:51 UTC (rev 14014) +++ trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutB= ean.java 2009-05-05 00:24:43 UTC (rev 14015) @@ -22,7 +22,7 @@ = private boolean rendered =3D true; = - private String width; + private float width; = /** * @return the rendered @@ -41,14 +41,14 @@ /** * @return the width */ - public String getWidth() { + public float getWidth() { return width; } = /** * @param width the width to set */ - public void setWidth(String width) { + public void setWidth(float width) { this.width =3D width; } = Added: trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml = (rev 0) +++ trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml 2009-05= -05 00:24:43 UTC (rev 14015) @@ -0,0 +1,40 @@ + + + + + + + + + + +

top

+
+ +

center

+
+ +

left

+
+ +

right

+
+ +

bottom

+
+
+
+ + +

center-right

+
+
+
+ + \ No newline at end of file Property changes on: trunk/samples/layout-sample/src/main/webapp/pages/RF-6= 641.xhtml ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml 2009-05-= 04 22:02:51 UTC (rev 14014) +++ trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml 2009-05-= 05 00:24:43 UTC (rev 14015) @@ -1,10 +1,10 @@ - @@ -53,12 +54,29 @@ = = - - Center panel - Left - Right - Top - Bottom - +
+
Top
+
Left + panel xxxx yyy zzz
+
+
+
Top
+
Left + panel xxxx yyy zzz
+
Center + panel dhisdf ncdl dcd
+
Right + wersdupsdo; osajo;sca
+
.<= /div> +
Bottom
+
+
+
Right + wersdupsdo; osajo;sca
+
.<= /div> +
Bottom
+
= - \ No newline at end of file + \ No newline at end of file Modified: trunk/ui/layout/src/main/config/component/layoutPanel.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/config/component/layoutPanel.xml 2009-05-04 22= :02:51 UTC (rev 14014) +++ trunk/ui/layout/src/main/config/component/layoutPanel.xml 2009-05-05 00= :24:43 UTC (rev 14015) @@ -38,7 +38,7 @@ = width - java.lang.String + float Sets the width of the layout area Modified: trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPan= el.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.jav= a 2009-05-04 22:02:51 UTC (rev 14014) +++ trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.jav= a 2009-05-05 00:24:43 UTC (rev 14015) @@ -33,13 +33,13 @@ * Get Panel width. * @return */ - public abstract String getWidth(); + public abstract float getWidth(); = /** * Set Panel width. * @param newvalue */ - public abstract void setWidth(String newvalue); + public abstract void setWidth(float newvalue); = = } Added: trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayout= PanelRenderer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPan= elRenderer.java (rev 0) +++ trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPan= elRenderer.java 2009-05-05 00:24:43 UTC (rev 14015) @@ -0,0 +1,66 @@ +/** + * = + */ +package org.richfaces.renderkit; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; + +import org.ajax4jsf.renderkit.HeaderResourcesRendererBase; +import org.ajax4jsf.renderkit.RendererUtils.HTML; +import org.richfaces.component.LayoutPosition; +import org.richfaces.component.UILayout; +import org.richfaces.component.UILayoutPanel; + +/** + * @author asmirnov + * + */ +public abstract class AbstractLayoutPanelRenderer extends + HeaderResourcesRendererBase { + = + public String layoutStyle(FacesContext context, UILayoutPanel panel) { + StringBuilder style =3D new StringBuilder(); + LayoutPosition position =3D panel.getPosition(); + Object componentStyle =3D panel.getAttributes().get(HTML.style_ATTRIBUTE= ); + if(null !=3D componentStyle){ + style.append(componentStyle).append(";"); + } + if(!LayoutPosition.top.equals(position)&&!LayoutPosition.bottom.equals(p= osition)){ + if(LayoutPosition.right.equals(position)){ + style.append("float:right;"); + } else { + style.append("float:left;"); = + } + // find siblings. + // get layout depth. + int deep =3D layoutDeep(panel); + // calculate real width. + float width =3D panel.getWidth(); + if(width>=3D0.0f){ + style.append("width:").append(width).append("%;"); + width =3D width/(1.0f+(float)deep); + style.append("*width:").append(width).append("%;"); + } + } else { + // top and buttom style. + } + return style.length()>0?style.toString():null; + } + + /** + * Calculate deep of layout components. + * @param component + * @return + */ + private int layoutDeep(UIComponent component) { + int deep =3D 0; + if(null !=3D component){ + deep =3D layoutDeep(component.getParent()); + if(component instanceof UILayout){ + deep++; + } + } + return deep; + } +} Property changes on: trunk/ui/layout/src/main/java/org/richfaces/renderkit/= AbstractLayoutPanelRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLay= outRenderer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRen= derer.java 2009-05-04 22:02:51 UTC (rev 14014) +++ trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRen= derer.java 2009-05-05 00:24:43 UTC (rev 14015) @@ -4,6 +4,7 @@ package org.richfaces.renderkit; = import java.io.IOException; +import java.util.Map; = import javax.faces.FacesException; import javax.faces.component.UIComponent; @@ -86,90 +87,23 @@ } if (columns > 0) { // Reorder panels to fill ordeg left->center->right. - if (null =3D=3D left) { - if (null =3D=3D center) { - left =3D right; - right =3D null; - } else { - left =3D center; - center =3D right; - right =3D null; - } - } else if (null =3D=3D center) { - center =3D right; - right =3D null; - } - if (columns > 1) { - // Render Y! CSS Grid - writer.startElement(HTML.DIV_ELEM, layout); - // calculate class. - String yahooClass =3D calculateLayoutClass(left, right, center); - writer.writeAttribute(HTML.class_ATTRIBUTE, yahooClass, null); - left.getAttributes().put("first", "first"); - center.getAttributes().remove("first"); + if (null !=3D left) { left.encodeAll(context); + } = + if (null !=3D center) { center.encodeAll(context); - if (null !=3D right) { - right.getAttributes().remove("first"); - right.encodeAll(context); - } - writer.endElement(HTML.DIV_ELEM); - } else { - left.encodeAll(context); - } + } = + if (null !=3D right) { + right.encodeAll(context); + } = } + // line separator. + writer.startElement(HTML.DIV_ELEM, layout); + writer.writeAttribute(HTML.style_ATTRIBUTE, "display: block; height: 0; = clear: both; visibility: hidden;", null); + writer.writeText(".", null); + writer.endElement(HTML.DIV_ELEM); if (null !=3D bottom) { renderChild(context, bottom); } } - - /** - * @param left - * @param right - * @param center - * @return - */ - protected String calculateLayoutClass(UILayoutPanel left, - UILayoutPanel right, UILayoutPanel center) { - String yahooClass =3D "yui-g"; - if (null !=3D left && null !=3D right && null !=3D center) { - // We have only equal size for an three-column layout. - yahooClass =3D "yui-gb"; - } else if(null !=3D left && null !=3D center){ - int leftPart =3D 0; - String leftWidth =3D left.getWidth(); - if(!isEmpty(leftWidth)){ - leftPart =3D Integer.parseInt(leftWidth); - } - int rightPart =3D 0; - String centerWidth =3D center.getWidth(); - if(!isEmpty(centerWidth)){ - rightPart =3D Integer.parseInt(centerWidth); - if(0 =3D=3DleftPart && 0>rightPart && centerWidth.endsWith("%")){ - leftPart =3D 100 - rightPart; - } - } - if(0 > leftPart && 0 =3D=3D rightPart && leftWidth.endsWith("%")){ - rightPart =3D 100 - leftPart; - } - // Calculate properly class. - if(0>leftPart && 0>rightPart){ - double ratio =3D (double)leftPart/(double)(leftPart+rightPart); - if (ratio <=3D 0.25) { - yahooClass =3D "yui-gf"; - } else if (ratio <=3D 0.33) { - yahooClass =3D "yui-gd"; - } else if (ratio <=3D 0.66) { - yahooClass =3D "yui-gc"; - } else { - yahooClass =3D "yui-ge"; - } - } - } - return yahooClass; - } - - private boolean isEmpty(String leftWidth) { - return null =3D=3D leftWidth || leftWidth.length() =3D=3D 0; - } } Modified: trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java = 2009-05-04 22:02:51 UTC (rev 14014) +++ trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java = 2009-05-05 00:24:43 UTC (rev 14015) @@ -45,10 +45,12 @@ if (this.contentType !=3D null) { String v =3D this.contentType.getValue(ctx); ctx.getFacesContext().getExternalContext().getRequestMap()= .put("facelets.ContentType", v); + root.getAttributes().put("contentType", v); } if (this.encoding !=3D null) { String v =3D this.encoding.getValue(ctx); ctx.getFacesContext().getExternalContext().getRequestMap()= .put("facelets.Encoding", v); + root.getAttributes().put("encoding", v); } } } Modified: trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx 2009-0= 5-04 22:02:51 UTC (rev 14014) +++ trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx 2009-0= 5-05 00:24:43 UTC (rev 14015) @@ -11,11 +11,11 @@ baseclass=3D"org.richfaces.renderkit.AbstractLayoutRenderer" component=3D"org.richfaces.component.UILayout" = > - css/layout.css +
+ style=3D"#{component.attributes['style']};zoom:1;" + x:passThruWithExclusions=3D"value,name,type,id,style" > Modified: trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.= jspx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx 2= 009-05-04 22:02:51 UTC (rev 14014) +++ trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx 2= 009-05-05 00:24:43 UTC (rev 14015) @@ -8,13 +8,12 @@ xmlns:vcp=3D" http://jsf.exadel.com/vcp" xmlns:x=3D" http://ajax4jsf.org/cdk/x" class=3D"org.richfaces.renderkit.html.LayoutPanelRenderer" - baseclass=3D"org.ajax4jsf.renderkit.AjaxComponentRendererBase" + baseclass=3D"org.richfaces.renderkit.AbstractLayoutPanelRenderer" component=3D"org.richfaces.component.UILayoutPanel" = > - = -
--===============3301970822937137207==--