]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge branch 'master' into layoutgraph
authorJohn Ahlroos <john@vaadin.com>
Tue, 28 Aug 2012 06:41:55 +0000 (09:41 +0300)
committerJohn Ahlroos <john@vaadin.com>
Tue, 28 Aug 2012 06:41:55 +0000 (09:41 +0300)
Conflicts:
tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java

1  2 
client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java
client/src/com/vaadin/terminal/gwt/client/LayoutManager.java
client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java

index e515c2626c34aa2bc403d2879baa64c65a3abc0c,f1a2b9b925cc9e473a544bade3dfbeef66427585..7c759131266e899f3291c17aff061022730a3dfd
@@@ -28,10 -28,9 +28,10 @@@ import com.vaadin.shared.ComponentState
  import com.vaadin.shared.Connector;
  import com.vaadin.shared.communication.SharedState;
  import com.vaadin.terminal.gwt.client.ui.SubPartAware;
+ import com.vaadin.terminal.gwt.client.ui.UI.VUI;
  import com.vaadin.terminal.gwt.client.ui.gridlayout.VGridLayout;
 +import com.vaadin.terminal.gwt.client.ui.orderedlayout.VBoxLayout;
  import com.vaadin.terminal.gwt.client.ui.orderedlayout.VMeasuringOrderedLayout;
- import com.vaadin.terminal.gwt.client.ui.root.VRoot;
  import com.vaadin.terminal.gwt.client.ui.tabsheet.VTabsheetPanel;
  import com.vaadin.terminal.gwt.client.ui.window.VWindow;
  import com.vaadin.terminal.gwt.client.ui.window.WindowConnector;
index aeae09e7b968f577411a7e15a7a10bcd4ae92120,5aaaaec6a602174e3f32d6901a817f67eef00bb9..a10e69e188ac8aeb18c0bfa8fe42490a0c7bf1fd
@@@ -21,58 -20,57 +21,59 @@@ import com.vaadin.ui.HorizontalLayout
  import com.vaadin.ui.NativeSelect;
  import com.vaadin.ui.VerticalLayout;
  
- public class OrderedLayoutCases extends AbstractTestRoot {
 +@Theme("tests-components")
+ public class OrderedLayoutCases extends AbstractTestUI {
++
      private static final String[] dimensionValues = { "-1px", "5px", "350px",
--            "800px", "100%", "50%" };
++        "800px", "100%", "50%" };
  
      private static class SampleChild extends VerticalLayout {
          public SampleChild() {
              setStyleName("sampleChild");
              addComponent(createSimpleSelector("Child width",
                      new ValueChangeListener() {
--                        @Override
--                        public void valueChange(ValueChangeEvent event) {
--                            setWidth(event.getProperty().getValue().toString());
--                        }
--                    }, dimensionValues));
++                @Override
++                public void valueChange(ValueChangeEvent event) {
++                    setWidth(event.getProperty().getValue().toString());
++                }
++            }, dimensionValues));
              addComponent(createSimpleSelector("Child height",
                      new ValueChangeListener() {
--                        @Override
--                        public void valueChange(ValueChangeEvent event) {
--                            setHeight(event.getProperty().getValue().toString());
--                        }
--                    }, dimensionValues));
++                @Override
++                public void valueChange(ValueChangeEvent event) {
++                    setHeight(event.getProperty().getValue().toString());
++                }
++            }, dimensionValues));
              addComponent(createSimpleSelector("Caption",
                      new ValueChangeListener() {
--                        @Override
--                        public void valueChange(ValueChangeEvent event) {
--                            String value = event.getProperty().getValue()
--                                    .toString();
--                            if (value.length() == 0) {
--                                setCaption(null);
--                            } else if (value.equals("Long")) {
--                                setCaption("A rather long caption just to see what happens");
--                            } else {
--                                setCaption(value);
--                            }
--                        }
--                    }, "", "Short", "Long"));
++                @Override
++                public void valueChange(ValueChangeEvent event) {
++                    String value = event.getProperty().getValue()
++                            .toString();
++                    if (value.length() == 0) {
++                        setCaption(null);
++                    } else if (value.equals("Long")) {
++                        setCaption("A rather long caption just to see what happens");
++                    } else {
++                        setCaption(value);
++                    }
++                }
++            }, "", "Short", "Long"));
  
              addComponent(createSimpleSelector("Expand ratio",
                      new ValueChangeListener() {
--                        @Override
--                        public void valueChange(ValueChangeEvent event) {
--                            AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent();
--                            if (parent == null) {
--                                return;
--                            }
--                            String value = event.getProperty().getValue()
--                                    .toString();
--                            parent.setExpandRatio(SampleChild.this,
--                                    Float.parseFloat(value));
--                        }
--                    }, "0", "1", "2"));
++                @Override
++                public void valueChange(ValueChangeEvent event) {
++                    AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent();
++                    if (parent == null) {
++                        return;
++                    }
++                    String value = event.getProperty().getValue()
++                            .toString();
++                    parent.setExpandRatio(SampleChild.this,
++                            Float.parseFloat(value));
++                }
++            }, "0", "1", "2"));
  
              // Why is Alignment not an enum? Now we have to use reflection just
              // to get the different values as hardcoding is never an option! ;)
              }
              addComponent(createSimpleSelector("Alignment",
                      new ValueChangeListener() {
--                        @Override
--                        public void valueChange(ValueChangeEvent event) {
--                            String value = event.getProperty().getValue()
--                                    .toString();
--                            AlignmentHandler parent = (AlignmentHandler) getParent();
--                            if (parent == null) {
--                                return;
--                            }
--                            try {
--                                Field field = Alignment.class
--                                        .getDeclaredField(value);
--                                Alignment alignment = (Alignment) field
--                                        .get(null);
--                                parent.setComponentAlignment(SampleChild.this,
--                                        alignment);
--                            } catch (Exception e) {
--                                throw new RuntimeException(e);
--                            }
--                        }
--                    }, alignmentValues, "TOP_LEFT")); // Sorry for not using
--                                                      // more reflection magic
--                                                      // just to find the
--                                                      // default value...
++                @Override
++                public void valueChange(ValueChangeEvent event) {
++                    String value = event.getProperty().getValue()
++                            .toString();
++                    AlignmentHandler parent = (AlignmentHandler) getParent();
++                    if (parent == null) {
++                        return;
++                    }
++                    try {
++                        Field field = Alignment.class
++                                .getDeclaredField(value);
++                        Alignment alignment = (Alignment) field
++                                .get(null);
++                        parent.setComponentAlignment(SampleChild.this,
++                                alignment);
++                    } catch (Exception e) {
++                        throw new RuntimeException(e);
++                    }
++                }
++            }, alignmentValues, "TOP_LEFT")); // Sorry for not using
++            // more reflection magic
++            // just to find the
++            // default value...
  
          }
      }
      @Override
      protected void setup(WrappedRequest request) {
          TestUtils
--                .injectCSS(
-                         getRoot(),
 -                        getUI(),
--                        ".sampleChild, .theLayout {border: 1px solid black;}"
--                                + ".theLayout > div:first-child {background: aqua;}"
--                                + ".theLayout > div:first-child + div {background: yellow;}"
--                                + ".theLayout > div:first-child + div + div {background: lightgrey;}");
++        .injectCSS(
++                getUI(),
++                ".sampleChild, .theLayout {border: 1px solid black;}"
++                        + ".theLayout > div:first-child {background: aqua;}"
++                        + ".theLayout > div:first-child + div {background: yellow;}"
++                        + ".theLayout > div:first-child + div + div {background: lightgrey;}");
  
          currentLayout = new HorizontalLayout();
          for (int i = 0; i < 3; i++) {
  
          sizeBar.addComponent(createSimpleSelector("Layout width",
                  new ValueChangeListener() {
--                    @Override
--                    public void valueChange(ValueChangeEvent event) {
--                        currentLayout.setWidth(event.getProperty().getValue()
--                                .toString());
--                    }
--                }, dimensionValues));
++            @Override
++            public void valueChange(ValueChangeEvent event) {
++                currentLayout.setWidth(event.getProperty().getValue()
++                        .toString());
++            }
++        }, dimensionValues));
          sizeBar.addComponent(createSimpleSelector("Layout height",
                  new ValueChangeListener() {
--                    @Override
--                    public void valueChange(ValueChangeEvent event) {
--                        currentLayout.setHeight(event.getProperty().getValue()
--                                .toString());
--                    }
--                }, dimensionValues));
++            @Override
++            public void valueChange(ValueChangeEvent event) {
++                currentLayout.setHeight(event.getProperty().getValue()
++                        .toString());
++            }
++        }, dimensionValues));
          sizeBar.addComponent(createSimpleSelector("Spacing",
                  new ValueChangeListener() {
--                    @Override
--                    public void valueChange(ValueChangeEvent event) {
--                        currentLayout.setSpacing(Boolean.parseBoolean(event
--                                .getProperty().getValue().toString()));
--                    }
--                }, "false", "true"));
++            @Override
++            public void valueChange(ValueChangeEvent event) {
++                currentLayout.setSpacing(Boolean.parseBoolean(event
++                        .getProperty().getValue().toString()));
++            }
++        }, "false", "true"));
          sizeBar.addComponent(createSimpleSelector("Margin",
                  new ValueChangeListener() {
--                    @Override
--                    public void valueChange(ValueChangeEvent event) {
--                        currentLayout.setMargin(Boolean.parseBoolean(event
--                                .getProperty().getValue().toString()));
--                    }
--                }, "false", "true"));
++            @Override
++            public void valueChange(ValueChangeEvent event) {
++                currentLayout.setMargin(Boolean.parseBoolean(event
++                        .getProperty().getValue().toString()));
++            }
++        }, "false", "true"));
          sizeBar.addComponent(createSimpleSelector("Direction",
                  new ValueChangeListener() {
--                    @Override
--                    public void valueChange(ValueChangeEvent event) {
--                        Object value = event.getProperty().getValue();
++            @Override
++            public void valueChange(ValueChangeEvent event) {
++                Object value = event.getProperty().getValue();
  
--                        AbstractOrderedLayout newLayout;
--                        if (value.equals("Horizontal")) {
--                            newLayout = new HorizontalLayout();
--                        } else {
--                            newLayout = new VerticalLayout();
--                        }
++                AbstractOrderedLayout newLayout;
++                if (value.equals("Horizontal")) {
++                    newLayout = new HorizontalLayout();
++                } else {
++                    newLayout = new VerticalLayout();
++                }
  
--                        while (currentLayout.getComponentCount() > 0) {
--                            newLayout.addComponent(currentLayout
--                                    .getComponent(0));
--                        }
--                        newLayout.setStyleName("theLayout");
++                while (currentLayout.getComponentCount() > 0) {
++                    newLayout.addComponent(currentLayout
++                            .getComponent(0));
++                }
++                newLayout.setStyleName("theLayout");
  
--                        newLayout.setHeight(currentLayout.getHeight(),
--                                currentLayout.getHeightUnits());
--                        newLayout.setWidth(currentLayout.getWidth(),
--                                currentLayout.getWidthUnits());
++                newLayout.setHeight(currentLayout.getHeight(),
++                        currentLayout.getHeightUnits());
++                newLayout.setWidth(currentLayout.getWidth(),
++                        currentLayout.getWidthUnits());
  
--                        newLayout.setMargin(currentLayout.getMargin());
--                        newLayout.setSpacing(currentLayout.isSpacing());
++                newLayout.setMargin(currentLayout.getMargin());
++                newLayout.setSpacing(currentLayout.isSpacing());
  
--                        getLayout().replaceComponent(currentLayout, newLayout);
--                        getLayout().setExpandRatio(newLayout, 1);
--                        currentLayout = newLayout;
--                    }
--                }, "Horizontal", "Vertical"));
++                getLayout().replaceComponent(currentLayout, newLayout);
++                getLayout().setExpandRatio(newLayout, 1);
++                currentLayout = newLayout;
++            }
++        }, "Horizontal", "Vertical"));
  
          HorizontalLayout caseBar = new HorizontalLayout();
          caseBar.addComponent(new Button("Undefined without relative",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        setState(sizeBar, 2, 1);
--                        // width: 350px to middle child
--                        setChildState(1, 0, 2);
--                        // middle center allign to middle child
--                        setChildState(1, 4, 5);
--                        // long captions to right child
--                        setChildState(2, 2, 2);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                setState(sizeBar, 2, 1);
++                // width: 350px to middle child
++                setChildState(1, 0, 2);
++                // middle center allign to middle child
++                setChildState(1, 4, 5);
++                // long captions to right child
++                setChildState(2, 2, 2);
++            }
++        }));
          caseBar.addComponent(new Button("Undefined with relative",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // width: 100% to middle child
--                        setChildState(1, 0, 4);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // width: 100% to middle child
++                setChildState(1, 0, 4);
++            }
++        }));
          caseBar.addComponent(new Button("Fixed with overflow",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // layout width: 350px
--                        setState(sizeBar, 0, 2);
--                        // layout margin enabled
--                        setState(sizeBar, 3, 1);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // layout width: 350px
++                setState(sizeBar, 0, 2);
++                // layout margin enabled
++                setState(sizeBar, 3, 1);
++            }
++        }));
          caseBar.addComponent(new Button("Fixed with extra space",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // Layout width: 800px
--                        setState(sizeBar, 0, 3);
--                        // layout margin enabled
--                        setState(sizeBar, 3, 1);
--                        // width: 350px to middle child
--                        setChildState(1, 0, 2);
--                        // short caption for middle child
--                        setChildState(1, 2, 1);
--                        // top center align for middle child
--                        setChildState(1, 4, 2);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // Layout width: 800px
++                setState(sizeBar, 0, 3);
++                // layout margin enabled
++                setState(sizeBar, 3, 1);
++                // width: 350px to middle child
++                setChildState(1, 0, 2);
++                // short caption for middle child
++                setChildState(1, 2, 1);
++                // top center align for middle child
++                setChildState(1, 4, 2);
++            }
++        }));
  
          caseBar.addComponent(new Button("Expand with alignment",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // Layout width: 800px
--                        setState(sizeBar, 0, 3);
--                        // Layout height: 350px
--                        setState(sizeBar, 1, 2);
--                        // Expand: 1 to middle child
--                        setChildState(1, 3, 1);
--                        // Align bottom left to middle child
--                        setChildState(1, 4, 6);
--                        // Long caption to middle child
--                        setChildState(1, 2, 2);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // Layout width: 800px
++                setState(sizeBar, 0, 3);
++                // Layout height: 350px
++                setState(sizeBar, 1, 2);
++                // Expand: 1 to middle child
++                setChildState(1, 3, 1);
++                // Align bottom left to middle child
++                setChildState(1, 4, 6);
++                // Long caption to middle child
++                setChildState(1, 2, 2);
++            }
++        }));
  
          caseBar.addComponent(new Button("Multiple expands",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // Layout width: 800px
--                        setState(sizeBar, 0, 3);
--                        // Layout height: 350px
--                        setState(sizeBar, 1, 2);
--                        // Long caption to left child
--                        setChildState(0, 2, 2);
--                        // Width 350px to middle child
--                        setChildState(1, 0, 2);
--                        // Apply to left and middle child
--                        for (int i = 0; i < 2; i++) {
--                            // Expand: 1
--                            setChildState(i, 3, 1);
--                            // Align: middle center
--                            setChildState(i, 4, 5);
--                        }
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // Layout width: 800px
++                setState(sizeBar, 0, 3);
++                // Layout height: 350px
++                setState(sizeBar, 1, 2);
++                // Long caption to left child
++                setChildState(0, 2, 2);
++                // Width 350px to middle child
++                setChildState(1, 0, 2);
++                // Apply to left and middle child
++                for (int i = 0; i < 2; i++) {
++                    // Expand: 1
++                    setChildState(i, 3, 1);
++                    // Align: middle center
++                    setChildState(i, 4, 5);
++                }
++            }
++        }));
  
          caseBar.addComponent(new Button("Fixed + relative height",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // Layout height: 100%
--                        setState(sizeBar, 1, 4);
--                        // Height: 350px to left child
--                        setChildState(0, 1, 2);
--                        // Height: 100% to middle child
--                        setChildState(1, 1, 4);
--                        // Short caption to middle child
--                        setChildState(1, 2, 1);
--                        // Alignment: bottom left to right child
--                        setChildState(2, 4, 7);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // Layout height: 100%
++                setState(sizeBar, 1, 4);
++                // Height: 350px to left child
++                setChildState(0, 1, 2);
++                // Height: 100% to middle child
++                setChildState(1, 1, 4);
++                // Short caption to middle child
++                setChildState(1, 2, 1);
++                // Alignment: bottom left to right child
++                setChildState(2, 4, 7);
++            }
++        }));
  
          caseBar.addComponent(new Button("Undefined + relative height",
                  new ClickListener() {
--                    @Override
--                    public void buttonClick(ClickEvent event) {
--                        resetState();
--                        // Height: 350px to left child
--                        setChildState(0, 1, 2);
--                        // Short caption to left child
--                        setChildState(0, 2, 1);
--                        // Height: 100% to middle child
--                        setChildState(1, 1, 4);
--                        // Alignment: bottom left to right child
--                        setChildState(2, 4, 7);
--                    }
--                }));
++            @Override
++            public void buttonClick(ClickEvent event) {
++                resetState();
++                // Height: 350px to left child
++                setChildState(0, 1, 2);
++                // Short caption to left child
++                setChildState(0, 2, 1);
++                // Height: 100% to middle child
++                setChildState(1, 1, 4);
++                // Alignment: bottom left to right child
++                setChildState(2, 4, 7);
++            }
++        }));
  
          caseBar.setSpacing(true);