Package com.ponysdk.ui.server.basic

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


        super.onFirstShowPage();

        scroll = new PScrollPanel();
        layout = new PFlowPanel();
        actions = new PFlexTable();
        listContainer = new PSimplePanel();

        scroll.setWidget(layout);
        layout.add(actions);
        layout.add(listContainer);
View Full Code Here


        super.onFirstShowPage();

        final PScrollPanel scroll = new PScrollPanel();
        final PFlowPanel layout = new PFlowPanel();
        final PFlexTable formContainer = new PFlexTable();
        final PSimplePanel listContainer = new PSimplePanel();
        layout.add(formContainer);

        final PButton add = new PButton("Add");
        add.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                final Integer i = Integer.parseInt(line.getText());
                final Pony father = dataGrid.getVisibleItem(i);
                final List<Pony> copy = new ArrayList<Pony>();
                for (int j = 0; j < 3; j++) {
                    final Pony p = new Pony(father.getId(), "Copy-" + father.getName(), father.getAge(), father.getRace());
                    copy.add(p);
                }
                dataGrid.insertSubList(father, copy);
            }
        });

        final PButton remove = new PButton("Remove");
        remove.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                final Integer i = Integer.parseInt(line.getText());
                final Pony father = dataGrid.getVisibleItem(i);
                dataGrid.removeSubList(father);
            }
        });

        layout.add(line);
        layout.add(add);
        layout.add(remove);
        layout.add(listContainer);
        scroll.setWidget(layout);
        examplePanel.setWidget(scroll);

        // Register handler
        addHandler(SubmitFormEvent.TYPE, this);

        final Pager<Pony> pager = new Pager<Pony>(new DefaultPagerView());
        dataGrid = new DataGridActivity<Pony>(new DefaultSimpleListView());

        final DefaultActionSelectorView actionSelectorView = new DefaultActionSelectorView();
        final DefaultInfoSelectorView infoSelectorView = new DefaultInfoSelectorView();
        final CompositeSelectorView selectorView = new CompositeSelectorView(actionSelectorView, infoSelectorView);
        final Selector<Pony> selector = new Selector<Pony>(selectorView);

        final RemoteDataProvider<Pony> dataProvider = new RemoteDataProvider<Pony>(pager, dataGrid) {

            @Override
            protected List<Pony> getData(final Query query) {
                final Result<List<Pony>> result = new FindPonysCommand(query).execute();
                final List<Pony> data = result.getData();
                final int fullSize = result.getFullSize();
                pager.process(fullSize);
                selector.reset();
                selector.setPageSize(data.size());
                selector.setFullSize(fullSize);
                return data;
            }

            @Override
            protected List<Pony> getFullData(final Query query) {
                return new FindPonysCommand(query).execute().getData();
            }

        };

        final DataGridColumnDescriptor<Pony, Pony> selectColumnDescriptor = new DataGridColumnDescriptor<Pony, Pony>();
        selectColumnDescriptor.setHeaderCellRenderer(new StringHeaderCellRenderer("Select"));
        selectColumnDescriptor.setValueProvider(new IdentityValueProvider<Pony>());
        final CellRenderer<Pony> selectCellRenderer = new CellRenderer<Pony>() {

            @Override
            public IsPWidget render(final int row, final Pony value) {
                final SelectorCheckBox<Pony> selectorCheckBox = new SelectorCheckBox<Pony>();
                selectorCheckBox.setData(value);
                selectorCheckBox.addSelectableListener(selector);
                selector.registerSelectable(selectorCheckBox);

                selectorCheckBox.addValueChangeHandler(new PValueChangeHandler<Boolean>() {

                    @Override
                    public void onValueChange(final PValueChangeEvent<Boolean> event) {
                        if (event.getValue()) {
                            selectorCheckBox.onCheck();
                            dataGrid.selectRow(value);

                        } else {
                            selectorCheckBox.onUncheck();
                            dataGrid.unSelectRow(value);

                        }
                    }
                });

                return selectorCheckBox;
            }
        };
        selectColumnDescriptor.setCellRenderer(selectCellRenderer);
        selectColumnDescriptor.setSubCellRenderer(selectCellRenderer);

        final DataGridColumnDescriptor<Pony, Pony> descriptor = new DataGridColumnDescriptor<Pony, Pony>();
        descriptor.setHeaderCellRenderer(new HeaderCellRenderer() {

            @Override
            public IsPWidget render() {
                return new PLabel();
            }
        });

        final DataGridColumnDescriptor<Pony, String> nameColumnDescriptor = new DataGridColumnDescriptor<Pony, String>();
        final ComplexHeaderCellRenderer nameHeaderCellRender = new FilterableHeaderCellRenderer("Name", new StringTextBoxFormField(), "name");
        nameHeaderCellRender.addFilterListener(dataProvider);
        nameColumnDescriptor.setHeaderCellRenderer(nameHeaderCellRender);
        nameColumnDescriptor.setValueProvider(new BeanValueProvider<Pony, String>("name"));
        nameColumnDescriptor.setCellRenderer(new LabelCellRenderer<String>());
        nameColumnDescriptor.setSubCellRenderer(new LabelCellRenderer<String>());

        nameColumnDescriptor.setSubCellRenderer(new LabelCellRenderer<String>());

        final PListBox ageListBox = new PListBox(true);
        for (int i = 0; i < 30; i++)
            ageListBox.addItem(i + " year", i);

        final DataGridColumnDescriptor<Pony, String> ageColumnDescriptor = new DataGridColumnDescriptor<Pony, String>();
        ageColumnDescriptor.setValueProvider(new BeanValueProvider<Pony, String>("age"));
        final ComplexHeaderCellRenderer ageHeaderCellRender = new ComplexHeaderCellRenderer("Age", new ListBoxFormField<Integer>(ageListBox), "age");
        ageHeaderCellRender.addFilterListener(dataProvider);
        ageColumnDescriptor.setHeaderCellRenderer(ageHeaderCellRender);
        ageColumnDescriptor.setCellRenderer(new LabelCellRenderer<String>());
        ageColumnDescriptor.setSubCellRenderer(new LabelCellRenderer<String>());

        final DataGridColumnDescriptor<Pony, String> raceColumnDescriptor = new DataGridColumnDescriptor<Pony, String>();
        raceColumnDescriptor.setValueProvider(new BeanValueProvider<Pony, String>("race"));
        final ComplexHeaderCellRenderer raceHeaderCellRender = new ComplexHeaderCellRenderer("Race", new StringTextBoxFormField(), "race");
        raceHeaderCellRender.addFilterListener(dataProvider);
        raceColumnDescriptor.setHeaderCellRenderer(raceHeaderCellRender);
        raceColumnDescriptor.setCellRenderer(new LabelCellRenderer<String>());
        raceColumnDescriptor.setSubCellRenderer(new LabelCellRenderer<String>());

        dataGrid.addDataGridColumnDescriptor(selectColumnDescriptor);
        dataGrid.addDataGridColumnDescriptor(nameColumnDescriptor);
        dataGrid.addDataGridColumnDescriptor(ageColumnDescriptor);
        dataGrid.addDataGridColumnDescriptor(raceColumnDescriptor);

        dataProvider.registerHasCriteria(ageHeaderCellRender);
        dataProvider.registerHasCriteria(nameHeaderCellRender);
        dataProvider.registerHasCriteria(raceHeaderCellRender);

        formContainer.setWidget(0, 0, actionSelectorView);

        final PButton refresh = new PButton("Refresh");
        refresh.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                dataProvider.onPageChange(0);
            }
        });
        formContainer.setWidget(0, 1, refresh);

        final PButton addPonyButton = new PButton("Create new pony");
        addPonyButton.addClickHandler(new PClickHandler() {

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

        });
        addPonyButton.addStyleName(PonySDKTheme.BUTTON_GREEN);
        formContainer.setWidget(0, 2, addPonyButton);

        formContainer.setWidget(0, 3, pager.asWidget());
        formContainer.setWidget(0, 4, infoSelectorView);

        // Build create pony form
        buildCreatePonyActivity();

        dataProvider.onPageChange(0);
View Full Code Here

        createPony.addFormField(nameFormField);
        createPony.addFormField(raceFormField);
        createPony.addFormField(ageFormField);

        createPonyActivityPanel = new PFlexTable();
        createPonyActivityPanel.setWidget(0, 0, new PLabel("Add a pony"));
        createPonyActivityPanel.getFlexCellFormatter().setColSpan(0, 0, 3);
        createPonyActivityPanel.setWidget(1, 0, new FormFieldComponent("Name", nameFormField));
        createPonyActivityPanel.setWidget(1, 1, new FormFieldComponent("Race", raceFormField));
        createPonyActivityPanel.setWidget(1, 2, new FormFieldComponent("Age", ageFormField));
View Full Code Here

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

        final PFlexTable table = new PFlexTable();

        final PListBox listBoxCategory = new PListBox();
        listBoxCategory.addItem("Test1");
        listBoxCategory.addItem("Test2");
        listBoxCategory.addItem("Test3");
        listBoxCategory.addItem("Test2");
        listBoxCategory.addItem("Test2");
        listBoxCategory.addItem("Test2");
        listBoxCategory.addItem("Test2");
        listBoxCategory.addItem("Test2");
        listBoxCategory.addItem("Test2");

        table.setWidth("100%");
        table.setWidget(0, 0, listBoxCategory);

        final PListBox roleListBox = new PListBox(false, true);
        roleListBox.setVisibleItemCount(5);
        for (int i = 0; i < 10; i++) {
            roleListBox.addItem("Role" + i, i);
        }

        final PButton selectedRole = new PButton("Selected roles [1,2]");
        selectedRole.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                roleListBox.setSelectedValue(1);
                roleListBox.setSelectedValue(2);

                PNotificationManager.showHumanizedNotification("Selected items " + roleListBox.getSelectedItems());
            }
        });
        final PButton unSelectedRole = new PButton("Selected roles [1,2]");
        unSelectedRole.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                roleListBox.setSelectedValue(1, false);
                roleListBox.setSelectedValue(2, false);
                PNotificationManager.showHumanizedNotification("Unselected items " + roleListBox.getSelectedItems());
            }
        });
        table.setWidget(1, 0, roleListBox);
        table.setWidget(1, 1, selectedRole);
        table.setWidget(1, 2, unSelectedRole);

        examplePanel.setWidget(table);
    }
View Full Code Here

    protected void onFirstShowPage() {

        super.onFirstShowPage();

        row = 0;
        layout = new PFlexTable();

        addLabel("Show a basic popup");
        final PButton anchor2 = addButton("Open");
        anchor2.addClickHandler(new PClickHandler() {
View Full Code Here

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

        PDecoratorPanel decoratorPanel = new PDecoratorPanel();

        PFlexTable panel = new PFlexTable();

        panel.setStyleProperty("padding", "10px");

        panel.setWidget(0, 0, new PLabel("Name :"));
        panel.setWidget(0, 1, new PTextBox("name"));
        panel.setWidget(1, 0, new PLabel("Description :"));
        panel.setWidget(1, 1, new PTextBox("description"));

        decoratorPanel.setWidget(panel);

        examplePanel.setWidget(decoratorPanel);
    }
View Full Code Here

        form.addFormField(gray.formField);
        form.addFormField(grayLight.formField);
        form.addFormField(grayLighter.formField);
        form.addFormField(white.formField);

        final PFlexTable formLayout = new PFlexTable();
        formLayout.setWidget(0, 0, new FormFieldComponent("header", header.formField));
        formLayout.setWidget(1, 0, new FormFieldComponent("headerTextColor", headerTextColor.formField));
        formLayout.setWidget(2, 0, new FormFieldComponent("footer", footer.formField));
        formLayout.setWidget(3, 0, new FormFieldComponent("footerTextColor", footerTextColor.formField));
        formLayout.setWidget(5, 0, new FormFieldComponent("highlight", highlight.formField));

        formLayout.setWidget(0, 1, headerPreview);
        formLayout.setWidget(1, 1, headerTextColorPreview);
        formLayout.setWidget(2, 1, footerPreview);
        formLayout.setWidget(3, 1, footerTextColorPreview);
        formLayout.setWidget(5, 1, highlightPreview);

        formLayout.setWidget(0, 2, new FormFieldComponent("black", black.formField));
        formLayout.setWidget(1, 2, new FormFieldComponent("grayDarker", grayDarker.formField));
        formLayout.setWidget(2, 2, new FormFieldComponent("grayDark", grayDark.formField));
        formLayout.setWidget(3, 2, new FormFieldComponent("gray", gray.formField));
        formLayout.setWidget(4, 2, new FormFieldComponent("grayLight", grayLight.formField));
        formLayout.setWidget(5, 2, new FormFieldComponent("grayLighter", grayLighter.formField));
        formLayout.setWidget(6, 2, new FormFieldComponent("white", white.formField));

        formLayout.setWidget(0, 3, blackPreview);
        formLayout.setWidget(1, 3, grayDarkerPreview);
        formLayout.setWidget(2, 3, grayDarkPreview);
        formLayout.setWidget(3, 3, grayPreview);
        formLayout.setWidget(4, 3, grayLightPreview);
        formLayout.setWidget(5, 3, grayLighterPreview);
        formLayout.setWidget(6, 3, whitePreview);

        final PButton validateButton = new PButton("Validate");
        validateButton.setStyleName("pony-PButton accent");
        validateButton.addClickHandler(new PClickHandler() {
View Full Code Here

    protected void onFirstShowPage() {
        final PPusher pusher = PPusher.initialize();

        super.onFirstShowPage();

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

        labels = new PLabel[100][10];

        for (int r = 0; r < 100; r++) {
            for (int c = 0; c < 10; c++) {
                final PLabel pLabel = new PLabel(r + "_" + c);
                labels[r][c] = pLabel;
                pLabel.setWidth("40px");
                table.setWidget(r, c, pLabel);
            }
        }

        pusher.addConnectionListener(new ConnectionListener() {
View Full Code Here

        final PVerticalPanel verticalPanel = new PVerticalPanel();
        verticalPanel.setSpacing(10);

        // Open popup with custom URL
        final PFlexTable table = new PFlexTable();
        table.setWidget(0, 0, new PLabel("URL"));
        table.setWidget(0, 1, urlTextBox = new PTextBox("https://github.com/PonySDK/PonySDK"));
        table.setWidget(1, 0, new PLabel("Name"));
        table.setWidget(1, 1, nameTextBox = new PTextBox("PonySDK"));
        table.setWidget(2, 0, new PLabel("Features"));
        table.setWidget(2, 1, featuresTextBox = new PTextBox("width=1280,height=800,resizable,status=1"));

        final PButton open = new PButton("Open new window");
        open.addClickHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
                final String url = urlTextBox.getText();
                final String name = nameTextBox.getText();
                final String features = featuresTextBox.getText();
                final PWindow w = new PWindow(url, name, features);
                w.open();
            }
        });

        // Open popup that communicate with server
        final PFlexTable table2 = new PFlexTable();
        table2.setWidget(0, 0, new PLabel("Name"));
        table2.setWidget(0, 1, popNameTextBox = new PTextBox("Popup"));
        table2.setWidget(1, 0, new PLabel("Features"));
        table2.setWidget(1, 1, popFeaturesTextBox = new PTextBox("width=500,height=300,resizable"));

        final PButton open2 = new PButton("Open new window");
        open2.addClickHandler(new PClickHandler() {

            @Override
View Full Code Here

        contentContainer = new PSimplePanel();
        captionContainer.setStyleName(PonySDKTheme.CLOSABLE_DIALOGBOX_CAPTION);
        closeContainer.setStyleName(PonySDKTheme.CLOSABLE_DIALOGBOX_CLOSE);
        contentContainer.setStyleName(PonySDKTheme.CLOSABLE_DIALOGBOX_CONTENT);

        final PFlexTable layout = new PFlexTable();
        layout.addStyleName(PonySDKTheme.CLOSABLE_DIALOGBOX_LAYOUT);

        layout.setWidget(0, 0, captionContainer);
        layout.setWidget(0, 1, closeContainer);
        layout.setWidget(1, 0, contentContainer);

        layout.getFlexCellFormatter().setColSpan(1, 0, 2);
        layout.getFlexCellFormatter().setHorizontalAlignment(0, 0, PHorizontalAlignment.ALIGN_LEFT);
        layout.getFlexCellFormatter().setHorizontalAlignment(0, 1, PHorizontalAlignment.ALIGN_RIGHT);
        layout.getFlexCellFormatter().addStyleName(0, 0, PonySDKTheme.CLOSABLE_DIALOGBOX_HEADER);
        layout.getFlexCellFormatter().addStyleName(0, 1, PonySDKTheme.CLOSABLE_DIALOGBOX_HEADER);

        closeContainer.addDomHandler(new PClickHandler() {

            @Override
            public void onClick(final PClickEvent event) {
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.