예제 #1
0
    def get_schema_wdg(my, schema):
        web = WebContainer.get_web()

        div = DivWdg()
        div.add_style("margin: 10 0 10 0")

        if not schema:
            Environment.add_warning("No schema", "No schema found")
            return div
        schema_xml = schema.get_xml_value("schema")
        code = schema.get_code()


        schema_search_types = schema_xml.get_values("schema/search_type/@name")
        if not schema_search_types:
            return


        title = DivWdg()
        view_margin_top = '4px'
        title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
        if not web.is_IE():
            title.add_styles( "margin-left: -10px; margin-right: -10px;" )
        title.add_looks( "navmenu_header" )

        title_label = SpanWdg()
        title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" )
        title_label.add_looks( "fnt_title_5 fnt_bold" )
        title_label.add("%s Schema" % code.capitalize())
        title.add(title_label)
        #title.add_style("margin-top: 7px")
        #title.add_style("font-weight: bold")
        #title.add_style("font-size: 1.1em")
        #title.add_style("color: black")
        #underline = HtmlElement.hr()
        #underline.add_style("color: black")
        #underline.add_style("size: 1px")
        #underline.add_style("margin-top: -3px")
        #title.add(underline)
        div.add( title )



        for schema_search_type in schema_search_types:
            try:
                search_type_obj = SearchType.get(schema_search_type)
            except SearchException:
                title = "<span style='color: #F44'>? %s</span>" % schema_search_type
            else:
                title = search_type_obj.get_title()


            span = DivWdg()
            span.add_style("padding: 1px")

            options = {
                'search_type': schema_search_type,
                'view': 'table',
                'schema_default_view': 'true',
            }
            link = my.get_link_wdg("schema", "main_body", title, options)


            # walk up the tree
            current_type = schema_search_type
            has_parent = False
            while 1:
                parent_type = schema.get_parent_type(current_type)
                if parent_type and parent_type != '*':
                    span.add("&nbsp;&nbsp;&nbsp;")
                    has_parent = True
                else:
                    if has_parent:
                        span.add("+&nbsp;")
                    break
                current_type = parent_type

            span.add(link)
            div.add(span)

        return div
예제 #2
0
    def get_display(self):
        self.config_search_type = self.kwargs.get("config_search_type")
        if not self.config_search_type:
            self.config_search_type = "SideBarWdg"

        title = self.kwargs.get('title')
        config = self.kwargs.get('config')
        view = self.kwargs.get('view')
        width = self.kwargs.get('width')
        #sortable = self.kwargs.get('sortable')
        if not width:
            width = "175"

        self.prefix = self.kwargs.get("prefix")
        if not self.prefix:
            self.prefix = "side_bar"

        self.mode = self.kwargs.get("mode")
        if not self.mode:
            self.mode = 'view'

        self.default = self.kwargs.get('default') == 'True'

        div = DivWdg()
        div.add_class("spt_section_top")
        div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")

        # create the top widgets
        label = SpanWdg()
        label.add(title)
        label.add_style("font-size: 1.1em")
        section_div = LabeledHidableWdg(label=label)
        div.add(section_div)

        section_div.set_attr('spt_class_name',
                             Common.get_full_class_name(self))
        for name, value in self.kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        bgcolor = label.get_color("background3")
        project_div = RoundedCornerDivWdg(hex_color_code=bgcolor,
                                          corner_size="10")
        project_div.set_dimensions(width_str='%spx' % width,
                                   content_height_str='100px')
        content_div = project_div.get_content_wdg()

        #project_div = DivWdg()
        #content_div = project_div

        section_div.add(project_div)

        content_div.add_class("spt_side_bar_content")
        content_div.add_attr("spt_view", view)

        if type(view) in types.StringTypes:
            view = [view]

        view_margin_top = '4px'

        web = WebContainer.get_web()
        for viewx in view:
            config = self.get_config(self.config_search_type,
                                     viewx,
                                     default=self.default)
            if not config:
                continue

            # make up a title
            title = DivWdg()
            title.add_gradient("background",
                               "side_bar_title",
                               0,
                               -15,
                               default="background")
            title.add_color("color", "side_bar_title_color", default="color")
            title.add_styles(
                "margin-top: %s; margin-bottom: 3px; vertical-align: middle" %
                view_margin_top)
            if not web.is_IE():
                title.add_styles("margin-left: -5px; margin-right: -5px;")
            title.add_looks("navmenu_header")
            title.add_style("height: 18px")
            title.add_style("padding-top: 2px")
            """
            title = DivWdg()
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -10px; margin-right: -10px;")
            title.add_looks( "navmenu_header" )
            """

            # FIXME: not sure if this logic should be here. It basically
            # makes special titles for certain view names
            view_attrs = config.get_view_attributes()
            title_str = view_attrs.get("title")
            if not title_str:
                if viewx.startswith("self_view_"):
                    title_str = "My Views"
                else:
                    title_str = viewx

            title_str = Common.get_display_title(title_str)

            title_label = SpanWdg()
            title_label.add_styles("margin-left: 6px; padding-bottom: 2px;")
            title_label.add_looks("fnt_title_5 fnt_bold")
            title_label.add(title_str)
            title.add(title_label)

            content_div.add(title)

            info = {'counter': 10, 'view': viewx}
            self.generate_section(config, content_div, info)
            error_list = Container.get_seq(self.ERR_MSG)
            if error_list:
                span = SpanWdg()
                span.add_style('background', 'red')
                span.add('<br/>'.join(error_list))
                content_div.add(span)
                Container.clear_seq(self.ERR_MSG)
            self.add_dummy(config, content_div)

        return div
예제 #3
0
    def get_display(self):

        if self.is_popup:
            icon_chooser_popup_id = "IconChooserPopup"
            icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id,
                                          allow_page_activity=False,
                                          width="760px")
            icon_chooser_popup.add("Icon Chooser", "title")

        orig_icon_list = IconWdg.icons.keys()
        icon_list = ['-- No Icon --']
        do_not_list = [
            'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE',
            'CHECK_OUT_LG', 'CHECK_OUT', 'PUBLISH_LG'
        ]

        for k in orig_icon_list:
            if k in do_not_list:
                continue
            icon_list.append(k)

        icon_list.sort()
        icon_list_len = float(len(icon_list))

        num_cols = 5
        num_rows = int(math.ceil(icon_list_len / float(num_cols)))

        chooser_wrapper_div = DivWdg()
        chooser_wrapper_div.add_class("SPT_ICON_CHOOSER_WRAPPER_DIV")

        chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494",
                                             corner_size="10")
        chooser_bkg_rc.set_dimensions(width_str='740px',
                                      content_height_str='520px')

        table = Table()
        for r in range(num_rows):
            table.add_row()
            for c in range(num_cols):
                td = table.add_cell()
                td.add_styles(
                    "color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;"
                )
                td.add_styles(
                    "border: 1px solid transparent; cursor: pointer;")
                td.add_behavior({
                    'type': 'hover',
                    'mod_styles': 'background-color: #555555;'
                })

                if c > 0:
                    td.add_styles("border-left-color: black;")

                idx = int(c * num_rows + r)
                if idx < icon_list_len:
                    icon_name = icon_list[idx]
                    icon_path = ''
                    if icon_name != '-- No Icon --':
                        icon_path = IconWdg.get_icon_path(icon_name)
                        icon = IconWdg(icon_name, icon_path)
                        td.add(icon)
                    text_span = SpanWdg()
                    text_span.add_looks("fnt_code")
                    text_span.add_styles("font-size: 10px")
                    if len(icon_name) > 16:
                        text_span.add("%s..." % icon_name[:15])
                    else:
                        text_span.add(icon_name)
                    td.add(text_span)
                    if icon_name == '-- No Icon --':
                        icon_name = ''
                    td.add_class("SPT_ICON_SELECT_%s" % icon_name)
                    if self.is_popup:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.popup.close( spt.popup.get_popup( bvr.src_el ) );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,
                               "ICON_CHOOSER_SELECTION_MADE")
                    else:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.hide( cwd );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,
                               "ICON_CHOOSER_SELECTION_MADE")
                        pass
                    td.add_behavior({
                        'type': 'click_up',
                        'cbjs_action': cbjs_action
                    })

        chooser_bkg_rc.add(table)
        chooser_wrapper_div.add(chooser_bkg_rc)

        if self.is_popup:
            icon_chooser_popup.add(chooser_wrapper_div, "content")
            return icon_chooser_popup

        return div
예제 #4
0
    def get_schema_wdg(self, schema):
        web = WebContainer.get_web()

        div = DivWdg()
        div.add_style("margin: 10 0 10 0")

        if not schema:
            Environment.add_warning("No schema", "No schema found")
            return div
        schema_xml = schema.get_xml_value("schema")
        code = schema.get_code()


        schema_search_types = schema_xml.get_values("schema/search_type/@name")
        if not schema_search_types:
            return


        title = DivWdg()
        view_margin_top = '4px'
        title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
        if not web.is_IE():
            title.add_styles( "margin-left: -10px; margin-right: -10px;" )
        title.add_looks( "navmenu_header" )

        title_label = SpanWdg()
        title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" )
        title_label.add_looks( "fnt_title_5 fnt_bold" )
        title_label.add("%s Schema" % code.capitalize())
        title.add(title_label)
        #title.add_style("margin-top: 7px")
        #title.add_style("font-weight: bold")
        #title.add_style("font-size: 1.1em")
        #title.add_style("color: black")
        #underline = HtmlElement.hr()
        #underline.add_style("color: black")
        #underline.add_style("size: 1px")
        #underline.add_style("margin-top: -3px")
        #title.add(underline)
        div.add( title )



        for schema_search_type in schema_search_types:
            try:
                search_type_obj = SearchType.get(schema_search_type)
            except SearchException:
                title = "<span style='color: #F44'>? %s</span>" % schema_search_type
            else:
                title = search_type_obj.get_title()


            span = DivWdg()
            span.add_style("padding: 1px")

            options = {
                'search_type': schema_search_type,
                'view': 'table',
                'schema_default_view': 'true',
            }
            link = self.get_link_wdg("schema", "main_body", title, options)


            # walk up the tree
            current_type = schema_search_type
            has_parent = False
            while 1:
                parent_type = schema.get_parent_type(current_type)
                if parent_type and parent_type != '*':
                    span.add("&nbsp;&nbsp;&nbsp;")
                    has_parent = True
                else:
                    if has_parent:
                        span.add("+&nbsp;")
                    break
                current_type = parent_type

            span.add(link)
            div.add(span)

        return div
예제 #5
0
    def get_display(my):
        my.config_search_type = my.kwargs.get("config_search_type")
        if not my.config_search_type:
            my.config_search_type = "SideBarWdg"

        title = my.kwargs.get('title')
        config = my.kwargs.get('config')
        view = my.kwargs.get('view')
        width = my.kwargs.get('width')
        #sortable = my.kwargs.get('sortable')
        if not width:
            width = "175"

        my.prefix = my.kwargs.get("prefix")
        if not my.prefix:
            my.prefix = "side_bar"

        my.mode = my.kwargs.get("mode")
        if not my.mode:
            my.mode = 'view'


        my.default = my.kwargs.get('default') == 'True'

        div = DivWdg()
        div.add_class("spt_section_top")
        div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")


        # create the top widgets
        label = SpanWdg()
        label.add(title)
        label.add_style("font-size: 1.1em")
        section_div = LabeledHidableWdg(label=label)
        div.add(section_div)

        section_div.set_attr('spt_class_name', Common.get_full_class_name(my))
        for name, value in my.kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        bgcolor = label.get_color("background3")
        project_div = RoundedCornerDivWdg(hex_color_code=bgcolor,corner_size="10")
        project_div.set_dimensions( width_str='%spx' % width, content_height_str='100px' )
        content_div = project_div.get_content_wdg()

        #project_div = DivWdg()
        #content_div = project_div


        section_div.add( project_div )

        content_div.add_class("spt_side_bar_content")
        content_div.add_attr("spt_view", view)

        if type(view) in types.StringTypes:
            view = [view]

        view_margin_top = '4px'

        web = WebContainer.get_web()
        for viewx in view:
            config = my.get_config(my.config_search_type, viewx, default=my.default)
            if not config:
                continue

            # make up a title
            title = DivWdg()
            title.add_gradient( "background", "side_bar_title", 0, -15, default="background" )
            title.add_color( "color", "side_bar_title_color", default="color" )
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -5px; margin-right: -5px;")
            title.add_looks( "navmenu_header" )
            title.add_style( "height: 18px" )
            title.add_style( "padding-top: 2px" )
            """
            title = DivWdg()
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -10px; margin-right: -10px;")
            title.add_looks( "navmenu_header" )
            """

            # FIXME: not sure if this logic should be here. It basically
            # makes special titles for certain view names
            view_attrs = config.get_view_attributes()
            title_str = view_attrs.get("title")
            if not title_str:
                if viewx.startswith("my_view_"):
                    title_str = "My Views"
                else:
                    title_str = viewx

            title_str = Common.get_display_title(title_str)

            title_label = SpanWdg()
            title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" )
            title_label.add_looks( "fnt_title_5 fnt_bold" )
            title_label.add( title_str )
            title.add( title_label )

            content_div.add( title )

            info = { 'counter' : 10, 'view': viewx }
            my.generate_section( config, content_div, info )
            error_list = Container.get_seq(my.ERR_MSG)
            if error_list: 
                span = SpanWdg()
                span.add_style('background', 'red')
                span.add('<br/>'.join(error_list))
                content_div.add(span)
                Container.clear_seq(my.ERR_MSG)
            my.add_dummy(config, content_div) 

        return div
예제 #6
0
파일: chooser_wdg.py 프로젝트: 0-T-0/TACTIC
    def get_display(my):

        if my.is_popup:
            icon_chooser_popup_id = "IconChooserPopup"
            icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id, allow_page_activity=False, width="760px")
            icon_chooser_popup.add("Icon Chooser", "title")

        orig_icon_list = IconWdg.icons.keys()
        icon_list = ['-- No Icon --']
        do_not_list = [ 'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE', 'CHECK_OUT_LG','CHECK_OUT','PUBLISH_LG' ]

        for k in orig_icon_list:
            if k in do_not_list:
                continue
            icon_list.append(k)

        icon_list.sort()
        icon_list_len = float(len(icon_list))

        num_cols = 5
        num_rows = int( math.ceil( icon_list_len / float(num_cols) ) )

        chooser_wrapper_div = DivWdg()
        chooser_wrapper_div.add_class( "SPT_ICON_CHOOSER_WRAPPER_DIV" )

        chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        chooser_bkg_rc.set_dimensions( width_str='740px', content_height_str='520px' )

        table = Table()
        for r in range(num_rows):
            table.add_row()
            for c in range(num_cols):
                td = table.add_cell()
                td.add_styles("color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;")
                td.add_styles("border: 1px solid transparent; cursor: pointer;")
                td.add_behavior( {'type': 'hover', 'mod_styles': 'background-color: #555555;'} )

                if c > 0:
                    td.add_styles("border-left-color: black;")

                idx = int( c * num_rows + r )
                if idx < icon_list_len:
                    icon_name = icon_list[ idx ]
                    icon_path = ''
                    if icon_name != '-- No Icon --':
                        icon_path = IconWdg.get_icon_path(icon_name)
                        icon = IconWdg( icon_name, icon_path )
                        td.add(icon)
                    text_span = SpanWdg()
                    text_span.add_looks( "fnt_code" )
                    text_span.add_styles( "font-size: 10px" )
                    if len(icon_name) > 16:
                        text_span.add( "%s..." % icon_name[:15] )
                    else:
                        text_span.add( icon_name )
                    td.add( text_span )
                    if icon_name == '-- No Icon --':
                        icon_name = ''
                    td.add_class( "SPT_ICON_SELECT_%s" % icon_name )
                    if my.is_popup:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.popup.close( spt.popup.get_popup( bvr.src_el ) );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE")
                    else:
                        cbjs_action = '''
                            var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV");
                            cwd.setProperty("spt_icon_selected", "%s");
                            cwd.setProperty("spt_icon_path", "%s");
                            spt.hide( cwd );
                            spt.named_events.fire_event("%s",bvr);
                        ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE")
                        pass
                    td.add_behavior( {'type': 'click_up', 'cbjs_action': cbjs_action} )

        chooser_bkg_rc.add( table )
        chooser_wrapper_div.add( chooser_bkg_rc )


        if my.is_popup:
            icon_chooser_popup.add(chooser_wrapper_div, "content")
            return icon_chooser_popup


        return div