<commit_before>package com.vaadin.tests.layouts;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.tests.VaadinClasses;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.PopupView;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;

public class MovingComponentsWhileOldParentInvisible extends TestBase {

    private ComponentContainer cc = new AbsoluteLayout(); // initial dummy
                                                          // contents
    private Label lab;

    @Override
    protected void setup() {
        lab = new Label("Label inside the component container");
        lab.setWidth(null);

        ComboBox componentContainerSelect = new ComboBox("Container") {
            {
                pageLength = 0;
            }
        };
        componentContainerSelect.setId("componentContainerSelect");
        componentContainerSelect.setWidth("300px");
        componentContainerSelect.setImmediate(true);
        componentContainerSelect.setNullSelectionAllowed(false);
        // componentContainer.addContainerProperty(CAPTION, String.class, "");
        // componentContainer.addContainerProperty(CLASS, Class.class, "");

        for (Class<? extends ComponentContainer> cls : VaadinClasses
                .getComponentContainers()) {
            if (cls == LoginForm.class || cls == CustomLayout.class
                    || CustomComponent.class.isAssignableFrom(cls)
                    || cls == PopupView.class || cls == Window.class
                    || cls == UI.class) {
                // Does not support addComponent
                continue;
            }
            componentContainerSelect.addItem(cls);
        }
        componentContainerSelect.addListener(new ValueChangeListener() {

            @Override
            @SuppressWarnings("unchecked")
            public void valueChange(ValueChangeEvent event) {
                ComponentContainer oldCC = cc;
                cc = createComponentContainer((Class<? extends ComponentContainer>) event
                        .getProperty().getValue());
                cc.addComponent(lab);

                replaceComponent(oldCC, cc);
            }<commit_msg>Do not include LegacyWindow or LabelDataSource.MockUI in test<commit_after>package com.vaadin.tests.layouts;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.tests.VaadinClasses;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.LabelDataSource;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.PopupView;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;

public class MovingComponentsWhileOldParentInvisible extends TestBase {

    private ComponentContainer cc = new AbsoluteLayout(); // initial dummy
                                                          // contents
    private Label lab;

    @Override
    protected void setup() {
        lab = new Label("Label inside the component container");
        lab.setWidth(null);

        ComboBox componentContainerSelect = new ComboBox("Container") {
            {
                pageLength = 0;
            }
        };
        componentContainerSelect.setId("componentContainerSelect");
        componentContainerSelect.setWidth("300px");
        componentContainerSelect.setImmediate(true);
        componentContainerSelect.setNullSelectionAllowed(false);
        // componentContainer.addContainerProperty(CAPTION, String.class, "");
        // componentContainer.addContainerProperty(CLASS, Class.class, "");

        for (Class<? extends ComponentContainer> cls : VaadinClasses
                .getComponentContainers()) {
            if (cls == LoginForm.class || cls == CustomLayout.class
                    || CustomComponent.class.isAssignableFrom(cls)
                    || cls == PopupView.class || cls == Window.class
                    || cls == UI.class || cls == LegacyWindow.class
                    || cls == LabelDataSource.MockUI.class) {
                // Does not support addComponent
                continue;
            }
            componentContainerSelect.addItem(cls);
        }
        componentContainerSelect.addListener(new ValueChangeListener() {

            @Override
            @SuppressWarnings("unchecked")
            public void valueChange(ValueChangeEvent event) {
                ComponentContainer oldCC = cc;
                cc = createComponentContainer((Class<? extends ComponentContainer>) event
                        .getProperty().getValue());
                cc.addComponent(lab);

                replaceComponent(oldCC, cc);
            }
{'fraction_non_alphanumeric': 0.09532745355601425, 'fraction_numerical': 0.0015012197410395947, 'mean_word_length': 2.4387096774193546, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3231818', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1305, 'n_words': 257}