@Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);
setLayout(new FlowLayout(10));
final Window complex = new Window();
complex.setMaximizable(true);
complex.setHeading("Accordion Window");
complex.setWidth(200);
complex.setHeight(350);
ToolBar toolBar = new ToolBar();
Button item = new Button();
item.setIcon(Resources.ICONS.connect());
toolBar.add(item);
toolBar.add(new SeparatorToolItem());
complex.setTopComponent(toolBar);
item = new Button();
item.setIcon(Resources.ICONS.user_add());
toolBar.add(item);
item = new Button();
item.setIcon(Resources.ICONS.user_delete());
toolBar.add(item);
complex.setIcon(Resources.ICONS.accordion());
complex.setLayout(new AccordionLayout());
ContentPanel cp = new ContentPanel();
cp.setAnimCollapse(false);
cp.setHeading("Online Users");
cp.setLayout(new FitLayout());
cp.getHeader().addTool(new ToolButton("x-tool-refresh"));
complex.add(cp);
TreeStore<ModelData> store = new TreeStore<ModelData>();
TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
tree.setIconProvider(new ModelIconProvider<ModelData>() {
public AbstractImagePrototype getIcon(ModelData model) {
if (model.get("icon") != null) {
return IconHelper.createStyle((String) model.get("icon"));
} else {
return null;
}
}
});
tree.setDisplayProperty("name");
ModelData m = newItem("Family", null);
store.add(m, false);
tree.setExpanded(m, true);
store.add(m, newItem("Darrell", "user"), false);
store.add(m, newItem("Maro", "user-girl"), false);
store.add(m, newItem("Lia", "user-kid"), false);
store.add(m, newItem("Alec", "user-kid"), false);
store.add(m, newItem("Andrew", "user-kid"), false);
m = newItem("Friends", null);
store.add(m, false);
tree.setExpanded(m, true);
store.add(m, newItem("Bob", "user"), false);
store.add(m, newItem("Mary", "user-girl"), false);
store.add(m, newItem("Sally", "user-girl"), false);
store.add(m, newItem("Jack", "user"), false);
cp.add(tree);
cp = new ContentPanel();
cp.setAnimCollapse(false);
cp.setHeading("Settings");
cp.setBodyStyleName("pad-text");
cp.addText(TestData.DUMMY_TEXT_SHORT);
complex.add(cp);
cp = new ContentPanel();
cp.setAnimCollapse(false);
cp.setHeading("Stuff");
cp.setBodyStyleName("pad-text");
cp.addText(TestData.DUMMY_TEXT_SHORT);
complex.add(cp);
cp = new ContentPanel();
cp.setAnimCollapse(false);
cp.setHeading("More Stuff");
cp.setBodyStyleName("pad-text");
cp.addText(TestData.DUMMY_TEXT_SHORT);
complex.add(cp);
add(new Button("Open", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
complex.show();
}
}));
}