diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractOrderedLayout.java | 28 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/GridLayout.java | 23 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Layout.java | 17 |
3 files changed, 67 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 8c2f86926d..b06b2e0871 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -53,6 +53,8 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements */ protected LinkedList<Component> components = new LinkedList<Component>(); + private Alignment defaultComponentAlignment = Alignment.TOP_LEFT; + /* Child component alignments */ /** @@ -147,7 +149,9 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } private void componentAdded(Component c) { - getState().childData.put(c, new ChildComponentData()); + ChildComponentData ccd = new ChildComponentData(); + ccd.alignmentBitmask = getDefaultComponentAlignment().getBitMask(); + getState().childData.put(c, ccd); } /** @@ -417,4 +421,26 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements public void setMargin(MarginInfo marginInfo) { getState().marginsBitmask = marginInfo.getBitMask(); } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Layout.AlignmentHandler#getDefaultComponentAlignment() + */ + @Override + public Alignment getDefaultComponentAlignment() { + return defaultComponentAlignment; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.Layout.AlignmentHandler#setDefaultComponentAlignment(com + * .vaadin.ui.Alignment) + */ + public void setDefaultComponentAlignment(Alignment defaultAlignment) { + defaultComponentAlignment = defaultAlignment; + } + } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index e60d9c676a..60664c8937 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -92,6 +92,7 @@ public class GridLayout extends AbstractLayout implements private Map<Integer, Float> columnExpandRatio = new HashMap<Integer, Float>(); private Map<Integer, Float> rowExpandRatio = new HashMap<Integer, Float>(); + private Alignment defaultComponentAlignment = Alignment.TOP_LEFT; /** * Constructor for a grid of given size (number of columns and rows). @@ -573,6 +574,7 @@ public class GridLayout extends AbstractLayout implements int row2) { this.component = component; childData = new ChildComponentData(); + childData.alignment = getDefaultComponentAlignment().getBitMask(); childData.column1 = column1; childData.row1 = row1; childData.column2 = column2; @@ -1226,4 +1228,25 @@ public class GridLayout extends AbstractLayout implements return new MarginInfo(getState().marginsBitmask); } + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Layout.AlignmentHandler#getDefaultComponentAlignment() + */ + @Override + public Alignment getDefaultComponentAlignment() { + return defaultComponentAlignment; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.Layout.AlignmentHandler#setDefaultComponentAlignment(com + * .vaadin.ui.Alignment) + */ + public void setDefaultComponentAlignment(Alignment defaultAlignment) { + defaultComponentAlignment = defaultAlignment; + } + } diff --git a/server/src/com/vaadin/ui/Layout.java b/server/src/com/vaadin/ui/Layout.java index cd6ffc42d2..dc16b186f2 100644 --- a/server/src/com/vaadin/ui/Layout.java +++ b/server/src/com/vaadin/ui/Layout.java @@ -61,6 +61,23 @@ public interface Layout extends ComponentContainer, Serializable { */ public Alignment getComponentAlignment(Component childComponent); + /** + * Sets the alignment used for new components added to this layout. The + * default is {@link Alignment#TOP_LEFT}. + * + * @param defaultComponentAlignment + * The new default alignment + */ + public void setDefaultComponentAlignment( + Alignment defaultComponentAlignment); + + /** + * Returns the alignment used for new components added to this layout + * + * @return The default alignment + */ + public Alignment getDefaultComponentAlignment(); + } /** |