Package org.mcarthur.sandy.gwt.table.client

Examples of org.mcarthur.sandy.gwt.table.client.TableRow


        }

        public void render(final Object obj, final TableBodyGroup rowGroup) {
            final String[] rgs = ptm.getRowGroupSpec().split(" ");

            final TableRow tr = rowGroup.newTableRow();
            for (int i=0; i < rgs.length; i++) {
                final PropertyDescriptor pd = (PropertyDescriptor)propertyDescriptorsMap.get(rgs[i]);
                final TableCell tc = tr.newTableDataCell();
                tc.add(pd.createWidget(obj));
                tr.add(tc);
            }
            rowGroup.add(tr);
        }
View Full Code Here


        }

        public void renderHeader(final TableHeaderGroup headerGroup) {
            final String[] rgs = ptm.getRowGroupSpec().split(" ");

            final TableRow tr = headerGroup.newTableRow();
            for (int i=0; i < rgs.length; i++) {
                final PropertyDescriptor pd = (PropertyDescriptor)propertyDescriptorsMap.get(rgs[i]);
                final TableHeaderCell thc = tr.newTableHeaderCell();

                final MenuBar colMenu = new MenuBar(true);
                if (pd instanceof SortablePropertyDescriptor) {
                    final MenuItem sortItem = createSortMenu((SortablePropertyDescriptor)pd);
                    colMenu.addItem(sortItem);
                }
                if (pd instanceof FilterablePropertyDescriptor) {
                    // TODO: filter menu items
                }

                colMenu.addItem("Hide Column", new Command() {
                    public void execute() {
                        Window.alert("Hide not yet supported.");
                    }
                });

                final MenuBar menu = new MenuBar();
                menu.addItem(pd.getDisplayName(), colMenu);
                thc.add(menu);
                tr.add(thc);
            }
            headerGroup.add(tr);
        }
View Full Code Here

    private static class Renderer1 implements ObjectListTable.Renderer, ObjectListTable.ColSpecRenderer {

        public void render(final Object obj, final TableBodyGroup bodyGroup) {
            final Message message = (Message)obj;
            final TableRow tr = bodyGroup.newTableRow();
            tr.addStyleName("rr");

            final TableDataCell cb = tr.newTableDataCell();
            cb.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
            cb.setWidth("31px");
            cb.add(new CheckBox());

            final TableDataCell star = tr.newTableDataCell();
            star.setWidth("20px");
            star.addStyleName("sc");
            star.addStyleName("t");

            final TableDataCell from = tr.newTableDataCell();
            from.setWidth("27ex");
            from.add(new Label(message.getFrom()));

            final TableDataCell tome = tr.newTableDataCell();
            tome.setWidth("2ex");
            if (message.isTome()) {
                tome.add(new HTML("&raquo;"));
            }

            final TableDataCell subject = tr.newTableDataCell();
            subject.add(new Label(message.getSubject()));

            final TableDataCell attachment = tr.newTableDataCell();
            attachment.setWidth("17px");
            if (message.isAttachment()) {
                attachment.add(new Image("http://mail.google.com/mail/images/paperclip.gif"));
            }

            final TableDataCell date = tr.newTableDataCell();
            date.setWidth("9.5ex");
            date.add(new Label(message.getDate().toString()));

            tr.add(cb);
            tr.add(star);
            tr.add(from);
            tr.add(tome);
            tr.add(subject);
            tr.add(attachment);
            tr.add(date);

            bodyGroup.add(tr);
        }
View Full Code Here

    private static class Renderer2 implements ObjectListTable.Renderer, ObjectListTable.ColSpecRenderer {

        public void render(final Object obj, final TableBodyGroup bodyGroup) {
            final Message message = (Message)obj;
            final TableRow tr = bodyGroup.newTableRow();
            tr.addStyleName("rr");

            final TableDataCell cb = tr.newTableDataCell();
            cb.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
            //cb.setWidth("31px");
            cb.addStyleName("w31px");
            cb.add(new CheckBox());

            final TableDataCell star = tr.newTableDataCell();
            //star.setWidth("20px");
            star.addStyleName("w20px");
            star.addStyleName("sc");
            star.addStyleName("t");

            final TableDataCell from = tr.newTableDataCell();
            //from.setWidth("27ex");
            from.addStyleName("w27ex");
            from.addStyleName("nooverflow");
            from.add(new Label(message.getFrom()));

            final TableDataCell tome = tr.newTableDataCell();
            //tome.setWidth("2ex");
            tome.addStyleName("w2ex");
            if (message.isTome()) {
                tome.add(new HTML("&raquo;"));
            }

            final TableDataCell subject = tr.newTableDataCell();
            subject.add(new Label(message.getSubject()));
            subject.addStyleName("nooverflow");

            final TableDataCell attachment = tr.newTableDataCell();
            //attachment.setWidth("17px");
            attachment.addStyleName("w17px");
            if (message.isAttachment()) {
                attachment.add(new Image("http://mail.google.com/mail/images/paperclip.gif"));
            }

            final TableDataCell date = tr.newTableDataCell();
            //date.setWidth("9.5ex");
            date.addStyleName("w9p5ex");
            date.addStyleName("nooverflow");
            date.add(new Label(message.getDate().toString()));

            tr.add(cb);
            tr.add(star);
            tr.add(from);
            tr.add(tome);
            tr.add(subject);
            tr.add(attachment);
            tr.add(date);

            bodyGroup.add(tr);
        }
View Full Code Here

    }

    private static class NumberRenderer implements ObjectListTable.Renderer {
        public void render(final Object obj, final TableBodyGroup bodyGroup) {
            final Number num = (Number)obj;
            final TableRow tr = bodyGroup.newTableRow();
            final TableDataCell td = tr.newTableDataCell();
            td.add(makeLabel(num));
            tr.add(td);
            bodyGroup.add(tr);
        }
View Full Code Here

    private class OLTR implements ObjectListTable.AttachRenderer, ObjectListTable.ConcealRenderer, ObjectListTable.ColSpecRenderer {

        public void render(final Object obj, final TableBodyGroup rowGroup) {
            final Person person = (Person)obj;

            final TableRow tr = rowGroup.newTableRow();

            final TableCell a = tr.newTableDataCell();
            final CheckBox checkBox = new CheckBox();
            checkBox.setEnabled(false);
            checkBox.setTitle("Doesn't do anything.");
            a.add(checkBox);
            a.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
            a.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
            a.setRowSpan(2);
            tr.add(a);

            final TableCell nameCell = tr.newTableDataCell();
            nameCell.addStyleName("name");
            final TextBox tb = new TextBox();
            tb.addChangeListener(new ChangeListener() {
                public void onChange(final Widget sender) {
                    final TextBox tb = (TextBox)sender;
                    person.setName(tb.getText());
                }
            });
            tb.addKeyboardListener(new KeyboardListenerAdapter() {
                public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
                    super.onKeyUp(sender, keyCode, modifiers);
                    if (KeyboardListener.KEY_ENTER == keyCode) {
                        final TextBox tb = (TextBox)sender;
                        tb.setFocus(false);
                    }
                }
            });
            tb.addFocusListener(new FocusListenerAdapter() {
                public void onFocus(final Widget sender) {
                    tb.setSelectionRange(0, tb.getText().length());
                }
            });
            tb.setText(person.getName());
            nameCell.add(tb);
            tr.add(nameCell);

            final TableCell ageCell = tr.newTableDataCell();
            ageCell.addStyleName("age");
            //ageCell.add(new Label(Integer.toString(person.getAge())));
            ageCell.add(new AgeLabel(person.getAge()));
            ageCell.setWidth("5em");
            ageCell.setAlignment(HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
            tr.add(ageCell);

            final TableCell removeCell = tr.newTableDataCell();
            removeCell.addStyleName("remove");
            final Button button = new Button("Remove");
            button.addClickListener(new ClickListener() {
                public void onClick(final Widget sender) {
                    ot.getObjects().remove(person);
                }
            });
            removeCell.add(button);
            tr.add(removeCell);

            rowGroup.add(tr);

            final TableRow tr2 = rowGroup.newTableRow();
            final TableCell tc2 = tr2.newTableDataCell();
            tc2.addStyleName("random");
            tc2.add(new Label("Something " + Math.random()));
            //tc2.add(makeMenuBar());
            tc2.setColSpan(3);

            tc2.setAxis("summary");
            tr2.add(tc2);
            rowGroup.add(tr2);
        }
View Full Code Here

        public void renderFooter(final TableFooterGroup footerGroup) {
            renderHeaderAndFooter(footerGroup);
        }

        private void renderHeaderAndFooter(final TableRowGroup rowGroup) {
            TableRow tr = rowGroup.newTableRow();

            TableHeaderCell th = tr.newTableHeaderCell();
            th.add(new Label("rowSpan=2", true));
            th.setRowSpan(2);
            tr.add(th);
            {
                th = tr.newTableHeaderCell();
                final MenuBar nameMenu = new MenuBar();

                final MenuBar nameSubMenu = new MenuBar(true);
                final MenuItem nameSortUp = new MenuItem("Sort Up", new Command() {
                    Comparator c = new Comparator() {
                        public int compare(final Object o1, final Object o2) {
                            final Person p1 = (Person)o1;
                            final Person p2 = (Person)o2;
                            return p1.getName().compareTo(p2.getName());
                        }
                    };
                    public void execute() {
                        if (sel != null) {
                            sel.setComparator(c);
                        }
                    }
                });
                final MenuItem nameSortDown = new MenuItem("Sort Down", new Command() {
                    Comparator c = new Comparator() {
                        public int compare(final Object o1, final Object o2) {
                            final Person p1 = (Person)o1;
                            final Person p2 = (Person)o2;
                            return p2.getName().compareTo(p1.getName());
                        }
                    };
                    public void execute() {
                        if (sel != null) {
                            sel.setComparator(c);
                        }
                    }
                });
                nameSubMenu.addItem(nameSortUp);
                nameSubMenu.addItem(nameSortDown);

                final MenuItem nameMenuItem = new MenuItem("Name", nameSubMenu);
                nameMenu.addItem(nameMenuItem);
                th.add(nameMenu);
                tr.add(th);
            }

            {
                th = tr.newTableHeaderCell();
                final MenuBar ageMenu = new MenuBar();

                final MenuBar ageSubMenu = new MenuBar(true);
                final MenuItem ageSortUp = new MenuItem("Sort Up", new Command() {
                    Comparator c = new Comparator() {
                        public int compare(final Object o1, final Object o2) {
                            final Person p1 = (Person)o1;
                            final Person p2 = (Person)o2;
                            return p1.getAge() - p2.getAge();
                        }
                    };
                    public void execute() {
                        if (sel != null) {
                            sel.setComparator(c);
                        }
                    }
                });
                final MenuItem ageSortDown = new MenuItem("Sort Down", new Command() {
                    Comparator c = new Comparator() {
                        public int compare(final Object o1, final Object o2) {
                            final Person p1 = (Person)o1;
                            final Person p2 = (Person)o2;
                            return p2.getAge() - p1.getAge();
                        }
                    };
                    public void execute() {
                        if (sel != null) {
                            sel.setComparator(c);
                        }
                    }
                });
                ageSubMenu.addItem(ageSortUp);
                ageSubMenu.addItem(ageSortDown);

                final MenuItem ageMenuItem = new MenuItem("Age", ageSubMenu);
                ageMenu.addItem(ageMenuItem);
                th.add(ageMenu);
                tr.add(th);
            }
            th = tr.newTableHeaderCell();
            th.add(new Label("Remove"));
            tr.add(th);

            rowGroup.add(tr);

            tr = rowGroup.newTableRow();

            th = tr.newTableHeaderCell();
            th.setColSpan(3);
            th.add(new Label("Random Number"));
            th.setTitle("ColSpan=3");
            tr.add(th);

            rowGroup.add(tr);
        }
View Full Code Here

        public void onAttach(final Object obj, final TableBodyGroup rowGroup) {
            rowGroup.addMouseListener(rgml);
            final Iterator iter = rowGroup.getRows().iterator();
            while (iter.hasNext()) {
                final TableRow tr = (TableRow)iter.next();
                tr.addMouseListener(rml);
            }
        }
View Full Code Here

        public void onDetach(final Object obj, final TableBodyGroup rowGroup) {
            rowGroup.removeMouseListener(rgml);
            final Iterator iter = rowGroup.getRows().iterator();
            while (iter.hasNext()) {
                final TableRow tr = (TableRow)iter.next();
                tr.removeMouseListener(rml);
            }
        }
View Full Code Here

TOP

Related Classes of org.mcarthur.sandy.gwt.table.client.TableRow

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.