You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/06/04 14:31:33 UTC

svn commit: r1489414 - in /myfaces/tobago/branches/tobago-1.5.x: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ tobago-example/tobago-example-test/s...

Author: lofwyr
Date: Tue Jun  4 12:31:33 2013
New Revision: 1489414

URL: http://svn.apache.org/r1489414
Log:
TOBAGO-1273: New Attribute visible or hidden for "layoutet" tags
 - implemented with for the grid layout manager

Added:
    myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/rigid.xhtml
      - copied, changed from r1488934, myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/margin.xhtml
Modified:
    myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java
    myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
    myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java?rev=1489414&r1=1489413&r2=1489414&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java Tue Jun  4 12:31:33 2013
@@ -73,7 +73,7 @@ public abstract class AbstractUIGridLayo
       if (LOG.isDebugEnabled()) {
         LOG.debug("\n" + grid);
       }
-      if (component instanceof LayoutContainer && component.isRendered()) {
+      if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
         ((LayoutContainer) component).getLayoutManager().init();
       }
     }
@@ -123,7 +123,7 @@ public abstract class AbstractUIGridLayo
           }
         }
       }
-      if (neitherRendered) {
+      if (neitherRendered && !isRigid()) {
         heads[i].setRendered(false);
       }
     }
@@ -145,7 +145,7 @@ public abstract class AbstractUIGridLayo
       LayoutToken token = head.getToken();
 
       if (token instanceof PixelLayoutToken) {
-        if (head.isRendered()) {
+        if (head.isRendered() || isRigid()) {
           int pixel = ((PixelLayoutToken) token).getPixel();
           heads[i].setCurrent(Measure.valueOf(pixel)); // XXX refactor
         } else {
@@ -160,12 +160,12 @@ public abstract class AbstractUIGridLayo
           OriginCell origin = (OriginCell) cell;
           LayoutComponent component = cell.getComponent();
 
-          if (component instanceof LayoutContainer && component.isRendered()) {
+          if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
             ((LayoutContainer) component).getLayoutManager().preProcessing(orientation);
           }
 
           if (token instanceof AutoLayoutToken || token instanceof RelativeLayoutToken) {
-            if (origin.getSpan(orientation) == 1 && component.isRendered()) {
+            if (origin.getSpan(orientation) == 1 && (component.isRendered() || isRigid())) {
               intervalList.add(new Interval(component, orientation));
             } else {
               if (LOG.isDebugEnabled()) {
@@ -312,7 +312,7 @@ public abstract class AbstractUIGridLayo
           }
 
           // call sub layout manager
-          if (component instanceof LayoutContainer && component.isRendered()) {
+          if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
             ((LayoutContainer) component).getLayoutManager().mainProcessing(orientation);
           }
         }
@@ -371,7 +371,7 @@ public abstract class AbstractUIGridLayo
           }
 
           // call sub layout manager
-          if (component instanceof LayoutContainer && component.isRendered()) {
+          if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
             ((LayoutContainer) component).getLayoutManager().postProcessing(orientation);
           }
 
@@ -455,6 +455,8 @@ public abstract class AbstractUIGridLayo
 
   public abstract boolean isRowOverflow();
 
+  public abstract boolean isRigid();
+
   @Override
   public boolean getRendersChildren() {
     return false;

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java?rev=1489414&r1=1489413&r2=1489414&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java Tue Jun  4 12:31:33 2013
@@ -109,8 +109,7 @@ public interface GridLayoutTagDeclaratio
    * @param columnOverflow Does the component need a horizontal scrollbar?
    */
   @TagAttribute
-  @UIComponentTagAttribute(
-      type = "boolean")
+  @UIComponentTagAttribute(type = "boolean")
   void setColumnOverflow(String columnOverflow);
 
   /**
@@ -119,8 +118,14 @@ public interface GridLayoutTagDeclaratio
    * @param rowOverflow Does the component need a vertical scrollbar?
    */
   @TagAttribute
-  @UIComponentTagAttribute(
-      type = "boolean")
+  @UIComponentTagAttribute(type = "boolean")
   void setRowOverflow(String rowOverflow);
 
+  /**
+   * This attribute advises the layout manager, to not use space that comes from non rendered components.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "boolean")
+  void setRigid(String rigid);
+
 }

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js?rev=1489414&r1=1489413&r2=1489414&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js Tue Jun  4 12:31:33 2013
@@ -26,8 +26,7 @@ var TobagoAssert = {
     epsilon = epsilon != null ? epsilon : 0;
     var offsetLeft = element.offset().left;
     if (Math.abs(offsetLeft - left) > epsilon) {
-      LOG.error("The element '" + element.get(0).tagName + "' with id='" + element.attr("id")
-          + "' has wrong left: expected=" + left + " actual=" + offsetLeft);
+      TobagoAssert.fail("left", element, left, offsetLeft);
     }
   },
 
@@ -36,8 +35,7 @@ var TobagoAssert = {
     epsilon = epsilon != null ? epsilon : 0;
     var offsetTop = element.offset().top;
     if (Math.abs(offsetTop - top) > epsilon) {
-      LOG.error("The element '" + element.get(0).tagName + "' with id='" + element.attr("id")
-          + "' has wrong top: expected=" + top + " actual=" + offsetTop);
+      TobagoAssert.fail("top", element, top, offsetTop);
     }
   },
 
@@ -46,8 +44,7 @@ var TobagoAssert = {
     epsilon = epsilon != null ? epsilon : 0;
     var offsetWidth = element.get(0).offsetWidth;
     if (Math.abs(offsetWidth - width) > epsilon) {
-      LOG.error("The element '" + element.get(0).tagName + "' with id='" + element.attr("id")
-          + "' has wrong width: expected=" + width + " actual=" + offsetWidth);
+      TobagoAssert.fail("width", element, width, offsetWidth);
     }
   },
 
@@ -56,11 +53,19 @@ var TobagoAssert = {
     epsilon = epsilon != null ? epsilon : 0;
     var offsetHeight = element.get(0).offsetHeight;
     if (Math.abs(offsetHeight - height) > epsilon) {
-      LOG.error("The element '" + element.get(0).tagName + "' with id='" + element.attr("id")
-          + "' has wrong height: expected=" + height + " actual=" + offsetHeight);
+      TobagoAssert.fail("height", element, height, offsetHeight);
     }
   },
 
+  fail: function(name, element, expected, actual) {
+    element.overlay({error: true, ajax: true});
+    var text = "The element '" + element.get(0).tagName + "' with id='" + element.attr("id")
+        + "' has wrong " + name + ": expected=" + expected + " actual=" + actual;
+    var overlay = element.data("tobago-overlay").overlay;
+    overlay.attr("title", (overlay.attr("title") === undefined ? "" : overlay.attr("title")+ "\n" ) + text);
+    LOG.error(text);
+  },
+
   assertLayout:function (elementOrId, left, top, width, height) {
     var element = TobagoAssert.jQueryElement(elementOrId);
     TobagoAssert.assertLeft(element, left);

Copied: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/rigid.xhtml (from r1488934, myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/margin.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/rigid.xhtml?p2=myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/rigid.xhtml&p1=myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/margin.xhtml&r1=1488934&r2=1489414&rev=1489414&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/margin.xhtml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/gridLayout/rigid.xhtml Tue Jun  4 12:31:33 2013
@@ -18,23 +18,123 @@
 
 <f:view
     xmlns:tc="http://myfaces.apache.org/tobago/component"
-    xmlns:tx="http://myfaces.apache.org/tobago/extension"
-    xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:f="http://java.sun.com/jsf/core">
 
   <tc:page id="page">
-    <tc:gridLayoutConstraint width="600px" height="600px"/>
+    <tc:script file="script/tobago-assert.js"/>
+
+    <!--
+    width  =  1 + 5 + 101 + 5 + 101 + 5 + 101 + 5 + 2 = 326
+    height = 21 + 5 +  51 + 5 +  51 + 5 +  51 + 5 + 2 = 196
+    -->
     <f:facet name="layout">
-      <tc:gridLayout marginLeft="10" marginTop="20px" marginRight="30" marginBottom="40px"/>
-<!--
-      <tc:gridLayout marginLeft="10" marginTop="20px" marginRight="#{10+20}" marginBottom='#{"40px"}'/>
--->
+      <tc:gridLayout rowSpacing="20px" columns="326px" rows="196px;196px;196px"/>
     </f:facet>
 
-    <tc:image id="id" value="pidgeon-point.jpg"/>
+    <tc:box label="1. All rendered">
+      <f:facet name="layout">
+        <tc:gridLayout columns="*;*;*"/>
+      </f:facet>
+
+      <tc:textarea value="1">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="2">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="3">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+
+      <tc:textarea value="4">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="5">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="6">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+
+      <tc:textarea value="7">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="8">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="9">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+    </tc:box>
+
+    <tc:box label="2. Middle row and column are not rendered.">
+      <f:facet name="layout">
+        <tc:gridLayout columns="*;*;*"/>
+      </f:facet>
+
+      <tc:textarea value="1">
+        <tc:dataAttribute name="assert-width" value="154"/>
+        <tc:dataAttribute name="assert-height" value="79"/>
+      </tc:textarea>
+      <tc:textarea value="2" rendered="false"/>
+      <tc:textarea value="3">
+        <tc:dataAttribute name="assert-width" value="154"/>
+        <tc:dataAttribute name="assert-height" value="79"/>
+      </tc:textarea>
+
+      <tc:textarea value="4" rendered="false"/>
+      <tc:textarea value="5" rendered="false"/>
+      <tc:textarea value="6" rendered="false"/>
+
+      <tc:textarea value="7">
+        <tc:dataAttribute name="assert-width" value="154"/>
+        <tc:dataAttribute name="assert-height" value="79"/>
+      </tc:textarea>
+      <tc:textarea value="8" rendered="false"/>
+      <tc:textarea value="9">
+        <tc:dataAttribute name="assert-width" value="154"/>
+        <tc:dataAttribute name="assert-height" value="79"/>
+      </tc:textarea>
+    </tc:box>
+
+    <tc:box label="3. Like 2. but rigid='true'">
+      <f:facet name="layout">
+        <tc:gridLayout columns="*;*;*" rigid="true"/>
+      </f:facet>
+
+      <tc:textarea value="1">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="2" rendered="false"/>
+      <tc:textarea value="3">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+
+      <tc:textarea value="4" rendered="false"/>
+      <tc:textarea value="5" rendered="false"/>
+      <tc:textarea value="6" rendered="false"/>
+
+      <tc:textarea value="7">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+      <tc:textarea value="8" rendered="false"/>
+      <tc:textarea value="9">
+        <tc:dataAttribute name="assert-width" value="101"/>
+        <tc:dataAttribute name="assert-height" value="51"/>
+      </tc:textarea>
+    </tc:box>
 
-    <tc:script file="script/tobago-assert.js"/>
-    <tc:script onload="TobagoAssert.assertLayout('page:id', 10, 20, 560, 540);"/>
-    
   </tc:page>
 </f:view>