summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2016-12-12 17:44:54 +0200
committerGitHub <noreply@github.com>2016-12-12 17:44:54 +0200
commit95a61630bb71237acc9614d492ba13939dba146c (patch)
treebeeeb9b83b3a7b0e2c70e0df28979ef48af4355b /server
parente63b51a831676bdcc15b889c1636c0dcccbc0bc0 (diff)
downloadvaadin-framework-95a61630bb71237acc9614d492ba13939dba146c.tar.gz
vaadin-framework-95a61630bb71237acc9614d492ba13939dba146c.zip
VerticalLayout has spacing = true and margin = true by default .
HorizontalLayout has spacing = true and margin = false by default. Fixes vaadin/framework8-issues#526
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractLayout.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/HorizontalLayout.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/LegacyWindow.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/VerticalLayout.java2
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java34
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java10
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java2
7 files changed, 34 insertions, 23 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractLayout.java b/server/src/main/java/com/vaadin/ui/AbstractLayout.java
index d4f8042355..fe073eb687 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractLayout.java
@@ -105,7 +105,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer
*/
protected void writeMargin(Element design, MarginInfo margin,
MarginInfo defMargin, DesignContext context) {
- if (margin.hasAll()) {
+ if (margin.hasAll() || margin.hasNone()) {
DesignAttributeHandler.writeAttribute("margin", design.attributes(),
margin.hasAll(), defMargin.hasAll(), boolean.class,
context);
diff --git a/server/src/main/java/com/vaadin/ui/HorizontalLayout.java b/server/src/main/java/com/vaadin/ui/HorizontalLayout.java
index 4682937ff5..07583c6712 100644
--- a/server/src/main/java/com/vaadin/ui/HorizontalLayout.java
+++ b/server/src/main/java/com/vaadin/ui/HorizontalLayout.java
@@ -33,7 +33,7 @@ public class HorizontalLayout extends AbstractOrderedLayout {
* Constructs an empty HorizontalLayout.
*/
public HorizontalLayout() {
-
+ setSpacing(true);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/LegacyWindow.java b/server/src/main/java/com/vaadin/ui/LegacyWindow.java
index 2705d56486..dda734899d 100644
--- a/server/src/main/java/com/vaadin/ui/LegacyWindow.java
+++ b/server/src/main/java/com/vaadin/ui/LegacyWindow.java
@@ -40,7 +40,7 @@ public class LegacyWindow extends UI {
*/
public LegacyWindow() {
super(new VerticalLayout());
- ((VerticalLayout) getContent()).setMargin(true);
+ ((VerticalLayout) getContent()).setSpacing(false);
}
/**
@@ -50,8 +50,7 @@ public class LegacyWindow extends UI {
* the caption of the window
*/
public LegacyWindow(String caption) {
- super(new VerticalLayout());
- ((VerticalLayout) getContent()).setMargin(true);
+ this();
setCaption(caption);
}
diff --git a/server/src/main/java/com/vaadin/ui/VerticalLayout.java b/server/src/main/java/com/vaadin/ui/VerticalLayout.java
index 7fcf6d438a..d441e8a664 100644
--- a/server/src/main/java/com/vaadin/ui/VerticalLayout.java
+++ b/server/src/main/java/com/vaadin/ui/VerticalLayout.java
@@ -35,6 +35,8 @@ public class VerticalLayout extends AbstractOrderedLayout {
*/
public VerticalLayout() {
setWidth("100%");
+ setSpacing(true);
+ setMargin(true);
}
/**
diff --git a/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java
index b264df1e1a..7aabfe4f7f 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java
@@ -25,7 +25,7 @@ import com.vaadin.ui.Layout.MarginHandler;
public abstract class DeclarativeMarginTestBase<L extends Layout & MarginHandler>
extends DeclarativeTestBase<L> {
- protected void testMargins(String componentTag) {
+ protected void testMargins(String componentTag, boolean defaultMargin) {
for (int i = 0; i < 16; ++i) {
boolean top = (i & 1) == 1;
@@ -35,37 +35,41 @@ public abstract class DeclarativeMarginTestBase<L extends Layout & MarginHandler
MarginInfo m = new MarginInfo(top, right, bottom, left);
- String design = getMarginTag(componentTag, top, right, bottom,
+ String design = getMarginTag(componentTag, defaultMargin, top, right, bottom,
left);
// The assertEquals machinery in DeclarativeTestBase uses bean
// introspection and MarginInfo is not a proper bean. It ends up
// considering *all* MarginInfo objects equal... (#18229)
L layout = read(design);
- Assert.assertEquals(m, layout.getMargin());
+ Assert.assertEquals("For tag: " + design, m, layout.getMargin());
testWrite(design, layout);
}
}
- private String getMarginTag(String componentTag, boolean top, boolean right,
- boolean bottom, boolean left) {
+ private String getMarginTag(String componentTag, boolean defaultMargin, boolean top, boolean right,
+ boolean bottom, boolean left) {
String s = "<" + componentTag + " ";
+ String suffix = defaultMargin ? "=false " : " ";
- if (left && right && top && bottom) {
- s += "margin";
+ if (top == left && top == right && top == bottom) {
+ if(top != defaultMargin)
+ {
+ s += "margin" + suffix;
+ }
} else {
- if (left) {
- s += "margin-left ";
+ if (left != defaultMargin) {
+ s += "margin-left" + suffix;
}
- if (right) {
- s += "margin-right ";
+ if (right != defaultMargin) {
+ s += "margin-right" + suffix;
}
- if (top) {
- s += "margin-top ";
+ if (top != defaultMargin) {
+ s += "margin-top" + suffix;
}
- if (bottom) {
- s += "margin-bottom ";
+ if (bottom != defaultMargin) {
+ s += "margin-bottom" + suffix;
}
}
return s + " />";
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java
index 9764692345..7e84bce54c 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java
@@ -18,6 +18,7 @@ package com.vaadin.tests.server.component.abstractorderedlayout;
import java.util.Arrays;
import java.util.List;
+import org.junit.Ignore;
import org.junit.Test;
import com.vaadin.shared.ui.label.ContentMode;
@@ -40,8 +41,13 @@ public class AbstractOrderedLayoutDeclarativeTest
private List<String> defaultAlignments = Arrays.asList(":top", ":left");
@Test
- public void testMargins() {
- testMargins("vaadin-vertical-layout");
+ public void testMarginsVertical() {
+ testMargins("vaadin-vertical-layout", true);
+ }
+
+ @Test
+ public void testMarginsHorizontal() {
+ testMargins("vaadin-horizontal-layout", false);
}
@Test
diff --git a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
index a9003c23fc..43176a5ce8 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
@@ -38,7 +38,7 @@ public class GridLayoutDeclarativeTest
@Test
public void testMargins() {
- testMargins("vaadin-grid-layout");
+ testMargins("vaadin-grid-layout",false);
}
@Test