if I write the following
public static HierarchicalContainer getContainer() {
Item root = null;
Item son = null;
HierarchicalContainer hwContainer = new HierarchicalContainer();
//root Property Name
hwContainer.addContainerProperty(dp_PROPERTY_NAME, String.class, null);
// root Icon
hwContainer.addContainerProperty(dp_PROPERTY_ICON, ThemeResource.class,
new ThemeResource("icons/16/folder.png"));
root = hwContainer.addItem(0);
root.getItemProperty(dp_PROPERTY_NAME).setValue(dispositivo[0]
);
hwContainer.setChildrenAllowed(0, false);
for (int i = 1; i < source.length; i++) {
//son property
son = hwContainer.addItem(i);
//son icon
son.getItemProperty(dp_PROPERTY_NAME).setValue(source[i]
);
son.getItemProperty(dp_PROPERTY_ICON).setValue(
new ThemeResource("icons/16/document.png"));
//root and you son
hwContainer.setParent(i, 0);
hwContainer.setChildrenAllowed(i, false);
}
return hwContainer;
}
I have now
root
[0]
—> (Property.Name,icon)------->(“source 0”,folder.png)
[1]
------>(Property.Name,icon)------->(“source 1”,document.png)
[2]
------>(Property.Name,icon)------->(“source 2”,document.png)
I write the following
myTree.setContainerDataSource(DataTree.getContainer());
I write the following
Item item = event.getItem();
Property name = item.getItemProperty(DataTree.dp_PROPERTY_NAME);
String valor = (String) name.getValue();
valor=“source 0”;
icon=??
id=???
I get the id???
I get the icon??
and as I get all id in tree ???