}
protected LayoutClickListener createLayoutClickListener() {
return new LayoutClickListener() {
public void layoutClick(LayoutClickEvent event) {
FlexibleOptionGroupItemComponent c = null;
boolean allowUnselection = optionGroup.isMultiSelect();
if (event.getChildComponent() instanceof FlexibleOptionGroupItemComponent) {
c = (FlexibleOptionGroupItemComponent) event.getChildComponent();
}
else if (event.getChildComponent() instanceof AbstractComponent) {
Object data = ((AbstractComponent) event.getChildComponent()).getData();
if (data instanceof FlexibleOptionGroupItemComponent) {
c = (FlexibleOptionGroupItemComponent) data;
}
if (event.getChildComponent() instanceof HorizontalLayout) {
allowUnselection = false;
}
}
if (c != null) {
Object itemId = c.getItemId();
if (optionGroup.isSelected(itemId) && allowUnselection) {
optionGroup.unselect(itemId);
}
else {
optionGroup.select(itemId);