You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2014/11/05 10:54:15 UTC
svn commit: r1636842 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/
tobago-theme/tobag...
Author: weber
Date: Wed Nov 5 09:54:15 2014
New Revision: 1636842
URL: http://svn.apache.org/r1636842
Log:
TOBAGO-1423 - Sheet: forceVerticalScrollbar="true" breaks column alignment
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java?rev=1636842&r1=1636841&r2=1636842&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java Wed Nov 5 09:54:15 2014
@@ -232,6 +232,16 @@ public abstract class AbstractUISheetLay
currentWidthList = null;
}
+ Measure space = data.getCurrentWidth();
+ final LayoutComponentRenderer renderer = data.getLayoutComponentRenderer(facesContext);
+ space = space.subtractNotNegative(renderer.getBorderLeft(facesContext, data));
+ space = space.subtractNotNegative(renderer.getBorderRight(facesContext, data));
+ Measure verticalScrollbarWeight = renderer.getVerticalScrollbarWeight(facesContext, data);
+ boolean needVerticalScrollbar = needVerticalScrollbar(facesContext, data);
+ if (needVerticalScrollbar) {
+ space = space.subtractNotNegative(verticalScrollbarWeight);
+ }
+
if (currentWidthList == null) {
final LayoutTokens tokens = data.getColumnLayout();
final List<AbstractUIColumn> allColumns = data.getAllColumns();
@@ -255,13 +265,6 @@ public abstract class AbstractUISheetLay
}
}
- Measure space = data.getCurrentWidth();
- final LayoutComponentRenderer renderer = data.getLayoutComponentRenderer(facesContext);
- space = space.subtractNotNegative(renderer.getBorderLeft(facesContext, data));
- space = space.subtractNotNegative(renderer.getBorderRight(facesContext, data));
- if (needVerticalScrollbar(facesContext, data)) {
- space = space.subtractNotNegative(renderer.getVerticalScrollbarWeight(facesContext, data));
- }
/*
// todo: not nice: 1 left + 1 right border
space = space.subtract(renderedColumns.size() * 2);
@@ -273,9 +276,26 @@ public abstract class AbstractUISheetLay
parseFixedWidth(layoutInfo, renderedColumns, columnSelectorWidth);
layoutInfo.parseColumnLayout(space.getPixel());
currentWidthList = layoutInfo.getSpaceList();
- currentWidthList.add(0); // empty filler column
+ if (needVerticalScrollbar) {
+ currentWidthList.add(verticalScrollbarWeight.getPixel()); // filler column
+ } else {
+ currentWidthList.add(0); // empty filler column
+ }
}
+ int usedWidth = 0;
+ for (int i = 0, currentWidthListSize = currentWidthList.size(); i < currentWidthListSize - 1; i++) {
+ usedWidth += currentWidthList.get(i);
+ }
+
+ if (needVerticalScrollbar) {
+ space = space.add(verticalScrollbarWeight);
+ }
+ if (usedWidth < space.getPixel()) {
+ currentWidthList.set(currentWidthList.size() - 1, space.getPixel() - usedWidth);
+ }
+
+
if (renderedColumns.size() + 1 != currentWidthList.size()) {
LOG.warn("widthList.size() = " + currentWidthList.size()
+ " != columns.size() = " + renderedColumns.size() + " + 1. The widthList: "
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1636842&r1=1636841&r2=1636842&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Wed Nov 5 09:54:15 2014
@@ -259,16 +259,25 @@ public class SheetRenderer extends Layou
/*
bodyStyle.setPaddingTop(ie6SelectOneFix ? Measure.ZERO : headerHeight);
*/
+ final boolean needVerticalScrollbar = needVerticalScrollbar(facesContext, sheet);
writer.writeStyleAttribute(bodyStyle);
bodyStyle.setHeight(null);
bodyStyle.setTop(null);
final Style sheetBodyStyle = new Style(bodyStyle);
- // is null, in AJAX case.
- if (sheet.getNeedVerticalScrollbar() == Boolean.TRUE) {
- tableBodyWidth = tableBodyWidth.subtractNotNegative(getVerticalScrollbarWeight(facesContext, sheet));
+ if (columnWidths != null) {
+ int tmp = 0;
+ for (Integer columnWidth : columnWidths) {
+ tmp += columnWidth;
+ }
+ sheetBodyStyle.setWidth(Measure.valueOf(tmp));
+ } else {
+ // is null, in AJAX case.
+ if (needVerticalScrollbar) {
+ tableBodyWidth = tableBodyWidth.subtractNotNegative(getVerticalScrollbarWeight(facesContext, sheet));
+ }
+ sheetBodyStyle.setWidth(tableBodyWidth);
}
- sheetBodyStyle.setWidth(tableBodyWidth);
writer.startElement(HtmlElements.TABLE, null);
writer.writeAttribute(HtmlAttributes.CELLSPACING, "0", false);
@@ -771,13 +780,7 @@ public class SheetRenderer extends Layou
writer.startElement(HtmlElements.COLGROUP, null);
for (int i = 0; i < columnWidths.size(); i++) {
writer.startElement(HtmlElements.COL, null);
- if (i == columnWidths.size() - 2 && needVerticalScrollbar) {
- // if scrollbar is needed the coll for column in header must have own width + scrollbarWidth
- writer.writeAttribute(
- HtmlAttributes.WIDTH, columnWidths.get(i) + verticalScrollbarWidth);
- } else {
- writer.writeAttribute(HtmlAttributes.WIDTH, columnWidths.get(i));
- }
+ writer.writeAttribute(HtmlAttributes.WIDTH, columnWidths.get(i));
writer.endElement(HtmlElements.COL);
}
writer.endElement(HtmlElements.COLGROUP);
@@ -919,6 +922,12 @@ public class SheetRenderer extends Layou
writer.startElement(HtmlElements.DIV, null);
// todo: is the filler class needed here?
writer.writeClassAttribute(Classes.create(sheet, "headerCell", Markup.FILLER));
+ writer.startElement(HtmlElements.SPAN, null);
+ writer.writeClassAttribute(Classes.create(sheet, "header"));
+ final Style headerStyle = new Style();
+ headerStyle.setHeight(Measure.valueOf(14)); // XXX todo
+ writer.writeStyleAttribute(headerStyle);
+ writer.endElement(HtmlElements.SPAN);
writer.endElement(HtmlElements.DIV);
writer.endElement(HtmlElements.TD);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1636842&r1=1636841&r2=1636842&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Wed Nov 5 09:54:15 2014
@@ -288,11 +288,23 @@ Tobago.Sheet.setup2 = function (sheets)
var bodyDiv = table.parent().next();
var bodyHeight = bodyDiv.css("height").replace("px", "");
var scrollHeight = bodyDiv.prop("scrollHeight");
+ console.log("bodyHeight : " + bodyHeight); // @DEV_ONLY
+ console.log("scrollHeight : " + scrollHeight); // @DEV_ONLY
if (bodyHeight >= scrollHeight) {
table = bodyDiv.find("table");
- table.find("col").last().attr("width", verticalScrollbarWidth);
+ var bodyDivWidth = bodyDiv.css("width").replace("px", "") * 1;
+ console.log("bodyDivWidth : " + bodyDivWidth); // @DEV_ONLY
var tableWidth = table.css("width").replace("px", "") * 1;
- table.css("width", tableWidth + verticalScrollbarWidth);
+ console.log("tableWidth : " + tableWidth); // @DEV_ONLY
+ if (tableWidth < bodyDivWidth) {
+
+ var fillerWidth = bodyDiv.prev().find("col").last().attr("width").replace("px", "") * 1;
+ console.log("set filler col width : " + fillerWidth); // @DEV_ONLY
+ table.find("col").last().attr("width", fillerWidth);
+
+ console.log("set table width : " + bodyDivWidth); // @DEV_ONLY
+ table.css("width", bodyDivWidth);
+ }
}
}
});
@@ -350,10 +362,13 @@ Tobago.Sheet.setup2 = function (sheets)
for (i = 0; i < bodyList.length; i++) {
oldWidthList[i] = bodyList.eq(i).width();
}
- for (i = 0; i < headerList.length; i++) {
+ var usedWidth = 0;
+ for (i = 0; i < headerList.length -1; i++) {
+ // last column is the filler column
var newWidth = headerList.eq(i).width();
// for the hidden field
widths = widths + newWidth + ",";
+ usedWidth += newWidth;
var oldWidth = bodyList.eq(i).width();
if (oldWidth != newWidth) {
@@ -369,6 +384,24 @@ Tobago.Sheet.setup2 = function (sheets)
}
}
}
+ // adjust filler space
+ var sheetHeaderWidth = headerTable.parent().width();
+ console.log("usedWidth : " + usedWidth); // @DEV_ONLY
+ console.log("sheetHeaderWidth : " + sheetHeaderWidth); // @DEV_ONLY
+
+ if (usedWidth <= sheetHeaderWidth) {
+ var fillerWidth = sheetHeaderWidth - usedWidth;
+ console.log("SET fillerWidth : " + fillerWidth); // @DEV_ONLY
+ widths = widths + fillerWidth + ",";
+ headerList.last().attr("width", fillerWidth);
+ bodyList.last().attr("width", fillerWidth); // TODO ? verticalScrollbarWidth
+ bodyTable.css("width", sheetHeaderWidth); // TODO ? verticalScrollbarWidth
+ } else {
+ console.log("SET fillerWidth : 0"); // @DEV_ONLY
+ widths = widths + "0,";
+ headerList.last().attr("width", 0);
+ bodyList.last().attr("width", 0); // TODO ? verticalScrollbarWidth
+ }
// store the width values in a hidden field
Tobago.Sheet.hidden(sheet, "widths").val(widths);
return false;