From 308d75a1d7c3c5c975c90b579fb7d4622bac064a Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Mon, 21 Jan 2013 15:02:56 +0200 Subject: Hide components if width 100% + expand ratio 0 #10783 Change-Id: I5ca5eac5fbfeec744078ebcb83f08192c1bf2af8 --- .../HorizontalRelativeSizeWithoutExpand.html | 27 +++++++++++ .../HorizontalRelativeSizeWithoutExpand.java | 51 +++++++++++++++++++++ .../orderedlayout/OrderedLayoutCases.java | 36 ++++++++++++++- .../orderedlayout/RelativeChildWithoutExpand.html | 46 +++++++++++++++++++ .../VerticalRelativeSizeWithoutExpand.html | 27 +++++++++++ .../VerticalRelativeSizeWithoutExpand.java | 53 ++++++++++++++++++++++ 6 files changed, 238 insertions(+), 2 deletions(-) create mode 100755 uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.html create mode 100755 uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.java create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildWithoutExpand.html create mode 100755 uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.html create mode 100755 uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.html b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.html new file mode 100755 index 0000000000..06de880bcf --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.html @@ -0,0 +1,27 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.orderedlayout.HorizontalRelativeSizeWithoutExpand?restartApplication
screenCapturespacing-and-panel
+ + diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.java b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.java new file mode 100755 index 0000000000..8c5953104f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalRelativeSizeWithoutExpand.java @@ -0,0 +1,51 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Tree; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +public class HorizontalRelativeSizeWithoutExpand extends UI { + + @Override + protected void init(VaadinRequest request) { + + final HorizontalLayout layout = new HorizontalLayout(); + layout.setSizeFull(); + layout.setMargin(true); + layout.setSpacing(true); + setContent(layout); + + Panel panel1 = new Panel("This should not be seen"); + panel1.setSizeFull(); + VerticalLayout verticalLayout1 = new VerticalLayout(); + verticalLayout1.setSizeFull(); + Tree tree = new Tree(); + tree.setSizeFull(); + tree.setContainerDataSource(new BeanItemContainer(String.class)); + String a = "aaaaaaaaaaaaaaaaaaaaaaaa"; + String b = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; + String c = "ccccccccccccccccccccccccccccccccccccccccccccccccc"; + tree.addItem(a); + tree.addItem(b); + tree.addItem(c); + tree.setChildrenAllowed(a, true); + tree.setChildrenAllowed(b, true); + tree.setParent(b, a); + tree.setParent(c, b); + verticalLayout1.addComponent(tree); + panel1.setContent(verticalLayout1); + layout.addComponent(panel1); + + final Panel panel2 = new Panel("This should use all space"); + panel2.setSizeFull(); + + layout.addComponent(panel2); + layout.setExpandRatio(panel2, 1); + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index fe1dfe3e6d..d7dbe11769 100644 --- a/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -179,8 +179,15 @@ public class OrderedLayoutCases extends AbstractTestUI { } while (currentLayout.getComponentCount() > 0) { - newLayout.addComponent(currentLayout - .getComponent(0)); + Component child = currentLayout.getComponent(0); + Alignment alignment = currentLayout + .getComponentAlignment(child); + float expRatio = currentLayout + .getExpandRatio(child); + newLayout.addComponent(child); + newLayout.setExpandRatio(child, expRatio); + newLayout.setComponentAlignment(child, alignment); + } newLayout.setStyleName("theLayout"); @@ -337,6 +344,24 @@ public class OrderedLayoutCases extends AbstractTestUI { setChildState(2, 4, 7); } })); + caseBar.addComponent(new Button("Relative child without expand", + new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + resetState(); + // Width 800px + setState(sizeBar, 0, 3); + // First child 100% wide + setChildState(0, 0, 4); + // Second child expand 1 + setChildState(1, 3, 1); + } + })); + /* + * Hidden for not to avoid changing screenshots, functionality is still + * available by adding case=9 to the query string... + */ + caseBar.getComponent(9).setVisible(false); caseBar.setSpacing(true); @@ -348,6 +373,13 @@ public class OrderedLayoutCases extends AbstractTestUI { getContent().setSizeFull(); getLayout().setSizeFull(); getLayout().setExpandRatio(currentLayout, 1); + + String caseParameter = request.getParameter("case"); + if (caseParameter != null) { + int caseIndex = Integer.parseInt(caseParameter); + Button button = (Button) caseBar.getComponent(caseIndex); + button.click(); + } } private void resetState() { diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildWithoutExpand.html b/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildWithoutExpand.html new file mode 100644 index 0000000000..c7f75ff55a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildWithoutExpand.html @@ -0,0 +1,46 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.orderedlayout.OrderedLayoutCases?case=9
screenCapturefirst-child-hidden-two-visible
selectvaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VNativeSelect[0]/domChild[0]label=0
screenCapturethree-children-visible
selectvaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VNativeSelect[0]/domChild[0]label=1
screenCapturefirst-child-hidden-two-visible-again
+ + diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.html b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.html new file mode 100755 index 0000000000..caf4347b45 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.html @@ -0,0 +1,27 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.orderedlayout.VerticalRelativeSizeWithoutExpand?restartApplication
screenCapturespacing-and-panel
+ + diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java new file mode 100755 index 0000000000..86525da3ef --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.orderedlayout; +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Tree; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * The Application's "main" class + */ +@SuppressWarnings("serial") +public class VerticalRelativeSizeWithoutExpand extends UI { + + @Override + protected void init(VaadinRequest request) { + + final VerticalLayout layout = new VerticalLayout(); + layout.setSizeFull(); + layout.setMargin(true); + layout.setSpacing(true); + setContent(layout); + + Panel panel1 = new Panel("This should not be seen"); + panel1.setSizeFull(); + VerticalLayout verticalLayout1 = new VerticalLayout(); + verticalLayout1.setSizeFull(); + Tree tree = new Tree(); + tree.setSizeFull(); + tree.setContainerDataSource(new BeanItemContainer(String.class)); + String a = "aaaaaaaaaaaaaaaaaaaaaaaa"; + String b = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; + String c = "ccccccccccccccccccccccccccccccccccccccccccccccccc"; + tree.addItem(a); + tree.addItem(b); + tree.addItem(c); + tree.setChildrenAllowed(a, true); + tree.setChildrenAllowed(b, true); + tree.setParent(b, a); + tree.setParent(c, b); + verticalLayout1.addComponent(tree); + panel1.setContent(verticalLayout1); + layout.addComponent(panel1); + + final Panel panel2 = new Panel("This should use all space"); + panel2.setSizeFull(); + + layout.addComponent(panel2); + layout.setExpandRatio(panel2, 1); + + } + +} -- cgit v1.2.3