}
return null;
}
private Tree createChartsTree() {
final Tree tree = new Tree("Chart Type");
tree.setContainerDataSource(getContainer());
tree.setImmediate(true);
tree.setItemCaptionPropertyId(TREE_ITEM_CAPTION_PROP_ID);
tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);
tree.setNullSelectionAllowed(false);
for (Object id : tree.rootItemIds()) {
tree.expandItemsRecursively(id);
}
tree.addListener(new Tree.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
try {
Object selectedId = event.getProperty().getValue();
if (tree.getParent(selectedId) != null) {
Object parentId = tree.getParent(selectedId);
String demoSeriesTypeName = (String) tree
.getContainerProperty(parentId,
TREE_ITEM_CAPTION_PROP_ID).getValue();
String seriesInstanceName = (String) tree
.getContainerProperty(selectedId,
TREE_ITEM_CAPTION_PROP_ID).getValue();
System.out.println("parent : " + demoSeriesTypeName
+ ", selected : " + seriesInstanceName);
showChart(demoSeriesTypeName, seriesInstanceName);
} else {
String demoSeriesTypeName = (String) tree
.getContainerProperty(selectedId,
TREE_ITEM_CAPTION_PROP_ID).getValue();
System.out.println("Selected " + demoSeriesTypeName);
showChartInstancesForSeriesType(demoSeriesTypeName);
}