Package com.ponysdk.ui.server.basic

Examples of com.ponysdk.ui.server.basic.PTabPanel


        super.onFirstShowPage();

        final PDockLayoutPanel dockLayoutPanel = new PDockLayoutPanel(PUnit.PX);
        dockLayoutPanel.setSizeFull();

        final PTabPanel tabPanel = new PTabPanel();
        tabPanel.setSizeFull();

        tabPanel.addBeforeSelectionHandler(new PBeforeSelectionHandler<Integer>() {

            @Override
            public void onBeforeSelection(final PBeforeSelectionEvent<Integer> event) {
                PNotificationManager.showTrayNotification("onBeforeSelection, tab index : " + event.getSelectedItem());
            }
        });
        tabPanel.addSelectionHandler(new PSelectionHandler<Integer>() {

            @Override
            public void onSelection(final PSelectionEvent<Integer> event) {
                PNotificationManager.showTrayNotification("onSelection, tab index : " + event.getSelectedItem());
            }
        });

        final PButton button = new PButton("Add Tab");
        button.setStyleProperty("margin", "10px");
        button.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent clickEvent) {
                addTabContent(tabPanel);
            }
        });

        final PButton addCustomTabButton = new PButton("Add Tab (custom tab)");
        addCustomTabButton.setStyleProperty("margin", "10px");
        addCustomTabButton.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent clickEvent) {
                addCustomTabContent(tabPanel);
            }
        });

        final PTextBox indexTextBox = new PTextBox();
        final PButton selectButton = new PButton("Select Tab");
        selectButton.setStyleProperty("margin", "10px");
        selectButton.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent clickEvent) {
                final String text = indexTextBox.getText();
                tabPanel.selectTab(Integer.valueOf(text));
            }
        });

        final PHorizontalPanel horizontalPanel = new PHorizontalPanel();
        horizontalPanel.setVerticalAlignment(PVerticalAlignment.ALIGN_MIDDLE);
View Full Code Here


            public void onRequest() {
                final PLabel tab2Label = new PLabel("tab 2");
                tab2Label.ensureDebugId("tab2Label");
                final PHTML tab3Label = new PHTML("tab <font color='red'>3</font>");

                final PTabPanel tabPanel1 = new PTabPanel();
                tabPanel1.add(new PLabel("content 1"), "tab 1");
                tabPanel1.add(new PLabel("content 2"), tab2Label);
                tabPanel1.add(new PLabel("content 3"), tab3Label);
                tabPanel1.addBeforeSelectionHandler(eventsListener);
                tabPanel1.addSelectionHandler(eventsListener);
                tabPanel1.ensureDebugId("tabPanel1");
                PRootPanel.get().add(tabPanel1);
                register(tabPanel1);
            }
        });

        WebElement tabPanel1Bar = findElementById("tabPanel1-bar");
        List<WebElement> tabBarElements = tabPanel1Bar.findElements(By.tagName("td"));
        Assert.assertEquals(5, tabBarElements.size()); // 3 +(start+end);
        Assert.assertEquals("tab 1", tabBarElements.get(1).getText());
        Assert.assertEquals("tab 2", tabBarElements.get(2).getText());
        Assert.assertEquals("tab 3", tabBarElements.get(3).getText());

        final WebElement fontElement = tabBarElements.get(3).findElement(By.tagName("font"));
        Assert.assertEquals("red", fontElement.getAttribute("color"));

        final PTabPanel ptabPanel1 = get("tabPanel1");
        Assert.assertEquals(3, ptabPanel1.getWidgetCount());

        final PSelectionEvent<Integer> sa = eventsListener.poll();
        Assert.assertEquals(new Integer(0), sa.getSelectedItem());

        // add / remove
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PTabPanel tabPanel1 = get("tabPanel1");
                tabPanel1.remove(2);
                tabPanel1.insert(new PLabel("content 1.5"), "tab 1.5", 1);
            }
        });

        tabPanel1Bar = findElementById("tabPanel1-bar");
        tabBarElements = tabPanel1Bar.findElements(By.tagName("td"));
        Assert.assertEquals(5, tabBarElements.size()); // 3 +(start+end);
        Assert.assertEquals(5, tabBarElements.size()); // 3 +(start+end);
        Assert.assertEquals("tab 1", tabBarElements.get(1).getText());
        Assert.assertEquals("tab 1.5", tabBarElements.get(2).getText());
        Assert.assertEquals("tab 2", tabBarElements.get(3).getText());

        Assert.assertEquals(null, ptabPanel1.getSelectedItemIndex());

        final WebElement tab2Label = findElementById("tab2Label");
        tab2Label.click();

        final PBeforeSelectionEvent<Integer> s0 = eventsListener.poll();
        Assert.assertEquals(new Integer(2), s0.getSelectedItem());

        final PSelectionEvent<Integer> s1 = eventsListener.poll();
        Assert.assertEquals(new Integer(2), s1.getSelectedItem());

        // server-side selection
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PTabPanel tabPanel1 = get("tabPanel1");
                tabPanel1.selectTab(1);
            }
        });

        tabPanel1Bar = findElementById("tabPanel1-bar");
        Assert.assertEquals(new Integer(1), ptabPanel1.getSelectedItemIndex());
View Full Code Here

TOP

Related Classes of com.ponysdk.ui.server.basic.PTabPanel

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.