Package com.ponysdk.ui.server.basic

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


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

        final PFlowPanel panel = new PFlowPanel();

        final PListBox listBox = new PListBox(true);
        listBox.addItem("Altai horseBengin");
        listBox.addItem("American Warmblood");
        listBox.addItem("Falabella");
        listBox.addItem("Friesian horse");
        listBox.addItem("Mustang");
        listBox.addItem("Altai horse");

        listBox.addChangeHandler(new PChangeHandler() {

            @Override
            public void onChange(final PChangeEvent event) {
                if (listBox.getSelectedIndex() != -1) {
                    PNotificationManager.showTrayNotification("Item selected : " + listBox.getSelectedItem());
                }
            }
        });

        final PListBox multiListBox = new PListBox(true, true);
        multiListBox.setVisibleItemCount(10);
        multiListBox.addItem("Altai horseBengin");
        multiListBox.addItem("American Warmblood");
        multiListBox.addItem("Falabella");
        multiListBox.addItem("Friesian horse");
        multiListBox.addItem("Mustang");
        multiListBox.addItem("Altai horse");

        multiListBox.addChangeHandler(new PChangeHandler() {

            @Override
            public void onChange(final PChangeEvent event) {
                PNotificationManager.showTrayNotification("Item selected : " + multiListBox.getSelectedItems());
            }
        });

        panel.add(listBox);
        panel.add(multiListBox);
View Full Code Here


        examplePanel.setWidget(scrollPanel);
    }

    private PListBox buildIntListBox() {
        final PListBox r = new PListBox(false);
        for (int i = 0; i < 10; i++) {
            r.addItem("" + i, i);
        }
        r.setSelectedIndex(0);
        return r;
    }
View Full Code Here

        r.setSelectedIndex(0);
        return r;
    }

    private PListBox buildActionListBox() {
        final PListBox r = new PListBox(false);
        r.addItem("add row style", 1);
        r.addItem("remove row style", 2);
        r.addItem("set row style", 3);
        r.addItem("add column style", 4);
        r.addItem("remove column style", 5);
        r.addItem("set column style", 6);
        r.addItem("add cell style", 7);
        r.addItem("remove cell style", 8);
        r.addItem("set cell style", 9);
        r.setSelectedIndex(0);
        return r;
    }
View Full Code Here

        r.setSelectedIndex(0);
        return r;
    }

    private PListBox buildStyleListBox() {
        final PListBox r = new PListBox(false);
        r.addItem("orange", "orange");
        r.addItem("yellow", "yellow");
        r.addItem("bold", "bold");
        r.setSelectedIndex(0);
        return r;
    }
View Full Code Here

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

        final PTwinListBox<String> twinListBox = new PTwinListBox<String>("From", "To");

        final PListBox leftListBox = twinListBox.getLeftListBox();
        leftListBox.addItem("Item1");
        leftListBox.addItem("Item2");
        leftListBox.addItem("Item3");
        leftListBox.addItem("Item4");
        leftListBox.addItem("Item5");
        leftListBox.setVisibleItemCount(10);
        leftListBox.addChangeHandler(new PChangeHandler() {

            @Override
            public void onChange(final PChangeEvent event) {
                PNotificationManager.showTrayNotification("Item selected : " + leftListBox.getSelectedItem());
            }
        });

        final PListBox rightListBox = twinListBox.getRightListBox();
        rightListBox.addItem("Item6");
        rightListBox.addItem("Item7");
        rightListBox.addItem("Item8");
        rightListBox.addItem("Item9");
        rightListBox.setVisibleItemCount(10);
        rightListBox.addChangeHandler(new PChangeHandler() {

            @Override
            public void onChange(final PChangeEvent event) {
                PNotificationManager.showTrayNotification("Item selected : " + rightListBox.getSelectedItem());
            }
        });

        twinListBox.addChangeHandler(new PChangeHandler() {
View Full Code Here

        // creation / insert / update
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox1 = new PListBox();
                listBox1.ensureDebugId("listBox1");
                listBox1.addItem("Item 1");
                listBox1.addItem("Item 2");
                listBox1.addItem("Item 4");
                listBox1.insertItem("Item 3", 2);
                listBox1.addItem("Item A");
                listBox1.addItem("Item 6");
                listBox1.setItemText(4, "Item 5");
                listBox1.addChangeHandler(eventsListener);
                PRootPanel.get().add(listBox1);
                register(listBox1);
            }
        });

        final WebElement listBox1 = findElementById("listBox1");
        List<WebElement> options = listBox1.findElements(By.tagName("option"));
        final PListBox plistBox1 = get("listBox1");

        Assert.assertEquals(false, plistBox1.isEmptySelection());
        Assert.assertEquals(false, plistBox1.isMultipleSelect());

        Assert.assertEquals(6, options.size());
        Assert.assertEquals("Item 1", options.get(0).getText());
        Assert.assertEquals("Item 2", options.get(1).getText());
        Assert.assertEquals("Item 3", options.get(2).getText());
        Assert.assertEquals("Item 4", options.get(3).getText());
        Assert.assertEquals("Item 5", options.get(4).getText());
        Assert.assertEquals("Item 6", options.get(5).getText());

        Assert.assertEquals("Item 1", plistBox1.getItem(0));
        Assert.assertEquals("Item 2", plistBox1.getItem(1));
        Assert.assertEquals("Item 3", plistBox1.getItem(2));
        Assert.assertEquals("Item 4", plistBox1.getItem(3));
        Assert.assertEquals("Item 5", plistBox1.getItem(4));
        Assert.assertEquals("Item 6", plistBox1.getItem(5));

        options.get(4).click();

        final PChangeEvent e1 = eventsListener.poll();
        Assert.assertNotNull(e1);

        Assert.assertEquals(4, plistBox1.getSelectedIndex());
        Assert.assertEquals("Item 5", plistBox1.getSelectedItem());

        // remove
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox1 = get("listBox1");
                listBox1.removeItem("Item 2");
                listBox1.removeItem(2);
            }
        });

        options = listBox1.findElements(By.tagName("option"));

        Assert.assertEquals(4, options.size());
        Assert.assertEquals("Item 1", options.get(0).getText());
        Assert.assertEquals("Item 3", options.get(1).getText());
        Assert.assertEquals("Item 5", options.get(2).getText());
        Assert.assertEquals("Item 6", options.get(3).getText());

        Assert.assertEquals(4, plistBox1.getItemCount());
        Assert.assertEquals("Item 1", plistBox1.getItem(0));
        Assert.assertEquals("Item 3", plistBox1.getItem(1));
        Assert.assertEquals("Item 5", plistBox1.getItem(2));
        Assert.assertEquals("Item 6", plistBox1.getItem(3));

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

            @Override
            public void onRequest() {
                final PListBox listBox1 = get("listBox1");
                listBox1.setSelectedItem("Item 5");
            }
        });

        Select select = new Select(listBox1);
        final WebElement selectedOption = select.getFirstSelectedOption();
        Assert.assertEquals("Item 5", selectedOption.getText());
        Assert.assertEquals("Item 5", plistBox1.getSelectedItem());

        // clear
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox1 = get("listBox1");
                listBox1.clear();
            }
        });

        select = new Select(listBox1);
        Assert.assertEquals(0, select.getOptions().size());
View Full Code Here

        // creation / insert / update
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox2 = new PListBox(false, true);
                listBox2.ensureDebugId("listBox2");
                listBox2.addItem("Item 1", new Long(1));
                listBox2.addItem("Item 2", new Long(2));
                listBox2.addItem("Item 4", new Long(4));
                listBox2.insertItem("Item 3", new Long(3), 2);
                listBox2.addItem("Item A", new Long(5));
                listBox2.addItem("Item 6", new Long(6));
                listBox2.setItemText(4, "Item 5");
                listBox2.addChangeHandler(eventsListener);
                PRootPanel.get().add(listBox2);
                register(listBox2);
            }
        });

        final WebElement listBox2 = findElementById("listBox2");
        List<WebElement> options2 = listBox2.findElements(By.tagName("option"));
        final PListBox plistBox2 = get("listBox2");

        Assert.assertEquals(false, plistBox2.isEmptySelection());
        Assert.assertEquals(true, plistBox2.isMultipleSelect());

        Assert.assertEquals(6, options2.size());
        Assert.assertEquals("Item 1", options2.get(0).getText());
        Assert.assertEquals("Item 2", options2.get(1).getText());
        Assert.assertEquals("Item 3", options2.get(2).getText());
        Assert.assertEquals("Item 4", options2.get(3).getText());
        Assert.assertEquals("Item 5", options2.get(4).getText());
        Assert.assertEquals("Item 6", options2.get(5).getText());

        Assert.assertEquals("Item 1", plistBox2.getItem(0));
        Assert.assertEquals("Item 2", plistBox2.getItem(1));
        Assert.assertEquals("Item 3", plistBox2.getItem(2));
        Assert.assertEquals("Item 4", plistBox2.getItem(3));
        Assert.assertEquals("Item 5", plistBox2.getItem(4));
        Assert.assertEquals("Item 6", plistBox2.getItem(5));
        Assert.assertEquals(new Long(1), plistBox2.getValue(0));
        Assert.assertEquals(new Long(2), plistBox2.getValue(1));
        Assert.assertEquals(new Long(3), plistBox2.getValue(2));
        Assert.assertEquals(new Long(4), plistBox2.getValue(3));
        Assert.assertEquals(new Long(5), plistBox2.getValue(4));
        Assert.assertEquals(new Long(6), plistBox2.getValue(5));

        final Select select2 = new Select(listBox2);
        select2.selectByIndex(4); // select item5

        final PChangeEvent e2 = eventsListener.poll();
        Assert.assertNotNull(e2);

        Assert.assertEquals(4, plistBox2.getSelectedIndex());
        Assert.assertEquals("Item 5", plistBox2.getSelectedItem());
        Assert.assertEquals(new Long(5), plistBox2.getSelectedValue());

        // remove
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox2 = get("listBox2");
                listBox2.removeItem("Item 2");
                listBox2.removeItem(2);
                listBox2.removeValue(new Long(6));
            }
        });

        options2 = listBox2.findElements(By.tagName("option"));

        Assert.assertEquals(3, options2.size());
        Assert.assertEquals("Item 1", options2.get(0).getText());
        Assert.assertEquals("Item 3", options2.get(1).getText());
        Assert.assertEquals("Item 5", options2.get(2).getText());

        Assert.assertEquals(3, plistBox2.getItemCount());
        Assert.assertEquals("Item 1", plistBox2.getItem(0));
        Assert.assertEquals("Item 3", plistBox2.getItem(1));
        Assert.assertEquals("Item 5", plistBox2.getItem(2));
        Assert.assertEquals(new Long(1), plistBox2.getValue(0));
        Assert.assertEquals(new Long(3), plistBox2.getValue(1));
        Assert.assertEquals(new Long(5), plistBox2.getValue(2));

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

            @Override
            public void onRequest() {
                final PListBox listBox2 = get("listBox2");
                listBox2.setSelectedValue(new Long(3)); // select item3
            }
        });

        final WebElement selectedOption2 = select2.getFirstSelectedOption();
        Assert.assertEquals("Item 3", selectedOption2.getText());
View Full Code Here

public class ListBoxFormField<T> extends FormField<T> {

    private PListBox listBox;

    public ListBoxFormField() {
        this(new PListBox(), null);
    }
View Full Code Here

    public ListBoxFormField() {
        this(new PListBox(), null);
    }

    public ListBoxFormField(final DataConverter<String, T> dataProvider) {
        this(new PListBox(), dataProvider);
    }
View Full Code Here

    public ListBoxFormField(final PListBox listBox) {
        this(listBox, null);
    }

    public ListBoxFormField(final Map<String, T> datas) {
        this(new PListBox(), null);
        for (final Entry<String, T> entry : datas.entrySet()) {
            listBox.addItem(entry.getKey(), entry.getValue());
        }
    }
View Full Code Here

TOP

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

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.