123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- package com.vaadin.tests.components.absolutelayout;
-
- import com.vaadin.annotations.Theme;
- import com.vaadin.server.VaadinRequest;
- import com.vaadin.shared.ui.MarginInfo;
- import com.vaadin.tests.components.AbstractReindeerTestUI;
- import com.vaadin.ui.AbsoluteLayout;
- import com.vaadin.ui.Component;
- import com.vaadin.ui.HorizontalLayout;
- import com.vaadin.v7.ui.Table;
-
- /**
- * Tests how AbsoluteLayout handles relative sized contents.
- *
- * @author Vaadin Ltd
- */
- @Theme("tests-tickets")
- public class AbsoluteLayoutRelativeSizeContent extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- HorizontalLayout level1 = new HorizontalLayout(
- createComparisonTableOnFixed(), createTableOnFixed(),
- createHalfTableOnFixed(), createHalfTableAndFixedTableOnFixed(),
- createHalfTableOnFull());
- level1.setSpacing(true);
- level1.setWidth(100, Unit.PERCENTAGE);
- level1.setExpandRatio(
- level1.getComponent(level1.getComponentCount() - 1), 1);
- level1.setMargin(new MarginInfo(true, false, false, false));
-
- HorizontalLayout level2 = new HorizontalLayout(createFullOnFixed(),
- createFullOnFull());
- level2.setSpacing(true);
- level2.setWidth(100, Unit.PERCENTAGE);
- level2.setExpandRatio(
- level2.getComponent(level2.getComponentCount() - 1), 1);
- level2.setMargin(new MarginInfo(true, false, false, false));
-
- addComponent(level1);
- addComponent(level2);
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of fixed size that contains a
- * full-sized {@link Table} that has been forced to full size with css.
- * Represents the workaround given for this ticket.
- *
- * @return the created layout
- */
- private Component createComparisonTableOnFixed() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setWidth(200, Unit.PIXELS);
- absoluteLayout.setHeight(200, Unit.PIXELS);
- absoluteLayout.setCaption("comparison table in full size");
-
- Table table = new Table();
- table.setSizeFull();
- table.setId("comparison-table");
- absoluteLayout.addComponent(table, "top:0;bottom:0;left:0;right:0;");
- return absoluteLayout;
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of fixed size that contains a
- * full-sized {@link Table}.
- *
- * @return the created layout
- */
- private Component createTableOnFixed() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setWidth(200, Unit.PIXELS);
- absoluteLayout.setHeight(200, Unit.PIXELS);
- absoluteLayout.setCaption("full-sized table expected");
-
- Table table = new Table();
- table.setSizeFull();
- table.setId("full-table");
- absoluteLayout.addComponent(table);
- return absoluteLayout;
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of fixed size that contains a
- * half-sized {@link Table}.
- *
- * @return the created layout
- */
- private Component createHalfTableOnFixed() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setWidth(200, Unit.PIXELS);
- absoluteLayout.setHeight(200, Unit.PIXELS);
- absoluteLayout.setCaption("half-sized table expected");
-
- Table table = new Table();
- table.setWidth(50, Unit.PERCENTAGE);
- table.setHeight(50, Unit.PERCENTAGE);
- table.setId("half-table");
- absoluteLayout.addComponent(table);
- return absoluteLayout;
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of fixed size that contains a
- * half-sized {@link Table} and a fixed size {@link Table}.
- *
- * @return the created layout
- */
- private Component createHalfTableAndFixedTableOnFixed() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setWidth(200, Unit.PIXELS);
- absoluteLayout.setHeight(200, Unit.PIXELS);
- absoluteLayout.setCaption("half-sized and tiny expected");
-
- Table table = new Table();
- table.setWidth(50, Unit.PERCENTAGE);
- table.setHeight(50, Unit.PERCENTAGE);
- table.setId("halfwithtiny-table");
- absoluteLayout.addComponent(table);
-
- Table tableTiny = new Table();
- tableTiny.setWidth(50, Unit.PIXELS);
- tableTiny.setHeight(50, Unit.PIXELS);
- absoluteLayout.addComponent(tableTiny, "right:50;");
- return absoluteLayout;
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of full size that contains a half-sized
- * {@link Table}.
- *
- * @return the created layout
- */
- private Component createHalfTableOnFull() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setSizeFull();
- absoluteLayout.setId("halfinfull-layout");
- absoluteLayout.setCaption("half-sized table expected");
-
- Table table = new Table();
- table.setWidth(50, Unit.PERCENTAGE);
- table.setHeight(50, Unit.PERCENTAGE);
- table.setId("halfinfull-table");
- absoluteLayout.addComponent(table);
- return absoluteLayout;
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of fixed size that contains a
- * fixed-sized {@link AbsoluteLayout}.
- *
- * @return the created layout
- */
- private Component createFullOnFixed() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setWidth(200, Unit.PIXELS);
- absoluteLayout.setHeight(200, Unit.PIXELS);
- absoluteLayout.setId("fullonfixed-outer");
- absoluteLayout.addStyleName("green");
- absoluteLayout.setCaption("yellow area expected");
-
- AbsoluteLayout absoluteLayout2 = new AbsoluteLayout();
- absoluteLayout2.setSizeFull();
- absoluteLayout2.setId("fullonfixed-inner");
- absoluteLayout2.addStyleName("yellow");
-
- absoluteLayout.addComponent(absoluteLayout2, "top:50px;left:100px;");
- return absoluteLayout;
- }
-
- /**
- * Creates an {@link AbsoluteLayout} of full size that contains another
- * full-sized {@link AbsoluteLayout}.
- *
- * @return the created layout
- */
- private AbsoluteLayout createFullOnFull() {
- AbsoluteLayout absoluteLayout = new AbsoluteLayout();
- absoluteLayout.setSizeFull();
- absoluteLayout.setId("fullonfull-outer");
- absoluteLayout.addStyleName("cyan");
- absoluteLayout.setCaption("area with red border expected");
-
- AbsoluteLayout absoluteLayout2 = new AbsoluteLayout();
- absoluteLayout2.setSizeFull();
- absoluteLayout2.setId("fullonfull-inner");
- absoluteLayout2.addStyleName("redborder");
-
- absoluteLayout.addComponent(absoluteLayout2, "top:50px;left:100px;");
- return absoluteLayout;
- }
-
- @Override
- protected String getTestDescription() {
- return "Full size component in AbsoluteLayout shouldn't get undefined size";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 13131;
- }
-
- }
|