Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,77 @@ public void testConstructor1() {
// Create Margin with "all"
Margin margin = new Margin(Size.SMALL);
Assert.assertEquals("Incorrect all margin returned", Size.SMALL, margin.getMargin());
Assert.assertEquals("Incorrect top margin returned", null, margin.getTop());
Assert.assertEquals("Incorrect right margin returned", null, margin.getRight());
Assert.assertEquals("Incorrect bottom margin returned", null, margin.getBottom());
Assert.assertEquals("Incorrect left margin returned", null, margin.getLeft());

Assert.assertEquals("Incorrect all margin returned", -1, margin.getAll());
Assert.assertEquals("Incorrect north margin returned", -1, margin.getNorth());
Assert.assertEquals("Incorrect east margin returned", -1, margin.getEast());
Assert.assertEquals("Incorrect south margin returned", -1, margin.getSouth());
Assert.assertEquals("Incorrect west margin returned", -1, margin.getWest());
}

@Test
public void testConstructor2() {
// Create Margin for all sides
Margin margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
Assert.assertEquals("Incorrect all margin returned", null, margin.getMargin());
Assert.assertEquals("Incorrect top margin returned", Size.SMALL, margin.getTop());
Assert.assertEquals("Incorrect right margin returned", Size.MEDIUM, margin.getRight());
Assert.assertEquals("Incorrect bottom margin returned", Size.LARGE, margin.getBottom());
Assert.assertEquals("Incorrect left margin returned", Size.XL, margin.getLeft());

Assert.assertEquals("Incorrect all margin returned", -1, margin.getAll());
Assert.assertEquals("Incorrect north margin returned", -1, margin.getNorth());
Assert.assertEquals("Incorrect east margin returned", -1, margin.getEast());
Assert.assertEquals("Incorrect south margin returned", -1, margin.getSouth());
Assert.assertEquals("Incorrect west margin returned", -1, margin.getWest());
}

// Deprecated constructors
@Test
public void testConstructor3() {
// Create Margin with "all"
int intSize = 6;
Size size = SpaceUtil.intToSize(intSize);
Margin margin = new Margin(6);
Assert.assertEquals("Incorrect all margin returned", intSize, margin.getAll());
Assert.assertEquals("Incorrect all margin returned", size, margin.getMargin());
Assert.assertEquals("Incorrect north margin returned", -1, margin.getNorth());
Assert.assertEquals("Incorrect east margin returned", -1, margin.getEast());
Assert.assertEquals("Incorrect south margin returned", -1, margin.getSouth());
Assert.assertEquals("Incorrect west margin returned", -1, margin.getWest());

Assert.assertEquals("Incorrect all margin returned", size, margin.getMargin());
Assert.assertEquals("Incorrect north margin returned", null, margin.getTop());
Assert.assertEquals("Incorrect east margin returned", null, margin.getRight());
Assert.assertEquals("Incorrect south margin returned", null, margin.getBottom());
Assert.assertEquals("Incorrect west margin returned", null, margin.getLeft());
}

@Test
public void testConstructor2() {
public void testConstructor4() {
// Create Margin for all sides
Margin margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
final int north = 1;
final int east = 5;
final int south = 9;
final int west = 17;

Margin margin = new Margin(north, east, south, west);

Assert.assertEquals("Incorrect north margin returned", -1, margin.getAll());
Assert.assertEquals("Incorrect north margin returned", north, margin.getNorth());
Assert.assertEquals("Incorrect east margin returned", east, margin.getEast());
Assert.assertEquals("Incorrect south margin returned", south, margin.getSouth());
Assert.assertEquals("Incorrect west margin returned", west, margin.getWest());

Assert.assertEquals("Incorrect all margin returned", null, margin.getMargin());
Assert.assertEquals("Incorrect north margin returned", Size.SMALL, margin.getTop());
Assert.assertEquals("Incorrect east margin returned", Size.MEDIUM, margin.getRight());
Assert.assertEquals("Incorrect south margin returned", Size.LARGE, margin.getBottom());
Assert.assertEquals("Incorrect west margin returned", Size.XL, margin.getLeft());
Assert.assertEquals("Incorrect north margin returned", SpaceUtil.intToSize(north), margin.getTop());
Assert.assertEquals("Incorrect east margin returned", SpaceUtil.intToSize(east), margin.getRight());
Assert.assertEquals("Incorrect south margin returned", SpaceUtil.intToSize(south), margin.getBottom());
Assert.assertEquals("Incorrect west margin returned", SpaceUtil.intToSize(west), margin.getLeft());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void testMarginAccessors() {
WCollapsible collapsible = new WCollapsible(new WText(""), "",
WCollapsible.CollapsibleMode.CLIENT);
assertAccessorsCorrect(collapsible, WCollapsible::getMargin, WCollapsible::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void testTypeAccessors() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WDefinitionList(), WDefinitionList::getMargin, WDefinitionList::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testTitleAccessors() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WFieldLayout(), WFieldLayout::getMargin, WFieldLayout::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testMandatoryWithMessage() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WFieldSet(""), WFieldSet::getMargin, WFieldSet::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public void testModeAccessors() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WFigure(new WText(), ""), WFigure::getMargin, WFigure::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testConstructorInvalidType4() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WHeading(HeadingLevel.H1, "test"), WHeading::getMargin, WHeading::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testRowsAccessors() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WMenu(), WMenu::getMargin, WMenu::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public void testModeAccessors() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WSection(""), WSection::getMargin, WSection::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public void testSetShowHeadOnly() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WTabSet(), WTabSet::getMargin, WTabSet::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void testRenderFootersAccessors() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WTable(), WTable::getMargin, WTable::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testTypeNull() {
@Test
public void testMarginAccessors() {
assertAccessorsCorrect(new WTree(), WTree::getMargin, WTree::setMargin,
null, new Margin(1), new Margin(2));
null, new Margin(Size.SMALL), new Margin(Size.MEDIUM));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.EAGER);
assertXpathNotExists("//ui:collapsible/ui:margin", collapsible);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
collapsible.setMargin(margin);
assertXpathNotExists("//ui:collapsible/ui:margin", collapsible);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WDefinitionList section = new WDefinitionList();
assertXpathNotExists("//ui:definitionlist/ui:margin", section);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
section.setMargin(margin);
assertXpathNotExists("//ui:definitionlist/ui:margin", section);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WFieldLayout layout = new WFieldLayout();
assertXpathNotExists("//ui:fieldlayout/ui:margin", layout);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
layout.setMargin(margin);
assertXpathNotExists("//ui:fieldlayout/ui:margin", layout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WFieldSet fieldSet = new WFieldSet("");
assertXpathNotExists("//ui:fieldset/ui:margin", fieldSet);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
fieldSet.setMargin(margin);
assertXpathNotExists("//ui:fieldset/ui:margin", fieldSet);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WFigure figure = new WFigure(new WText(FIGURE_CONTENT), FIGURE_HEADING);
assertXpathNotExists("//ui:figure/ui:margin", figure);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
figure.setMargin(margin);
assertXpathNotExists("//ui:figure/ui:margin", figure);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WHeading heading = new WHeading(HeadingLevel.H1, "test");
assertXpathNotExists("//ui:heading/ui:margin", heading);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
heading.setMargin(margin);
assertXpathNotExists("//ui:heading/ui:margin", heading);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
list.setRepeatedComponent(new WText());
assertXpathNotExists("//ui:panel/ui:margin", list);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
list.setMargin(margin);
assertXpathNotExists("//ui:panel/ui:margin", list);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc

assertXpathNotExists("//ui:menu/ui:margin", menu);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
menu.setMargin(margin);
assertXpathNotExists("//ui:menu/ui:margin", menu);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WPanel panel = new WPanel();
assertXpathNotExists("//ui:panel/ui:margin", panel);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
panel.setMargin(margin);
assertXpathNotExists("//ui:panel/ui:margin", panel);

Expand All @@ -164,26 +164,10 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@south", panel);
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@west", panel);

margin = new Margin(0, 0, 0, 0);
margin = new Margin(null, null, null, null);
panel.setMargin(margin);
assertXpathNotExists("//ui:panel/ui:margin", panel);

margin = new Margin(1, 0, 0, 0);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);

margin = new Margin(0, 1, 0, 0);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);

margin = new Margin(0, 0, 1, 0);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);

margin = new Margin(0, 0, 0, 1);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);

margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
panel.setMargin(margin);
assertSchemaMatch(panel);
Expand All @@ -193,5 +177,4 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
assertXpathEvaluatesTo("lg", "//ui:panel/ui:margin/@south", panel);
assertXpathEvaluatesTo("xl", "//ui:panel/ui:margin/@west", panel);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.bordertech.wcomponents.Size;
import com.github.bordertech.wcomponents.WColumn;
import com.github.bordertech.wcomponents.WRow;
import com.github.bordertech.wcomponents.util.SpaceUtil;
import java.io.IOException;
import org.junit.Assert;
import org.custommonkey.xmlunit.exceptions.XpathException;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc

assertXpathNotExists("//ui:row/ui:margin", row);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
row.setMargin(margin);
assertXpathNotExists("//ui:row/ui:margin", row);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
WSection section = new WSection("");
assertXpathNotExists("//ui:section/ui:margin", section);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
section.setMargin(margin);
assertXpathNotExists("//ui:section/ui:margin", section);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc

assertXpathNotExists("//ui:tabset/ui:margin", tabSet);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
tabSet.setMargin(margin);
assertXpathNotExists("//ui:tabset/ui:margin", tabSet);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public void testRenderedWithMargins() throws IOException, SAXException, XpathExc
table.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
assertXpathNotExists("//ui:table/ui:margin", table);

Margin margin = new Margin(0);
Margin margin = new Margin(null);
table.setMargin(margin);
assertXpathNotExists("//ui:table/ui:margin", table);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.bordertech.wcomponents.examples;

import com.github.bordertech.wcomponents.HeadingLevel;
import com.github.bordertech.wcomponents.Size;
import com.github.bordertech.wcomponents.WButton;
import com.github.bordertech.wcomponents.WCheckBox;
import com.github.bordertech.wcomponents.WContainer;
Expand Down Expand Up @@ -136,7 +137,7 @@ private void init() {
addTab(sampleTabContent("Content 4"), "Tab 4 (lazy)", WTabSet.TAB_MODE_LAZY);
addTab(sampleTabContent("Content 5"), "Tab 5 (dynamic)", WTabSet.TAB_MODE_DYNAMIC);
addTab(sampleTabContent("Content 6"), "Tab 6 (eager)", WTabSet.TAB_MODE_EAGER);
setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0));
setMargin(new com.github.bordertech.wcomponents.Margin(Size.ZERO, Size.ZERO, Size.LARGE, Size.ZERO));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.bordertech.wcomponents.ActionEvent;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.Size;
import com.github.bordertech.wcomponents.WButton;
import com.github.bordertech.wcomponents.WCheckBox;
import com.github.bordertech.wcomponents.WContainer;
Expand Down Expand Up @@ -129,7 +130,7 @@ private WFieldSet getButtonControls(final WValidationErrors errors) {
layout.addField("Open in a new window", cbOpenNew);
layout.addField("setImage ('/image/attachment.png')", cbSetImage);
layout.addField("Image Position", ddImagePosition);
layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 6, 0));
layout.setMargin(new com.github.bordertech.wcomponents.Margin(Size.ZERO, Size.ZERO, Size.MEDIUM, Size.ZERO));

// Apply Button
WButton apply = new WButton("Apply");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.bordertech.wcomponents.HeadingLevel;
import com.github.bordertech.wcomponents.MessageContainer;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.Size;
import com.github.bordertech.wcomponents.WAjaxControl;
import com.github.bordertech.wcomponents.WButton;
import com.github.bordertech.wcomponents.WCancelButton;
Expand Down Expand Up @@ -427,7 +428,7 @@ private SelectPersonPanel() {

final WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
buttonPanel.setLayout(new BorderLayout());
buttonPanel.setMargin(new com.github.bordertech.wcomponents.Margin(12, 0, 0, 0));
buttonPanel.setMargin(new com.github.bordertech.wcomponents.Margin(Size.LARGE, Size.ZERO, Size.ZERO, Size.ZERO));
add(buttonPanel);
buttonPanel.add(cancelButton, BorderLayout.WEST);
buttonPanel.add(selectButton, BorderLayout.EAST);
Expand Down Expand Up @@ -557,7 +558,7 @@ private static final class SearchFieldSet extends WFieldSet {
*/
private SearchFieldSet() {
super("Search for person");
setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0));
setMargin(new com.github.bordertech.wcomponents.Margin(Size.ZERO, Size.ZERO, Size.LARGE, Size.ZERO));
firstName.setMandatory(true);
WFieldLayout fieldLayout = new WFieldLayout();
add(fieldLayout);
Expand Down
Loading