throw new IllegalArgumentException("No focusable children to focus on");
}
}
public static Tree createTree() {
Tree tree = new Tree();
TreeItem a = new TreeItem("a");
TreeItem b = new TreeItem(
"b, though this is a very, very long text field in order to trigger text wrapping bugs, if there are any such bugs currently in the tree.");
TreeItem ba = new TreeItem("b.a");
TreeItem bb = new TreeItem("b.b");
TreeItem bba = new TreeItem("b.b.a");
TreeItem bc = new TreeItem("b.c");
TreeItem c = new TreeItem("c");
TreeItem d = new TreeItem(new RadioButton("myradio",
"I should line up nicely"));
TreeItem e = new TreeItem(new CheckBox("I should line up nicely"));
TreeItem f = new TreeItem(new CheckBox("I should also line up nicely"));
f.addItem(new CheckBox("me to"));
SimplePanel panel = new SimplePanel();
panel.setWidget(new Label("There should not be any space above me"));
TreeItem g = new TreeItem(panel);
tree.setSelectedItem(b);
tree.addItem(a);
tree.addItem(b);
tree.addItem(c);
tree.addItem(d);
tree.addItem(e);
tree.addItem(f);
tree.addItem(g);
b.addItem(ba);
b.addItem(bb);
bb.addItem(bba);
b.addItem(bc);
// Focus checks
DelegatingFocusPanel focus = new DelegatingFocusPanel();
focus.add(new Label("first check box should have focus "));
focus.add(new SimpleCheckBox());
focus.add(new SimpleCheckBox());
final DelegatingFocusPanel focus2 = new DelegatingFocusPanel();
focus2.add(new Label("second check box should have focus "));
focus2.add(new SimpleCheckBox());
focus2.add(new SimpleCheckBox());
TreeItem customFocus = new TreeItem(focus2) {
@Override
public Focusable getFocusable() {
return (Focusable) focus2.getWidget(2);
}
};
tree.addItem(focus);
tree.addItem(customFocus);
return tree;
}