Package com.ponysdk.ui.server.basic

Examples of com.ponysdk.ui.server.basic.PFlexTable$PFlexCellFormatter


    @Override
    protected void onFirstShowPage() {
        super.onFirstShowPage();

        final PFlexTable table = new PFlexTable();
        table.setCellPadding(0);
        table.setCellSpacing(0);
        table.setSizeFull();

        final PVerticalPanel bodyLayout = new PVerticalPanel();
        bodyLayout.setSizeFull();

        final PButton button = new PButton("Remove last row");
        button.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent clickEvent) {
                table.removeRow(table.getRowCount() - 1);
            }
        });

        bodyLayout.add(button);
        bodyLayout.add(table);

        final PButton scheduleButton = new PButton("Schedule");
        scheduleButton.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent clickEvent) {
                if (currentTimer != null) {
                    currentTimer.cancel();
                }

                currentTimer = new PTimer() {

                    @Override
                    public void run() {
                        time++;
                        updateTableData(100);
                    }
                };

                for (int r = 0; r < 100; r++) {
                    for (int c = 0; c < 6; c++) {
                        final PLabel label = new PLabel(r + "_" + c + Math.random());
                        labels[r][c] = label;
                        table.setWidget(r, c, label);
                    }
                }

                currentTimer.scheduleRepeating(Integer.valueOf(textBox.getText()));
            }
View Full Code Here


    @Override
    protected void onFirstShowPage() {
        super.onFirstShowPage();

        final PFlexTable panel = new PFlexTable();

        final Form form = new Form();

        final FormField<String> field1 = new StringTextBoxFormField();
        field1.setValidator(new NotEmptyFieldValidator());
        final FormField<String> field2 = new StringTextBoxFormField();
        field2.setValidator(new DoubleFieldValidator());
        final FormField<String> field3 = new StringTextBoxFormField();
        field3.setValidator(new CompositeFieldValidator(new NotEmptyFieldValidator(), new DoubleFieldValidator()));
        final FormField<String> field4 = new StringTextBoxFormField();
        field4.setValidator(new CompositeFieldValidator(new NotEmptyFieldValidator(), new EmailFieldValidator()));
        final FormField<Boolean> field5 = new CheckBoxFormField();
        field5.setValidator(new UncheckedFieldValidator());

        final PListBox listBox = new PListBox(true);
        listBox.addItem("Item 1");
        listBox.addItem("Item 2");
        listBox.addItem("Item 3");
        listBox.addItem("Item 4");
        listBox.addItem("Item 5");
        listBox.addItem("Item 6");

        final FormField<String> field6 = new StringListBoxFormField(listBox);
        field6.setValidator(new NotEmptyFieldValidator());

        final FormField<Date> field7 = new DateBoxFormField();
        field7.setValidator(new NotEmptyFieldValidator());

        final FormField<Date> field8 = new DateBoxFormField();
        field7.setValidator(new NotEmptyFieldValidator());

        final FormField<String> field9 = new StringTextBoxFormField();
        field9.setValidator(new NotEmptyFieldValidator());

        final FormField<String> field10 = new StringTextBoxFormField();
        field10.setValidator(new TwinFieldValidator("Field doesn't match", field9));

        form.addFormField(field1);
        form.addFormField(field2);
        form.addFormField(field3);
        form.addFormField(field4);
        form.addFormField(field5);
        form.addFormField(field6);
        form.addFormField(field7);
        form.addFormField(field8);
        form.addFormField(field9);
        form.addFormField(field10);

        final FormFieldComponent formFieldComponent1 = new FormFieldComponent("field1", field1);
        final FormFieldComponent formFieldComponent2 = new FormFieldComponent("field2", field2);
        final FormFieldComponent formFieldComponent3 = new FormFieldComponent("field3", field3);
        final FormFieldComponent formFieldComponent4 = new FormFieldComponent("field4", field4);
        final FormFieldComponent formFieldComponent5 = new FormFieldComponent("field5", field5);
        final FormFieldComponent formFieldComponent6 = new FormFieldComponent("field6", field6);
        final FormFieldComponent formFieldComponent7 = new FormFieldComponent("field7", field7);
        final FormFieldComponent formFieldComponent8 = new FormFieldComponent("field8", field8);
        final FormFieldComponent formFieldComponent9 = new FormFieldComponent("field9", field9);
        final FormFieldComponent formFieldComponent10 = new FormFieldComponent("field10", field10);

        final PFlexTable formLayout = new PFlexTable();
        formLayout.addStyleName("cell-top");
        formLayout.setWidget(0, 0, formFieldComponent1);
        formLayout.setWidget(0, 1, formFieldComponent2);
        formLayout.setWidget(1, 0, formFieldComponent3);
        formLayout.setWidget(1, 1, formFieldComponent4);
        formLayout.setWidget(2, 0, formFieldComponent5);
        formLayout.setWidget(2, 1, formFieldComponent6);
        formLayout.setWidget(3, 0, formFieldComponent7);
        formLayout.setWidget(3, 1, formFieldComponent8);
        formLayout.setWidget(4, 0, formFieldComponent9);
        formLayout.setWidget(4, 1, formFieldComponent10);

        final PButton validateButton = new PButton("Validate");
        validateButton.addClickHandler(new PClickHandler() {

            @Override
View Full Code Here

    }

    public ComplexHeaderCellRenderer(final String caption, final FormField formField, final String pojoPropertyKey, final boolean enableComparatorType) {

        this.caption = caption;
        this.container = new PFlexTable();
        this.formField = formField;
        this.header = new PLabel(caption);
        this.sortableHeader = new SortableHeader(header, pojoPropertyKey);

        container.setSizeFull();
View Full Code Here

        // creation
        updateUI(new RequestHandler() {

            @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);
            }
        });

        flexTable1 = findElementById("flexTable1");
        rows = flexTable1.findElements(By.tagName("tr"));
        cells = flexTable1.findElements(By.tagName("td"));

        Assert.assertEquals(6, rows.size());
        Assert.assertEquals(10, cells.size());
        Assert.assertEquals("2", cells.get(6).getAttribute("colSpan"));
        Assert.assertEquals("2", cells.get(8).getAttribute("rowSpan"));
View Full Code Here

TOP

Related Classes of com.ponysdk.ui.server.basic.PFlexTable$PFlexCellFormatter

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.