def get_display(self):
    top = self.top
    top.add_class('spt_tab_top')
    if self._use_bootstrap():
        top.add(self.get_bootstrap_styles())
    else:
        top.add(self.get_styles())
    self.search_type = None
    self.view = self.kwargs.get('view')
    config_xml = self.kwargs.get('config_xml')
    config = self.kwargs.get('config')
    saved_config_xml = None
    self.save_state = self.kwargs.get('save_state')
    if (self.save_state in [True, 'true']):
        self.save_state = 'save_state|main_tab'
    if self.save_state:
        saved_config_xml = WidgetSettings.get_value_by_key(self.save_state)
        if saved_config_xml:
            if (not config_xml):
                config_xml = saved_config_xml
            else:
                saved_xml_data = Xml()
                saved_xml_data.read_string(saved_config_xml)
                saved_xml_root = saved_xml_data.get_root_node()
                saved_xml_tab = Xml.get_first_child(saved_xml_root)
                nodes = Xml.get_children(saved_xml_tab)
                xml_data = Xml()
                xml_data.read_string(config_xml)
                xml_root = xml_data.get_root_node()
                xml_tab = Xml.get_first_child(xml_root)
                curr_nodes = Xml.get_children(xml_tab)
                curr_node_names = [Xml.get_attribute(node, 'name') for node in curr_nodes]
                for node in nodes:
                    node_name = Xml.get_attribute(node, 'name')
                    if (node_name not in curr_node_names):
                        Xml.append_child(xml_tab, node)
                config_xml = xml_data.get_xml()
                saved_config_xml = None
        top.add_class('spt_tab_save_state')
        top.add_attr('spt_tab_save_state', self.save_state)
    self.mode = self.kwargs.get('mode')
    if (not self.mode):
        self.mode = 'default'
    if (self.view and (self.view != 'tab') and (not config_xml)):
        config = None
        includes = self.kwargs.get('include')
        if includes:
            includes = includes.split('|')
            for include in includes:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path = ('%s/../config/%s' % (dir_name, include))
                config = WidgetConfig.get(file_path=file_path, view=self.view)
                if (config and config.has_view(self.view)):
                    pass
                else:
                    config = None
        if (not config):
            search = Search('config/widget_config')
            search.add_filter('category', 'TabWdg')
            search.add_filter('view', self.view)
            config_sobj = search.get_sobject()
            if (not config_sobj):
                config_xml = ('<config><%s></%s></config>' % (self.view, self.view))
            else:
                config_xml = config_sobj.get_value('config')
            config = WidgetConfig.get(view=self.view, xml=config_xml)
    elif saved_config_xml:
        if (not self.view):
            self.view = 'tab'
        config = WidgetConfig.get(view=self.view, xml=saved_config_xml)
    elif config:
        pass
    elif config_xml:
        if (not self.view):
            self.view = 'tab'
        config = WidgetConfig.get(view=self.view, xml=config_xml)
    elif self.widgets:
        config_xml = '\n                <config>\n                <tab></tab>\n                </config>\n                '
    else:
        config_xml = '\n                <config>\n                <tab>\n                  <element name="untitled" title="(Untitled)"/>\n                </tab>\n                </config>\n                '
        self.view = 'tab'
        config = WidgetConfig.get(view=self.view, xml=config_xml)
    element_names = None
    if (self.save_state and config):
        element_names = config.get_element_names()
    if (not element_names):
        element_names = self.kwargs.get('element_names')
        if (element_names and isinstance(element_names, basestring)):
            element_names = element_names.split(',')
    if ((not element_names) and config):
        element_names = config.get_element_names()
    if (not element_names):
        element_names = []
    top.set_id(self.unique_id)
    top.set_attr('spt_tab_id', self.unique_id)
    top.set_attr('spt_tab_mode', self.mode)
    gradient = top.get_gradient('background', (- 5), 5)
    inner = DivWdg()
    top.add(inner)
    inner.add_style('position: relative')
    inner.add_style('width: auto')
    if (not Container.get_dict('JSLibraries', 'spt_tab')):
        inner.add_behavior({'type': 'load', 'gradient': gradient, 'cbjs_action': self.get_onload_js()})
    header_div = self.header
    header_id = self.get_header_id()
    inner.add(header_div)
    header_div.add_class('spt_tab_header_top')
    header_div.add_class('nav nav-tabs')
    subheader_div = DivWdg()
    subheader_div.add_class('spt_tab_subheader_top')
    subheader_div.add_class('SPT_TEMPLATE')
    inner.add(subheader_div)
    self.add_subheader_behaviors(subheader_div)
    if (not self._use_bootstrap()):
        self.add_styles()
    state = self.kwargs.get('state')
    if (not state):
        state = self.kwargs
    search_key = self.kwargs.get('search_key')
    if search_key:
        state['search_key'] = search_key
    selected = self.kwargs.get('selected')
    if (not selected):
        if element_names:
            selected = element_names[0]
        else:
            selected = ''
    offset = self.kwargs.get('tab_offset')
    if offset:
        header_div.add_style(('padding-left: %s' % offset))
    if (self.mode == 'hidden'):
        header_div.add_style('display: none')
        header_div.add_style('visibility: hidden')
        header_div.add_style('height: 0px')
    header_defs = {}
    title_dict = {}
    self.add_context_menu(header_div)
    min_width = self.kwargs.get('min_width')
    if min_width:
        try:
            min_width = int(min_width)
            min_width = (str(min_width) + 'px')
        except ValueError:
            pass
        header_div.add_style('min-width', min_width)
    resize_headers = self.kwargs.get('resize_headers')
    if resize_headers:
        offset = 120
        header_div.add_behavior({'type': 'load', 'offset': offset, 'cbjs_action': '\n\n                var top = bvr.src_el;\n                top.spt_last_width = 0;\n\n                var offset = bvr.offset;\n\n                setInterval( function() {\n\n                    if (!top.isVisible() ) {\n                        return;\n                    }\n\n                    var size = top.getSize();\n                    if (size.x == top.spt_last_width) {\n                        return;\n                    }\n\n                    top.spt_last_width = size.x;\n\n                    var els = bvr.src_el.getElements(".spt_tab_header");\n                    var count = els.length;\n\n                    var width = parseInt((size.x-offset) / (count));\n                    if (width > 120) {\n                        width = 120;\n                    }\n\n                    if (width < 30) {\n                        width = 30;\n                    }\n\n                    for (var i = 0; i < els.length; i++) {\n                        els[i].setStyle("width", width + "px");\n                    }\n\n\n                }, 250);\n                '})
    show_remove = self.kwargs.get('show_remove')
    resize_headers = self.kwargs.get('resize_headers')
    resize_headers = True
    if resize_headers:
        header_div.add_behavior({'type': 'mouseleave', 'cbjs_action': '\n                    spt.tab.resize_headers();\n                '})
    if (show_remove == 'hover'):
        header_div.add_relay_behavior({'type': 'mouseenter', 'bvr_match_class': 'spt_tab_header', 'cbjs_action': '\n                var el = bvr.src_el.getElement(".spt_tab_remove");\n                el.setStyle("display", "");\n                '})
        header_div.add_relay_behavior({'type': 'mouseleave', 'bvr_match_class': 'spt_tab_header', 'cbjs_action': '\n                var el = bvr.src_el.getElement(".spt_tab_remove");\n                el.setStyle("display", "none");\n                '})
    header_div.add_relay_behavior({'type': 'mouseenter', 'bvr_match_class': 'spt_tab_remove', 'cbjs_action': '\n        var active = bvr.src_el.getElement(".spt_icon_active");\n        active.setStyle("opacity", 1.0);\n        '})
    header_div.add_relay_behavior({'type': 'mouseleave', 'bvr_match_class': 'spt_tab_remove', 'cbjs_action': '\n        var active = bvr.src_el.getElement(".spt_icon_active");\n        active.setStyle("opacity", 0.3);\n        '})
    loaded_dict = {}
    for element_name in element_names:
        attrs = config.get_element_attributes(element_name)
        title = attrs.get('title')
        if (not title):
            title = Common.get_display_title(element_name)
        title = _(title)
        if (attrs.get('display') == 'false'):
            continue
        load_now = attrs.get('load')
        is_loaded = (load_now == 'true')
        loaded_dict[element_name] = is_loaded
        display_class = config.get_display_handler(element_name)
        display_options = config.get_display_options(element_name)
        header_defs[element_name] = {'display_class': display_class, 'display_options': display_options}
        for (name, value) in display_options.items():
            if (re.search('^{[@$]', value) and re.search('}$', value)):
                value = Search.eval(value, state=state)
                display_options[name] = value
        if (display_options.get('use_state') in [True, 'true']):
            for (state_name, state_value) in state.items():
                display_options[state_name] = state_value
        if (element_name == selected):
            is_selected = True
        else:
            is_selected = False
        header = self.get_tab_header(element_name, title, display_class, display_options, is_selected=is_selected, is_loaded=is_loaded, is_template=False, attrs=attrs)
        header_div.add(header)
    for (i, widget) in enumerate(self.widgets):
        name = widget.get_name()
        if (not name):
            num = Common.randint(0, 10000)
            name = ('noname%s' % num)
            widget.set_name(name)
            title = '(Untitled)'
        else:
            title = Common.get_display_title(name)
        if (not title):
            title = '(Untitled)'
        title_dict[name] = title
        if (name == selected):
            is_selected = True
        else:
            is_selected = False
        class_name = Common.get_full_class_name(widget)
        if isinstance(widget, BaseRefreshWdg):
            kwargs = widget.get_kwargs()
        else:
            kwargs = {}
        header = self.get_tab_header(name, title, class_name, kwargs, is_selected=is_selected, is_loaded=True, is_template=False)
        header_div.add(header)
    show_add = (self.kwargs.get('show_add') not in [False, 'false'])
    if show_add:
        header_div.add(self.get_add_wdg())
    content_top = DivWdg()
    content_top.add_class('spt_tab_content_top')
    content_top.add_attr('spt_tab_id', self.get_tab_id())
    inner.add(content_top)
    resize_offset = self.kwargs.get('resize_offset')
    resize_attr = (self.kwargs.get('resize_attr') or 'height')
    if (resize_offset != None):
        content_top.add_class('spt_window_resize')
        content_top.add_attr('spt_window_resize_offset', resize_offset)
        content_top.add_attr('spt_window_resize_attr', resize_attr)
        content_top.add_style('overflow: auto')
    else:
        height = self.kwargs.get('height')
        if height:
            try:
                height = int(height)
                height = (str(height) + 'px')
            except ValueError:
                pass
            content_top.add_style(('height: %s' % height))
            content_top.add_style('overflow-y: auto')
            content_top.add_style(('min-height: %s' % height))
    width = self.kwargs.get('width')
    if (not width):
        width = self.kwargs.get('min_width')
    if width:
        try:
            width = int(width)
            width = (str(width) + 'px')
        except ValueError:
            pass
        content_top.add_style(('min-width: %s' % width))
    content_top.add_class('tab_content_top')
    color_mode = self.kwargs.get('color_mode')
    if (color_mode == 'transparent'):
        pass
    else:
        content_top.add_color('color', 'color')
    for element_name in element_names:
        content_div = DivWdg()
        content_top.add(content_div)
        content_div.add_class('spt_tab_content')
        content_div.add_attr('spt_tab_id', self.unique_id)
        content_div.add_attr('spt_element_name', element_name)
        resize_offset = self.kwargs.get('resize_offset')
        if (resize_offset != None):
            content_div.add_class('spt_window_resize')
            content_div.add_attr('spt_window_resize_offset', resize_offset)
            content_div.add_style('overflow: auto')
        content_div.add_style('width: 100%')
        content_div.add_style('text-align: left')
        is_loaded = loaded_dict.get(element_name)
        if ((element_name == selected) or is_loaded):
            header_def = header_defs[element_name]
            display_class = header_def.get('display_class')
            if (not display_class):
                widget = DivWdg()
                widget.add_color('background', 'background')
                widget.add_style('height: 300px')
                widget.add_style('padding-top: 50px')
                inner = DivWdg()
                widget.add(inner)
                inner.add_style('margin-left: auto')
                inner.add_style('margin-right: auto')
                inner.add_style('width: 500px')
                inner.add_style('height: 100px')
                inner.add_border()
                inner.add_style('text-align: center')
                inner.add_style('padding-top: 50px')
                inner.add_color('color', 'color3')
                inner.add_color('background', 'background3')
                inner.add(IconWdg('WARNING', IconWdg.WARNING))
                inner.add(' <b>Nothing to display</b>')
            else:
                display_options = header_def.get('display_options')
                widget = Common.create_from_class_path(display_class, kwargs=display_options)
            content_div.add(widget)
            content_div.add_class('spt_content_loaded')
            if (is_loaded and (element_name != selected)):
                content_div.add_style('display: none')
        else:
            content_div.add('&nbsp;')
            content_div.add_style('display: none')
    for widget in self.widgets:
        name = widget.get_name()
        content_div = DivWdg()
        content_div.add_class('spt_tab_content')
        content_div.add_attr('spt_tab_id', self.unique_id)
        content_div.add_class('spt_content_loaded')
        content_div.add_attr('spt_element_name', name)
        resize_offset = self.kwargs.get('resize_offset')
        if (resize_offset != None):
            content_div.add_class('spt_window_resize')
            content_div.add_attr('spt_window_resize_offset', resize_offset)
            content_div.add_style('overflow: auto')
        title = title_dict.get(name)
        content_div.add_attr('spt_title', title)
        if (name != selected):
            content_div.add_style('display: none')
        content_div.add(widget)
        content_div.add_style('width: 100%')
        content_div.add_style('text-align: left')
        content_top.add(content_div)
    template_div = DivWdg()
    template_div.add_class('spt_tab_template_top')
    template_div.add_style('display: none')
    template_div.add_class('SPT_TEMPLATE')
    name = ''
    title = ''
    is_selected = False
    header = self.get_tab_header(name, title, None, None, is_selected=is_selected, is_template=True)
    template_div.add(header)
    subheader = self.get_tab_subheader(name, title, None, None, is_selected=is_selected, is_template=True, config=config)
    template_div.add(subheader)
    subheader.add_style('z-index: 3')
    header.add_relay_behavior({'type': 'click', 'bvr_match_class': 'spt_tab_header', 'cbjs_action': '\n\n            var header_top = bvr.src_el.getParent(".spt_tab_header_top");\n            var top = bvr.src_el.getParent(".spt_tab_top");\n        \n\n            var subheader_id = bvr.src_el.getAttribute("spt_subheader_id")\n\n            var subheaders = top.getElements(".spt_tab_subheader");\n            for ( var i = 0; i < subheaders.length; i++) {\n                subheaders[i].setStyle("display", "none");\n            }\n\n            var el = document.id(subheader_id);\n            var items = el.getElements(".spt_tab_subheader_item");\n            if (items.length == 0) {\n                return;\n            }\n\n            var size = bvr.src_el.getSize();\n            var pos = bvr.src_el.getPosition(header_top);\n\n            if (el) {\n                el.setStyle("display", "");\n                spt.body.add_focus_element(el);\n\n                el.position({x: pos.x, y: pos.y+size.y-1}, el);\n            }\n\n            '})
    top.add(template_div)
    content_div = DivWdg()
    content_div.add_class('spt_tab_content')
    content_div.add_attr('spt_element_name', 'NEW')
    content_div.add_attr('spt_tab_id', self.unique_id)
    content_div.add('')
    content_div.add_style('width: 100%')
    content_div.add_style('text-align: left')
    template_div.add(content_div)
    return top
def get_display(self):
    top = self.top
    top.add_class('spt_tab_top')
    if self._use_bootstrap():
        top.add(self.get_bootstrap_styles())
    else:
        top.add(self.get_styles())
    self.search_type = None
    self.view = self.kwargs.get('view')
    config_xml = self.kwargs.get('config_xml')
    config = self.kwargs.get('config')
    saved_config_xml = None
    self.save_state = self.kwargs.get('save_state')
    if (self.save_state in [True, 'true']):
        self.save_state = 'save_state|main_tab'
    if self.save_state:
        saved_config_xml = WidgetSettings.get_value_by_key(self.save_state)
        if saved_config_xml:
            if (not config_xml):
                config_xml = saved_config_xml
            else:
                saved_xml_data = Xml()
                saved_xml_data.read_string(saved_config_xml)
                saved_xml_root = saved_xml_data.get_root_node()
                saved_xml_tab = Xml.get_first_child(saved_xml_root)
                nodes = Xml.get_children(saved_xml_tab)
                xml_data = Xml()
                xml_data.read_string(config_xml)
                xml_root = xml_data.get_root_node()
                xml_tab = Xml.get_first_child(xml_root)
                curr_nodes = Xml.get_children(xml_tab)
                curr_node_names = [Xml.get_attribute(node, 'name') for node in curr_nodes]
                for node in nodes:
                    node_name = Xml.get_attribute(node, 'name')
                    if (node_name not in curr_node_names):
                        Xml.append_child(xml_tab, node)
                config_xml = xml_data.get_xml()
                saved_config_xml = None
        top.add_class('spt_tab_save_state')
        top.add_attr('spt_tab_save_state', self.save_state)
    self.mode = self.kwargs.get('mode')
    if (not self.mode):
        self.mode = 'default'
    if (self.view and (self.view != 'tab') and (not config_xml)):
        config = None
        includes = self.kwargs.get('include')
        if includes:
            includes = includes.split('|')
            for include in includes:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path = ('%s/../config/%s' % (dir_name, include))
                config = WidgetConfig.get(file_path=file_path, view=self.view)
                if (config and config.has_view(self.view)):
                    pass
                else:
                    config = None
        if (not config):
            search = Search('config/widget_config')
            search.add_filter('category', 'TabWdg')
            search.add_filter('view', self.view)
            config_sobj = search.get_sobject()
            if (not config_sobj):
                config_xml = ('<config><%s></%s></config>' % (self.view, self.view))
            else:
                config_xml = config_sobj.get_value('config')
            config = WidgetConfig.get(view=self.view, xml=config_xml)
    elif saved_config_xml:
        if (not self.view):
            self.view = 'tab'
        config = WidgetConfig.get(view=self.view, xml=saved_config_xml)
    elif config:
        pass
    elif config_xml:
        if (not self.view):
            self.view = 'tab'
        config = WidgetConfig.get(view=self.view, xml=config_xml)
    elif self.widgets:
        config_xml = '\n                <config>\n                <tab></tab>\n                </config>\n                '
    else:
        config_xml = '\n                <config>\n                <tab>\n                  <element name="untitled" title="(Untitled)"/>\n                </tab>\n                </config>\n                '
        self.view = 'tab'
        config = WidgetConfig.get(view=self.view, xml=config_xml)
    element_names = None
    if (self.save_state and config):
        element_names = config.get_element_names()
    if (not element_names):
        element_names = self.kwargs.get('element_names')
        if (element_names and isinstance(element_names, basestring)):
            element_names = element_names.split(',')
    if ((not element_names) and config):
        element_names = config.get_element_names()
    if (not element_names):
        element_names = []
    top.set_id(self.unique_id)
    top.set_attr('spt_tab_id', self.unique_id)
    top.set_attr('spt_tab_mode', self.mode)
    gradient = top.get_gradient('background', (- 5), 5)
    inner = DivWdg()
    top.add(inner)
    inner.add_style('position: relative')
    inner.add_style('width: auto')
    if (not Container.get_dict('JSLibraries', 'spt_tab')):
        inner.add_behavior({'type': 'load', 'gradient': gradient, 'cbjs_action': self.get_onload_js()})
    header_div = self.header
    header_id = self.get_header_id()
    inner.add(header_div)
    header_div.add_class('spt_tab_header_top')
    header_div.add_class('nav nav-tabs')
    subheader_div = DivWdg()
    subheader_div.add_class('spt_tab_subheader_top')
    subheader_div.add_class('SPT_TEMPLATE')
    inner.add(subheader_div)
    self.add_subheader_behaviors(subheader_div)
    if (not self._use_bootstrap()):
        self.add_styles()
    state = self.kwargs.get('state')
    if (not state):
        state = self.kwargs
    search_key = self.kwargs.get('search_key')
    if search_key:
        state['search_key'] = search_key
    selected = self.kwargs.get('selected')
    if (not selected):
        if element_names:
            selected = element_names[0]
        else:
            selected = 
    offset = self.kwargs.get('tab_offset')
    if offset:
        header_div.add_style(('padding-left: %s' % offset))
    if (self.mode == 'hidden'):
        header_div.add_style('display: none')
        header_div.add_style('visibility: hidden')
        header_div.add_style('height: 0px')
    header_defs = {}
    title_dict = {}
    self.add_context_menu(header_div)
    min_width = self.kwargs.get('min_width')
    if min_width:
        try:
            min_width = int(min_width)
            min_width = (str(min_width) + 'px')
        except ValueError:
            pass
        header_div.add_style('min-width', min_width)
    resize_headers = self.kwargs.get('resize_headers')
    if resize_headers:
        offset = 120
        header_div.add_behavior({'type': 'load', 'offset': offset, 'cbjs_action': '\n\n                var top = bvr.src_el;\n                top.spt_last_width = 0;\n\n                var offset = bvr.offset;\n\n                setInterval( function() {\n\n                    if (!top.isVisible() ) {\n                        return;\n                    }\n\n                    var size = top.getSize();\n                    if (size.x == top.spt_last_width) {\n                        return;\n                    }\n\n                    top.spt_last_width = size.x;\n\n                    var els = bvr.src_el.getElements(".spt_tab_header");\n                    var count = els.length;\n\n                    var width = parseInt((size.x-offset) / (count));\n                    if (width > 120) {\n                        width = 120;\n                    }\n\n                    if (width < 30) {\n                        width = 30;\n                    }\n\n                    for (var i = 0; i < els.length; i++) {\n                        els[i].setStyle("width", width + "px");\n                    }\n\n\n                }, 250);\n                '})
    show_remove = self.kwargs.get('show_remove')
    resize_headers = self.kwargs.get('resize_headers')
    resize_headers = True
    if resize_headers:
        header_div.add_behavior({'type': 'mouseleave', 'cbjs_action': '\n                    spt.tab.resize_headers();\n                '})
    if (show_remove == 'hover'):
        header_div.add_relay_behavior({'type': 'mouseenter', 'bvr_match_class': 'spt_tab_header', 'cbjs_action': '\n                var el = bvr.src_el.getElement(".spt_tab_remove");\n                el.setStyle("display", );\n                '})
        header_div.add_relay_behavior({'type': 'mouseleave', 'bvr_match_class': 'spt_tab_header', 'cbjs_action': '\n                var el = bvr.src_el.getElement(".spt_tab_remove");\n                el.setStyle("display", "none");\n                '})
    header_div.add_relay_behavior({'type': 'mouseenter', 'bvr_match_class': 'spt_tab_remove', 'cbjs_action': '\n        var active = bvr.src_el.getElement(".spt_icon_active");\n        active.setStyle("opacity", 1.0);\n        '})
    header_div.add_relay_behavior({'type': 'mouseleave', 'bvr_match_class': 'spt_tab_remove', 'cbjs_action': '\n        var active = bvr.src_el.getElement(".spt_icon_active");\n        active.setStyle("opacity", 0.3);\n        '})
    loaded_dict = {}
    for element_name in element_names:
        attrs = config.get_element_attributes(element_name)
        title = attrs.get('title')
        if (not title):
            title = Common.get_display_title(element_name)
        title = _(title)
        if (attrs.get('display') == 'false'):
            continue
        load_now = attrs.get('load')
        is_loaded = (load_now == 'true')
        loaded_dict[element_name] = is_loaded
        display_class = config.get_display_handler(element_name)
        display_options = config.get_display_options(element_name)
        header_defs[element_name] = {'display_class': display_class, 'display_options': display_options}
        for (name, value) in display_options.items():
            if (re.search('^{[@$]', value) and re.search('}$', value)):
                value = Search.eval(value, state=state)
                display_options[name] = value
        if (display_options.get('use_state') in [True, 'true']):
            for (state_name, state_value) in state.items():
                display_options[state_name] = state_value
        if (element_name == selected):
            is_selected = True
        else:
            is_selected = False
        header = self.get_tab_header(element_name, title, display_class, display_options, is_selected=is_selected, is_loaded=is_loaded, is_template=False, attrs=attrs)
        header_div.add(header)
    for (i, widget) in enumerate(self.widgets):
        name = widget.get_name()
        if (not name):
            num = Common.randint(0, 10000)
            name = ('noname%s' % num)
            widget.set_name(name)
            title = '(Untitled)'
        else:
            title = Common.get_display_title(name)
        if (not title):
            title = '(Untitled)'
        title_dict[name] = title
        if (name == selected):
            is_selected = True
        else:
            is_selected = False
        class_name = Common.get_full_class_name(widget)
        if isinstance(widget, BaseRefreshWdg):
            kwargs = widget.get_kwargs()
        else:
            kwargs = {}
        header = self.get_tab_header(name, title, class_name, kwargs, is_selected=is_selected, is_loaded=True, is_template=False)
        header_div.add(header)
    show_add = (self.kwargs.get('show_add') not in [False, 'false'])
    if show_add:
        header_div.add(self.get_add_wdg())
    content_top = DivWdg()
    content_top.add_class('spt_tab_content_top')
    content_top.add_attr('spt_tab_id', self.get_tab_id())
    inner.add(content_top)
    resize_offset = self.kwargs.get('resize_offset')
    resize_attr = (self.kwargs.get('resize_attr') or 'height')
    if (resize_offset != None):
        content_top.add_class('spt_window_resize')
        content_top.add_attr('spt_window_resize_offset', resize_offset)
        content_top.add_attr('spt_window_resize_attr', resize_attr)
        content_top.add_style('overflow: auto')
    else:
        height = self.kwargs.get('height')
        if height:
            try:
                height = int(height)
                height = (str(height) + 'px')
            except ValueError:
                pass
            content_top.add_style(('height: %s' % height))
            content_top.add_style('overflow-y: auto')
            content_top.add_style(('min-height: %s' % height))
    width = self.kwargs.get('width')
    if (not width):
        width = self.kwargs.get('min_width')
    if width:
        try:
            width = int(width)
            width = (str(width) + 'px')
        except ValueError:
            pass
        content_top.add_style(('min-width: %s' % width))
    content_top.add_class('tab_content_top')
    color_mode = self.kwargs.get('color_mode')
    if (color_mode == 'transparent'):
        pass
    else:
        content_top.add_color('color', 'color')
    for element_name in element_names:
        content_div = DivWdg()
        content_top.add(content_div)
        content_div.add_class('spt_tab_content')
        content_div.add_attr('spt_tab_id', self.unique_id)
        content_div.add_attr('spt_element_name', element_name)
        resize_offset = self.kwargs.get('resize_offset')
        if (resize_offset != None):
            content_div.add_class('spt_window_resize')
            content_div.add_attr('spt_window_resize_offset', resize_offset)
            content_div.add_style('overflow: auto')
        content_div.add_style('width: 100%')
        content_div.add_style('text-align: left')
        is_loaded = loaded_dict.get(element_name)
        if ((element_name == selected) or is_loaded):
            header_def = header_defs[element_name]
            display_class = header_def.get('display_class')
            if (not display_class):
                widget = DivWdg()
                widget.add_color('background', 'background')
                widget.add_style('height: 300px')
                widget.add_style('padding-top: 50px')
                inner = DivWdg()
                widget.add(inner)
                inner.add_style('margin-left: auto')
                inner.add_style('margin-right: auto')
                inner.add_style('width: 500px')
                inner.add_style('height: 100px')
                inner.add_border()
                inner.add_style('text-align: center')
                inner.add_style('padding-top: 50px')
                inner.add_color('color', 'color3')
                inner.add_color('background', 'background3')
                inner.add(IconWdg('WARNING', IconWdg.WARNING))
                inner.add(' <b>Nothing to display</b>')
            else:
                display_options = header_def.get('display_options')
                widget = Common.create_from_class_path(display_class, kwargs=display_options)
            content_div.add(widget)
            content_div.add_class('spt_content_loaded')
            if (is_loaded and (element_name != selected)):
                content_div.add_style('display: none')
        else:
            content_div.add('&nbsp;')
            content_div.add_style('display: none')
    for widget in self.widgets:
        name = widget.get_name()
        content_div = DivWdg()
        content_div.add_class('spt_tab_content')
        content_div.add_attr('spt_tab_id', self.unique_id)
        content_div.add_class('spt_content_loaded')
        content_div.add_attr('spt_element_name', name)
        resize_offset = self.kwargs.get('resize_offset')
        if (resize_offset != None):
            content_div.add_class('spt_window_resize')
            content_div.add_attr('spt_window_resize_offset', resize_offset)
            content_div.add_style('overflow: auto')
        title = title_dict.get(name)
        content_div.add_attr('spt_title', title)
        if (name != selected):
            content_div.add_style('display: none')
        content_div.add(widget)
        content_div.add_style('width: 100%')
        content_div.add_style('text-align: left')
        content_top.add(content_div)
    template_div = DivWdg()
    template_div.add_class('spt_tab_template_top')
    template_div.add_style('display: none')
    template_div.add_class('SPT_TEMPLATE')
    name = 
    title = 
    is_selected = False
    header = self.get_tab_header(name, title, None, None, is_selected=is_selected, is_template=True)
    template_div.add(header)
    subheader = self.get_tab_subheader(name, title, None, None, is_selected=is_selected, is_template=True, config=config)
    template_div.add(subheader)
    subheader.add_style('z-index: 3')
    header.add_relay_behavior({'type': 'click', 'bvr_match_class': 'spt_tab_header', 'cbjs_action': '\n\n            var header_top = bvr.src_el.getParent(".spt_tab_header_top");\n            var top = bvr.src_el.getParent(".spt_tab_top");\n        \n\n            var subheader_id = bvr.src_el.getAttribute("spt_subheader_id")\n\n            var subheaders = top.getElements(".spt_tab_subheader");\n            for ( var i = 0; i < subheaders.length; i++) {\n                subheaders[i].setStyle("display", "none");\n            }\n\n            var el = document.id(subheader_id);\n            var items = el.getElements(".spt_tab_subheader_item");\n            if (items.length == 0) {\n                return;\n            }\n\n            var size = bvr.src_el.getSize();\n            var pos = bvr.src_el.getPosition(header_top);\n\n            if (el) {\n                el.setStyle("display", );\n                spt.body.add_focus_element(el);\n\n                el.position({x: pos.x, y: pos.y+size.y-1}, el);\n            }\n\n            '})
    top.add(template_div)
    content_div = DivWdg()
    content_div.add_class('spt_tab_content')
    content_div.add_attr('spt_element_name', 'NEW')
    content_div.add_attr('spt_tab_id', self.unique_id)
    content_div.add()
    content_div.add_style('width: 100%')
    content_div.add_style('text-align: left')
    template_div.add(content_div)
    return top