Reviewers: rdayal,
Description:
Adding a method to DockLayoutPanel to get the size of a child widget.
Issue: 4613
Author: tuckerpmt
Reviewer: jlabanca
Please review this at http://gwt-code-reviews.appspot.com/1705803/
Affected files:
M user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
M user/test/com/google/gwt/user/client/ui/DockLayoutPanelTest.java
Index: user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java (revision
10965)
+++ user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java (working
copy)
@@ -283,6 +283,7 @@
* @param child the widget to be queried
* @return the widget's layout direction, or <code>null</code> if it is
not a
* child of this panel
+ * @throws AssertionError if the widget is not a child and assertions
are enabled
*/
public Direction getWidgetDirection(Widget child) {
assertIsChild(child);
@@ -290,6 +291,22 @@
return null;
}
return ((LayoutData) child.getLayoutData()).direction;
+ }
+
+ /**
+ * Gets the layout size of the given child widget.
+ *
+ * @param child the widget to be queried
+ * @return the widget's layout size, or <code>null</code> if it is not a
child of
+ * this panel
+ * @throws AssertionError if the widget is not a child and assertions
are enabled
+ */
+ public Double getWidgetSize(Widget child) {
+ assertIsChild(child);
+ if (child.getParent() != this) {
+ return null;
+ }
+ return ((LayoutData) child.getLayoutData()).size;
}
/**
Index: user/test/com/google/gwt/user/client/ui/DockLayoutPanelTest.java
===================================================================
--- user/test/com/google/gwt/user/client/ui/DockLayoutPanelTest.java
(revision 10965)
+++ user/test/com/google/gwt/user/client/ui/DockLayoutPanelTest.java
(working copy)
@@ -160,6 +160,13 @@
assertPhysicalPaternity(panel, widget);
}
+ public void testGetWidgetSize() {
+ DockLayoutPanel panel = createDockLayoutPanel();
+ Widget widget = new Label();
+ panel.addEast(widget, 123.4);
+ assertEquals(123.4, panel.getWidgetSize(widget), 0.1);
+ }
+
public void testInsertLineEnd() {
DockLayoutPanel panel = createDockLayoutPanel();
Widget widget = new Label();
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors