Package com.ponysdk.ui.server.basic

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


        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PLabel label1 = new PLabel("Date test");
                label1.ensureDebugId("label1");
                PRootPanel.get().add(label1);
                register(label1);

                final PDateBox dateBox1 = new PDateBox(new SimpleDateFormat(datePattern));
                dateBox1.ensureDebugId("dateBox1");
View Full Code Here


        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
                final PLabel label = new PLabel("Text");
                label.ensureDebugId("label1");
                disclosurePanel1.setContent(label);
                disclosurePanel1.addOpenHandler(eventsListener);
                disclosurePanel1.addCloseHandler(eventsListener);
                register(disclosurePanel1);
            }
View Full Code Here

                ul1.ensureDebugId("ul1");
                final PElement li1 = new PElement("li");
                li1.setInnerText("1rst element");
                final PElement li2 = new PElement("li");
                li2.setInnerHTML("<font color='red'>2d</font> element");
                final PLabel label1 = new PLabel("A widget");
                ul1.add(li1);
                ul1.add(li2);
                ul1.add(label1);
                PRootPanel.get().add(ul1);
                register(ul1);
View Full Code Here

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = new PFlexTable();
                flexTable1.ensureDebugId("flexTable1");
                final PLabel cell11 = new PLabel("Cell_1_1");
                cell11.ensureDebugId("cell11");
                flexTable1.setWidget(0, 0, new PLabel("Cell_0_0"));
                flexTable1.setWidget(0, 1, new PLabel("Cell_0_1"));
                flexTable1.setWidget(1, 0, new PLabel("Cell_1_0"));
                flexTable1.setWidget(1, 1, cell11);
                flexTable1.setBorderWidth(1);
                flexTable1.setCellPadding(2);
                flexTable1.setCellSpacing(3);
                PRootPanel.get().add(flexTable1);
                register(flexTable1);
                register(cell11);
            }
        });

        WebElement flexTable1 = findElementById("flexTable1");
        Assert.assertEquals(flexTable1.getAttribute("border"), "1");
        Assert.assertEquals(flexTable1.getAttribute("cellPadding"), "2");
        Assert.assertEquals(flexTable1.getAttribute("cellSpacing"), "3");

        List<WebElement> rows = flexTable1.findElements(By.tagName("tr"));
        Assert.assertEquals(rows.size(), 2);
        List<WebElement> cells = flexTable1.findElements(By.tagName("td"));
        Assert.assertEquals(cells.size(), 4);
        Assert.assertEquals(cells.get(0).getText(), "Cell_0_0");

        final PFlexTable pFlexTable1 = get("flexTable1");
        Assert.assertEquals(2, pFlexTable1.getRowCount());
        Assert.assertEquals(2, pFlexTable1.getCellCount(0));

        // clear cell, insert new elements
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = get("flexTable1");
                final PLabel cell11 = get("cell11");
                flexTable1.remove(cell11);
                flexTable1.insertRow(0);
                flexTable1.setWidget(0, 0, new PLabel("Cell_2_0"));
                flexTable1.setWidget(0, 1, new PLabel("Cell_2_1"));
                flexTable1.setWidget(3, 0, new PLabel("Cell_3_0"));
                flexTable1.setWidget(3, 1, new PLabel("Cell_3_1"));
            }
        });

        flexTable1 = findElementById("flexTable1");
        rows = flexTable1.findElements(By.tagName("tr"));
        Assert.assertEquals(rows.size(), 4);

        cells = flexTable1.findElements(By.tagName("td"));
        Assert.assertEquals(cells.size(), 8);
        Assert.assertEquals(cells.get(0).getText(), "Cell_2_0");
        Assert.assertEquals(cells.get(1).getText(), "Cell_2_1");
        Assert.assertEquals(cells.get(2).getText(), "Cell_0_0");
        Assert.assertEquals(cells.get(3).getText(), "Cell_0_1");
        Assert.assertEquals(cells.get(4).getText(), "Cell_1_0");
        Assert.assertEquals(cells.get(5).getText(), "");
        Assert.assertEquals(cells.get(6).getText(), "Cell_3_0");
        Assert.assertEquals(cells.get(7).getText(), "Cell_3_1");

        Assert.assertEquals(4, pFlexTable1.getRowCount());
        Assert.assertEquals(2, pFlexTable1.getCellCount(0));

        // remove row, add/remove row style, add/remove column style, add/remove cell style
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = get("flexTable1");
                flexTable1.removeRow(2);

                flexTable1.getRowFormatter().addStyleName(1, "row1");
                flexTable1.getRowFormatter().addStyleName(2, "row2");
                flexTable1.getRowFormatter().addStyleName(2, "row2bis");
                flexTable1.getRowFormatter().addStyleName(2, "row2ter");
                flexTable1.getRowFormatter().removeStyleName(2, "row2bis");

                flexTable1.getColumnFormatter().addStyleName(0, "col0");
                flexTable1.getColumnFormatter().addStyleName(1, "col1");
                flexTable1.getColumnFormatter().addStyleName(1, "col1bis");
                flexTable1.getColumnFormatter().addStyleName(1, "col1ter");
                flexTable1.getColumnFormatter().removeStyleName(1, "col1bis");

                flexTable1.getCellFormatter().addStyleName(1, 1, "cell11");
                flexTable1.getCellFormatter().addStyleName(2, 0, "cell20");
                flexTable1.getCellFormatter().addStyleName(2, 0, "cell20bis");
                flexTable1.getCellFormatter().addStyleName(2, 0, "cell20ter");
                flexTable1.getCellFormatter().removeStyleName(2, 0, "cell20bis");
            }
        });

        flexTable1 = findElementById("flexTable1");
        rows = flexTable1.findElements(By.tagName("tr"));
        cells = flexTable1.findElements(By.tagName("td"));
        final List<WebElement> cols = flexTable1.findElements(By.tagName("col"));

        Assert.assertEquals(3, rows.size());
        Assert.assertEquals(6, cells.size());
        Assert.assertEquals(2, cols.size());
        Assert.assertTrue(rows.get(1).getAttribute("class").contains("row1"));
        Assert.assertTrue(rows.get(2).getAttribute("class").contains("row2"));
        Assert.assertTrue(rows.get(2).getAttribute("class").contains("row2ter"));
        Assert.assertTrue(!rows.get(2).getAttribute("class").contains("row2bis"));

        Assert.assertTrue(cols.get(0).getAttribute("class").contains("col0"));
        Assert.assertTrue(cols.get(1).getAttribute("class").contains("col1"));
        Assert.assertTrue(cols.get(1).getAttribute("class").contains("col1ter"));
        Assert.assertTrue(!cols.get(1).getAttribute("class").contains("col1bis"));

        Assert.assertTrue(cells.get(3).getAttribute("class").contains("cell11"));
        Assert.assertTrue(cells.get(4).getAttribute("class").contains("cell20"));
        Assert.assertTrue(cells.get(4).getAttribute("class").contains("cell20ter"));
        Assert.assertTrue(!cells.get(4).getAttribute("class").contains("cell20bis"));

        final PLabel cell00 = (PLabel) pFlexTable1.getWidget(0, 0);
        final PLabel cell31 = (PLabel) pFlexTable1.getWidget(2, 1);
        Assert.assertEquals("Cell_2_0", cell00.getText());
        Assert.assertEquals("Cell_3_1", cell31.getText());

        // colspan / rowspan
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = get("flexTable1");

                flexTable1.setWidget(3, 0, new PLabel("Cell_4_0"));
                flexTable1.setWidget(4, 0, new PLabel("Cell_5_0"));
                flexTable1.setWidget(4, 1, new PLabel("Cell_5_1"));
                flexTable1.setWidget(5, 0, new PLabel("Cell_6_0"));

                flexTable1.getFlexCellFormatter().setColSpan(3, 0, 2);
                flexTable1.getFlexCellFormatter().setRowSpan(4, 1, 2);
            }
        });
View Full Code Here

        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {

                final PLabel focusTest = new PLabel("Focus top label");
                focusTest.ensureDebugId("focusTopLabel");
                final PLabel focusTest2 = new PLabel("Focus bottom label");
                focusTest2.ensureDebugId("focusBottomLabel");

                final PFocusPanel focusPanel1 = new PFocusPanel();
                focusPanel1.setHeight("30px");
                focusPanel1.setWidth("300px");
                focusPanel1.setStyleProperty("border", "1px solid blue");
                focusPanel1.ensureDebugId("focusPanel1");
                focusPanel1.setWidget(new PLabel("A focusable widget"));
                focusPanel1.addMouseOverHandler(eventsListener);
                focusPanel1.addFocusHandler(eventsListener);
                focusPanel1.addKeyPressHandler(eventsListener);
                focusPanel1.addKeyUpHandler(eventsListener);
                focusPanel1.addBlurHandler(eventsListener);
View Full Code Here

            @Override
            public void onRequest() {
                final PHorizontalPanel horizontal1 = new PHorizontalPanel();
                horizontal1.ensureDebugId("horizontal1");
                horizontal1.add(new PLabel("cell1"));
                horizontal1.add(new PLabel("cell2"));
                horizontal1.add(new PLabel("cell3"));
                horizontal1.add(new PLabel("cell4"));
                horizontal1.setBorderWidth(2);
                horizontal1.setSpacing(3);
                PRootPanel.get().add(horizontal1);
                register(horizontal1);
            }
View Full Code Here

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PLabel label2 = new PLabel();
                label2.ensureDebugId("label2");
                label2.setText("A label");
                PRootPanel.get().add(label2);
                register(label2);
            }
        });

        final WebElement label2 = findElementById("label2");
        final PLabel plabel2 = get("label2");
        Assert.assertEquals("A label", label2.getText());
        Assert.assertEquals("A label", plabel2.getText());
    }
View Full Code Here

        updateUI(new RequestHandler() {

            @SuppressWarnings("unchecked")
            @Override
            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();
View Full Code Here

    public SortableHeaderCellRenderer(final String caption, final String key) {
        this(caption, key, null);
    }

    public SortableHeaderCellRenderer(final String caption, final String key, final FilterListener filterListener) {
        this.title = new PLabel(caption);
        this.key = key;
        this.filterListener = filterListener;

        builGUI();
    }
View Full Code Here

        super(caption, formField, key, filterListener);
    }

    @Override
    protected void buildCaption(final String s) {
        caption = new PLabel(s);
        panel.setWidget(0, 0, caption);
    }
View Full Code Here

TOP

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

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.