diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-09-07 16:31:16 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-09-07 17:12:24 +0300 |
commit | 1fb7d999a09bea25256eef0e9837523c7c81841f (patch) | |
tree | 62e239d911bdc064a07621a4b4203c54c7c11349 /server/src/com | |
parent | 544152d1adc3a098445f7b11b4651fcc3c2f13bc (diff) | |
download | vaadin-framework-1fb7d999a09bea25256eef0e9837523c7c81841f.tar.gz vaadin-framework-1fb7d999a09bea25256eef0e9837523c7c81841f.zip |
Commit Pekka's patch for #8030 ((Component...) constructor for layouts) and #5422 (addComponents(Component...) for layouts) with minor formatting/javadoc changes
Diffstat (limited to 'server/src/com')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractOrderedLayout.java | 14 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/CssLayout.java | 31 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/FormLayout.java | 22 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/GridLayout.java | 31 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/HorizontalLayout.java | 17 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/VerticalLayout.java | 16 |
6 files changed, 123 insertions, 8 deletions
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index fb345d30ec..cb3d9cfe9f 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -56,7 +56,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements /* Child component alignments */ /** - * Mapping from components to alignments (horizontal + vertical). + * Constructs an empty AbstractOrderedLayout. */ public AbstractOrderedLayout() { registerRpc(rpc); @@ -113,6 +113,18 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } /** + * Adds the given components in the given order to the container. + * + * @param components + * The components to add. + */ + public void addComponents(Component... components) { + for (Component c : components) { + addComponent(c); + } + } + + /** * Adds a component into indexed position in this container. * * @param c diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index 9ac29c4deb..401eafe6e9 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -84,13 +84,29 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { */ protected LinkedList<Component> components = new LinkedList<Component>(); + /** + * Constructs an empty CssLayout. + */ public CssLayout() { registerRpc(rpc); } /** + * Constructs a CssLayout with the given components in the given order. + * + * @see #addComponents(Component...) + * + * @param children + * Components to add to the container. + */ + public CssLayout(Component... children) { + this(); + addComponents(children); + } + + /** * Add a component into this container. The component is added to the right - * or under the previous component. + * or below the previous component. * * @param c * the component to be added. @@ -110,6 +126,19 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } /** + * Adds the given components into this container. Each component is added to + * the right or below the previous component. + * + * @param components + * The components to add. + */ + public void addComponents(Component... components) { + for (Component c : components) { + addComponent(c); + } + } + + /** * Adds a component into this container. The component is added to the left * or on top of the other components. * diff --git a/server/src/com/vaadin/ui/FormLayout.java b/server/src/com/vaadin/ui/FormLayout.java index 15ea478597..4df9e8f3c0 100644 --- a/server/src/com/vaadin/ui/FormLayout.java +++ b/server/src/com/vaadin/ui/FormLayout.java @@ -22,12 +22,9 @@ import com.vaadin.shared.ui.MarginInfo; * FormLayout is used by {@link Form} to layout fields. It may also be used * separately without {@link Form}. * - * FormLayout is a close relative to vertical {@link OrderedLayout}, but in - * FormLayout caption is rendered on left side of component. Required and - * validation indicators are between captions and fields. - * - * FormLayout does not currently support some advanced methods from - * OrderedLayout like setExpandRatio and setComponentAlignment. + * FormLayout is a close relative of {@link VerticalLayout}, but in FormLayout + * captions are rendered to the left of their respective components. Required + * and validation indicators are shown between the captions and the fields. * * FormLayout by default has component spacing on. Also margin top and margin * bottom are by default on. @@ -42,4 +39,17 @@ public class FormLayout extends AbstractOrderedLayout { setWidth(100, UNITS_PERCENTAGE); } + /** + * Constructs a FormLayout and adds the given components to it. + * + * @see AbstractOrderedLayout#addComponents(Component...) + * + * @param children + * Components to add to the FormLayout + */ + public FormLayout(Component... children) { + this(); + addComponents(children); + } + } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index de167962e7..566bd812a3 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -140,6 +140,24 @@ public class GridLayout extends AbstractLayout implements this(1, 1); } + /** + * Constructs a GridLayout of given size (number of columns and rows) and + * adds the given components in order to the grid. + * + * @see #addComponents(Component...) + * + * @param columns + * Number of columns in the grid. + * @param rows + * Number of rows in the grid. + * @param children + * Components to add to the grid. + */ + public GridLayout(int columns, int rows, Component... children) { + this(columns, rows); + addComponents(children); + } + @Override protected GridLayoutState getState() { return (GridLayoutState) super.getState(); @@ -258,6 +276,19 @@ public class GridLayout extends AbstractLayout implements } /** + * Adds the given components to the grid starting from the current cursor + * position. + * + * @param components + * Components to add. + */ + public void addComponents(Component... components) { + for (Component c : components) { + this.addComponent(c); + } + } + + /** * Tests if the given area overlaps with any of the items already on the * grid. * diff --git a/server/src/com/vaadin/ui/HorizontalLayout.java b/server/src/com/vaadin/ui/HorizontalLayout.java index 9207b59353..3797d5252a 100644 --- a/server/src/com/vaadin/ui/HorizontalLayout.java +++ b/server/src/com/vaadin/ui/HorizontalLayout.java @@ -27,8 +27,25 @@ package com.vaadin.ui; @SuppressWarnings("serial") public class HorizontalLayout extends AbstractOrderedLayout { + /** + * Constructs an empty HorizontalLayout. + */ public HorizontalLayout() { } + /** + * Constructs a HorizontalLayout with the given components. The components + * are added in the given order. + * + * @see AbstractOrderedLayout#addComponents(Component...) + * + * @param children + * The components to add. + */ + public HorizontalLayout(Component... children) { + this(); + addComponents(children); + } + } diff --git a/server/src/com/vaadin/ui/VerticalLayout.java b/server/src/com/vaadin/ui/VerticalLayout.java index 0a13ca9a36..ba07603166 100644 --- a/server/src/com/vaadin/ui/VerticalLayout.java +++ b/server/src/com/vaadin/ui/VerticalLayout.java @@ -28,8 +28,24 @@ package com.vaadin.ui; @SuppressWarnings("serial") public class VerticalLayout extends AbstractOrderedLayout { + /** + * Constructs an empty VerticalLayout. + */ public VerticalLayout() { setWidth("100%"); } + /** + * Constructs a VerticalLayout with the given components. The components are + * added in the given order. + * + * @see AbstractOrderedLayout#addComponents(Component...) + * + * @param children + * The components to add. + */ + public VerticalLayout(Component... children) { + this(); + addComponents(children); + } } |