# Path: conjureup/ui/widgets/selectors.py
# class OptionalRadioList(RadioList):
#     option_type = OptionalValuedRadioButton
# 
# class RadioList(SelectList):
#     option_type = ValuedRadioButton
#     allow_multiple = False
# 
#     def __init__(self, *args, **kwargs):
#         self.group = []
#         super().__init__(*args, **kwargs)
# 
#     def _create_option(self, label, value):
#         return self.option_type(self.group, label, value)
# 
#     def select_first_option(self):
#         """
#         Select the first option.
#         """
#         for item in self.contents:
#             if isinstance(item, self.option_type):
#                 item.set_state(True)
#                 break
# 
#     def select_option(self, value):
#         """
#         Select an option by value.
#         """
#         for item in self.contents:
#             if isinstance(item, self.option_type):
#                 item.set_state(item.value == value)


from ubuntui.utils import Color
from ubuntui.widgets.hr import HR
from urwid import Columns, Text
from conjureup.ui.views.base import BaseView
from conjureup.ui.widgets.selectors import OptionalRadioList, RadioList



class VSphereSetupView(BaseView):
    title = "VSphere Configuration"

    def __init__(self, datacenter, update_cloud_cb, back_cb):
        self.update_cloud_cb = update_cloud_cb
        self.prev_screen = back_cb
        self.datacenter = datacenter
        self.vsphere_config = {
            'primary-network': RadioList(
                [net.name for net in self.datacenter.network]),
            'external-network': OptionalRadioList(
                [net.name for net in self.datacenter.network]),

# Path: conjureup/ui/widgets/selectors.py
# class OptionalRadioList(RadioList):
#     option_type = OptionalValuedRadioButton
# 
# class RadioList(SelectList):
#     option_type = ValuedRadioButton
#     allow_multiple = False
# 
#     def __init__(self, *args, **kwargs):
#         self.group = []
#         super().__init__(*args, **kwargs)
# 
#     def _create_option(self, label, value):
#         return self.option_type(self.group, label, value)
# 
#     def select_first_option(self):
#         """
#         Select the first option.
#         """
#         for item in self.contents:
#             if isinstance(item, self.option_type):
#                 item.set_state(True)
#                 break
# 
#     def select_option(self, value):
#         """
#         Select an option by value.
#         """
#         for item in self.contents:
#             if isinstance(item, self.option_type):
#                 item.set_state(item.value == value)


# Path: conjureup/ui/views/vspheresetup.py
from ubuntui.utils import Color
from ubuntui.widgets.hr import HR
from urwid import Columns, Text
from conjureup.ui.views.base import BaseView
from conjureup.ui.widgets.selectors import OptionalRadioList, RadioList




class VSphereSetupView(BaseView):
    title = "VSphere Configuration"

    def __init__(self, datacenter, update_cloud_cb, back_cb):
        self.update_cloud_cb = update_cloud_cb
        self.prev_screen = back_cb
        self.datacenter = datacenter
        self.vsphere_config = {
            'primary-network': RadioList(
                [net.name for net in self.datacenter.network]),
            'external-network': OptionalRadioList(
                [net.name for net in self.datacenter.network]),

            'datastore': RadioList(