jeudi 8 mai 2014

How to make items in a Tree unselectable

I have a Tree object which contains a few objects of my own class (MenuItem) which has a few simple attributes (mostly Strings). When specific conditions are met, I would like to make some of the items in the Tree are unselectable, so that the user cannot select them in the tree.

Here is how my tree is defined:



Code:



Tree<MenuItem, ?> menuTree = getView().getMenu();

TreeSelectionModel<MenuItem> selectionModel = menuTree.getSelectionModel();
selectionModel.addSelectionHandler(new SelectionHandler<MenuItem>() {

@Override
public void onSelection(SelectionEvent<MenuItem> event) {
MenuItem menu = event.getSelectedItem();

// some business logic code

}
});

Is there any way how to do that? Do I need to have a custom selection model for my Tree?


Aucun commentaire:

Enregistrer un commentaire