final PVerticalPanel panel = new PVerticalPanel();
panel.add(new PLabel("Static Tree:"));
final PTree tree = new PTree();
tree.setAnimationEnabled(false);
tree.setWidth("300px");
tree.addSelectionHandler(new PSelectionHandler<PTreeItem>() {
@Override
public void onSelection(final PSelectionEvent<PTreeItem> event) {
final String msg = "Selected item : name = " + event.getSelectedItem();
UIContext.getRootEventBus().fireEvent(new DemoBusinessEvent(msg));
}
});
final PTreeItem firstItem = new PTreeItem("First item");
final PAnchor anchor = new PAnchor("Second item");
final PTreeItem secondItem = new PTreeItem(anchor);
anchor.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
secondItem.setState(secondItem.getState() ? false : true);
}
});
final PTreeItem thirdItem = new PTreeItem(new PImage("images/pony.png"));
tree.addItem(firstItem);
tree.addItem(secondItem);
tree.addItem(thirdItem);
final Query query = new Query();
final FindPonysCommand command = new FindPonysCommand(query);
final Result<List<Pony>> ponys = command.execute();