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

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


            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 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

TOP

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

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.