Package com.vaadin.ui

Examples of com.vaadin.ui.TabSheet$SelectedTabChangeEvent


        panelLayout.setMargin(true);
        final Panel panel = new Panel("Panel", panelLayout);
        test(panel);
        populateLayout(panelLayout);

        final TabSheet tabsheet = new TabSheet();
        test(tabsheet);
        final VerticalLayout tab1 = new VerticalLayout();
        tab1.addComponent(new Label("try tab2"));
        final VerticalLayout tab2 = new VerticalLayout();
        test(tab2);
        populateLayout(tab2);
        tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif"));
        tabsheet.addTab(tab2, "TabSheet tab2", new ClassResource("m.gif"));

        final VerticalLayout expandLayout = new VerticalLayout();
        test(expandLayout);
        populateLayout(expandLayout);
View Full Code Here


        assertEquals(4, tabSheet.getTabPosition(tab3));
    }

    @Test
    public void addTabWithAllParameters() {
        TabSheet tabSheet = new TabSheet();
        Tab tab1 = tabSheet.addTab(new Label("aaa"));
        Tab tab2 = tabSheet.addTab(new Label("bbb"));
        Tab tab3 = tabSheet.addTab(new Label("ccc"));

        Tab tab4 = tabSheet.addTab(new Label("ddd"), "ddd", null, 1);
        Tab tab5 = tabSheet.addTab(new Label("eee"), "eee", null, 3);

        assertEquals(0, tabSheet.getTabPosition(tab1));
        assertEquals(1, tabSheet.getTabPosition(tab4));
        assertEquals(2, tabSheet.getTabPosition(tab2));
        assertEquals(3, tabSheet.getTabPosition(tab5));
        assertEquals(4, tabSheet.getTabPosition(tab3));

        // Calling addTab with existing component does not move tab
        tabSheet.addTab(tab1.getComponent(), "xxx", null, 3);

        assertEquals(0, tabSheet.getTabPosition(tab1));
        assertEquals(1, tabSheet.getTabPosition(tab4));
        assertEquals(2, tabSheet.getTabPosition(tab2));
        assertEquals(3, tabSheet.getTabPosition(tab5));
        assertEquals(4, tabSheet.getTabPosition(tab3));
    }
View Full Code Here

        assertEquals(4, tabSheet.getTabPosition(tab3));
    }

    @Test
    public void getTabByPosition() {
        TabSheet tabSheet = new TabSheet();
        Tab tab1 = tabSheet.addTab(new Label("aaa"));
        Tab tab2 = tabSheet.addTab(new Label("bbb"));
        Tab tab3 = tabSheet.addTab(new Label("ccc"));

        assertEquals(tab1, tabSheet.getTab(0));
        assertEquals(tab2, tabSheet.getTab(1));
        assertEquals(tab3, tabSheet.getTab(2));

        assertEquals(null, tabSheet.getTab(3));
    }
View Full Code Here

        assertEquals(null, tabSheet.getTab(3));
    }

    @Test
    public void selectTab() {
        TabSheet tabSheet = new TabSheet();
        Tab tab1 = tabSheet.addTab(new Label("aaa"));
        Tab tab2 = tabSheet.addTab(new Label("bbb"));
        Tab tab3 = tabSheet.addTab(new Label("ccc"));
        Label componentNotInSheet = new Label("ddd");
        Tab tabNotInSheet = new TabSheet().addTab(new Label("eee"));

        assertEquals(tab1.getComponent(), tabSheet.getSelectedTab());

        // Select tab by component...
        tabSheet.setSelectedTab(tab2.getComponent());
        assertEquals(tab2.getComponent(), tabSheet.getSelectedTab());

        // by tab instance
        tabSheet.setSelectedTab(tab3);
        assertEquals(tab3.getComponent(), tabSheet.getSelectedTab());

        // by index
        tabSheet.setSelectedTab(0);
        assertEquals(tab1.getComponent(), tabSheet.getSelectedTab());

        // Should be no-op...
        tabSheet.setSelectedTab(componentNotInSheet);
        assertEquals(tab1.getComponent(), tabSheet.getSelectedTab());

        // this as well
        tabSheet.setSelectedTab(tabNotInSheet);
        assertEquals(tab1.getComponent(), tabSheet.getSelectedTab());

        // and this
        tabSheet.setSelectedTab(123);
        assertEquals(tab1.getComponent(), tabSheet.getSelectedTab());
    }
View Full Code Here

        assertEquals(tab1.getComponent(), tabSheet.getSelectedTab());
    }

    @Test
    public void replaceComponent() {
        TabSheet tabSheet = new TabSheet();
        Label lbl1 = new Label("aaa");
        Label lbl2 = new Label("bbb");
        Label lbl3 = new Label("ccc");
        Label lbl4 = new Label("ddd");

        Tab tab1 = tabSheet.addTab(lbl1);
        tab1.setCaption("tab1");
        tab1.setClosable(true);
        Tab tab2 = tabSheet.addTab(lbl2);
        tab2.setDescription("description");
        tab2.setEnabled(false);

        // Replace component not in tabsheet with one already in tabsheet -
        // should be no-op
        tabSheet.replaceComponent(lbl3, lbl2);
        assertEquals(2, tabSheet.getComponentCount());
        assertSame(tab1, tabSheet.getTab(lbl1));
        assertSame(tab2, tabSheet.getTab(lbl2));
        assertNull(tabSheet.getTab(lbl3));

        // Replace component not in tabsheet with one not in tabsheet either
        // should add lbl4 as last tab
        tabSheet.replaceComponent(lbl3, lbl4);
        assertEquals(3, tabSheet.getComponentCount());
        assertSame(tab1, tabSheet.getTab(lbl1));
        assertSame(tab2, tabSheet.getTab(lbl2));
        assertEquals(2, tabSheet.getTabPosition(tabSheet.getTab(lbl4)));

        // Replace component in tabsheet with another
        // should swap places, tab association should stay the same but tabs
        // should swap metadata
        tabSheet.replaceComponent(lbl1, lbl2);
        assertSame(tab1, tabSheet.getTab(lbl1));
        assertSame(tab2, tabSheet.getTab(lbl2));
        assertEquals(false, tab1.isClosable());
        assertEquals(true, tab2.isClosable());
        assertEquals(false, tab1.isEnabled());
        assertEquals(true, tab2.isEnabled());
        assertEquals("description", tab1.getDescription());
        assertEquals(null, tab2.getDescription());
        assertEquals(3, tabSheet.getComponentCount());
        assertEquals(1, tabSheet.getTabPosition(tabSheet.getTab(lbl1)));
        assertEquals(0, tabSheet.getTabPosition(tabSheet.getTab(lbl2)));

        // Replace component in tabsheet with one not in tabsheet
        // should create a new tab instance for the new component, old tab
        // instance should become unattached
        // tab metadata should be copied from old to new
        tabSheet.replaceComponent(lbl1, lbl3);
        assertEquals(3, tabSheet.getComponentCount());
        assertNull(tabSheet.getTab(lbl1));
        assertNull(tab1.getComponent());
        assertNotNull(tabSheet.getTab(lbl3));
        assertEquals(false, tabSheet.getTab(lbl3).isEnabled());
        assertEquals("description", tab1.getDescription());
        assertEquals(1, tabSheet.getTabPosition(tabSheet.getTab(lbl3)));
    }
View Full Code Here

                transferable.getSourceComponent().removeItem(
                        transferable.getItemId());
            }
        });

        TabSheet tabSheet = new TabSheet();
        tabSheet.addComponent(source1);
        tabSheet.addComponent(source2);

        addComponent(tabSheet);
        addComponent(target);
    }
View Full Code Here

        VerticalLayout ol = new VerticalLayout();
        ol.setCaption("Tab 1");
        VerticalLayout ol2 = new VerticalLayout();
        ol2.setCaption("Tab 2");

        TabSheet ts = (verticalAkaAccordion ? accordion : tabsheet);
        ts.setSizeFull();

        ts.removeAllComponents();

        ts.addComponent(ol);
        ts.addComponent(ol2);

        ol.setWidth((String) width.getValue());
        ol.setHeight((String) height.getValue());
        ol2.setWidth((String) width.getValue());
        ol2.setHeight((String) height.getValue());
View Full Code Here

    @Override
    protected void setup() {

        outerPanel = new Panel("Outer panel, enabled");
        innerTabsheet = new TabSheet();
        innerTabsheet.setCaption("Inner Tabsheet, enabled");

        button = new Button("Button, enabled");
        nativeButton = new NativeButton("NativeButton, enabled");
        textField = new TextField("TextField with caption and value, enabled");
View Full Code Here

        Table testTable = TestForTablesInitialColumnWidthLogicRendering
                .getTestTable(5, 50);
        testTable.setSizeFull();

        TabSheet ts = new TabSheet();
        ts.setSizeFull();

        Label red = new Label(
                "<div style='background:red;width:100%;height:100%;'>??</div>",
                ContentMode.HTML);
        // red.setCaption("cap");
        // red.setSizeFull();

        // el.addComponent(testTable);
        // el.setExpandRatio(testTable,1);

        el.addComponent(ts);
        el.setExpandRatio(ts, 1);
        ts.addComponent(red);
        ts.getTab(red).setCaption("REd tab");

        Label l = new Label("<div style='background:blue;'>sdf</div>",
                ContentMode.HTML);
        el.addComponent(l);
        el.setComponentAlignment(l, Alignment.MIDDLE_RIGHT);
View Full Code Here

        layoutG2.addComponent(getExamplePicture("x=0, y=3"), 0, 3);

        //
        // Create TabSheet
        //
        final TabSheet tabsheet = new TabSheet();
        tabsheet.setCaption("Tabsheet, above layouts are added to this component");
        tabsheet.addTab(layoutA, "Horizontal ordered layout", null);
        tabsheet.addTab(layoutB, "Vertical ordered layout", null);
        tabsheet.addTab(layoutG, "First grid layout", null);
        tabsheet.addTab(layoutG2, "Second grid layout", null);

        //
        // Add demo layouts to main window
        //
        mainWindow.addComponent(new Label(
View Full Code Here

TOP

Related Classes of com.vaadin.ui.TabSheet$SelectedTabChangeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.