@@ -0,0 +1,3355 @@
+/* %0A@ITMillApache2LicenseForJavaFiles@%0A */%0A%0Apackage com.itmill.toolkit.tests;%0A%0Aimport java.util.ArrayList;%0A%0Aimport com.itmill.toolkit.ui.Button;%0Aimport com.itmill.toolkit.ui.CustomComponent;%0Aimport com.itmill.toolkit.ui.Label;%0Aimport com.itmill.toolkit.ui.OrderedLayout;%0Aimport com.itmill.toolkit.ui.Button.ClickEvent;%0A%0A/**%0A * %0A * This Component contains some simple test to see that component updates its%0A * contents propertly.%0A * %0A * @author IT Mill Ltd.%0A */%0Apublic class OrderedLayoutSwapComponents extends CustomComponent %7B%0A%0A    private final OrderedLayout main;%0A%0A    ArrayList order = new ArrayList();%0A%0A    public OrderedLayoutSwapComponents() %7B%0A%0A        main = new OrderedLayout();%0A        // main.setSizeFull();%0A        setCompositionRoot(main);%0A        createNewView();%0A    %7D%0A%0A    public void createNewView() %7B%0A        main.removeAllComponents();%0A%0A        for (int i = 0; i %3C 10; i++) %7B%0A            MyComponent c = new MyComponent(%22Component %22 + i);%0A            main.addComponent(c);%0A            order.add(c);%0A        %7D%0A        setCompositionRoot(main);%0A%0A    %7D%0A%0A    class MyComponent extends CustomComponent %7B%0A%0A        private static final int FIRST = 0;%0A        private static final int LAST = 1;%0A        private Button up;%0A        private Button down;%0A%0A        MyComponent(String name) %7B%0A            OrderedLayout ol = new OrderedLayout(%0A                    OrderedLayout.ORIENTATION_HORIZONTAL);%0A            ol.setDebugId(name.replaceAll(%22 %22, %22%22));%0A            ol.addComponent(new Label(name));%0A            up = new Button(%22up%22);%0A            up.addListener(new Button.ClickListener() %7B%0A                public void buttonClick(ClickEvent event) %7B%0A                    int newIndex = order.indexOf(MyComponent.this) - 1;%0A                    MyComponent old = (MyComponent) order.get(newIndex);%0A                    main.replaceComponent(old, MyComponent.this);%0A                    order.remove(MyComponent.this);%0A                    order.add(newIndex, MyComponent.this);%0A                    if (newIndex == 0) %7B%0A                        MyComponent.this.setMode(FIRST);%0A                    %7D else %7B%0A                        MyComponent.this.setMode(69);%0A                    %7D%0A                %7D%0A            %7D);%0A            ol.addComponent(up);%0A%0A            down = new Button(%22down%22);%0A            down.addListener(new Button.ClickListener() %7B%0A                public void buttonClick(ClickEvent event) %7B%0A                    int newIndex = order.indexOf(MyComponent.this) + 1;%0A                    MyComponent old = (MyComponent) order.get(newIndex);%0A                    main.replaceComponent(old, MyComponent.this);%0A                    order.remove(MyComponent.this);%0A                    order.add(newIndex, MyComponent.this);%0A                    if (newIndex == order.size() - 1) %7B%0A                        MyComponent.this.setMode(LAST);%0A                    %7D else %7B%0A                        MyComponent.this.setMode(69);%0A                    %7D%0A                %7D%0A            %7D);%0A            ol.addComponent(down);%0A%0A            setCompositionRoot(ol);%0A%0A        %7D%0A%0A        public void setMode(int mode) %7B%0A            up.setEnabled(true);%0A            down.setEnabled(true);%0A            if (mode == FIRST) %7B%0A                up.setEnabled(false);%0A            %7D else if (mode == LAST) %7B%0A                down.setEnabled(false);%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

test case for OrderedLayout component swapping