diff options
author | Artur <artur@vaadin.com> | 2017-04-13 10:25:20 +0300 |
---|---|---|
committer | Aleksi Hietanen <aleksi@vaadin.com> | 2017-04-13 10:25:20 +0300 |
commit | 4454e6bdc13dec8198c9e5e95557fcf59f9f97e4 (patch) | |
tree | e9a37b2b92e709e7f4404ab3eb65d4974e9481df /client | |
parent | 60a6e0282e8e013acb56821f30573c65f1a6c36d (diff) | |
download | vaadin-framework-4454e6bdc13dec8198c9e5e95557fcf59f9f97e4.tar.gz vaadin-framework-4454e6bdc13dec8198c9e5e95557fcf59f9f97e4.zip |
Provide GridLayout size and cell elements to JS and TB (#9019)
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VGridLayout.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VGridLayout.java b/client/src/main/java/com/vaadin/client/ui/VGridLayout.java index f34c7eabde..c8c6cce0f3 100644 --- a/client/src/main/java/com/vaadin/client/ui/VGridLayout.java +++ b/client/src/main/java/com/vaadin/client/ui/VGridLayout.java @@ -88,8 +88,24 @@ public class VGridLayout extends ComplexPanel { setStyleName(CLASSNAME); addStyleName(StyleConstants.UI_LAYOUT); + + publishJSHelpers(getElement()); } + private native void publishJSHelpers(Element root) + /*-{ + var self = this; + root.getRowCount = $entry(function () { + return self.@VGridLayout::getRowCount()(); + }); + root.getColumnCount = $entry(function () { + return self.@VGridLayout::getColumnCount()(); + }); + root.getCell = $entry(function (row,column) { + return self.@VGridLayout::getCellElement(*)(row, column); + }); + }-*/; + private GridLayoutConnector getConnector() { return (GridLayoutConnector) ConnectorMap.get(client) .getConnector(this); @@ -623,6 +639,10 @@ public class VGridLayout extends ComplexPanel { Cell[][] cells; + private int rowCount; + + private int columnCount; + /** * Private helper class. */ @@ -781,6 +801,20 @@ public class VGridLayout extends ComplexPanel { return cells[col][row]; } + private Element getCellElement(int row, int col) { + if (row < 0 || row >= getRowCount() || col < 0 + || col >= getColumnCount()) { + return null; + } + + Cell cell = cells[col][row]; + if (cell == null || cell.slot == null) { + return null; + } + + return cell.slot.getWrapperElement(); + } + /** * Creates a new Cell with the given coordinates. * <p> @@ -882,6 +916,8 @@ public class VGridLayout extends ComplexPanel { } public void setSize(int rows, int cols) { + rowCount = rows; + columnCount = cols; if (cells == null) { cells = new Cell[cols][rows]; } else if (cells.length != cols || cells[0].length != rows) { @@ -897,6 +933,14 @@ public class VGridLayout extends ComplexPanel { } } + private int getRowCount() { + return rowCount; + } + + private int getColumnCount() { + return columnCount; + } + @Override public boolean remove(Widget w) { boolean removed = super.remove(w); |