diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-20 19:29:04 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-08-22 13:58:50 +0300 |
commit | 667ef9c144bf3522100e5c8eac4d76a3c4faf65b (patch) | |
tree | 186994e13b55cda64fc5df96b5464d0905a8006b /shared | |
parent | 514bffe7a6aa2c599ab9f4ba239295d63f229125 (diff) | |
download | vaadin-framework-667ef9c144bf3522100e5c8eac4d76a3c4faf65b.tar.gz vaadin-framework-667ef9c144bf3522100e5c8eac4d76a3c4faf65b.zip |
Refactored margin handlers (#8292)
Only layouts actually supporting margins now implement MarginHandler
CssLayout should be simplified before 7.0.0 so margin support was removed. GridLayout, VerticalLayout and HorizontalLayout were the only other layouts which actually supported margin.
MarginInfo is now passed directly in the state.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/src/com/vaadin/shared/ui/AbstractLayoutState.java | 9 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/ui/MarginInfo.java (renamed from shared/src/com/vaadin/shared/ui/VMarginInfo.java) | 17 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java | 9 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java | 10 |
4 files changed, 29 insertions, 16 deletions
diff --git a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java index 675d11d0b7..4fc865626c 100644 --- a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java @@ -18,14 +18,5 @@ package com.vaadin.shared.ui; import com.vaadin.shared.ComponentState; public class AbstractLayoutState extends ComponentState { - private int marginsBitmask; - - public int getMarginsBitmask() { - return marginsBitmask; - } - - public void setMarginsBitmask(int marginsBitmask) { - this.marginsBitmask = marginsBitmask; - } }
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/VMarginInfo.java b/shared/src/com/vaadin/shared/ui/MarginInfo.java index 9e9e0a4bb4..21e52f258a 100644 --- a/shared/src/com/vaadin/shared/ui/VMarginInfo.java +++ b/shared/src/com/vaadin/shared/ui/MarginInfo.java @@ -18,8 +18,7 @@ package com.vaadin.shared.ui; import java.io.Serializable; -@SuppressWarnings("serial") -public class VMarginInfo implements Serializable { +public class MarginInfo implements Serializable { private static final int TOP = 1; private static final int RIGHT = 2; @@ -28,11 +27,15 @@ public class VMarginInfo implements Serializable { private int bitMask; - public VMarginInfo(int bitMask) { + public MarginInfo(boolean enabled) { + this(enabled, enabled, enabled, enabled); + } + + public MarginInfo(int bitMask) { this.bitMask = bitMask; } - public VMarginInfo(boolean top, boolean right, boolean bottom, boolean left) { + public MarginInfo(boolean top, boolean right, boolean bottom, boolean left) { setMargins(top, right, bottom, left); } @@ -44,7 +47,7 @@ public class VMarginInfo implements Serializable { bitMask += left ? LEFT : 0; } - public void setMargins(VMarginInfo marginInfo) { + public void setMargins(MarginInfo marginInfo) { bitMask = marginInfo.bitMask; } @@ -78,11 +81,11 @@ public class VMarginInfo implements Serializable { @Override public boolean equals(Object obj) { - if (!(obj instanceof VMarginInfo)) { + if (!(obj instanceof MarginInfo)) { return false; } - return ((VMarginInfo) obj).bitMask == bitMask; + return ((MarginInfo) obj).bitMask == bitMask; } @Override diff --git a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java index d2e685d8cb..381a6a7f85 100644 --- a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java @@ -21,6 +21,7 @@ public class GridLayoutState extends AbstractLayoutState { private boolean spacing = false; private int rows = 0; private int columns = 0; + private int marginsBitmask = 0; public boolean isSpacing() { return spacing; @@ -30,6 +31,14 @@ public class GridLayoutState extends AbstractLayoutState { this.spacing = spacing; } + public int getMarginsBitmask() { + return marginsBitmask; + } + + public void setMarginsBitmask(int marginsBitmask) { + this.marginsBitmask = marginsBitmask; + } + public int getRows() { return rows; } diff --git a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java index 235c9eab13..3fa2ad771c 100644 --- a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java @@ -27,6 +27,8 @@ public class AbstractOrderedLayoutState extends AbstractLayoutState { public HashMap<Connector, ChildComponentData> childData = new HashMap<Connector, ChildComponentData>(); + private int marginsBitmask = 0; + public static class ChildComponentData implements Serializable { private int alignmentBitmask = AlignmentInfo.TOP_LEFT.getBitMask(); private float expandRatio = 0.0f; @@ -65,4 +67,12 @@ public class AbstractOrderedLayoutState extends AbstractLayoutState { this.spacing = spacing; } + public int getMarginsBitmask() { + return marginsBitmask; + } + + public void setMarginsBitmask(int marginsBitmask) { + this.marginsBitmask = marginsBitmask; + } + }
\ No newline at end of file |