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 2015/05/21 11:23:10 UTC
svn commit: r1680776 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-example/tobago-example-test/src/main/webapp/WEB-INF/
tobago-example/tobago-example-test/src/main/webapp/test...
Author: lofwyr
Date: Thu May 21 09:23:10 2015
New Revision: 1680776
URL: http://svn.apache.org/r1680776
Log:
TOBAGO-1368: Create a new theme which uses Bootstrap
- fix Sheet Header
- simplifications
Added:
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.js
- copied, changed from r1680529, myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/tobago-config.xml
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java Thu May 21 09:23:10 2015
@@ -420,6 +420,8 @@ public abstract class AbstractUISheet ex
super.processEvent(event);
if (event instanceof PreRenderComponentEvent) {
sort(getFacesContext(), null);
+ AbstractUISheetLayout.ensureColumnWidthList(FacesContext.getCurrentInstance(), this);
+ AbstractUISheetLayout.layoutHeader(this); // XXX see comment there...
}
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheetLayout.java Thu May 21 09:23:10 2015
@@ -19,10 +19,8 @@
package org.apache.myfaces.tobago.internal.component;
-import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.internal.layout.Grid;
import org.apache.myfaces.tobago.internal.layout.OriginCell;
-import org.apache.myfaces.tobago.internal.util.StringUtils;
import org.apache.myfaces.tobago.layout.AutoLayoutToken;
import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutManager;
@@ -30,20 +28,15 @@ import org.apache.myfaces.tobago.layout.
import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.layout.Measure;
import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
-import org.apache.myfaces.tobago.model.SheetState;
-import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
import org.apache.myfaces.tobago.util.LayoutInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-/**
- * XXX: Not completely implemented yet.
- */
public abstract class AbstractUISheetLayout extends AbstractUILayoutBase implements LayoutManager {
private static final Logger LOG = LoggerFactory.getLogger(AbstractUISheetLayout.class);
@@ -201,7 +194,10 @@ public abstract class AbstractUISheetLay
return false;
}
- private void ensureColumnWidthList(final FacesContext facesContext, final AbstractUISheet data) {
+ // TBD: check it this class should be removed, and the logic goes to AbstractUISheet
+// private void ensureColumnWidthList(final FacesContext facesContext, final AbstractUISheet data) {
+ public static void ensureColumnWidthList(final FacesContext facesContext, final AbstractUISheet data) {
+/*
List<Integer> currentWidthList = null;
// TODO: Refactor: here be should use "getColumns()" instead of "getRenderedColumns()"
final List<AbstractUIColumn> renderedColumns = data.getRenderedColumns();
@@ -231,13 +227,16 @@ public abstract class AbstractUISheetLay
final LayoutComponentRenderer renderer = data.getLayoutComponentRenderer(facesContext);
space = space.subtractNotNegative(renderer.getBorderLeft(facesContext, data));
space = space.subtractNotNegative(renderer.getBorderRight(facesContext, data));
+*/
- if (currentWidthList == null) {
+ final List<AbstractUIColumn> allColumns = data.getAllColumns();
+ final List<Integer> currentWidthList = new ArrayList<Integer>(allColumns.size() + 1);
final LayoutTokens tokens = data.getColumnLayout();
- final List<AbstractUIColumn> allColumns = data.getAllColumns();
final LayoutTokens newTokens = new LayoutTokens();
for (int i = 0; i < allColumns.size(); i++) {
final AbstractUIColumn column = allColumns.get(i);
+ currentWidthList.add(null);
+/*
if (column.isRendered()) {
if (tokens == null) {
if (column instanceof AbstractUIColumn && column.getWidth() != null) {
@@ -253,8 +252,12 @@ public abstract class AbstractUISheetLay
}
}
}
+*/
}
+
+
+/*
final LayoutInfo layoutInfo =
new LayoutInfo(newTokens.getSize(), space.getPixel(), newTokens, data.getClientId(facesContext), false);
final Measure columnSelectorWidth
@@ -267,20 +270,16 @@ public abstract class AbstractUISheetLay
for (Integer width : currentWidthList) {
freeWidth -= width;
}
+*/
- currentWidthList.add(Math.max(freeWidth, 0)); // empty filler column
- }
+// currentWidthList.add(Math.max(freeWidth, 0)); // empty filler column
- if (renderedColumns.size() + 1 != currentWidthList.size()) {
- LOG.warn("widthList.size() = " + currentWidthList.size()
- + " != columns.size() = " + renderedColumns.size() + " + 1. The widthList: "
- + LayoutInfo.listToTokenString(currentWidthList));
- } else {
- data.setWidthList(currentWidthList);
- }
+
+
+ data.setWidthList(currentWidthList);
}
- private void parseFixedWidth(
+ private static void parseFixedWidth(
final LayoutInfo layoutInfo, final List<AbstractUIColumn> renderedColumns, final Measure columnSelectorWidth) {
final LayoutTokens tokens = layoutInfo.getLayoutTokens();
for (int i = 0; i < tokens.getSize(); i++) {
@@ -313,46 +312,10 @@ public abstract class AbstractUISheetLay
}
}
- private Measure getHeaderHeight(final FacesContext facesContext, final AbstractUISheet sheet) {
- if (sheet.isShowHeader()) {
- final Measure headerHeight = sheet.getLayoutComponentRenderer(facesContext)
- .getCustomMeasure(facesContext, sheet, "headerHeight");
- if (headerHeight != null) {
- return headerHeight;
- } else {
- return Measure.valueOf(20);
- }
- } else {
- return Measure.ZERO;
- }
- }
-
- private Measure getRowHeight(final FacesContext facesContext, final AbstractUISheet sheet) {
- final Measure rowHeight = sheet.getLayoutComponentRenderer(facesContext)
- .getCustomMeasure(facesContext, sheet, "rowHeight");
- if (rowHeight != null) {
- return rowHeight;
- } else {
- return Measure.valueOf(20);
- }
- }
-
- private Measure getFooterHeight(final FacesContext facesContext, final AbstractUISheet sheet) {
- if (sheet.isPagingVisible()) {
- final Measure footerHeight = sheet.getLayoutComponentRenderer(facesContext)
- .getCustomMeasure(facesContext, sheet, "footerHeight");
- if (footerHeight != null) {
- return footerHeight;
- } else {
- return Measure.valueOf(20);
- }
- } else {
- return Measure.ZERO;
- }
- }
-
- private void layoutHeader() {
- final AbstractUISheet sheet = (AbstractUISheet) getLayoutContainer();
+ // TBD: check it this class should be removed, and the logic goes to AbstractUISheet
+// private void layoutHeader() {
+ public static void layoutHeader(final AbstractUISheet sheet) {
+// final AbstractUISheet sheet = (AbstractUISheet) getLayoutContainer();
final UIComponent header = sheet.getHeader();
if (header == null) {
LOG.warn("This should not happen. Please file a bug in the issue tracker to reproduce this case.");
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/tobago-config.xml?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/tobago-config.xml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/tobago-config.xml Thu May 21 09:23:10 2015
@@ -22,11 +22,11 @@
version="2.0">
<theme-config>
- <default-theme>speyside</default-theme>
+ <default-theme>bootstrap</default-theme>
<supported-theme>scarborough</supported-theme>
<supported-theme>richmond</supported-theme>
<supported-theme>charlotteville</supported-theme>
- <supported-theme>bootstrap</supported-theme>
+ <!--<supported-theme>bootstrap</supported-theme>-->
<!-- for development -->
<supported-theme>standard</supported-theme>
</theme-config>
Copied: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.js (from r1680529, myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.js?p2=myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.js&p1=myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml&r1=1680529&r2=1680776&rev=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.js Thu May 21 09:23:10 2015
@@ -1,5 +1,4 @@
-<?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.
@@ -14,38 +13,15 @@
* 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:tx="http://myfaces.apache.org/tobago/extension"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:f="http://java.sun.com/jsf/core">
+function test_colorize() {
+ jQuery("td>span,th>span").css("background-color", "white");
+ jQuery("td:odd").css("background-color", "#ffbbff");
+ jQuery("td:even").css("background-color", "#bbffbb");
+ jQuery("th:odd").css("background-color", "#dd99dd");
+ jQuery("th:even").css("background-color", "#99dd99");
+}
- <tc:page id="page">
- <tc:gridLayoutConstraint width="600px" height="600px"/>
-
- <tc:sheet value="#{sheet.solarArray}" id="sheet" columns="*;*" var="luminary" rows="5">
- <tc:column label="Name" id="name" sortable="true">
- <tc:out value="#{luminary.name}"/>
- </tc:column>
- <tc:column label="Orbit Of" id="orbit">
- <tc:out value="#{luminary.orbit}"/>
- </tc:column>
- </tc:sheet>
-
- <tc:script file="script/tobago-assert.js"/>
- <!--todo-->
- <!--<tc:script onload="TobagoAssert.assertLayout('page:todo', 0, 0, 600, 14);"/>-->
-
- <tc:script>
- jQuery(document).ready(function() {
- jQuery("td>span").css("background-color", "white");
- jQuery("td:odd").css("background-color", "#ffbbff");
- jQuery("td:even").css("background-color", "#bbffbb");
- });
-
- </tc:script>
-
- </tc:page>
-</f:view>
+Tobago.registerListener(test_colorize, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(test_colorize, Tobago.Phase.AFTER_UPDATE);
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-test/src/main/webapp/test/sheet/sheet-simple.xhtml Thu May 21 09:23:10 2015
@@ -38,14 +38,7 @@
<!--todo-->
<!--<tc:script onload="TobagoAssert.assertLayout('page:todo', 0, 0, 600, 14);"/>-->
- <tc:script>
- jQuery(document).ready(function() {
- jQuery("td>span").css("background-color", "white");
- jQuery("td:odd").css("background-color", "#ffbbff");
- jQuery("td:even").css("background-color", "#bbffbb");
- });
-
- </tc:script>
+ <tc:script file="test/sheet/sheet-simple.js"/>
</tc:page>
</f:view>
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties Thu May 21 09:23:10 2015
@@ -146,10 +146,6 @@ SelectOneRadio.preferredWidth=200
Separator.height=14
Separator.withoutLabelHeight=2
-Sheet.headerHeight=20
-Sheet.footerHeight=20
-Sheet.rowHeight=20
-Sheet.rowPadding=5
Sheet.columnSelectorWidth=20
Sheet.cellPaddingWidth=4
Sheet.borderLeft=0
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties Thu May 21 09:23:10 2015
@@ -80,10 +80,6 @@ SelectOneListbox.preferredHeight=75
Separator.height=14
Separator.withoutLabelHeight=1
-Sheet.headerHeight=21
-Sheet.footerHeight=16
-Sheet.rowHeight=21
-Sheet.rowPadding=1
Sheet.cellPaddingWidth=4
TabGroup.headerHeight=21
Modified: myfaces/tobago/branches/tobago-3.0.x/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/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Thu May 21 09:23:10 2015
@@ -33,7 +33,6 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.component.UIReload;
import org.apache.myfaces.tobago.component.UISheet;
import org.apache.myfaces.tobago.component.UIToolBar;
-import org.apache.myfaces.tobago.config.Configurable;
import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
@@ -179,16 +178,6 @@ public class SheetRenderer extends Layou
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
final String sheetId = sheet.getClientId(facesContext);
- Measure sheetHeight;
- if (style.getHeight() == null) {
- // FIXME: nullpointer if height not defined
- LOG.error("no height in parent container, setting to 100");
- sheetHeight = Measure.valueOf(100);
- } else {
- sheetHeight = style.getHeight();
- }
- final Measure footerHeight = getFooterHeight(facesContext, sheet);
- final Measure headerHeight = getHeaderHeight(facesContext, sheet);
final String selectable = sheet.getSelectable();
final Application application = facesContext.getApplication();
@@ -251,22 +240,7 @@ public class SheetRenderer extends Layou
writer.writeClassAttribute(Classes.create(sheet, "bodyTable").getStringValue() + " "
+ BootstrapClass.TABLE.getName() + " " + BootstrapClass.TABLE_HOVER.getName()); // XXX
- if (columnWidths != null) {
- writer.startElement(HtmlElements.COLGROUP, null);
- for (final Integer columnWidth : columnWidths) {
- writer.startElement(HtmlElements.COL, null);
- writer.writeAttribute(HtmlAttributes.WIDTH, columnWidth);
- writer.endElement(HtmlElements.COL);
- }
- writer.endElement(HtmlElements.COLGROUP);
- }
-
-/* XXX this workaround doen't work correctly, because the table has one row more, and the JavaScript code doesn't
-respect that.
- if (showHeader) {
- renderHeaderWorkaround(sheet, hasClickAction, writer, renderedColumnList);
- }
-*/
+ writeColgroup(writer, columnWidths);
// Print the Content
@@ -581,56 +555,25 @@ respect that.
}
}
-/** XXX Simple workaround for bootstrap */
- private void renderHeaderWorkaround(UISheet sheet, boolean hasClickAction, TobagoResponseWriter writer,
- List<AbstractUIColumn> renderedColumnList) throws IOException {
- writer.startElement(HtmlElements.TR, null);
-
- int columnIndex = -1;
- for (final UIColumn column : renderedColumnList) {
- columnIndex++;
-
- writer.startElement(HtmlElements.TH, column);
-
- Markup markup = column instanceof SupportsMarkup ? ((SupportsMarkup) column).getMarkup() : Markup.NULL;
- if (markup == null) {
- markup = Markup.NULL;
- }
- if (columnIndex == 0) {
- markup = markup.add(Markup.FIRST);
- }
- if (hasClickAction) {
- markup = markup.add(Markup.CLICKABLE);
- }
- if (isPure(column)) {
- markup = markup.add(Markup.PURE);
- }
- writer.writeClassAttribute(Classes.create(sheet, "cell", markup));
- final TextAlign align = TextAlign.parse((String) column.getAttributes().get(Attributes.ALIGN));
- if (align != null) {
- final Style alignStyle = new Style();
- alignStyle.setTextAlign(align);
- writer.writeStyleAttribute(alignStyle);
- }
-
- if (column instanceof org.apache.myfaces.tobago.component.UIColumn) {
- org.apache.myfaces.tobago.component.UIColumn c = (org.apache.myfaces.tobago.component.UIColumn) column;
- writer.writeText(c.getLabel());
- } else {
- // todo
+ private void writeColgroup(final TobagoResponseWriter writer, final List<Integer> columnWidths) throws IOException {
+ if (columnWidths != null) {
+ writer.startElement(HtmlElements.COLGROUP, null);
+ for (final Integer columnWidth : columnWidths) {
+ writeCol(writer, columnWidth);
}
-
- writer.endElement(HtmlElements.TH);
+ writeCol(writer, 0); // extra entry for resizing...
+ // TODO: replace 0 later
+ // TODO: the value should be added to the list
+ writer.endElement(HtmlElements.COLGROUP);
}
+ }
- writer.startElement(HtmlElements.TH, null);
- writer.writeClassAttribute(Classes.create(sheet, "cell", Markup.FILLER));
-// writer.write(" ");
- writer.startElement(HtmlElements.DIV, null);
- writer.endElement(HtmlElements.DIV);
- writer.endElement(HtmlElements.TH);
-
- writer.endElement(HtmlElements.TR);
+ private void writeCol(final TobagoResponseWriter writer, final Integer columnWidth) throws IOException {
+ writer.startElement(HtmlElements.COL, null);
+ if (columnWidth != null) {
+ writer.writeAttribute(HtmlAttributes.WIDTH, columnWidth);
+ }
+ writer.endElement(HtmlElements.COL);
}
/**
@@ -726,23 +669,6 @@ respect that.
RenderUtils.decodedStateOfTreeData(facesContext, sheet);
}
- private Measure getHeaderHeight(final FacesContext facesContext, final UISheet sheet) {
- final int rows = sheet.getHeaderGrid() != null ? sheet.getHeaderGrid().getRowCount() : 0;
- return sheet.isShowHeader()
- ? getResourceManager().getThemeMeasure(facesContext, sheet, "headerHeight", Measure.valueOf(20)).multiply(rows)
- : Measure.ZERO;
- }
-
- private Measure getRowHeight(final FacesContext facesContext, final UISheet sheet) {
- return getResourceManager().getThemeMeasure(facesContext, sheet, "rowHeight", Measure.valueOf(20));
- }
-
- private Measure getFooterHeight(final FacesContext facesContext, final UISheet sheet) {
- return sheet.isPagingVisible()
- ? getResourceManager().getThemeMeasure(facesContext, sheet, "footerHeight", Measure.valueOf(20))
- : Measure.ZERO;
- }
-
private Markup markupForLeftCenterRight(final String name) {
if ("left".equals(name)) {
return Markup.LEFT;
@@ -847,15 +773,7 @@ respect that.
writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
writer.writeClassAttribute(Classes.create(sheet, "headerTable table")); // XXX table comes from bootstrap
- if (columnWidths != null) {
- writer.startElement(HtmlElements.COLGROUP, null);
- for (int i = 0; i < columnWidths.size(); i++) {
- writer.startElement(HtmlElements.COL, null);
- writer.writeAttribute(HtmlAttributes.WIDTH, columnWidths.get(i));
- writer.endElement(HtmlElements.COL);
- }
- writer.endElement(HtmlElements.COLGROUP);
- }
+ writeColgroup(writer, columnWidths);
writer.startElement(HtmlElements.TBODY, sheet);
for (int i = 0; i < grid.getRowCount(); i++) {
@@ -1217,27 +1135,6 @@ respect that.
}
@Override
- public Measure getPreferredHeight(final FacesContext facesContext, final Configurable component) {
- final UISheet sheet = (UISheet) component;
- final Measure headerHeight = getHeaderHeight(facesContext, sheet);
- final Measure rowHeight = getRowHeight(facesContext, sheet);
- final Measure footerHeight = getFooterHeight(facesContext, sheet);
- int rows = sheet.getRows();
- if (rows == 0) {
- rows = sheet.getRowCount();
- }
- if (rows == -1) {
- rows = 10; // estimating something to get a valid value...
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(headerHeight + " " + footerHeight + " " + rowHeight + " " + rows);
- }
-
- return headerHeight.add(rowHeight.multiply(rows)).add(footerHeight);
- }
-
- @Override
public void encodeChildren(final FacesContext context, final UIComponent component) throws IOException {
// DO Nothing
}
Modified: myfaces/tobago/branches/tobago-3.0.x/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/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Thu May 21 09:23:10 2015
@@ -252,6 +252,38 @@ Tobago.Sheet.setup2 = function (sheets)
Tobago.Sheet.resetInputFieldSize(jQuery(this));
});
+
+ // synchronize column widths
+ jQuery(sheets).each(function() {
+ var table = jQuery(this);
+
+ // todo make a function
+ var headerToBody = false;
+
+ var body = table.find(".tobago-sheet-bodyTable>colgroup>col");
+ var header = table.find(".tobago-sheet-headerTable>colgroup>col");
+
+ var sourceCols = headerToBody ? header : body;
+ var targetCols = headerToBody ? body : header;
+
+ console.assert(targetCols.length == sourceCols.length, "header and body column number doesn't match"); // @DEV_ONLY
+
+ for (var i = 0; i < sourceCols.length; i++) {
+
+ // if not set, pull the width from a cell (is needed for Chrome)
+ if (sourceCols.eq(i).attr("width") == null) {
+ var correspondingCell
+ = sourceCols.eq(i).parents("table:first").children("tbody").children("tr:first").children("td").eq(i);
+ sourceCols.eq(i).attr("width", correspondingCell.outerWidth())
+ }
+
+ targetCols.eq(i).attr("width", sourceCols.eq(i).attr("width"));
+ }
+
+
+ //COL elemente... // todo
+ });
+
// resize: mouse events
jQuery(sheets).find(".tobago-sheet-headerResize").each(function () {
jQuery(this).click(function () {
@@ -523,18 +555,6 @@ Tobago.Sheet.hidden = function(sheet, id
Tobago.Sheet.prototype.setup = function() {
console.time("[tobago-sheet] setup"); // @DEV_ONLY
- // IE 6+7
- if (Tobago.browser.isMsie67) {
- jQuery(Tobago.Utils.escapeClientId(this.id) + ">div>table>colgroup>col").each(function() {
- Tobago.Sheet.fixIE67ColWidth(jQuery(this));
- });
-
- // to avoid horizontal scroll bar. This value must be removed, when resizing the columns!
- jQuery(Tobago.Utils.escapeClientId(this.id)).find(".tobago-sheet-cell-markup-filler").each(function() {
- jQuery(this).css("width", "0");
- });
- }
-
this.setupPagePaging();
this.setupRowPaging();
@@ -782,16 +802,6 @@ Tobago.Sheet.deselectRow = function(sele
setTimeout(function() {checkbox.prop("checked", false);}, 0);
};
-/**
- * Fixes the wrong computation of col width in IE 6/7: padding will not be handled correctly.
- * @param col A jQuery object
- */
-Tobago.Sheet.fixIE67ColWidth = function(col) {
- var td = col.closest("table").children("tbody").children("tr:first").children("td").eq(col.index());
- var delta = td.outerWidth() - td.width();
- col.attr("width", col.attr("width") - delta);
-};
-
Tobago.Sheet.resetInputFieldSize = function (table) {
var span = table.find("td>div>span");
span.children("input,select").each(function () {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css?rev=1680776&r1=1680775&r2=1680776&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css Thu May 21 09:23:10 2015
@@ -144,6 +144,12 @@ body > form > .navbar-fixed-top + * {
vertical-align: top;
}
+table.tobago-sheet-headerTable>tbody>tr>th:last-child,
+table.tobago-sheet-bodyTable>tbody>tr>td:last-child {
+ padding-left: 0;
+ padding-right: 0;
+}
+
/* tab -------------------------------------------------------------- */
.tobago-tab-content {