/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.itmill.toolkit.ui;

/**
 * A layout that will give one of it's components as much space as possible,
 * while still showing the other components in the layout. The other components
 * will in effect be given a fixed sized space, while the space given to the
 * expanded component will grow/shrink to fill the rest of the space available -
 * for instance when re-sizing the window.
 * 
 * Note that this layout is 100% in both directions by default ({link
 * {@link #setSizeFull()}). Remember to set the units if you want to specify a
 * fixed size. If the layout fails to show up, check that the parent layout is
 * actually giving some space.
 * 
 * @deprecated Deprecated in favor of new OrderedLayout
 */
@Deprecated
public class ExpandLayout extends OrderedLayout {

    private Component expanded = null;

    public ExpandLayout() {
        this(ORIENTATION_VERTICAL);
    }

    public ExpandLayout(int orientation) {
        super(orientation);

        setSizeFull();
    }

    /**
     * @param c
     *            Component which container will be maximized
     */
    public void expand(Component c) {
        if (expanded != null) {
            try {
                setExpandRatio(expanded, 0.0f);
            } catch (IllegalArgumentException e) {
                // Ignore error if component has been removed
            }
        }

        expanded = c;
        setExpandRatio(expanded, 1.0f);
        requestRepaint();
    }

}

@@ -736,16 +736,20 @@
 avor of 
+the 
 new Orde
@@ -1428,16 +1428,52 @@
 ed = c;%0A
+        if (expanded != null) %7B%0A    
         
@@ -1500,24 +1500,35 @@
 ded, 1.0f);%0A
+        %7D%0A%0A
         requ
@@ -1548,10 +1548,1097 @@
 %0A    %7D%0A%0A
+    @Override%0A    public void addComponent(Component c, int index) %7B%0A        super.addComponent(c, index);%0A        if (expanded == null) %7B%0A            expand(c);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void addComponent(Component c) %7B%0A        super.addComponent(c);%0A        if (expanded == null) %7B%0A            expand(c);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void addComponentAsFirst(Component c) %7B%0A        super.addComponentAsFirst(c);%0A        if (expanded == null) %7B%0A            expand(c);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void removeComponent(Component c) %7B%0A        super.removeComponent(c);%0A        if (c == expanded) %7B%0A            if (getComponentIterator().hasNext()) %7B%0A                expand((Component) getComponentIterator().next());%0A            %7D else %7B%0A                expand(null);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void replaceComponent(Component oldComponent, Component newComponent) %7B%0A        super.replaceComponent(oldComponent, newComponent);%0A        if (oldComponent == expanded) %7B%0A            expand(newComponent);%0A        %7D%0A    %7D%0A
 %7D%0A

Fix for #2251 - ExpandLayout used to expand the first component if expand was not called.