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:43:46 UTC

svn commit: r1489416 - in /myfaces/tobago/trunk: 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/src/main/webapp/s...

Author: lofwyr
Date: Tue Jun  4 12:43:45 2013
New Revision: 1489416

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

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/gridLayout/rigid.xhtml
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java?rev=1489416&r1=1489415&r2=1489416&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java Tue Jun  4 12:43:45 2013
@@ -75,7 +75,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();
       }
     }
@@ -125,7 +125,7 @@ public abstract class AbstractUIGridLayo
           }
         }
       }
-      if (neitherRendered) {
+      if (neitherRendered && !isRigid()) {
         heads[i].setRendered(false);
       }
     }
@@ -147,7 +147,7 @@ public abstract class AbstractUIGridLayo
       LayoutToken token = head.getToken();
 
       if (token instanceof PixelLayoutToken) {
-        if (head.isRendered()) {
+        if (head.isRendered() || isRigid()) {
           heads[i].setCurrent(((PixelLayoutToken) token).getMeasure());
         } else {
           heads[i].setCurrent(Measure.ZERO);
@@ -161,12 +161,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()) {
@@ -313,7 +313,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);
           }
         }
@@ -372,7 +372,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);
           }
 
@@ -456,6 +456,8 @@ public abstract class AbstractUIGridLayo
 
   public abstract boolean isRowOverflow();
 
+  public abstract boolean isRigid();
+
   @Override
   public boolean getRendersChildren() {
     return false;

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java?rev=1489416&r1=1489415&r2=1489416&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java Tue Jun  4 12:43:45 2013
@@ -111,8 +111,7 @@ public interface GridLayoutTagDeclaratio
    * @param columnOverflow Does the component need a horizontal scrollbar?
    */
   @TagAttribute
-  @UIComponentTagAttribute(
-      type = "boolean")
+  @UIComponentTagAttribute(type = "boolean")
   void setColumnOverflow(String columnOverflow);
 
   /**
@@ -121,8 +120,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/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js?rev=1489416&r1=1489415&r2=1489416&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js Tue Jun  4 12:43:45 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);

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/gridLayout/rigid.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/gridLayout/rigid.xhtml?rev=1489416&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/gridLayout/rigid.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/gridLayout/rigid.xhtml Tue Jun  4 12:43:45 2013
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+    xmlns:tc="http://myfaces.apache.org/tobago/component"
+    xmlns:f="http://java.sun.com/jsf/core">
+
+  <tc:page id="page">
+    <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 rowSpacing="20px" columns="326px" rows="196px;196px;196px"/>
+    </f:facet>
+
+    <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:page>
+</f:view>