java - How to determine if a TreeItem is a leaf or not -
i have jface treeviewer
wherein user can select treeitem
, check whether ist leaf node or not through menu option.
how achieve this?
you can selected object tree viewer with:
istructuredselection selection = (istructuredselection)viewer.getselection(); object selected = selection.getfirstelement();
where 'viewer' treeviewer
selected
model object returned content provider.
you can use content provider test if has children with:
itreecontentprovider provider = (itreecontentprovider)viewer.getcontentprovider(); boolean haschildren = provider.haschildren(selected);