Tree caption select

Hi,
I started using Vaadin framework a couple weeks ago and I must say “It’s great!”.

I have question regarding expand/collapse tree items. Is there a way to expand/collapse item by clicking on item caption??

Thanks in advance.

Pseudocode…

	@Override
	public void valueChange(final Property.ValueChangeEvent event) {
		.
		.
		.
		.
		if (menuItem.isLeaf()) {
			if (tree.isExpanded(menuItem.getNodeId())) {
				tree.collapseItem(menuItem.getNodeId());
			} else {
				tree.expandItem(menuItem.getNodeId());
			}
		}
	}

Hi Carlo,
Thank you for your answer, but this is not what i am looking for.
Value change event fired only when you click onto item caption. This will not work properly, double click on item caption expand items, which is ok, but when you again click on it will not collapse because value didnt change, its the same. You need to click on other item, so the event could be fired, and item will collapse.
This will be problem if you have one parent node, you will need to click on child to activate event.

So this is not the proper solution!

I wanna item caption to behave like link for expand/collapse items, ValueChangeListener is not the answer.

PLS, Update!

“Item caption is item”. -_- ItemClickListener is solution.
Thanks