myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1766115 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ tobago-theme/tobago-theme-standard/src/main/java/org/apache/m...
Date Fri, 21 Oct 2016 20:04:23 GMT
Author: lofwyr
Date: Fri Oct 21 20:04:23 2016
New Revision: 1766115

URL: http://svn.apache.org/viewvc?rev=1766115&view=rev
Log:
TOBAGO-1578: tc:sheet behavior of showHeader and columns are different to Tobago2
tc:sheet behavior of showHeader and columns are different to Tobago2
* deprecated attribute "forceVerticalScrollBar" removed
* bugfix: <tc:style maxHeight> and <tc:style height> can now used in
<tc:sheet> without shrinking the header.
* bugfix: if no horizontal scrollbar is shown, the position of the bar
is set to 0
* columns of header and body are now among each other if the scroll bar
is on the right
* resizing now work with <tc:columnEvent>
* width of body columns is now updated instant while resizing
[developed by hnoeth]

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.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
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java?rev=1766115&r1=1766114&r2=1766115&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
Fri Oct 21 20:04:23 2016
@@ -81,11 +81,6 @@ public enum Attributes {
   frequency,
   focus,
   focusId,
-  /**
-   * @deprecated since Tobago 3.0.0
-   */
-  @Deprecated
-  forceVerticalScrollbar,
   formatPattern,
   forValue("for"),
   globalOnly,

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java?rev=1766115&r1=1766114&r2=1766115&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java
Fri Oct 21 20:04:23 2016
@@ -128,20 +128,6 @@ public interface SheetTagDeclaration
   void setDirectLinkCount(String directLinkCount);
 
   /**
-   * Flag indicating whether or not this sheet should reserve space for
-   * vertical toolbar when calculating column width's.<br>
-   * Possible values are: <pre>
-   *      'auto'  : sheet try to estimate the need of scrollbar.
-   *      'true'  : space for scrollbar is reserved.
-   *      'false' : no space is reserved.
-   *      </pre>
-   */
-  @TagAttribute
-  @UIComponentTagAttribute(defaultValue = "auto",
-      allowedValues = {"auto", "true", "false"})
-  void setForceVerticalScrollbar(String forceVerticalScrollbar);
-
-  /**
    * Flag indicating whether or not a range of direct paging links should be
    * rendered in the sheet's footer.
    */

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=1766115&r1=1766114&r2=1766115&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
Fri Oct 21 20:04:23 2016
@@ -243,12 +243,7 @@ public class SheetRenderer extends Rende
       writer.writeNameAttribute(sheetId + SUFFIX_WIDTHS);
       writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);
       if (definedColumnWidths) {
-        final List<Integer> encodedWidths = new ArrayList<Integer>(columnWidths.size());
-        for (int i = 0; i < columns.size(); i++) {
-          final Integer width = columnWidths.get(i);
-          encodedWidths.add(width > -1 ? width : 100);
-        }
-        writer.writeAttribute(HtmlAttributes.VALUE, JsonUtils.encode(encodedWidths), false);
+        writer.writeAttribute(HtmlAttributes.VALUE, JsonUtils.encode(columnWidths), false);
       }
       writer.endElement(HtmlElements.INPUT);
 
@@ -256,11 +251,14 @@ public class SheetRenderer extends Rende
       writer.writeIdAttribute(sheetId + SUFFIX_COLUMN_RENDERED);
       writer.writeNameAttribute(sheetId + SUFFIX_COLUMN_RENDERED);
       writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);
-      final String[] encodedRendered = new String[columns.size()];
-      for (int i = 0; i < encodedRendered.length; i++) {
-        encodedRendered[i] = columns.get(i).isRendered() ? "true" : "false";
+      final ArrayList<String> encodedRendered = new ArrayList<String>();
+      for (AbstractUIColumnBase column : columns) {
+        if (!(column instanceof AbstractUIColumnEvent)) {
+          encodedRendered.add(Boolean.toString(column.isRendered()));
+        }
       }
-      writer.writeAttribute(HtmlAttributes.VALUE, JsonUtils.encode(encodedRendered), false);
+      writer.writeAttribute(HtmlAttributes.VALUE,
+          JsonUtils.encode(encodedRendered.toArray(new String[encodedRendered.size()])),
false);
       writer.endElement(HtmlElements.INPUT);
     }
 
@@ -309,7 +307,7 @@ public class SheetRenderer extends Rende
           sheetMarkup.contains(Markup.SMALL) ? BootstrapClass.TABLE_SM : null,
           !autoLayout ? TobagoClass.TABLE_LAYOUT__FIXED : null);
 
-      writeColgroup(writer, columnWidths, columns);
+      writeColgroup(writer, columnWidths, columns, true);
 
       writer.startElement(HtmlElements.TBODY);
       encodeHeaderRows(facesContext, sheet, writer, columns);
@@ -343,7 +341,7 @@ public class SheetRenderer extends Rende
     }
 
     if (!autoLayout) {
-      writeColgroup(writer, columnWidths, columns);
+      writeColgroup(writer, columnWidths, columns, false);
     }
 
     // Print the Content
@@ -699,21 +697,25 @@ public class SheetRenderer extends Rende
       final List<Integer> columnWidths, final List<AbstractUIColumnBase> columns,
final List<Integer> samples) {
     // we have to fill the non rendered positions with some values.
     // on client site, we don't know nothing about the non-rendered columns.
-    for (int i = 0, j = 0; i < columns.size(); i++) {
-      AbstractUIColumnBase column = columns.get(i);
-      Integer newValue;
-      if (j < samples.size()) {
-        newValue = samples.get(j);
-        j++;
-      } else {
-        newValue = null;
-      }
-      if (columnWidths.size() > i) {
-        if (newValue != null) {
-          columnWidths.set(i, newValue);
+    int i = 0;
+    int j = 0;
+    for (AbstractUIColumnBase column : columns) {
+      if (column instanceof org.apache.myfaces.tobago.component.UIColumn) {
+        Integer newValue;
+        if (j < samples.size()) {
+          newValue = samples.get(j);
+          j++;
+        } else {
+          newValue = null;
         }
-      } else {
-        columnWidths.add(newValue != null ? newValue : -1); // -1 means unknown or undefined
+        if (columnWidths.size() > i) {
+          if (newValue != null) {
+            columnWidths.set(i, newValue);
+          }
+        } else {
+          columnWidths.add(newValue != null ? newValue : -1); // -1 means unknown or undefined
+        }
+        i++;
       }
     }
   }
@@ -765,7 +767,6 @@ public class SheetRenderer extends Rende
 
           final UIComponent cellComponent = cell.getComponent();
 
-          writer.startElement(HtmlElements.DIV);
           final CssItem align;
           final String alignString = ComponentUtils.getStringAttribute(column, Attributes.align);
           if(multiHeader && cell.getColumnSpan() > 1) {
@@ -890,47 +891,55 @@ public class SheetRenderer extends Rende
           writer.endElement(HtmlElements.SPAN);
           if (!autoLayout) {
             if (column.isResizable()) {
-              encodeResizing(writer, sheet, j + cell.getColumnSpan() - 1);
+              encodeResizing(writer, sheet, j - offset + cell.getColumnSpan() - 1);
             }
           }
-          writer.endElement(HtmlElements.DIV);
 
           writer.endElement(HtmlElements.TH);
         }
         }
       }
       if (!autoLayout) {
-        // add a filler column
-        writer.startElement(HtmlElements.TH);
-        writer.startElement(HtmlElements.DIV);
-        // todo: is the filler class needed here?
-        writer.writeClassAttribute(Classes.create(sheet, "headerCell", Markup.FILLER));
-        writer.startElement(HtmlElements.SPAN);
-        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.TH);
+        // Add two filler columns. The second one get the size of the scrollBar via JavaScript.
+        encodeHeaderFiller(writer, sheet);
+        encodeHeaderFiller(writer, sheet);
       }
 
       writer.endElement(HtmlElements.TR);
     }
   }
 
+  private void encodeHeaderFiller(final TobagoResponseWriter writer, final UISheet sheet)
throws IOException {
+    writer.startElement(HtmlElements.TH);
+    writer.writeClassAttribute(Classes.create(sheet, "headerCell", Markup.FILLER));
+    writer.startElement(HtmlElements.SPAN);
+    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.TH);
+  }
+
   private void writeColgroup(
       final TobagoResponseWriter writer, final List<Integer> columnWidths,
-      final List<AbstractUIColumnBase> columns) throws IOException {
+      final List<AbstractUIColumnBase> columns, boolean isHeader) throws IOException
{
     writer.startElement(HtmlElements.COLGROUP);
-    for (int i = 0; i < columns.size(); i++) {
-      final AbstractUIColumnBase column =  columns.get(i);
-      if (column.isRendered() && !(column instanceof AbstractUIColumnEvent)) {
-        final Integer width = columnWidths.get(i);
-        writeCol(writer, width >= 0 ? width : null);
+
+    int i = 0;
+    for (AbstractUIColumnBase column : columns) {
+      if (column instanceof org.apache.myfaces.tobago.component.UIColumn) {
+        if (column.isRendered()) {
+          final Integer width = columnWidths.get(i);
+          writeCol(writer, width >= 0 ? width : null);
+        }
+        i++;
       }
     }
     writeCol(writer, null); // extra entry for resizing...
+    if (isHeader) {
+      writeCol(writer, null); // extra entry for headerFiller
+    }
     // TODO: the value should be added to the list
     writer.endElement(HtmlElements.COLGROUP);
   }

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=1766115&r1=1766114&r2=1766115&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
Fri Oct 21 20:04:23 2016
@@ -149,7 +149,7 @@ Tobago.Sheet.setup2 = function (sheets)
         var $bodyTable = $sheet.children("div").children("table");
         var $bodyCol = $bodyTable.children("colgroup").children("col");
 
-        console.assert($headerCol.length == $bodyCol.length, "header and body column number
doesn't match");  // @DEV_ONLY
+        console.assert($headerCol.length - 1 == $bodyCol.length, "header and body column
number doesn't match");  // @DEV_ONLY
 
         var i;
         var sumRelative = 0;
@@ -193,6 +193,7 @@ Tobago.Sheet.setup2 = function (sheets)
         }
       }
     }
+    Tobago.Sheet.addHeaderFillerWidth($sheet);
   });
 
   // resize: mouse events
@@ -202,44 +203,42 @@ Tobago.Sheet.setup2 = function (sheets)
     });
     jQuery(this).mousedown(function (event) {
       // begin resizing
-//      console.log("begin");
-//      console.log(event);
       console.info("down"); // @DEV_ONLY
       var columnIndex = jQuery(this).data("tobago-column-index");
       var body = jQuery("body");
-      var column = jQuery(this).closest("table").children("colgroup").children("col").eq(columnIndex);
-      var filler = column.siblings("col:last");
+      var sheet = jQuery(this).closest(".tobago-sheet");
+      var headerTable = sheet.find(".tobago-sheet-headerTable");
+      var bodyTable = sheet.find(".tobago-sheet-bodyTable");
+      var headerColumn = headerTable.children("colgroup").children("col").eq(columnIndex);
+      var bodyColumn = bodyTable.children("colgroup").children("col").eq(columnIndex);
       var data = {
         columnIndex: columnIndex,
         originalClientX: event.clientX,
-        column: column,
-        originalColumnWidth: parseInt(column.attr("width")),
-        filler: filler,
-        originalFillerWidth: parseInt(filler.attr("width"))
+        headerColumn: headerColumn,
+        bodyColumn: bodyColumn,
+        originalHeaderColumnWidth: parseInt(headerColumn.attr("width"))
       };
+
+      // Set width attribute: Avoid scrollBar position flip to 0.
+      headerTable.css("width", headerTable.outerWidth());
+      bodyTable.css("width", bodyTable.outerWidth());
+
       body.on("mousemove", data, function(event) {
         console.info("move"); // @DEV_ONLY
         var delta = event.clientX - event.data.originalClientX;
-//        console.log("columnResize(): " + event.data.columnIndex + ", delta: " + delta);
-        delta = - Math.min(-delta, event.data.originalColumnWidth - 10);
-        var columnWidth = event.data.originalColumnWidth + delta;
-        var fillerWidth = Math.max(event.data.originalFillerWidth - delta, 0);
-        event.data.column.attr("width", columnWidth);
-        event.data.filler.attr("width", fillerWidth);
-        var sum = 0;
-        column.parent().children("col").each(function() {
-          sum += parseInt(jQuery(this).attr("width"));
-        });
-        Tobago.Sheet.resetInputFieldSize(column.closest("table"));
+        delta = -Math.min(-delta, event.data.originalHeaderColumnWidth - 10);
+        var columnWidth = event.data.originalHeaderColumnWidth + delta;
+        event.data.headerColumn.attr("width", columnWidth);
+        event.data.bodyColumn.attr("width", columnWidth);
+        Tobago.Sheet.resetInputFieldSize(headerColumn.closest("table"));
         Tobago.clearSelection();
         return false;
       });
-      body.one("mouseup", {sheet: jQuery(this).closest(".tobago-sheet")}, function (event)
{
+      body.one("mouseup", function(event) {
         // switch off the mouse move listener
         jQuery("body").off("mousemove");
         console.info("up"); // @DEV_ONLY
         // copy the width values from the header to the body, (and build a list of it)
-        var sheet = event.data.sheet;
         var tokens = sheet.data("tobago-layout").columns;
         var rendered = jQuery.parseJSON(Tobago.Sheet.findHiddenRendered(sheet).val());
         var hidden = Tobago.Sheet.findHiddenWidths(sheet);
@@ -247,8 +246,6 @@ Tobago.Sheet.setup2 = function (sheets)
         if (hidden.length > 0 && hidden.val()) {
           hiddenWidths = jQuery.parseJSON(hidden.val());
         }
-        var headerTable = sheet.find(".tobago-sheet-headerTable");
-        var bodyTable = sheet.find(".tobago-sheet-bodyTable");
         var headerCols = headerTable.find("col");
         var bodyCols = bodyTable.find("col");
         var widths = [];
@@ -296,30 +293,9 @@ Tobago.Sheet.setup2 = function (sheets)
             }
           }
         }
-        // adjust filler space
-        var bodyDiv = bodyTable.parent();
-        var bodyDivWidth = bodyDiv.css("width").replace("px", "") * 1;
-        console.log("usedWidth : " + usedWidth); // @DEV_ONLY
-        console.log("bodyDivWidth : " + bodyDivWidth); // @DEV_ONLY
-        var bodyHeight = bodyDiv.css("height").replace("px", "");
-        var scrollHeight = bodyDiv.prop("scrollHeight");
-        console.log("bodyHeight : " + bodyHeight); // @DEV_ONLY
-        console.log("scrollHeight : " + scrollHeight); // @DEV_ONLY
-
-        var headerFillerWidth = 0;
-        var bodyFillerWidth = 0;
-        if (usedWidth <= bodyDivWidth) {
-          bodyFillerWidth = bodyDivWidth - usedWidth;
-          headerFillerWidth = bodyFillerWidth;
-          bodyTable.css("width", bodyDivWidth);
-        } else {
-          bodyTable.css("width", usedWidth);
-        }
-
-        console.log("SET fillerWidth : " + headerFillerWidth); // @DEV_ONLY
-// TBD filler width seams not to be needed?        widths = widths + headerFillerWidth +
",";
-        bodyCols.last().attr("width", bodyFillerWidth);
-        headerCols.last().attr("width", headerFillerWidth);
+        // Remove width attribute: Avoid scrollBar position flip to 0.
+        headerTable.css("width", "");
+        bodyTable.css("width", "");
 
         // store the width values in a hidden field
         Tobago.Sheet.findHiddenWidths(sheet).val(JSON.stringify(widths));
@@ -476,29 +452,6 @@ Tobago.Sheet.setup2 = function (sheets)
   });
 };
 
-Tobago.Sheet.adjustTableWidth = function(bodyDiv) {
-  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) {
-    var table = bodyDiv.find("table");
-    var bodyDivWidth = bodyDiv.css("width").replace("px", "") * 1;
-    console.log("bodyDivWidth : " + bodyDivWidth); // @DEV_ONLY
-    var tableWidth = table.css("width").replace("px", "") * 1;
-    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);
-    }
-  }
-};
-
 Tobago.Sheet.hideInputOrSubmit = function(input) {
   var output = input.siblings(".tobago-sheet-pagingOutput");
   var changed = output.html() != input.val();
@@ -533,6 +486,19 @@ Tobago.Sheet.findHiddenRendered = functi
   return jQuery(Tobago.Utils.escapeClientId(id));
 };
 
+Tobago.Sheet.addHeaderFillerWidth = function($sheet) {
+  var $headerTable = $sheet.find(".tobago-sheet-headerTable");
+  var $headerCols = $headerTable.find("col");
+  $headerCols.last().attr("width", Tobago.Sheet.getScrollBarSize());
+};
+
+Tobago.Sheet.getScrollBarSize = function() {
+  var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
+      widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
+  $outer.remove();
+  return 100 - widthWithScroll;
+};
+
 Tobago.Sheet.prototype.setup = function() {
   console.time("[tobago-sheet] setup"); // @DEV_ONLY
   this.initReload();

Modified: myfaces/tobago/trunk/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/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css?rev=1766115&r1=1766114&r2=1766115&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
Fri Oct 21 20:04:23 2016
@@ -579,6 +579,11 @@ p.tobago-separator:after {
 
 /* sheet -------------------------------------------------------------- */
 
+.tobago-sheet-header {
+  overflow: hidden;
+  flex-shrink: 0;
+}
+
 .tobago-sheet {
   display: flex;
   flex-direction: column;
@@ -596,6 +601,10 @@ p.tobago-separator:after {
   text-align: justify;
 }
 
+.tobago-sheet-cell-markup-filler {
+  padding: 0 !important; /* fix for IE 11 */
+}
+
 .tobago-sheet-footer {
   text-align: center;
 }
@@ -634,6 +643,10 @@ p.tobago-separator:after {
   table-layout: fixed;
 }
 
+.tobago-sheet-headerCell-markup-filler {
+  border-width: 0 !important;
+}
+
 .tobago-sheet-headerCell {
   position: relative;
 }



Mime
View raw message