/** * Deselects <code>RadioOptionModel</code> items in a group when a selection is made within that * group. Operates by recursively searching <code>MenuModel</code>s for <code>RadioOptionModel * </code>s with a specific group id. * * @param menuModel the <code>MenuModel</code> to search * @param groupId the id of the group to deselect * @param newSelectionId the id of the new selection in the group */ private void deselectGroup(MenuModel menuModel, Object groupId, Object newSelectionId) { int count = menuModel.getItemCount(); for (int i = 0; i < count; ++i) { ItemModel itemModel = menuModel.getItem(i); if (itemModel instanceof MenuModel) { deselectGroup((MenuModel) itemModel, groupId, newSelectionId); } else if (itemModel instanceof RadioOptionModel) { RadioOptionModel radioOptionModel = (RadioOptionModel) itemModel; if (radioOptionModel.getGroupId() != null && radioOptionModel.getGroupId().equals(groupId)) { getStateModel().setSelected(radioOptionModel.getId(), false); } } } }