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 2011/03/29 21:58:31 UTC
svn commit: r1086704 - 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/layout/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/t...
Author: lofwyr
Date: Tue Mar 29 19:58:31 2011
New Revision: 1086704
URL: http://svn.apache.org/viewvc?rev=1086704&view=rev
Log:
TOBAGO-606: LayoutManager: Scollbars
- setting default style overflow back to hidden
- detect the need of a scrollbar in the layout manager, and set in this case the style overflow to auto
- add attributes to the layout manager to set the scrollbar explicit
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/layout/Grid.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutContext.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsGridLayoutContainer.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
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=1086704&r1=1086703&r2=1086704&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 Mar 29 19:58:31 2011
@@ -19,6 +19,7 @@ package org.apache.myfaces.tobago.intern
import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.tobago.component.SupportsMarkup;
+import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.internal.layout.BankHead;
import org.apache.myfaces.tobago.internal.layout.Cell;
import org.apache.myfaces.tobago.internal.layout.FactorList;
@@ -38,6 +39,7 @@ import org.apache.myfaces.tobago.layout.
import org.apache.myfaces.tobago.layout.Orientation;
import org.apache.myfaces.tobago.layout.PixelLayoutToken;
import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
+import org.apache.myfaces.tobago.util.VariableResolverUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,6 +75,9 @@ public abstract class AbstractUIGridLayo
((LayoutContainer) component).getLayoutManager().init();
}
}
+
+ grid.setColumnOverflow(isColumnOverflow());
+ grid.setRowOverflow(isRowOverflow());
}
public void fixRelativeInsideAuto(Orientation orientation, boolean auto) {
@@ -253,6 +258,13 @@ public abstract class AbstractUIGridLayo
available = available.subtractNotNegative(LayoutUtils.getPaddingEnd(orientation, container));
available = available.subtractNotNegative(LayoutUtils.getBorderEnd(orientation, container));
+ if (grid.isOverflow(orientation.other())) {
+ ClientProperties client = VariableResolverUtils.resolveClientProperties(FacesContext.getCurrentInstance());
+ final Measure scrollbar = orientation
+ == Orientation.HORIZONTAL ? client.getVerticalScrollbarWeight() : client.getHorizontalScrollbarWeight();
+ available = available.subtractNotNegative(scrollbar);
+ }
+
List<Measure> partition = factorList.partition(available);
// write values back into the header
@@ -300,6 +312,19 @@ public abstract class AbstractUIGridLayo
}
}
}
+
+ Measure size = Measure.ZERO;
+ size = size.add(LayoutUtils.getPaddingBegin(orientation, getLayoutContainer()));
+ size = size.add(getMarginBegin(orientation));
+ size = size.add(computeSpacing(orientation, 0, heads.length));
+ for (BankHead head : heads) {
+ size = size.add(head.getCurrent());
+ }
+ size = size.add(getMarginEnd(orientation));
+ size = size.add(LayoutUtils.getPaddingEnd(orientation, getLayoutContainer()));
+ if (size.greaterThan(LayoutUtils.getCurrentSize(orientation, getLayoutContainer()))) {
+ grid.setOverflow(true, orientation);
+ }
}
public void postProcessing(Orientation orientation) {
@@ -346,6 +371,14 @@ public abstract class AbstractUIGridLayo
((LayoutContainer) component).getLayoutManager().postProcessing(orientation);
}
+ // set scrolling stype
+ final boolean scroll = grid.isOverflow(orientation);
+ if (orientation == Orientation.HORIZONTAL) {
+ getLayoutContainer().setOverflowX(scroll);
+ } else {
+ getLayoutContainer().setOverflowY(scroll);
+ }
+
// todo: optimize: the AutoLayoutTokens with columnSpan=1 are already called
}
}
@@ -410,6 +443,10 @@ public abstract class AbstractUIGridLayo
public abstract Measure getMarginBottom();
+ public abstract boolean isColumnOverflow();
+
+ public abstract boolean isRowOverflow();
+
@Override
public boolean getRendersChildren() {
return false;
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java?rev=1086704&r1=1086703&r2=1086704&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java Tue Mar 29 19:58:31 2011
@@ -46,6 +46,9 @@ public class Grid {
private int columnCursor;
private int rowCursor;
+ private boolean columnOverflow;
+ private boolean rowOverflow;
+
private List<Integer> errorIndexes;
public Grid(LayoutTokens columns, LayoutTokens rows) {
@@ -174,6 +177,34 @@ public class Grid {
rowCount += newRows;
}
+ public boolean isOverflow(Orientation orientation) {
+ return orientation == Orientation.HORIZONTAL ? columnOverflow : rowOverflow;
+ }
+
+ public void setOverflow(boolean overflow, Orientation orientation) {
+ if (orientation == Orientation.HORIZONTAL) {
+ this.columnOverflow = overflow;
+ } else {
+ this.rowOverflow = overflow;
+ }
+ }
+
+ public boolean isOverflow() {
+ return columnOverflow;
+ }
+
+ public void setColumnOverflow(boolean columnOverflow) {
+ this.columnOverflow = columnOverflow;
+ }
+
+ public boolean isRowOverflow() {
+ return rowOverflow;
+ }
+
+ public void setRowOverflow(boolean rowOverflow) {
+ this.rowOverflow = rowOverflow;
+ }
+
public void addError(int i, int j) {
if (errorIndexes == null) {
errorIndexes = new ArrayList<Integer>();
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutContext.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutContext.java?rev=1086704&r1=1086703&r2=1086704&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutContext.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutContext.java Tue Mar 29 19:58:31 2011
@@ -73,25 +73,34 @@ public class LayoutContext {
LayoutManager layoutManager = container.getLayoutManager();
layoutManager.init();
- layoutManager.fixRelativeInsideAuto(Orientation.HORIZONTAL, false);
+// log("after init");
layoutManager.fixRelativeInsideAuto(Orientation.VERTICAL, false);
- layoutManager.preProcessing(Orientation.HORIZONTAL);
+// log("after fixRelativeInsideAuto vertical");
+ layoutManager.fixRelativeInsideAuto(Orientation.HORIZONTAL, false);
+// log("after fixRelativeInsideAuto horizontal");
layoutManager.preProcessing(Orientation.VERTICAL);
- layoutManager.mainProcessing(Orientation.HORIZONTAL);
+// log("after preProcessing vertical");
+ layoutManager.preProcessing(Orientation.HORIZONTAL);
+// log("after preProcessing horizontal");
layoutManager.mainProcessing(Orientation.VERTICAL);
- layoutManager.postProcessing(Orientation.HORIZONTAL);
+// log("after mainProcessing vertical");
+ layoutManager.mainProcessing(Orientation.HORIZONTAL);
+// log("after mainProcessing horizontal");
layoutManager.postProcessing(Orientation.VERTICAL);
+// log("after postProcessing vertical");
+ layoutManager.postProcessing(Orientation.HORIZONTAL);
+// log("after postProcessing horizontal");
if (LOG.isDebugEnabled()) {
LOG.debug("Laying out takes: {} ns", new DecimalFormat("#,##0").format(System.nanoTime() - begin));
}
+ log("after layout");
- log();
}
- private void log() {
+ private void log(String message) {
if (LOG.isDebugEnabled()) {
- StringBuffer buffer = new StringBuffer("\n");
+ StringBuffer buffer = new StringBuffer(message + "\n");
log(buffer, (UIComponent) container, 0);
LOG.debug(buffer.toString());
}
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=1086704&r1=1086703&r2=1086704&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 Mar 29 19:58:31 2011
@@ -19,7 +19,9 @@ package org.apache.myfaces.tobago.intern
import org.apache.myfaces.tobago.apt.annotation.BodyContent;
import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasBinding;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasBorder;
@@ -98,4 +100,25 @@ import org.apache.myfaces.tobago.interna
allowedChildComponenents = "NONE", isLayout = true)
public interface GridLayoutTagDeclaration extends HasId, HasBorder, HasSpacing, HasMargin,
HasMargins, HasColumnLayout, HasRowLayout, HasBinding, HasMarkup, HasCurrentMarkup {
+
+ /**
+ * This attribute is a hint for the layout manager. Should not be used in most cases.
+ *
+ * @param columnOverflow Does the component need a horizontal scollbar?
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(
+ type = "boolean")
+ void setColumnOverflow(String columnOverflow);
+
+ /**
+ * This attribute is a hint for the layout manager. Should not be used in most cases.
+ *
+ * @param rowOverflow Does the component need a vertical scollbar?
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(
+ type = "boolean")
+ void setRowOverflow(String rowOverflow);
+
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsGridLayoutContainer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsGridLayoutContainer.java?rev=1086704&r1=1086703&r2=1086704&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsGridLayoutContainer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsGridLayoutContainer.java Tue Mar 29 19:58:31 2011
@@ -103,4 +103,22 @@ public interface IsGridLayoutContainer {
+ "getRenderer(getFacesContext())).getPaddingBottom(getFacesContext(), this)")
void setPaddingBottom(String paddingBottom);
+ /**
+ * This attribute is for internal use only.
+ *
+ * @param overflowX Does the component need a horizontal scollbar.
+ */
+ @UIComponentTagAttribute(
+ type = "boolean")
+ void setOverflowX(String overflowX);
+
+ /**
+ * This attribute is for internal use only.
+ *
+ * @param overflowY Does the component need a vertical scollbar.
+ */
+ @UIComponentTagAttribute(
+ type = "boolean")
+ void setOverflowY(String overflowY);
+
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java?rev=1086704&r1=1086703&r2=1086704&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java Tue Mar 29 19:58:31 2011
@@ -54,4 +54,10 @@ public interface LayoutContainer extends
Measure getPaddingBottom();
void setPaddingBottom(Measure paddingBottom);
+
+ boolean isOverflowX();
+ void setOverflowX(boolean overflowX);
+
+ boolean isOverflowY();
+ void setOverflowY(boolean overflowY);
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java?rev=1086704&r1=1086703&r2=1086704&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java Tue Mar 29 19:58:31 2011
@@ -21,6 +21,7 @@ import org.apache.myfaces.tobago.context
import org.apache.myfaces.tobago.layout.Display;
import org.apache.myfaces.tobago.layout.LayoutBase;
import org.apache.myfaces.tobago.layout.LayoutComponent;
+import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.Measure;
import org.apache.myfaces.tobago.layout.TextAlign;
@@ -37,7 +38,8 @@ public class Style implements Serializab
private Measure top;
private Display display;
private Position position;
- private Overflow overflow;
+ private Overflow overflowX;
+ private Overflow overflowY;
private Measure marginLeft;
private Measure marginRight;
private Measure marginTop;
@@ -62,7 +64,8 @@ public class Style implements Serializab
this.top = map.top;
this.display = map.display;
this.position = map.position;
- this.overflow = map.overflow;
+ this.overflowX = map.overflowX;
+ this.overflowY = map.overflowY;
this.marginLeft = map.marginLeft;
this.marginRight = map.marginRight;
this.marginTop = map.marginTop;
@@ -118,6 +121,11 @@ public class Style implements Serializab
if (layout instanceof LayoutComponent) { // fixme
display = ((LayoutComponent) layout).getDisplay();
}
+
+ if (layout instanceof LayoutContainer) {
+ overflowX = ((LayoutContainer)layout).isOverflowX() ? Overflow.AUTO : null;
+ overflowY = ((LayoutContainer)layout).isOverflowY() ? Overflow.AUTO : null;
+ }
}
public String encode() {
@@ -152,9 +160,14 @@ public class Style implements Serializab
buf.append(position.getValue());
buf.append(';');
}
- if (overflow != null) {
- buf.append("overflow:");
- buf.append(overflow.getValue());
+ if (overflowX != null) {
+ buf.append("overflow-x:");
+ buf.append(overflowX.getValue());
+ buf.append(';');
+ }
+ if (overflowY != null) {
+ buf.append("overflow-y:");
+ buf.append(overflowY.getValue());
buf.append(';');
}
if (marginLeft != null) {
@@ -274,12 +287,20 @@ public class Style implements Serializab
this.position = position;
}
- public Overflow getOverflow() {
- return overflow;
+ public Overflow getOverflowX() {
+ return overflowX;
+ }
+
+ public void setOverflowX(Overflow overflowX) {
+ this.overflowX = overflowX;
+ }
+
+ public Overflow getOverflowY() {
+ return overflowY;
}
- public void setOverflow(Overflow overflow) {
- this.overflow = overflow;
+ public void setOverflowY(Overflow overflowY) {
+ this.overflowY = overflowY;
}
public Measure getMarginLeft() {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css?rev=1086704&r1=1086703&r2=1086704&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css Tue Mar 29 19:58:31 2011
@@ -53,7 +53,7 @@ fieldset.tobago-box {
.tobago-box-content {
position: absolute;
- overflow: auto;
+ overflow: hidden;
}
.tobago-box-toolbarOuter {
@@ -547,7 +547,7 @@ li.tobago-menu-markup-selected {
.tobago-page-content {
position: absolute;
z-index: 0;
- overflow: auto;
+ overflow: hidden;
}
.tobago-page-scrollbarWeight {
@@ -564,7 +564,7 @@ li.tobago-menu-markup-selected {
/* panel -------------------------------------------------------------- */
.tobago-panel {
- overflow: auto;
+ overflow: hidden;
}
/* popup -------------------------------------------------------------- */
@@ -1085,7 +1085,7 @@ div.tobago-richTextEditor-body {
border-width: 0 1px 1px 1px;
border-style: solid;
display: none;
- overflow: auto;
+ overflow: hidden;
}
.tobago-tab-content-markup-selected {