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 2009/09/01 10:42:31 UTC
svn commit: r809888 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/layout/
example/test/src/main/webapp/tc/box/
example/test/src/main/webapp/tc/gridLayout/
Author: lofwyr
Date: Tue Sep 1 08:42:31 2009
New Revision: 809888
URL: http://svn.apache.org/viewvc?rev=809888&view=rev
Log:
TOBAGO-606: Layout-Manager
- fix offset (e.g. of box) in bottom up computation
- not override width and height, when it was already set
- some more tests
Added:
myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-auto.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-relative.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/not-exact-4x4.xhtml
- copied unchanged from r805731, myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-not-exact-4x4.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/not-exact.xhtml
- copied unchanged from r805731, myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-not-exact.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-auto.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-maximum.xhtml
- copied, changed from r809638, myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-minimum.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-preferred.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-set.xhtml
Removed:
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-not-exact-4x4.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-not-exact.xhtml
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/auto-vertical-in+in.xhtml
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java?rev=809888&r1=809887&r2=809888&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java Tue Sep 1 08:42:31 2009
@@ -158,6 +158,8 @@
}
}
if (size != null) {
+ size = size.add(LayoutUtils.getBeginOffset(orientation, getLayoutContainer()));
+ size = size.add(LayoutUtils.getEndOffset(orientation, getLayoutContainer()));
LayoutUtils.setSize(orientation, getLayoutContainer(), size);
}
}
@@ -225,7 +227,7 @@
size = size.add(pixelMeasures[i + k]);
size = size.add(getSpacing(orientation));
}
- setSize(orientation, component, size);
+ LayoutUtils.setSize(orientation, component, size);
}
// call sub layout manager
@@ -249,10 +251,8 @@
component.setDisplay(Display.BLOCK); // TODO: use CSS via classes and style.css
- Integer span = ((OriginCell) cell).getSpan(orientation);
PixelMeasure[] pixelMeasures = grid.getSizes(orientation);
-
// compute the position of the cell
{
Measure position = LayoutUtils.getBeginOffset(orientation, getLayoutContainer());
@@ -466,7 +466,7 @@
firstIndex = i + horizontalIndexOffset;
} else {
layoutContext.getHorizontal().proportionate(
- firstIndex, i + horizontalIndexOffset, first, factor, getParent());
+ firstIndex, i + horizontalIndexOffset, first, factor, getLayoutContainer());
}
}
}
@@ -483,7 +483,7 @@
firstIndex = i + verticalIndexOffset;
} else {
layoutContext.getVertical().proportionate(
- firstIndex, i + verticalIndexOffset, first, factor, getParent());
+ firstIndex, i + verticalIndexOffset, first, factor, getLayoutContainer());
}
}
}
@@ -494,26 +494,6 @@
return ((LayoutContainer) getParent());
}
- private void setSize(boolean orientation, LayoutComponent component, Measure size) {
- if (orientation) {
- if (size.greaterThan(component.getMaximumWidth())) {
- size = component.getMaximumWidth();
- }
- if (size.lessThan(component.getMinimumWidth())) {
- size = component.getMinimumWidth();
- }
- component.setWidth(size);
- } else {
- if (size.greaterThan(component.getMaximumHeight())) {
- size = component.getMaximumHeight();
- }
- if (size.lessThan(component.getMinimumHeight())) {
- size = component.getMinimumHeight();
- }
- component.setHeight(size);
- }
- }
-
protected Grid getGrid() {
return grid;
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java?rev=809888&r1=809887&r2=809888&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java Tue Sep 1 08:42:31 2009
@@ -132,11 +132,30 @@
return available;
}
- public static void setSize(boolean orientation, LayoutContainer container, Measure size) {
+ public static void setSize(boolean orientation, LayoutObject component, Measure size) {
if (orientation) {
- container.setWidth(size);
+ if (component.getWidth() != null) { // to not override set sizes
+ return;
+ }
+ if (size.greaterThan(component.getMaximumWidth())) {
+ size = component.getMaximumWidth();
+ }
+ if (size.lessThan(component.getMinimumWidth())) {
+ size = component.getMinimumWidth();
+ }
+ component.setWidth(size);
} else {
- container.setHeight(size);
+ if (component.getHeight() != null) { // to not override set sizes
+ return;
+ }
+ if (size.greaterThan(component.getMaximumHeight())) {
+ size = component.getMaximumHeight();
+ }
+ if (size.lessThan(component.getMinimumHeight())) {
+ size = component.getMinimumHeight();
+ }
+ component.setHeight(size);
}
}
+
}
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-auto.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-auto.xhtml?rev=809888&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-auto.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-auto.xhtml Tue Sep 1 08:42:31 2009
@@ -0,0 +1,56 @@
+<?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:jsp="http://java.sun.com/JSP/Page"
+ 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="500px" height="200px"/>
+ <f:facet name="layout">
+ <tc:gridLayout columns="auto" rows="auto"/>
+ </f:facet>
+
+ <tc:box id="outerbox" label="outer box">
+ <f:facet name="layout">
+ <tc:gridLayout columns="auto" rows="auto"/>
+ </f:facet>
+
+ <tc:box id="innerbox" label="inner box">
+ <f:facet name="layout">
+ <tc:gridLayout columns="auto" rows="auto"/>
+ </f:facet>
+
+ <tc:textarea id="textarea" value="Some text.">
+ <tc:gridLayoutConstraint preferredWidth="200px" preferredHeight="50px"/>
+ </tc:textarea>
+
+ </tc:box>
+
+ </tc:box>
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout('page:outerbox', 0, 0, 226, 116);"/>
+ <tc:script onload="checkLayout('page:innerbox', 6, 26, 213, 83);"/>
+ <tc:script onload="checkLayout('page:textarea', 12, 52, 200, 50);"/>
+
+ </tc:page>
+</f:view>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-relative.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-relative.xhtml?rev=809888&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-relative.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/box/box-box-relative.xhtml Tue Sep 1 08:42:31 2009
@@ -0,0 +1,45 @@
+<?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:jsp="http://java.sun.com/JSP/Page"
+ 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="500px" height="200px"/>
+
+ <tc:box id="outerbox" label="outer box">
+
+ <tc:box id="innerbox" label="inner box">
+
+ <tc:textarea id="textarea" value="Some text."/>
+
+ </tc:box>
+
+ </tc:box>
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout('page:outerbox', 0, 0, 500, 200);"/>
+ <tc:script onload="checkLayout('page:innerbox', 6, 26, 487, 167);"/>
+ <tc:script onload="checkLayout('page:textarea', 12, 52, 474, 134);"/>
+
+ </tc:page>
+</f:view>
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/auto-vertical-in+in.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/auto-vertical-in%2Bin.xhtml?rev=809888&r1=809887&r2=809888&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/auto-vertical-in+in.xhtml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/auto-vertical-in+in.xhtml Tue Sep 1 08:42:31 2009
@@ -20,8 +20,8 @@
<tc:panel/>
<tc:script file="script/test-utils.js"/>
- <tc:script onload="checkLayout('page:in-0', 0, 0, 600, 20);"/>
- <tc:script onload="checkLayout('page:in-1', 0, 25, 600, 20);"/>
+ <tc:script onload="checkLayout('page:in-0', 0, 0, 60, 30);"/>
+ <tc:script onload="checkLayout('page:in-1', 0, 35, 600, 20);"/>
</tc:page>
</f:view>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-auto.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-auto.xhtml?rev=809888&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-auto.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-auto.xhtml Tue Sep 1 08:42:31 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ 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" label="Detect size of an image (not yet implemented)">
+ <f:facet name="layout">
+ <tc:gridLayout columns="fixed" rows="fixed"/>
+ </f:facet>
+ <tc:gridLayoutConstraint width="400px" height="400px"/>
+
+ <!--todo: not implmented yet-->
+
+ <tc:image id="image-0" value="pidgeon-point.jpg"/>
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout('page:image-0', 0, 0, 120, 180);"/>
+
+ </tc:page>
+</f:view>
Copied: myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-maximum.xhtml (from r809638, myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-minimum.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-maximum.xhtml?p2=myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-maximum.xhtml&p1=myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-minimum.xhtml&r1=809638&r2=809888&rev=809888&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-minimum.xhtml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-maximum.xhtml Tue Sep 1 08:42:31 2009
@@ -14,12 +14,12 @@
<tc:gridLayoutConstraint width="200px" height="200px"/>
<tc:image id="image-0" value="pidgeon-point.jpg">
- <tc:gridLayoutConstraint minimumWidth="300px" minimumHeight="300px"/>
+ <tc:gridLayoutConstraint maximumWidth="100px" maximumHeight="100px"/>
</tc:image>
<tc:script file="script/test-utils.js"/>
- <tc:script onload="checkLayout('page:image-0', 0, 0, 300, 300);"/>
+ <tc:script onload="checkLayout('page:image-0', 0, 0, 100, 100);"/>
</tc:page>
</f:view>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-preferred.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-preferred.xhtml?rev=809888&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-preferred.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-preferred.xhtml Tue Sep 1 08:42:31 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ 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">
+ <f:facet name="layout">
+ <tc:gridLayout columns="fixed" rows="fixed"/>
+ </f:facet>
+ <tc:gridLayoutConstraint width="200px" height="200px"/>
+
+ <tc:image id="image-0" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint preferredWidth="100px" preferredHeight="100px"/>
+ </tc:image>
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout('page:image-0', 0, 0, 100, 100);"/>
+
+ </tc:page>
+</f:view>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-set.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-set.xhtml?rev=809888&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-set.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-set.xhtml Tue Sep 1 08:42:31 2009
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ 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="200px" height="200px"/>
+
+ <tc:image id="image-0" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="120px" height="180px"/>
+ </tc:image>
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout('page:image-0', 0, 0, 120, 180);"/>
+
+ </tc:page>
+</f:view>