]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add class for last frozen column requested by designers (#18590)
authorTaras Hupalo <taras.hupalo@gmail.com>
Wed, 5 Aug 2015 10:09:30 +0000 (13:09 +0300)
committerpatrik <patrik@vaadin.com>
Wed, 12 Aug 2015 13:13:42 +0000 (16:13 +0300)
See https://github.com/vaadin/components/pull/57#issuecomment-127622121
for details

Change-Id: I71e64a420d9fc1ae0d970bdc7eb71fdfb34553c3

client/src/com/vaadin/client/widgets/Escalator.java

index a6247aee127ef59d0ccfbecb5983c48f43c63c19..99f13378d4d3389f2aa53f73857209ae935bd0b9 100644 (file)
@@ -1475,6 +1475,9 @@ public class Escalator extends Widget implements RequiresResize,
                         cellElem.addClassName("frozen");
                         position.set(cellElem, scroller.lastScrollLeft, 0);
                     }
+                    if (columnConfiguration.frozenColumns > 0 && col == columnConfiguration.frozenColumns - 1) {
+                        cellElem.addClassName("last-frozen");
+                    }
                 }
 
                 referenceRow = paintInsertRow(referenceRow, tr, row);
@@ -1732,6 +1735,14 @@ public class Escalator extends Widget implements RequiresResize,
         }
 
         public void setColumnFrozen(int column, boolean frozen) {
+            toggleFrozenColumnClass(column, frozen, "frozen");
+
+            if (frozen) {
+                updateFreezePosition(column, scroller.lastScrollLeft);
+            }
+        }
+
+        private void toggleFrozenColumnClass(int column, boolean frozen, String className) {
             final NodeList<TableRowElement> childRows = root.getRows();
 
             for (int row = 0; row < childRows.getLength(); row++) {
@@ -1742,16 +1753,16 @@ public class Escalator extends Widget implements RequiresResize,
 
                 TableCellElement cell = tr.getCells().getItem(column);
                 if (frozen) {
-                    cell.addClassName("frozen");
+                    cell.addClassName(className);
                 } else {
-                    cell.removeClassName("frozen");
+                    cell.removeClassName(className);
                     position.reset(cell);
                 }
             }
+        }
 
-            if (frozen) {
-                updateFreezePosition(column, scroller.lastScrollLeft);
-            }
+        public void setColumnLastFrozen(int column, boolean lastFrozen) {
+            toggleFrozenColumnClass(column, lastFrozen, "last-frozen");
         }
 
         public void updateFreezePosition(int column, double scrollLeft) {
@@ -4309,6 +4320,17 @@ public class Escalator extends Widget implements RequiresResize,
                     firstUnaffectedCol = oldCount;
                 }
 
+                if (oldCount > 0) {
+                    header.setColumnLastFrozen(oldCount - 1, false);
+                    body.setColumnLastFrozen(oldCount - 1, false);
+                    footer.setColumnLastFrozen(oldCount - 1, false);
+                }
+                if (count > 0) {
+                    header.setColumnLastFrozen(count - 1, true);
+                    body.setColumnLastFrozen(count - 1, true);
+                    footer.setColumnLastFrozen(count - 1, true);
+                }
+
                 for (int col = firstAffectedCol; col < firstUnaffectedCol; col++) {
                     header.setColumnFrozen(col, frozen);
                     body.setColumnFrozen(col, frozen);