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