Пример #1
0
    def get_content_wdg(self):
        div = DivWdg()

        inner = DivWdg()
        div.add(inner)

        # set up the context menus
        menus_in = {
            #'DG_HEADER_CTX': [ self.get_smart_header_context_menu_data() ],
            'DG_DROW_SMENU_CTX':
            [self.get_data_row_smart_context_menu_details()]
        }
        SmartMenu.attach_smart_context_menu(inner, menus_in, False)

        if self.sobjects:
            for i, sobject in enumerate(self.sobjects):
                if i == 0:
                    self.first = True
                else:
                    self.first = False

                inner.add(self.get_item_wdg(sobject))
                inner.add("<hr/>")
        else:
            table = Table()
            inner.add(table)
            self.handle_no_results(table)

        return div
Пример #2
0
    def get_section_wdg(my, title, description, image, behavior):

        section_wdg = DivWdg()
        section_wdg.set_round_corners()
        section_wdg.add_border()
        section_wdg.add_class("spt_report_top")
        section_wdg.add_style("width: 200px")
        section_wdg.add_style("height: 100px")
        section_wdg.add_style("overflow: hidden")
        section_wdg.add_style("margin: 10px")
        section_wdg.set_box_shadow("0px 0px 10px")

        title_wdg = DivWdg()
        section_wdg.add(title_wdg)
        title_wdg.add(title)
        title_wdg.add_style("height: 20px")
        title_wdg.add_style("padding: 3px")
        title_wdg.add_style("margin-top: 3px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_gradient("background", "background")


        button = IconButtonWdg(title="Options", icon=IconWdg.ARROWHEAD_DARK_DOWN)
        title_wdg.add(button)
        button.add_style("float: right")

        # set up menus
        menu = my.get_menu()
        SmartMenu.add_smart_menu_set( button, { 'MENU_ITEM': menu } )
        SmartMenu.assign_as_local_activator( button, "MENU_ITEM", True )


        section_wdg.add_color("background", "background")
        #section_wdg.add_gradient("background", "background", 0, -3)
        section_wdg.add_behavior( {
        'type': 'hover',
        'add_color_modifier': -5,
        'cb_set_prefix': 'spt.mouse.table_layout_hover',
        } )

        desc_div = DivWdg()
        desc_div.add(description)
        desc_div.add_style("padding: 5px 10px 10px 5px")


        div = DivWdg()
        section_wdg.add(div)
        div.add_style("padding: 3px")
        div.add_style("margin: 5px")
        div.add_style("width: 65px")
        div.add_style("height: 50px")
        div.add_style("float: left")
        div.add(image)
        section_wdg.add(desc_div)
        div.add_style("overflow: hidden")

        section_wdg.add_behavior( behavior )
        section_wdg.add_class("hand")

        return section_wdg
Пример #3
0
    def get_display(my):
        security = Environment.get_security()
        if security.check_access("builtin", "view_site_admin", "allow"):
            menus = [my.get_main_menu(), my.get_add_menu(), my.get_edit_menu(), my.get_tools_menu(), my.get_help_menu()]
        else:
            menus = [my.get_main_menu(), my.get_edit_menu(), my.get_help_menu()]

        """
        btn_dd = DivWdg()
        btn_dd.add_styles("width: 36px; height: 18px; padding: none; padding-top: 1px;")

        btn_dd.add( "<img src='/context/icons/common/transparent_pixel.gif' alt='' " \
                   # "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none; width: 4px;' />" )
        btn_dd.add( "<img src='/context/icons/silk/cog.png' alt='' " \
                "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none;' />" )
        btn_dd.add( "<img src='/context/icons/silk/bullet_arrow_down.png' alt='' " \
                "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none;' />" )
        """

        from tactic.ui.widget import SingleButtonWdg

        btn_dd = SingleButtonWdg(title="Global Options", icon=IconWdg.GEAR, show_arrow=True)

        # btn_dd.add_behavior( { 'type': 'hover',
        #            'mod_styles': 'background-image: url(/context/icons/common/gear_menu_btn_bkg_hilite.png); ' \
        #                            'background-repeat: no-repeat;' } )
        smenu_set = SmartMenu.add_smart_menu_set(btn_dd, {"DG_TABLE_GEAR_MENU": menus})
        SmartMenu.assign_as_local_activator(btn_dd, "DG_TABLE_GEAR_MENU", True)
        return btn_dd
Пример #4
0
    def get_content_wdg(self):
        div = DivWdg()

        inner = DivWdg()
        div.add(inner)

        # set up the context menus
        menus_in = {
            #'DG_HEADER_CTX': [ self.get_smart_header_context_menu_data() ],
            'DG_DROW_SMENU_CTX': [ self.get_data_row_smart_context_menu_details() ]
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )

        if self.sobjects:
            for i, sobject in enumerate(self.sobjects):
                if i == 0:
                    self.first = True
                else:
                    self.first = False
                
                inner.add(self.get_item_wdg(sobject))
                inner.add("<hr/>")
        else:
            table = Table()
            inner.add(table)
            self.handle_no_results(table);

        return div
Пример #5
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_tile_top")

        div.add_class("spt_table_row")


        top_view = my.kwargs.get("top_view")
        if top_view:
            title_wdg = my.get_view_wdg(sobject, top_view)
        else:
            title_wdg = my.get_title(sobject)
        div.add( title_wdg )


        div.add_attr("spt_search_key", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        div.add_border()
        div.set_box_shadow()
        div.add_color("background", "background", -3)
        div.add_style("margin: 10px")
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        thumb_div = DivWdg()
        thumb_div.add_class("spt_tile_content")
        #thumb_div.add_class("spt_tile_detail")
        div.add(thumb_div)

        width =  240
        height = 160

        thumb_div.add_style("width: %s" % width)
        thumb_div.add_style("height: %s" % height)
        thumb_div.add_style("overflow: hidden")

        thumb = ThumbWdg2()
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)


        bottom_view = my.kwargs.get("bottom_view")
        if bottom_view:
            div.add( my.get_view_wdg(sobject, bottom_view) )



        div.add_attr("ondragenter", "return false")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")


        return div
Пример #6
0
    def add_menu_wdg(my, button, menus):

        from tactic.ui.container import SmartMenu

        my.menus = []
        my.menus.append(menu.get_data())

        smenu_set = SmartMenu.add_smart_menu_set( button, { 'BUTTON_MENU': my.menus } )
        SmartMenu.assign_as_local_activator( button, "BUTTON_MENU", True )
Пример #7
0
    def add_menu_wdg(my, button, menus):

        from tactic.ui.container import SmartMenu

        my.menus = []
        my.menus.append(menu.get_data())

        smenu_set = SmartMenu.add_smart_menu_set(button,
                                                 {'BUTTON_MENU': my.menus})
        SmartMenu.assign_as_local_activator(button, "BUTTON_MENU", True)
Пример #8
0
    def add_file_behaviors(my, item_div, dirname, basename):

        path = "%s/%s" % (dirname, basename)
        item_div.add_attr("spt_path", path)

        item_div.add_class("spt_dir_list_item")
        SmartMenu.assign_as_local_activator( item_div, 'FILE_MENU_CTX' )
        # for explicit Browse
        if my.preselected:
            item_div.add_class("spt_preselected") 
        super(CheckinDirListWdg, my).add_file_behaviors(item_div, dirname, basename)
Пример #9
0
    def add_file_behaviors(my, item_div, dirname, basename):

        path = "%s/%s" % (dirname, basename)
        item_div.add_attr("spt_path", path)

        item_div.add_class("spt_dir_list_item")
        SmartMenu.assign_as_local_activator( item_div, 'FILE_MENU_CTX' )
        # for explicit Browse
        if my.preselected:
            item_div.add_class("spt_preselected") 
        super(CheckinDirListWdg, my).add_file_behaviors(item_div, dirname, basename)
Пример #10
0
    def get_item_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
        div.add_class("spt_table_row")
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

        table = Table()
        div.add(table)
        table.set_max_width()
        tr = table.add_row()

        width = my.kwargs.get("preview_width")
        if not width:
            width = "240px"

        td = table.add_cell()
        td.add_style("width: %s" % width);
        td.add_style("vertical-align: top")

        """
        from tile_layout_wdg import ThumbWdg2
        thumb_div = DivWdg()
        #td.add(thumb_div)
        thumb_div.add_border()
        thumb_div.set_box_shadow("0px 0px 5px")
        thumb_div.add_color("background", "background", -5)
        thumb_div.add_class("spt_item_content")
        #thumb_div.add_style("min-height: 120px")

        thumb = ThumbWdg2()
        thumb_div.add(thumb)
        thumb.set_sobject(sobject)
        """


        tile_wdg = my.tile_layout.get_tile_wdg(sobject)
        td.add(tile_wdg)

        info_div = my.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")


        return div
Пример #11
0
    def get_item_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
        div.add_class("spt_table_row")
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

        table = Table()
        div.add(table)
        table.set_max_width()
        tr = table.add_row()

        width = my.kwargs.get("preview_width")
        if not width:
            width = "240px"

        td = table.add_cell()
        td.add_style("width: %s" % width);
        td.add_style("vertical-align: top")

        """
        from tile_layout_wdg import ThumbWdg2
        thumb_div = DivWdg()
        #td.add(thumb_div)
        thumb_div.add_border()
        thumb_div.set_box_shadow("0px 0px 5px")
        thumb_div.add_color("background", "background", -5)
        thumb_div.add_class("spt_item_content")
        #thumb_div.add_style("min-height: 120px")

        thumb = ThumbWdg2()
        thumb_div.add(thumb)
        thumb.set_sobject(sobject)
        """


        tile_wdg = my.tile_layout.get_tile_wdg(sobject)
        td.add(tile_wdg)

        info_div = my.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")


        return div
Пример #12
0
    def add_dir_behaviors(my, dir_div, dirname, basename):

        path = "%s/%s" % (dirname, basename)
        dir_div.add_attr("spt_path", path)

        dir_div.add_class("spt_dir_list_item")
        SmartMenu.assign_as_local_activator( dir_div, 'FILE_MENU_CTX' )
        dir_div.add_class("spt_dir")
        # for explicit Browse
        if my.preselected:
            dir_div.add_class("spt_preselected")
            # for dir, only preselect the first one
            my.preselected = False
        super(CheckinDirListWdg, my).add_dir_behaviors(dir_div, dirname, basename)
Пример #13
0
    def add_dir_behaviors(my, dir_div, dirname, basename):

        path = "%s/%s" % (dirname, basename)
        dir_div.add_attr("spt_path", path)

        dir_div.add_class("spt_dir_list_item")
        SmartMenu.assign_as_local_activator( dir_div, 'FILE_MENU_CTX' )
        dir_div.add_class("spt_dir")
        # for explicit Browse
        if my.preselected:
            dir_div.add_class("spt_preselected")
            # for dir, only preselect the first one
            my.preselected = False
        super(CheckinDirListWdg, my).add_dir_behaviors(dir_div, dirname, basename)
Пример #14
0
    def add_file_behaviors(self, item_div, dirname, basename):

        path = "%s/%s" % (dirname, basename)

        file_objects = self.kwargs.get("files")
        file_object = file_objects.get(path)
        if not file_object:
            print("WARNING: No file object for [%s]" % path)
            return
        file_search_key = file_object.get_search_key()

        item_div.add_class("spt_dir_list_item")
        item_div.add_attr("spt_path", path)
        item_div.add_attr("spt_file_search_key", file_search_key)
        SmartMenu.assign_as_local_activator(item_div, 'FILE_MENU_CTX')
Пример #15
0
    def get_content_wdg(my):
        div = DivWdg()

        inner = DivWdg()
        div.add(inner)

        # set up the context menus
        menus_in = {
            #'DG_HEADER_CTX': [ my.get_smart_header_context_menu_data() ],
            'DG_DROW_SMENU_CTX': [ my.get_data_row_smart_context_menu_details() ]
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )

        for sobject in my.sobjects:
            inner.add(my.get_item_wdg(sobject))

        return div
Пример #16
0
    def add_file_behaviors(my, item_div, dirname, basename):


        path = "%s/%s" % (dirname, basename)

        file_objects = my.kwargs.get("files")
        file_object = file_objects.get(path)
        if not file_object:
            print "WARNING: No file object for [%s]" % path
            return
        file_search_key = file_object.get_search_key()


        item_div.add_class("spt_dir_list_item")
        item_div.add_attr("spt_path", path)
        item_div.add_attr("spt_file_search_key", file_search_key)
        SmartMenu.assign_as_local_activator( item_div, 'FILE_MENU_CTX' )
Пример #17
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        inner = DivWdg()
        div.add(inner)

        # set up the context menus
        menus_in = {
            'DG_HEADER_CTX': [ my.get_smart_header_context_menu_data() ],
            'DG_DROW_SMENU_CTX': [ my.get_data_row_smart_context_menu_details() ]
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )


        from tactic.ui.filter import FilterData
        filter_data = FilterData.get()
        data_list = filter_data.get_values_by_prefix("tile_layout")
        if data_list:
            data = data_list[0]
        else:
            data = {}
        my.scale = data.get("scale")
        if my.scale == None:
            my.scale = my.kwargs.get("scale")

        
        inner.add_style("margin-left: 20px")

        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for sobject in my.sobjects:
                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        inner.add("<br clear='all'/>")
        return div
Пример #18
0
    def get_display(my):
        security = Environment.get_security()
        if security.check_access("builtin", "view_site_admin", "allow"):
            menus = [
                my.get_main_menu(),
                my.get_add_menu(),
                my.get_edit_menu(),
                my.get_tools_menu(),
                my.get_help_menu()
            ]
        else:
            menus = [
                my.get_main_menu(),
                my.get_edit_menu(),
                my.get_help_menu()
            ]
        """
        btn_dd = DivWdg()
        btn_dd.add_styles("width: 36px; height: 18px; padding: none; padding-top: 1px;")

        btn_dd.add( "<img src='/context/icons/common/transparent_pixel.gif' alt='' " \
                   # "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none; width: 4px;' />" )
        btn_dd.add( "<img src='/context/icons/silk/cog.png' alt='' " \
                "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none;' />" )
        btn_dd.add( "<img src='/context/icons/silk/bullet_arrow_down.png' alt='' " \
                "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none;' />" )
        """

        from tactic.ui.widget import SingleButtonWdg
        btn_dd = SingleButtonWdg(title='Global Options',
                                 icon=IconWdg.GEAR,
                                 show_arrow=True)

        #btn_dd.add_behavior( { 'type': 'hover',
        #            'mod_styles': 'background-image: url(/context/icons/common/gear_menu_btn_bkg_hilite.png); ' \
        #                            'background-repeat: no-repeat;' } )
        smenu_set = SmartMenu.add_smart_menu_set(btn_dd,
                                                 {'DG_TABLE_GEAR_MENU': menus})
        SmartMenu.assign_as_local_activator(btn_dd, "DG_TABLE_GEAR_MENU", True)
        return btn_dd
Пример #19
0
    def get_display(my):
        assert my.load_script

        widget = DivWdg()
        widget.add_style('float', 'right')

        load_button = TextOptionBtnWdg(label='   Load   ', size='medium')
        load_button.get_top_el().add_style('float', 'left')
        load_button.get_top_el().set_id(my.LOAD_BUTTON_ID)
        load_button.add_behavior(
                {'type': "click_up",
                "cbjs_action":
                "setTimeout(function() {%s}, 200) "% my.load_script
                })
        widget.add(load_button)
        arrow_button = load_button.get_option_widget()
        #widget.add(arrow_button)
        suffix = "ASSET_LOADER_FUNCTIONS"
        menus_in = [ my.smart_menu_data ]


        SmartMenu.add_smart_menu_set( arrow_button,  menus_in)
        SmartMenu.assign_as_local_activator(arrow_button, None, True)

        #SmartMenu.attach_smart_context_menu( load_button, menus_in, False )
        x_div = FloatDivWdg("x")
        x_div.add_color('color','color')
        x_div.add_style('margin-right: 6px')
        widget.add(x_div)
        multiplier = TextWdg()
        multiplier.set_id("load_multiplier")
        multiplier.set_option("size", "1.5")
        multiplier.add_style("font-size: 0.8em")
        multiplier.add_style("float: left")
        multiplier.add_class("load_multiplier")
        widget.add( multiplier )
        return widget
Пример #20
0
    def get_share_wdg(self):

        div = DivWdg()
        div.add_style("padding: 20px")


        msg = '''<p>Before starting to work on a project that you are sharing, you should import the starting point.</p>'''
        div.add(msg)


        button = ActionButtonWdg(title="Import")
        div.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.sync.SyncImportWdg';

            var top = bvr.src_el.getParent(".spt_share_top");
            var content = top.getElement(".spt_share_content");
            spt.panel.load(content, class_name);
            //spt.panel.load_popup("Sync Import", class_name);
            '''
        } )




        msg = '''<p>This allows you to create a share for this project.  This will allow you to share this project with others.</p>'''
        div.add(msg)


        button = ActionButtonWdg(title="Share")
        div.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.sync.SyncServerAddWdg';
            spt.panel.load_popup("Sync Share", class_name);
            '''
        } )




        title_wdg = DivWdg()
        div.add( title_wdg )
        title_wdg.add( "Local" )
        title_wdg.add_style("padding: 5px")
        title_wdg.add_color("background", "background", -10)
        title_wdg.add_border()
        title_wdg.add_style("margin: 5px -22px 10px -22px")


        local_code = Config.get_value("install", "server") or ""
        local_div = DivWdg()
        div.add(local_div)
        local_div.add_class("spt_share_item")
        local_div.add_attr("spt_server_code", local_code)
        local_div.add_class("hand")
        local_div.add(local_code)

        local_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.LocalItemWdg';

            var top = bvr.src_el.getParent(".spt_share_top");
            var content = top.getElement(".spt_share_content");
            spt.panel.load(content, class_name);
            //spt.panel.load_popup("Sync Import", class_name);
            '''
        } )






        div.add("<br/>")




        search = Search("sthpw/sync_server")
        shares = search.get_sobjects()

        title_wdg = DivWdg()
        div.add( title_wdg )
        title_wdg.add( "Share List" )
        title_wdg.add_style("padding: 5px")
        title_wdg.add_color("background", "background", -10)
        title_wdg.add_border()
        title_wdg.add_style("margin: 5px -22px 10px -22px")





        shares_div = DivWdg()
        div.add(shares_div)

        shares_div.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': 'spt_share_item',
            'cbjs_action': '''
            var server_code = bvr.src_el.getAttribute("spt_server_code");
            var class_name = 'tactic.ui.startup.ShareItemWdg';
            var kwargs = {
                server_code: server_code
            }
            var top = bvr.src_el.getParent(".spt_share_top");
            var content = top.getElement(".spt_share_content");
            spt.panel.load(content, class_name, kwargs);
            '''
        } )


        bgcolor = shares_div.get_color("background", -5)
        shares_div.add_relay_behavior( {
            'type': 'mouseover',
            'bvr_match_class': 'spt_share_item',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.bgcolor);
            '''
        } )
        shares_div.add_relay_behavior( {
            'type': 'mouseout',
            'bvr_match_class': 'spt_share_item',
            'cbjs_action': '''
            bvr.src_el.setStyle("background", "");
            '''
        } )


        from pyasm.security import AccessManager
        access_manager = AccessManager()
        project = Project.get()
        project_code = project.get_code()



        # add in a context menu
        menu = self.get_context_menu()
        menus = [menu.get_data()]
        menus_in = {
            'SHARE_ITEM_CTX': menus,
        }
        SmartMenu.attach_smart_context_menu( shares_div, menus_in, False )



        count = 0
        for share in shares:

            # hide the shares that are not in this project
            rules = share.get_value("access_rules");
            access_manager.add_xml_rules(rules)

            key1 = { 'code': project_code }
            key2 = { 'code': '*' }
            keys = [key1, key2]
            if not access_manager.check_access("project", keys, "allow", default="deny"):
                continue
  

            share_div = DivWdg()
            shares_div.add(share_div)
            share_div.add_class("spt_share_item")
            share_div.add_attr("spt_server_code", share.get_code())
            share_div.add_class("hand")

            share_div.add(share.get_code())
            share_div.add_attr("title", share.get_value("description") )
            share_div.add_style("padding: 5px")

            base_dir = share.get_value("base_dir")
            if base_dir:
                base_div = SpanWdg()
                share_div.add(base_div)
                base_div.add_style("font-size: 0.9em")
                base_div.add_style("font-style: italic")
                base_div.add_style("opacity: 0.5")
                base_div.add(" (%s)" % base_dir)


            share_div.add_attr("spt_share_code", share.get_code() )
            SmartMenu.assign_as_local_activator( share_div, 'SHARE_ITEM_CTX' )

            count += 1


        if not count:
            share_div = DivWdg()
            shares_div.add(share_div)

            share_div.add("<i>No shares</i>")
            share_div.add_style("padding: 5px")


        return div
Пример #21
0
    def get_item_wdg(self, sobject):

        self.element_names = self.kwargs.get("element_names")
        if not self.element_names:
            self.element_names = ["preview","code","name","description",]
        else:
            self.element_names = self.element_names.split(",")

        if self.element_names[0] == "preview":
            has_preview = True
            self.element_names = self.element_names[1:]
        else:
            has_preview = False

        view = self.kwargs.get("view")
        if not view:
            view = "table"
        from pyasm.widget import WidgetConfigView
        search_type = sobject.get_search_type()
        self.config = WidgetConfigView.get_by_search_type(search_type, view)



        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
        #div.add_class("spt_table_row")
        #div.add_class("spt_table_row_%s" % self.table_id)
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

        table = Table()

        div.add(table)
        table.set_max_width()
        tr = table.add_row()

        width = self.kwargs.get("preview_width")
        if not width:
            width = "240px"

        if has_preview:
            td = table.add_cell()
            td.add_style("width: %s" % width);
            td.add_style("vertical-align: top")

            options = self.config.get_display_options("preview")
            redirect_expr = options.get("redirect_expr")
            if redirect_expr:
                parent = Search.eval(redirect_expr, sobject, single=True)
                #parent = sobject.get_parent()
                tile_wdg = self.tile_layout.get_tile_wdg(parent)
            else:
                tile_wdg = self.tile_layout.get_tile_wdg(sobject)

            td.add(tile_wdg)

        info_div = self.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")


        return div
Пример #22
0
    def add_top_behaviors(my, top):
        if my.sobject:
            search_key = my.sobject.get_search_key()
        else:
            search_key = None

        bg_color = top.get_color("background")
        hilight_color = top.get_color("background", -20)

        top.add_behavior({
            'type': 'smart_click_up',
            'bvr_match_class': 'spt_dir_list_item',
            'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.checkin_list.set_top(top);

        spt.checkin_list.unselect_all_rows();
        spt.checkin_list.select(bvr.src_el);

        var applet = spt.Applet.get();

        var path = bvr.src_el.getAttribute("spt_path");
        var checkin_type = top.getElement(".spt_checkin_type");
        if (applet.is_dir(path)) {
            checkin_type.value = "dir_checkin";
        }
        else {
            checkin_type.value = "file_checkin";
        }

        ''' % {
                'bg_color': bg_color,
                'hilight_color': hilight_color
            }
        })

        top.add_behavior({
            'type': 'smart_click_up',
            'bvr_match_class': 'spt_dir_list_item',
            'modkeys': 'CTRL',
            'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.checkin_list.set_top(top);

        //spt.checkin_list.unselect_all_rows();
        spt.checkin_list.select(bvr.src_el);

        var applet = spt.Applet.get();

        var path = bvr.src_el.getAttribute("spt_path");
        var checkin_type = top.getElement(".spt_checkin_type");
        if (applet.is_dir(path)) {
            checkin_type.value = "dir_checkin";
        }
        else {
            checkin_type.value = "file_checkin";
        }

        ''' % {
                'bg_color': bg_color,
                'hilight_color': hilight_color
            }
        })

        top.add_behavior({
            'type': 'load',
            'cbjs_action': '''

//for shift click feature
spt.checkin_list = {};
spt.checkin_list.top = null;
spt.checkin_list.last_selected = null;
spt.checkin_list.single_select = false;

spt.checkin_list.set_top = function(top) {
    spt.checkin_list.top = top;
}



spt.checkin_list.get_selected_paths = function() {
    // find the subcontext widget
    var rows = spt.checkin_list.get_all_rows();

    var paths = [];
    for (var i = 0; i < rows.length; i++) {
        var row = rows[i];
        if (row.is_selected == true) {
            var path = row.getAttribute("spt_path");
            paths.push(path);
        }
    }
    return paths;
} 


spt.checkin_list.get_all_rows = function() {
    var rows = spt.checkin_list.top.getElements(".spt_dir_list_item");
    return rows;
}

spt.checkin_list.unselect_all_rows = function() {

    var rows = spt.checkin_list.get_all_rows();
    for (var i = 0; i < rows.length; i++) {
        spt.checkin_list.unselect(rows[i]);
    }

}


spt.checkin_list.unselect = function(row) {
    var subcontext_el = row.getElement(".spt_subcontext");
    var context_el = row.getElement(".spt_context")
    row.is_selected = false;
    row.setStyle("background", '%(bg_color)s');
    row.setAttribute("spt_background", '%(bg_color)s');
    if (subcontext_el)
        subcontext_el.setStyle("display", "none");
    else if (context_el)
        context_el.setStyle("display", "none");

    spt.checkin_list.last_selected = null;

    spt.checkin_list.disable_checkin();
}



spt.checkin_list.select = function(row) {
    // find the subcontext widget
    var subcontext_el = row.getElement(".spt_subcontext")
    var context_el = row.getElement(".spt_context")

    if (row.is_selected == true) {
        row.is_selected = false;
        row.setStyle("background", '%(bg_color)s');
        row.setAttribute("spt_background", '%(bg_color)s');
        if (subcontext_el)
            subcontext_el.setStyle("display", "none");
        else if (context_el)
            context_el.setStyle("display", "none");

        spt.checkin_list.last_selected = null;

    }
    else {
        row.is_selected = true;
        row.setStyle("background", '%(hilight_color)s');
        row.setAttribute("spt_background", '%(hilight_color)s');
        if (subcontext_el)
            subcontext_el.setStyle("display", "");
		else if (context_el)
            context_el.setStyle("display", "");
        
        spt.checkin_list.last_selected = row;
    }
    var top = spt.checkin_list.top; 
    var paths = [];
    var els = top.getElements(".spt_dir_list_item");
    for (var i = 0; i < els.length; i++) {
        if (els[i].is_selected) {
            paths.push( els[i].getAttribute("spt_path") );
        }
    }

    var grey_el = top.getElement(".spt_publish_disable");
    if (paths.length == 0) {
        grey_el.setStyle("display", "");
        return;
    }

    grey_el.setStyle("display", "none");
}


spt.checkin_list.enable_checkin = function() {
    var top = spt.checkin_list.top; 
    var grey_el = top.getElement(".spt_publish_disable");
    grey_el.setStyle("display", "none");
} 


spt.checkin_list.disable_checkin = function() {
    var top = spt.checkin_list.top; 
    var grey_el = top.getElement(".spt_publish_disable");
    grey_el.setStyle("display", "");
} 





spt.checkin_list.select_preselected = function(){
    var top = spt.checkin_list.top; 
    var el = top.getElement(".spt_file_selector");
    if (el == null) {
        return;
    }

    var rows = spt.checkin_list.get_all_rows()
    //var cbs = top.getElements(".spt_dir_list_item");
    var paths = [];
    for (var k=0; k<rows.length; k++){
        var row = rows[k];
        if (spt.has_class(row, 'spt_preselected')) {
            var path = row.getAttribute("spt_path");
            paths.push(path); 
            spt.checkin_list.select(row);
        }
    }
    // reassign the new paths selection
    el.file_paths = paths;
}


var top = bvr.src_el.getParent(".spt_checkin_top");
spt.checkin_list.set_top(top);
spt.checkin_list.select_preselected();


        ''' % {
                'bg_color': bg_color,
                'hilight_color': hilight_color
            }
        })

        top.add_behavior({
            'type':
            'smart_click_up',
            'modkeys':
            'SHIFT',
            'bvr_match_class':
            'spt_dir_list_item',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_checkin_top");

        spt.checkin_list.set_top(top);

        var rows = spt.checkin_list.get_all_rows();

        var last_selected = spt.checkin_list.last_selected;
        var last_index;
        var cur_index;
        for (var i = 0; i < rows.length; i++) {
            if (rows[i] == last_selected) {
                last_index = i;
            }
            if (rows[i] == bvr.src_el) {
                cur_index = i;
            }
        }
        var start_index;
        var end_index;
        if (last_index < cur_index) {
            start_index = last_index + 1;
            end_index = cur_index ;
        }
        else {
            start_index = cur_index;
            end_index = last_index -1 ;
        }

        for (var i = start_index; i < end_index+1; i++) {
            spt.checkin_list.select(rows[i]);
        }

        spt.checkin_list.last_selected = bvr.src_el;
        '''
        })

        # add a top menu
        menu = Menu(width=180)
        my.menu = menu
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)

        #menu_item = MenuItem(type='action', label='Revert to Latest')
        #menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Open File')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            applet.open_file(path);
            '''
        })

        menu_item = MenuItem(type='action', label='Open Containing Folder')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var parts = path.split("/");
            parts.pop()
            path = parts.join("/");
            applet.open_explorer(path);
            '''
        })

        menu_item = MenuItem(type='action', label='Copy File to Sandbox')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var selected_paths = spt.checkin_list.get_selected_paths();
            if (!selected_paths.length) {
                selected_paths = [path];
            }

            var top = activator.getParent(".spt_checkin_top");
            var default_sandbox_dir = top.getAttribute("spt_default_sandbox_dir");

            spt.app_busy.show("Copying files to Sandbox");
            for (var i = 0; i < selected_paths.length; i++) {
                var path = selected_paths[i];
                var parts = path.split("/");
                var filename = parts[parts.length-1];
                applet.copy_file(path, default_sandbox_dir + "/" + filename);
            }
            spt.app_busy.hide();

            spt.notify.show_message("Copied " + selected_paths.length + " files to sandbox");
            '''
        })

        #menu_item = MenuItem(type='action', label='Rename File')
        #menu.add(menu_item)

        # DISABLING until we actually have something that works better
        menu_item = MenuItem(type='action', label='Copy File')
        #menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var applet = spt.Applet.get();

            var parts = path.split("/");
            var basename = parts[parts.length-1];

            // FIXME: new to create new path
            var new_path = path + "_copy";
            var index = 1;
            while(1) {
                if (applet.exists(new_path)) {
                    new_path = path + "_copy" + index;
                    index += 1;
                }
                else {
                    break;
                }

                if (index > 100) {
                    spt.alert("More than 100 copies.  Exiting");
                    break;
                }
            }

            applet.copy_file(path, new_path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        })

        menu_item = MenuItem(type='separator')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Delete File')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var parts = path.split("/");
            var filename = parts[parts.length-1];

            var applet = spt.Applet.get();
            var label = applet.is_dir(path) ? 'directory': 'file';
            if (!confirm("Are you sure you wish to delete the local " + label + " ["+filename+"]?")) {
                return;
            }

            applet.rmtree(path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        })

        menu_item = MenuItem(type='separator')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Properties')
        menu.add(menu_item)

        menu_item.add_behavior({
            'type':
            'click_up',
            'search_key':
            search_key,
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var snapshot_code = activator.getAttribute("spt_snapshot_code");
            var path = activator.getAttribute("spt_path");
            var md5 = activator.getAttribute("spt_md5");

            var applet = spt.Applet.get();
            var cur_md5 = applet.get_md5(path);

            //if (md5 != cur_md5) {
            //    activator.setStyle("background", "#A77");
            //}


            var class_name = 'tactic.ui.checkin.FilePropertiesWdg';
            var kwargs = {
                path: path,
                md5: cur_md5,
                snapshot_code: snapshot_code,
                search_key: bvr.search_key
            };
            spt.panel.load_popup("File Properties", class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='action', label='Check in Preview Image')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'search_key':
            search_key,
            'cbjs_action':
            '''
            var server = TacticServerStub.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var context = "icon";
            server.simple_checkin( bvr.search_key, context, path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        })

        menus_in = {
            'FILE_MENU_CTX': menu,
        }
        SmartMenu.attach_smart_context_menu(top, menus_in, False)

        super(CheckinDirListWdg, my).add_top_behaviors(top)
Пример #23
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        my.process = my.kwargs.get("process")
        my.sobject = Search.get_by_search_key(my.search_key)
        my.pipeline_code = my.kwargs.get("pipeline_code")

        top = DivWdg()
        top.add_class("spt_file_selector")
        top.add_style("position: relative")

        hidden = HiddenWdg("mode")
        #hidden = TextWdg("mode")
        hidden.add_class("spt_mode")
        top.add(hidden)

        top.add_style("padding: 5px")
        top.add_style("min-width: 500px")
        top.add_style("min-height: 400px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        #top.add_border()

        logo_wdg = DivWdg()
        logo = HtmlElement.img(src="/context/icons/logo/perforce_logo.gif")
        logo_wdg.add(logo)
        top.add(logo_wdg)
        logo_wdg.add_style("opacity: 0.2")
        logo_wdg.add_style("position: absolute")
        logo_wdg.add_style("bottom: 0px")
        logo_wdg.add_style("right: 5px")

        # get some info from the config file
        """
        client_env_var = Config.get_value("perforce", "client_env_var")
        if not client_env_var:
            client_env_var = "P4Client"
        port_env_var = Config.get_value("perforce", "port_env_var")
        if not port_env_var:
            port_env_var = "P4Port"
        user_env_var = Config.get_value("perforce", "user_env_var")
        if not user_env_var:
            user_env_var = "P4User"
        password_env_var = Config.get_value("perforce", "password_env_var")
        if not password_env_var:
            password_env_var = "P4Passwd"
        """

        # {GET(sthpw/login)}_user
        host = ""
        client = ""
        user = ""
        password = ""
        port = ""

        project = my.sobject.get_project()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = ""

        top.add_behavior({
            'type': 'load',
            #'client_env_var': client_env_var,
            #'port_env_var': port_env_var,
            #'user_env_var': user_env_var,
            #'password_env_var': password_env_var,
            'client': client,
            'user': user,
            'password': password,
            'host': host,
            'port': port,
            'depot': depot,
            'cbjs_action': get_onload_js()
        })

        list_wdg = DivWdg()
        top.add(list_wdg)
        list_wdg.add_style("height: 32px")

        from tactic.ui.widget import SingleButtonWdg, ButtonNewWdg, ButtonRowWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: left")

        button = ButtonNewWdg(title="Refresh",
                              icon=IconWdg.REFRESH,
                              long=False)
        button_row.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.app_busy.show("Reading file system ...")
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        spt.app_busy.hide();
        '''
        })

        button = ButtonNewWdg(title="Check-out",
                              icon=IconWdg.CHECK_OUT,
                              long=False)
        button_row.add(button)

        my.sandbox_dir = my.kwargs.get("sandbox_dir")

        # what are we trying to do here???
        #my.root_sandbox_dir = Environment.get_sandbox_dir()
        #project = my.sobject.get_project()
        #my.root_sandbox_dir = "%s/%s" % (my.root_sandbox_dir, project.get_code())
        #repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")
        #repo_dir = "%s/%s" % (project.get_code(), repo_dir)

        # checkout command requires either starting with //<depot>/ or just
        # the relative path to the root.  The following removes
        # the root of the sandbox folder assuming that this is mapped
        # to the base of the depot
        my.root_sandbox_dir = Environment.get_sandbox_dir()
        repo_dir = my.sandbox_dir
        repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")

        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'repo_dir':
            repo_dir,
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.app_busy.show("Reading file system ...")

        var data = spt.scm.checkout(bvr.repo_dir)
        spt.panel.refresh(top);

        spt.app_busy.hide();
        '''
        })

        button = ButtonNewWdg(title="Perforce Actions",
                              icon=IconWdg.PERFORCE,
                              show_arrow=True)
        #button.set_show_arrow_menu(True)
        button_row.add(button)

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='Perforce')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Show Workspaces')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.WorkspaceWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "workspace";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='action', label='Show Changelists')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "changelist";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='action', label='Show Branches')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "branch";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Add New Changelist')
        menu.add(menu_item)

        menu_item.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);
            spt.scm.run("add_changelist", ["New Changelist"]);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");
            spt.panel.load(content, class_name);

            '''
        })

        menu_item = MenuItem(type='separator')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Sign Out of Perforce')
        menu.add(menu_item)

        menu_item.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''

            if (!confirm("Are you sure you wish to sign out of Perforce?")) {
                return;
            }
            spt.scm.signout_user();

            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);


            '''
        })

        #SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } )
        #SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True )

        SmartMenu.add_smart_menu_set(button.get_button_wdg(),
                                     {'BUTTON_MENU': menu})
        SmartMenu.assign_as_local_activator(button.get_button_wdg(),
                                            "BUTTON_MENU", True)

        # Perforce script editor. (nice because it should run as the user
        # in the appopriate environment
        """
        button = ButtonNewWdg(title="P4 Script Editor", icon=IconWdg.CREATE, show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")
        """

        button = ButtonNewWdg(title="Changelists Counter",
                              icon=IconWdg.CHECK_OUT_SM,
                              show_arrow=True)
        #button_row.add(button)
        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                // find any changelists that were missed
                var changelists = spt.scm.run("get_changelists", []);
                for (var i = 0; i < changelists.length; i++) {
                    var changelist = changelists[i];
                    var info = spt.scm.run("get_changelist_info",[changelist.change]);
                    console.log(info);
                }
                '''
        })

        # Hiding this for now

        button = ButtonNewWdg(title="Create",
                              icon=IconWdg.NEW,
                              show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='New ...')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Text File')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'sandbox_dir':
            my.sandbox_dir,
            'cbjs_action':
            '''
        var path = bvr.sandbox_dir + "/" + "new_text_file.txt";
        var env = spt.Environment.get();
        var url = env.get_server_url() + "/context/VERSION_API";
        var applet = spt.Applet.get();
        applet.download_file(url, path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        })

        #create_sobj = SObject.create("sthpw/virtual")
        #create_sobj.set_value("title", "Maya Project")
        #create_sobj.set_value("script_path", "create/maya_project")

        script_path = 'create/maya_project'
        menu_item = MenuItem(type='action', label='Maya Project')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'sandbox_dir':
            my.sandbox_dir,
            'process':
            my.process,
            'script_path':
            script_path,
            'cbjs_action':
            '''
        var script = spt.CustomProject.get_script_by_path(bvr.script_path);
        var options = {};
        options.script = script;

        // add some data to options
        options.sandbox_dir = bvr.sandbox_dir;
        options.process = bvr.process;
        spt.CustomProject.exec_custom_script({}, options);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        '''
        })

        template_path = '/context/template/maya_project.zip'
        menu_item = MenuItem(type='action', label='Zipped Template')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'sandbox_dir':
            my.sandbox_dir,
            'template_path':
            template_path,
            'cbjs_action':
            '''
        var path = bvr.sandbox_dir + "/" + "_template.zip";
        var env = spt.Environment.get();
        var url = env.get_server_url() + bvr.template_path;
        var applet = spt.Applet.get();
        applet.download_file(url, path);
        applet.unzip_file(path, bvr.sandbox_dir);
        applet.rmtree(path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        })

        SmartMenu.add_smart_menu_set(button, {'BUTTON_MENU': menu})
        SmartMenu.assign_as_local_activator(button, "BUTTON_MENU", True)

        # Browse button for browsing files and dirs directly
        """
        browse_div = DivWdg()
        list_wdg.add(browse_div)
        browse_div.add_style("float: left")

        button = ActionButtonWdg(title="Browse", tip="Select Files or Folder to Check-In")
        browse_div.add(button)

        behavior = {
        'type': 'click_up',
        'base_dir': my.sandbox_dir,
        'cbjs_action': '''
            var current_dir = bvr.base_dir;
            var is_sandbox = false;
            spt.checkin.browse_folder(current_dir, is_sandbox);
        '''
        }
        button.add_behavior( behavior )
        """

        from tactic.ui.widget import SandboxButtonWdg, CheckoutButtonWdg, ExploreButtonWdg, GearMenuButtonWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: right")

        #button = SandboxButtonWdg(base_dir=my.sandbox_dir, process=my.process)
        #button_row.add(button)

        #button = CheckoutButtonWdg(base_dir=my.sandbox_dir, sobject=my.sobject, proces=my.process)
        #button_row.add(button)

        button = ExploreButtonWdg(base_dir=my.sandbox_dir)
        button_row.add(button)

        button = GearMenuButtonWdg(base_dir=my.sandbox_dir,
                                   process=my.process,
                                   pipeline_code=my.pipeline_code)
        button_row.add(button)

        list_wdg.add("<br clear='all'/>")

        top.add("<hr/>")

        content_div = DivWdg()
        top.add(content_div)
        content_div.add_class("spt_checkin_content")

        content = my.get_content_wdg()
        content_div.add(content)

        return top
Пример #24
0
    def add_top_behaviors(self, top):

        # convert this to a repo directory
        asset_dir = Environment.get_asset_dir()
        web_dir = Environment.get_web_dir()

        web = WebContainer.get_web()
        browser = web.get_browser()
        use_applet = web.use_applet()

        if browser == 'Qt':
            top.add_relay_behavior({
                'type':
                'dblclick',
                'bvr_match_class':
                'spt_dir_list_item',
                'cbjs_action':
                '''
            var path = bvr.src_el.getAttribute("spt_path");
            var asset_dir = '%s';
            var web_dir = '%s';
            var relative_dir = path.replace(asset_dir, "");
            var url = web_dir + "/" + relative_dir;

            var url_parts = url.split("/");
            var file = url_parts.pop();
            file = encodeURIComponent(file);
            url_parts.push(file);
            url = url_parts.join("/");

            var class_name = 'tactic.ui.widget.EmbedWdg';
            var kwargs = {
                src: url
            }

            var parts = path.split("/");
            var filename = parts[parts.length-1];
            spt.tab.set_main_body_tab()
            spt.tab.add_new(filename, filename, class_name, kwargs);
            ''' % (asset_dir, web_dir)
            })
        else:
            top.add_relay_behavior({
                'type':
                'dblclick',
                'bvr_match_class':
                'spt_dir_list_item',
                'cbjs_action':
                '''
            var path = bvr.src_el.getAttribute("spt_path");
            if (path.indexOf('####') != -1) {
                spt.info('Cannot open the file sequence');
            } else {
                var asset_dir = '%s';
                var web_dir = '%s';
                var relative_dir = path.replace(asset_dir, "");
                var url = web_dir + "/" + relative_dir;

                // Encode the filename
                var url_parts = url.split("/");
                var filename = url_parts.pop();
                filename = encodeURIComponent(filename);
                url_parts.push(filename);
                url = url_parts.join("/");

                window.open(url);
            }
            ''' % (asset_dir, web_dir)
            })

        if use_applet:
            # add a top menu
            menu = Menu(width=180)
            menu_item = MenuItem(type='title', label='Actions')
            menu.add(menu_item)

            menu_item = MenuItem(type='action', label='Download to Folder')
            menu.add(menu_item)
            menu_item.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                var activator = spt.smenu.get_activator(bvr);
                var applet = spt.Applet.get();
                var select_dir = true;
                var dir = applet.open_file_browser('', select_dir);
                if (!dir) {
                    dir = applet.get_current_dir();
                }
                if (!dir) {
                    spt.alert("No folder selected to copy to");
                    return;
                }
                
                var path = activator.getAttribute("spt_path");

                var asset_dir = '%s';
                var env = spt.Environment.get();
                var server_url = env.get_server_url();
                var url = server_url + "/assets/" + path.replace(asset_dir, "");
                var parts = path.split("/");
                var filename = parts[parts.length-1];
                spt.app_busy.show("Downloading file", filename);
                applet.download_file(url, dir + "/" + filename);
                spt.app_busy.hide();
                if (dir)
                    spt.notify.show_message("Download to '" + dir + "' completed.")
                ''' % asset_dir
            })
            #menu_item = MenuItem(type='action', label='Check-out To Sandbox')
            #menu.add(menu_item)
            #menu_item.add_behavior( {
            #'type': 'click_up',
            #'cbjs_action': '''spt.alert('Not implemented yet.')'''
            #} )
            menu_item = MenuItem(type='action', label='Copy to Clipboard')
            menu.add(menu_item)
            menu_item.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var search_key = activator.getAttribute("spt_file_search_key");

            var server = TacticServerStub.get();
            var class_name = 'tactic.command.clipboard_cmd.ClipboardCopyCmd';
            var search_keys = [search_key];
            var kwargs = {
                search_keys: search_keys
            }
            try {
                spt.app_busy.show("Copy to Clipboard ...");
                server.execute_cmd(class_name, kwargs);
                spt.app_busy.hide();
                }
            catch(e) {
                spt.alert(spt.exception.handler(e));
            }
            '''
            })

            menu_item = MenuItem(type='action', label='View Metadata')
            menu.add(menu_item)
            menu_item.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var search_key = activator.getAttribute("spt_file_search_key");

            var server = TacticServerStub.get();
            var class_name = 'tactic.ui.checkin.SnapshotMetadataWdg';
            var kwargs = {
                search_key: search_key
            }
            spt.panel.load_popup("Metadata", class_name, kwargs);
            '''
            })

            menus_in = {
                'FILE_MENU_CTX': menu,
            }
            SmartMenu.attach_smart_context_menu(top, menus_in, False)

        self.add_selection(top)

        super(SnapshotDirListWdg, self).add_top_behaviors(top)
Пример #25
0
    def get_display(my):

        menus = []

        widget = DivWdg(id='ProjectSelectWdg', css='spt_panel')
        widget.set_attr('spt_class_name', 'tactic.ui.app.ProjectSelectWdg') 
        if not WebContainer.get_web().is_IE():
            widget.add_style("float: right")

        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='Open Project', icon=IconWdg.PROJECT, show_arrow=True)
        widget.add(button)


        #from tactic.ui.activator import ButtonForDropdownMenuWdg
        #menu_data = []
        #menu_id = "project_select_menu"

        allowed = Project.get_user_projects()
        allowed_codes = [x.get_code() for x in allowed]

        search = Search("sthpw/project")
        search.add_filters("code", allowed_codes)
        # ignore some builtin projects
        search.add_where("\"code\" not in ('admin','sthpw','unittest')")
        search.add_op("begin")
        #search.add_filter("is_template", 'true', quoted=False, op='!=')
        search.add_filter("is_template", True, op='!=')
        search.add_filter("is_template", 'NULL', quoted=False, op='is')
        search.add_op("or")
        projects = search.get_sobjects()


        from tactic.ui.container import  Menu, MenuItem
        menu = Menu(width=240)
        menus.append(menu)
        menu.set_allow_icons(False)

        security = Environment.get_security()
        if security.check_access("builtin", "view_site_admin", "allow", default="deny") or security.check_access("builtin", "create_projects", "allow", default="deny"):
            menu_item = MenuItem(type='title', label='Project Action')
            menu.add(menu_item)

            menu_item = MenuItem(type='action', label='Create New Project')
            menu.add(menu_item)
            menu_item.add_behavior( {
            'cbjs_action': '''
            //spt.popup.open('create_project_wizard');
            //Effects.fade_in($('create_project_wizard'), 200);
            var env = spt.Environment.get();
            var project = env.get_project();
            if (project == 'admin') {
                spt.tab.set_main_body_top();
                var class_name = 'tactic.ui.app.ProjectCreateWdg';
                spt.tab.add_new("create_project", "Create Project", class_name);
            }
            else {
                document.location = "/tactic/admin/link/create_project";
            }
            '''
            } )


            search = Search("config/url")
            search.add_filter("url", "/index")
            url = search.get_sobject()
            if url:
                menu_item = MenuItem(type='action', label='Open Index')
                menu.add(menu_item)
                menu_item.add_behavior( {
                'cbjs_action': '''
                var env = spt.Environment.get();
                var project = env.get_project();
                //document.location = "/tactic/" + project + "/";
                window.open('/tactic/'+project+'/');
                '''
                } )




        menu_item = MenuItem(type='title', label='Open Project')
        menu.add(menu_item)


        def add_project_menu(menu, project):
            project_code = project.get_code()
            menu_item = MenuItem(type='action', label=project.get_value("title"))

            web = WebContainer.get_web()
            browser = web.get_browser()

            if browser != 'Qt':

                menu_item.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                window.open('/tactic/%s/');
                ''' % project_code
                } )

            else:
                menu_item.add_behavior( {
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Jumping to Project ["+bvr.project_code+"]", "");
                document.location = '/tactic/%s/';
                ''' % project_code
                } )

            menu.add(menu_item)


        search = Search("sthpw/project")
        search.add_column("category", distinct=True)
        categories = [x.get_value("category") for x in search.get_sobjects() ]
        for category in categories:
            if category == '':
                continue

            # FIXME: a little inefficient, but should be ok for now
            category_projects = []
            for project in projects:
                if project.get_value("category") != category:
                    continue

                project_code = project.get_code()
                if not security.check_access("project", project_code, "view"):
                    continue
                
                category_projects.append(project)

            if category_projects:
                suffix = Common.get_filesystem_name(category)
                label = "%s (%s)" % (category, len(category_projects))
                menu_item = MenuItem(type='submenu', label=label)
                menu_item.set_submenu_tag_suffix(suffix)
                menu.add(menu_item)

                submenu = Menu(width=200, menu_tag_suffix=suffix)
                menus.append(submenu)
                for project in category_projects:
                    add_project_menu(submenu, project)


        from pyasm.security import get_security_version
        security_version = get_security_version()

        for project in projects:
            if project.get_value("category") != "":
                continue

            project_code = project.get_code()
            if security_version >= 2:
                key = { "code": project_code }
                key2 = { "code": "*" }
                keys = [key, key2]
                default = "deny"
                if not security.check_access("project", keys, "allow", default=default):
                    continue
            else:
                if not security.check_access("project", project_code, "view", default="allow"):
                    continue

            add_project_menu(menu, project)



        if not projects:
            menu_item = MenuItem(type='action', label="- No Projects Created -")
            menu_item.add_behavior( {
            'cbjs_action': '''
            '''
            } )
            menu.add(menu_item)




        if security.check_access("builtin", "view_site_admin", "allow") or security.check_access("builtin", "view_template_projects", "allow"):
            search = Search("sthpw/project")
            #search.add_filter("is_template", 'true', quoted=False)
            search.add_filter("is_template", True)
            projects = search.get_sobjects()

            if projects:
                menu_item = MenuItem(type='title', label="Template Projects")
                menu.add(menu_item)

           

            for project in projects:
                project_code = project.get_code()
                if security_version >= 2:
                    key = { "code": project_code }
                    key2 = { "code": "*" }
                    keys = [key, key2]
                    default = "deny"
                    if not security.check_access("project", keys, "allow", default=default):
                        continue
                else:
                    if not security.check_access("project", project_code, "view", default="allow"):
                        continue

                menu_item = MenuItem(type='action', label=project.get_value("title"))
                menu_item.add_behavior( {
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Jumping to Project ["+bvr.project_code+"]", "");
                document.location = '/projects/%s/'
                ''' % project_code
                } )
                menu.add(menu_item)


        if security.check_access("builtin", "view_site_admin", "allow", default="deny") or security.check_access("builtin", "create_projects", "allow", default="deny"):
            menu_item = MenuItem(type='title', label="Admin")
            menu.add(menu_item)
            project = Project.get_by_code("admin")
            add_project_menu(menu, project)





        from tactic.ui.container import SmartMenu
        smenu_set = SmartMenu.add_smart_menu_set( button, { 'BUTTON_MENU': menus } )
        SmartMenu.assign_as_local_activator( button, "BUTTON_MENU", True )


        return widget
Пример #26
0
    def get_display(my):

        search_type_obj = SearchType.get(my.search_type)
        sobj_title = search_type_obj.get_title()

        my.color_mode = my.kwargs.get("color_mode")
        if not my.color_mode:
            my.color_mode = "default"


        top_div = my.top
        top_div.add_class("spt_edit_top")

        if not my.is_refresh:
            my.set_as_panel(top_div)
        content_div = DivWdg()
        content_div.add_class("spt_edit_top")
        content_div.add_class("spt_edit_form_top")
        content_div.set_attr("spt_search_key", my.search_key)

        if not Container.get_dict("JSLibraries", "spt_edit"):
            content_div.add_behavior( {
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            } )



        layout_view = my.kwargs.get("layout_view")
        if layout_view:
            layout_wdg = my.get_custom_layout_wdg(layout_view)
            content_div.add(layout_wdg)

            return content_div



        # add close listener
        # NOTE: this is an absolute search, but is here for backwards
        # compatibility
        content_div.add_named_listener('close_EditWdg', '''
            var popup = bvr.src_el.getParent( ".spt_popup" );
            if (popup)
                spt.popup.close(popup);
        ''')


        attrs = my.config.get_view_attributes()
        default_access = attrs.get("access")

        if not default_access:
            default_access = "edit"

        project_code = Project.get_project_code()

        security = Environment.get_security()
        base_key =  search_type_obj.get_base_key()
        key = {
            'search_type': base_key,
            'project': project_code
        }
        access = security.check_access("sobject", key, "edit", default=default_access)
        if not access:
            my.is_disabled = True
        else:
            my.is_disabled = False

        disable_wdg = None
        if my.is_disabled:
            # TODO: This overlay doesn't work in IE, size, position, 
            # and transparency all fail. 
            disable_wdg = DivWdg(id='edit_wdg')
            disable_wdg.add_style("position: absolute")
            disable_wdg.add_style("height: 90%")
            disable_wdg.add_style("width: 100%")
            disable_wdg.add_style("left: 0px")
            #disable_wdg.add_style("bottom: 0px")
            #disable_wdg.add_style("top: 0px")

            disable_wdg.add_style("opacity: 0.2")
            disable_wdg.add_style("background: #fff")
            #disable_wdg.add_style("-moz-opacity: 0.2")
            disable_wdg.add_style("filter: Alpha(opacity=20)")
            disable_wdg.add("<center>EDIT DISABLED</center>")
            content_div.add(disable_wdg)


        attrs = my.config.get_view_attributes()

        inner = DivWdg()
        content_div.add(inner)
        menu = my.get_header_context_menu()
        menus = [menu.get_data()]
        menus_in = {
            'HEADER_CTX': menus,
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )






        table = Table()
        inner.add(table)
        if my.color_mode == "default":
            table.add_color("background", "background")
        table.add_color("color", "color")



        width = attrs.get('width')
        if not width:
            width = my.kwargs.get("width")
        if not width:
            width = 500
        table.add_style("width: %s" % width)

        height = attrs.get('height')
        if height:
            table.add_style("height: %s" % height)

        
        tr = table.add_row()


        show_header = my.kwargs.get("show_header")
        if show_header not in ['false', False]:
            my.add_header(table, sobj_title)

        single = my.kwargs.get("single")
        if single in ['false', False] and my.mode == 'insert':
            multi_div = DivWdg()
            multi_div.add_style("text-align: left")

            multi_div.add("Specify the number of items that will be added with this form:<br/><br/>")


            multi_div.add("<b># of new items to add: </b>")
            multi_div.add("&nbsp;"*4)


            multi_text = TextWdg("multiplier")
            multi_text.add_style("width: 30px")
            multi_div.add(multi_text)

            tr, td = table.add_row_cell( multi_div )

            if my.color_mode == "default":
                td.add_color("border-color", "table_border", default="border")
                td.add_style("border-width: 1px")
                td.add_style("border-style: solid")

            td.add_style("padding: 8 3 8 3")
            td.add_color("background", "background3")
            td.add_color("color", "color3")
        
        security = Environment.get_security()

        # break the widgets up in columns
        num_columns = attrs.get('num_columns')
        if not num_columns:
            num_columns = my.kwargs.get('num_columns')

        if not num_columns:
            num_columns = 1
        else:
            num_columns = int(num_columns)

        # go through each widget and draw it
        for i, widget in enumerate(my.widgets):

            # since a widget name called code doesn't necessariy write to code column, it is commented out for now
            """
            key = { 'search_type' : search_type_obj.get_base_key(),
                'column' : widget.get_name(),
                'project': project_code}
            # check security on widget
            if not security.check_access( "sobject_column",\
                key, "edit"):
                my.skipped_element_names.append(widget.get_name())
                continue
            """

            if not hasattr(widget, 'set_input_prefix'): 
                msg = DivWdg("Warning: The widget definition for [%s] uses [%s] and is not meant for use in Edit Layout. Please revise the edit_definition in widget config."% (widget.get_name(), widget.__class__.__name__ ))
                msg.add_style('color: orange')
                content_div.add(msg)
                content_div.add(HtmlElement.br())
                continue
            if my.input_prefix:
                widget.set_input_prefix(my.input_prefix)

           
            if isinstance(widget, HiddenWdg):
                content_div.add(widget)
                continue


            # Set up any validations configured on the widget ...
            from tactic.ui.app import ValidationUtil
            v_util = ValidationUtil( widget=widget )
            v_bvr = v_util.get_validation_bvr()
            if v_bvr:
                if (isinstance(widget, CalendarInputWdg)):
                    widget.set_validation( v_bvr.get('cbjs_validation'), v_bvr.get('validation_warning') );
                else:
                    widget.add_behavior( v_bvr )
                    widget.add_behavior( v_util.get_input_onchange_bvr() )
                  



            new_row = i % num_columns == 0
            if new_row:
                tr = table.add_row()


                if my.color_mode == "default":
                    if i % 2 == 0:
                        tr.add_color("background", "background")
                    else:
                        tr.add_color("background", "background", -5)



           
            show_title = (widget.get_option("show_title") != "false")
            if show_title:
                title = widget.get_title()

                td = table.add_cell(title)
                td.add_style("padding: 10px 15px 10px 5px")
                td.add_style("vertical-align: top")

                title_width = my.kwargs.get("title_width")
                if title_width:
                    td.add_style("width: %s" % title_width)
                else:
                    td.add_style("width: 100px")

                security = Environment.get_security()
                if security.check_access("builtin", "view_site_admin", "allow"):
                    SmartMenu.assign_as_local_activator( td, 'HEADER_CTX' )

                if my.color_mode == "default":
                    td.add_color("border-color", "table_border", default="border")
                    td.add_style("border-width: 1" )
                    td.add_style("border-style: solid" )

                td.add_style("text-align: right" )
 

            if not show_title:
                th, td = table.add_row_cell( widget )
                #td.add_border()

                continue
            else:
                td = table.add_cell( widget )
                #td = table.add_cell( widget.get_value() )
                td.add_style("min-width: 300px")
                td.add_style("padding: 10px 15px 10px 5px")
                td.add_style("vertical-align: top")

                if my.color_mode == "default":
                    td.add_color("border-color", "table_border", default="border")
                    td.add_style("border-width: 1" )
                    td.add_style("border-style: solid" )

                hint = widget.get_option("hint")
                if hint:
                    table.add_data( HintWdg(hint) ) 


        if not my.is_disabled and not my.mode == 'view':
            tr, td = table.add_row_cell( my.get_action_html() )
        
        if my.input_prefix:
            prefix = HiddenWdg("input_prefix", my.input_prefix)
            tr, td = table.add_row_cell()
            td.add(prefix)

        top_div.add(content_div) 
        return top_div
Пример #27
0
    def get_action_wdg(self):
        div = DivWdg()
        div.add_gradient("background", "background", -5)
        div.add_border()
        div.add_style("padding: 3px")

        button_row = ButtonRowWdg()
        div.add(button_row)
        button_row.add_style("float: left")
        div.add("<br clear='all'/>")

        button = ButtonNewWdg(title='Save Layout', icon=IconWdg.SAVE)
        button_row.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.app_busy.show("Saving ...");
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);
        var xml = spt.freeform.export();
        var search_type = canvas.getAttribute("spt_search_type");
        var view = canvas.getAttribute("spt_view");
        if (!search_type || !view) {
            alert("Cannot find search type or view");
            return;
        }

        var server = TacticServerStub.get();
        var sobject = server.get_unique_sobject("config/widget_config", {search_type: search_type, view: view} );
        server.update(sobject, {config: xml} );
        spt.app_busy.hide();

        '''
        })

        button = ButtonNewWdg(title='Add', icon=IconWdg.ADD, show_arrow=True)
        button_row.add(button)

        from tactic.ui.container import SmartMenu
        smenu_set = SmartMenu.add_smart_menu_set(
            button.get_button_wdg(), {'BUTTON_MENU': self.get_add_menu()})
        SmartMenu.assign_as_local_activator(button.get_button_wdg(),
                                            "BUTTON_MENU", True)

        button = ButtonNewWdg(title='Remove', icon=IconWdg.DELETE)
        button_row.add(button)

        button = ButtonNewWdg(title='Clear', icon=IconWdg.KILL)
        button_row.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);

        if ( !confirm("Are you sure you wish to clear the canvas?") ) {
            return;
        }
        spt.freeform.clear_canvas();


        '''
        })

        return div
Пример #28
0
    def get_example_display(my):
        div = DivWdg()

        # ----------------------------- Smart Menu data ----------------------------------------------------------

        menus = [
            my.get_smart_menu_main_menu_details(),
            my.get_smart_menu_submenu_one_details(),
            my.get_smart_menu_submenu_two_details()
        ]

        # ----------------------------- Smart Context Menu example -----------------------------------------------

        my.setup_next_example(div, "Smart Context Menu example ...")

        ctx_click_div = DivWdg()
        ctx_click_div.add_styles("background: orange; color: white; border: 1px solid black; " \
                                 "padding: 10px; width: 100px;")
        ctx_click_div.add("Right Click")
        SmartMenu.attach_smart_context_menu(ctx_click_div, menus)

        div.add(ctx_click_div)

        # ----------------------------- Smart Drop-down Button Menu example --------------------------------------

        my.setup_next_example(div, "Smart Drop-down Button Menu example ...")

        btn_dd = SmartMenu.get_smart_button_dropdown_wdg("Hello", menus, 150)
        div.add(btn_dd)

        # ----------------------------- Original Context Menu examples -------------------------------------------

        my.setup_next_example(div, "Original Context Menu examples ...")

        # Create the element to right click on for the given main context menu ...
        activator = DivWdg()

        activator.add_style("width: 300px")
        activator.add_style("height: 50px")
        activator.add_style("background: #660000")
        activator.add_style("text-align: center")
        activator.add(
            "<br/>Right click on me!<br/>(this widget creates the context menus)"
        )

        s_menu_2 = my.get_ctx_sub_menu_two_details()
        s_menu_3 = {}
        s_menu_3.update(s_menu_2)
        s_menu_3.update({'menu_id': "CtxMenu_Mike_Submenu_Three"})

        ctx_menu = my.get_ctx_menu_details()
        menus = [ctx_menu, my.get_ctx_sub_menu_details(), s_menu_2, s_menu_3]
        attach_ctx_menu_wdg = AttachContextMenuWdg(activator_wdg=activator,
                                                   menus=menus)
        div.add(attach_ctx_menu_wdg)

        div.add(activator)
        div.add("<br/><br/>")

        # Create second context menu activator, but one that attaches to the already created context menus that
        # were generated above for the first activator. This allows for efficient use of context menus -- e.g.
        # you only need to actually generate one set, but still be able to use that same set of context menus
        # for all, say, edit cells of a DG table ...
        #
        activator2 = DivWdg()

        activator2.add_style("width: 300px")
        activator2.add_style("height: 50px")
        activator2.add_style("background: #000066")
        activator2.add_style("text-align: center")
        activator2.add(
            "<br/>Right click on me!<br/>(this widget attaches to already created context menus)"
        )

        AttachContextMenuWdg.attach_by_menu_id(activator2,
                                               ctx_menu.get('menu_id'))

        div.add(activator2)

        # -------------------- Drop-down Button Menu example ------------------------------------------------------

        my.setup_next_example(div,
                              "Original Drop-down Menu Button example ...")

        menus = [my.get_dd_plain_menu(), my.get_dd_plain_submenu_1()]
        dd_button = ButtonForDropdownMenuWdg(id="MikeDropDownBtn",
                                             title="LMB on Me For Menu",
                                             menus=menus,
                                             width=150,
                                             match_width=True)
        div.add(dd_button)

        return div
Пример #29
0
    def get_example_display(my):

        div = DivWdg()

        # Smart Menu data ...
        dog_menus = [ my.get_sm_dog_main_menu_details(),
                      my.get_sm_dog_submenu_one_details(),
                      my.get_sm_dog_submenu_two_details()
                    ]

        cat_menus = [ my.get_sm_cat_main_menu_details() ]

        SmartMenu.attach_smart_context_menu( div, { 'DOG': dog_menus, 'CAT': cat_menus }, False )



        table = Table(css="maq_view_table")
        table.set_id( "main_body_table" )
        table.add_class("spt_table")

        table.add_behavior( { "type": "smart_drag",
                              "bvr_match_class": "SPT_DO_RESIZE",
                              "cbjs_setup": 'spt.dg_table.resize_column_setup( evt, bvr, mouse_411 );',
                              "cbjs_motion": 'spt.dg_table.resize_column_motion( evt, bvr, mouse_411 );'
                             } )

        table.add_behavior( { "type": "smart_drag",
                              "bvr_match_class": "SPT_DO_DRAG",
                              "use_copy": 'true',
                              "use_delta": 'true', 'dx': 10, 'dy': 10,
                              "drop_code": 'TableExampleSwitchContents',
                              "cbjs_action": "spt.ui_play.drag_cell_drop_action( evt, bvr );",
                              "copy_styles": 'background: blue; opacity: .5; border: 1px solid black; text-align: left;'
                             } )

        row = table.add_row()
        for c in range(10):
            th = table.add_header()
            th.set_attr('col_idx', str(c))
            th.add_class("cell_left")
            th.add_styles("width: 150px; cursor: default;")

            # @@@
            th.add_behavior( {
                "type": "move",
                "cbjs_action": '''
                    // log.debug( "(x,y) = (" + mouse_411.curr_x + "," + mouse_411.curr_y + ")" );
                    spt.ui_play.header_half_move_cbk( evt, bvr, mouse_411 );
                ''',
                "cbjs_action_on": '''
                    // log.debug( "START MY MOVE!" );
                ''',
                "cbjs_action_off": '''
                    // log.debug( "DONE MY MOVE!" );
                    spt.ui_play.header_half_move_off_cbk( evt, bvr, mouse_411 );
                '''
            } )

            if (c%2):
                th.add("H%s (Cat)" % c)
            else:
                th.add("H%s (Dog)" % c)
            th_resize = table.add_cell()
            th_resize.set_attr('col_idx', str(c+1))
            th_resize.add_class("SPT_DO_RESIZE cell_right")
            th_resize.add_styles("width: 4px; cursor: col-resize;")

        for r in range(19):
            row = table.add_row()
            for c in range(10):
                col = table.add_cell()
                col.set_attr('col_idx', str(c))
                col.set_attr('SPT_ACCEPT_DROP', 'TableExampleSwitchContents')
                col.add_class("SPT_DO_DRAG cell_left")
                col.add_styles("cursor: pointer;")
                col.add("(%s,%s)" % (r,c))
                if (c % 2) == 0:
                    SmartMenu.assign_as_local_activator( col, "DOG" )
                else:
                    SmartMenu.assign_as_local_activator( col, "CAT" )
                resize = table.add_cell()
                resize.set_attr('col_idx', str(c+1))
                resize.add_class("SPT_DO_RESIZE cell_right")
                resize.add_styles("width: 6px; cursor: col-resize;")

        div.add( table )
        return div
Пример #30
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        if my.top_styles:
            div.add_styles(my.top_styles)
        inner = DivWdg()
        div.add(inner)


        
        menus_in = {}
        # set up the context menus
        if my.show_context_menu == True:
            menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
            menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
        elif my.show_context_menu == 'none':
            div.add_event('oncontextmenu', 'return false;')
        if menus_in:
            SmartMenu.attach_smart_context_menu( inner, menus_in, False )
 




        

        temp = my.kwargs.get("temp")
        has_loading = False

        
        inner.add_style("margin-left: 20px")
       

        inner.add_attr("ondragenter", "return false")
        inner.add_attr("ondragover", "return false")
        inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")

        inner.add("<br clear='all'/>")

        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for row, sobject in enumerate(my.sobjects):

                if False and not temp and row > 4: 
                    tile_wdg = DivWdg()
                    inner.add(tile_wdg)
                    tile_wdg.add_style("width: 120px")
                    tile_wdg.add_style("height: 120px")
                    tile_wdg.add_style("float: left")
                    tile_wdg.add_style("padding: 20px")
                    tile_wdg.add_style("text-align: center")
                    tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
                    tile_wdg.add(" Loading ...")
                    tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
                    tile_wdg.add_class("spt_loading")
                    has_loading = True
                    continue


                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        chunk_size = 5
        if has_loading:
            inner.add_behavior( {
            'type': 'load',
            'chunk': chunk_size,
            'cbjs_action': '''
            var layout = bvr.src_el.getParent(".spt_layout");
            spt.table.set_layout(layout);
            var rows = layout.getElements(".spt_loading");

            var jobs = [];
            var count = 0;
            var chunk = bvr.chunk;
            while (true) {
                var job_item = rows.slice(count, count+chunk);
                if (job_item.length == 0) {
                    break;
                }
                jobs.push(job_item);
                count += chunk;
            }

            var count = -1;
            var func = function() {
                count += 1;
                var rows = jobs[count];
                if (! rows || rows.length == 0) {
                    return;
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].removeClass("spt_loading");
                }
                spt.table.refresh_rows(rows, null, null, {on_complete: func});
            }
            func();

            '''
            } )





        inner.add("<br clear='all'/>")
        return div
Пример #31
0
    def get_display(self):

        top = self.top
        top.add_class("spt_panel_layout_top")
        self.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)


        self.view = self.kwargs.get("view")


        # Define some views that are pages.  Pages are views that are self
        # contained and do not require arguments.  They are often created
        # by users
        search = Search("config/widget_config")
        search.add_column("view")
        search.add_filter("category", "CustomLayoutWdg")
        search.add_filter("view", "pages.%", op="like")
        sobjects = search.get_sobjects()
        self.pages = SObject.get_values(sobjects, "view")

        config = None
        is_test = False
        if self.view:
            search = Search("config/widget_config")
            search.add_filter("category", "PanelLayoutWdg")
            search.add_filter("view", self.view)
            config = search.get_sobject()

        elif is_test:
            config_xml = '''
            <config>
            <elements>
              <element name="a">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>pages.test1</view>
                </display>
              </element>

              <element name="b">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>

              <element name="c">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>test.search</view>
                </display>
              </element>

     
              <element name="d">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)


        if not config:
            config_xml = '''
            <config>
            <elements>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)


        grid = self.kwargs.get("grid")
        if not grid:
            grid = config.get_view_attribute("grid")

        if grid:
            if isinstance(grid, basestring):
                grid = [int(x) for x in grid.split("x")]

        else:
            grid = (3,1)


        is_owner = True


        table = DivWdg() 
        inner.add(table)
        table.add_style("margin: 20px")
        table.add_style("box-sizing: border-box")


        if is_owner:
            menu = self.get_action_menu()
            #SmartMenu.add_smart_menu_set( top, { 'BUTTON_MENU': menu } )

        element_names = config.get_element_names()

        index = 0
        for y in range(grid[1]):
            row = DivWdg()
            table.add(row)
            row.add_class("row")
            row.add_style("box-sizing: border-box")

            num_cols = grid[0]
            size = 12 / num_cols

            for x in range(grid[0]):
                col = DivWdg()
                row.add(col)
                col.add_class("col-sm-%s" % size)
                col.add_style("box-sizing: border-box")
                col.add_style("overflow: auto")

                col.add_class("spt_panel_top")



                if is_owner:
                    header = DivWdg()
                    col.add(header)

                    menu_wdg = DivWdg()
                    header.add(menu_wdg)
                    menu_wdg.add_style("float: right")
                    menu_wdg.add("<i class='fa fa-bars'> </i>")
                    menu_wdg.add_class("hand")

                    SmartMenu.add_smart_menu_set( menu_wdg, { 'BUTTON_MENU': menu } )
                    SmartMenu.assign_as_local_activator( menu_wdg, "BUTTON_MENU", True )


                element = None
                title = None
                if index < len(element_names):
                    element_name = element_names[index]
                    #element_name = "%s,%s" % (x,y)

                    element = config.get_display_widget(element_name)
                    title = config.get_element_title(element_name)
                    if not title:
                        title = Common.get_display_title(element_name)

                if not element:
                    element = DivWdg()
                    element.add("No content")
                    element.add_style("height: 100%")
                    element.add_style("width: 100%")
                    element.add_style("text-align: center")
                    element.add_border()
                else:
                    try:
                        element = element.get_buffer_display()
                    except:

                        element = DivWdg()
                        element.add("No content")
                        element.add_style("height: 100%")
                        element.add_style("width: 100%")
                        element.add_style("text-align: center")
                        element.add_border()



                if is_owner:
                    if title:
                        header.add(title)
                    else:
                        header.add("Panel: %s,%s" % (x, y))
                    col.add("<hr/>")

                content = DivWdg()
                col.add(content)
                content.add_class("spt_panel_content")
                content.add_style("min-height: 200px;")


                content.add(element)


                index += 1

        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
Пример #32
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()

        
        div.add_class("spt_tile_top")
        div.add_class("unselectable")
        div.add_style('margin', my.spacing)
        div.add_style('background-color','transparent')

        div.add_class("spt_table_row")
        div.add_class("spt_table_row_%s" % my.table_id)

        if my.kwargs.get("show_title") not in ['false', False]:
            if my.title_wdg:
                my.title_wdg.set_sobject(sobject)
                div.add(my.title_wdg.get_buffer_display())
            else:
                title_wdg = my.get_title(sobject)
                div.add( title_wdg )

        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_key_v2", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        display_value = sobject.get_display_value(long=True)
        div.add_attr("spt_display_value", display_value)

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        
        if my.kwargs.get("show_drop_shadow") not in ['false', False]:
            div.set_box_shadow()
        div.add_color("background", "background", -3)
        
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        border_color = div.get_color('border', modifier=20)

        thumb_drag_div = DivWdg()
        div.add(thumb_drag_div)
        thumb_drag_div.add_class("spt_tile_drag")
        thumb_drag_div.add_style("width: auto")
        thumb_drag_div.add_style("height: auto")
        thumb_drag_div.add_behavior( {
            "type": "drag",
            #'drag_el': 'drag_ghost_copy',
            #//'use_copy': 'true',
            "drag_el": '@',
            'drop_code': 'DROP_ROW',
            'border_color': border_color,
            "cb_set_prefix": 'spt.tile_layout.image_drag'
        } )

        thumb_div = DivWdg()
        thumb_drag_div.add(thumb_div)
        thumb_div.add_class("spt_tile_content")


        
        thumb_div.add_style("width: %s" % my.aspect_ratio[0])

        thumb_div.add_style("height: %s" % my.aspect_ratio[1])
        #thumb_div.add_style("overflow: hidden")

        kwargs = {'show_name_hover': my.show_name_hover}

        thumb = ThumbWdg2(**kwargs)
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)
        thumb_div.add_border()

        #bottom_view = my.kwargs.get("bottom_view")
        #if bottom_view:
        #    div.add( my.get_view_wdg(sobject, bottom_view) )
        if my.bottom:
            my.bottom.set_sobject(sobject)
            div.add(my.bottom.get_buffer_display())
        

        div.add_attr("ondragenter", "return false")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")

        return div
Пример #33
0
    def get_example_display(self):
        div = DivWdg()

        # ----------------------------- Smart Menu data ----------------------------------------------------------

        menus = [ self.get_smart_menu_main_menu_details(),
                  self.get_smart_menu_submenu_one_details(),
                  self.get_smart_menu_submenu_two_details()
                ]


        # ----------------------------- Smart Context Menu example -----------------------------------------------

        self.setup_next_example( div, "Smart Context Menu example ..." )

        ctx_click_div = DivWdg()
        ctx_click_div.add_styles("background: orange; color: white; border: 1px solid black; " \
                                 "padding: 10px; width: 100px;")
        ctx_click_div.add( "Right Click" )
        SmartMenu.attach_smart_context_menu( ctx_click_div, menus )

        div.add(ctx_click_div)

        # ----------------------------- Smart Drop-down Button Menu example --------------------------------------

        self.setup_next_example( div, "Smart Drop-down Button Menu example ..." )

        btn_dd = SmartMenu.get_smart_button_dropdown_wdg( "Hello", menus, 150 )
        div.add(btn_dd)

        # ----------------------------- Original Context Menu examples -------------------------------------------

        self.setup_next_example( div, "Original Context Menu examples ..." )

        # Create the element to right click on for the given main context menu ...
        activator = DivWdg()

        activator.add_style( "width: 300px" )
        activator.add_style( "height: 50px" )
        activator.add_style( "background: #660000" )
        activator.add_style( "text-align: center" )
        activator.add( "<br/>Right click on me!<br/>(this widget creates the context menus)" )

        s_menu_2 = self.get_ctx_sub_menu_two_details()
        s_menu_3 = {}
        s_menu_3.update( s_menu_2 )
        s_menu_3.update( { 'menu_id': "CtxMenu_Mike_Submenu_Three" } )

        ctx_menu = self.get_ctx_menu_details()
        menus = [ ctx_menu, self.get_ctx_sub_menu_details(), s_menu_2, s_menu_3 ]
        attach_ctx_menu_wdg = AttachContextMenuWdg( activator_wdg=activator, menus=menus )
        div.add( attach_ctx_menu_wdg )

        div.add( activator )
        div.add( "<br/><br/>" )

        # Create second context menu activator, but one that attaches to the already created context menus that
        # were generated above for the first activator. This allows for efficient use of context menus -- e.g.
        # you only need to actually generate one set, but still be able to use that same set of context menus
        # for all, say, edit cells of a DG table ...
        #
        activator2 = DivWdg()

        activator2.add_style( "width: 300px" )
        activator2.add_style( "height: 50px" )
        activator2.add_style( "background: #000066" )
        activator2.add_style( "text-align: center" )
        activator2.add( "<br/>Right click on me!<br/>(this widget attaches to already created context menus)" )

        AttachContextMenuWdg.attach_by_menu_id( activator2, ctx_menu.get('menu_id') )

        div.add( activator2 )

        # -------------------- Drop-down Button Menu example ------------------------------------------------------

        self.setup_next_example( div, "Original Drop-down Menu Button example ..." )

        menus = [ self.get_dd_plain_menu(), self.get_dd_plain_submenu_1() ]
        dd_button = ButtonForDropdownMenuWdg( id="MikeDropDownBtn", title="LMB on Me For Menu", menus=menus,
                                                 width=150, match_width=True)
        div.add( dd_button )

        return div
Пример #34
0
    def get_item_wdg(self, sobject):

        self.element_names = self.kwargs.get("element_names")
        if not self.element_names:
            self.element_names = [
                "preview",
                "code",
                "name",
                "description",
            ]
        else:
            self.element_names = self.element_names.split(",")

        if self.element_names[0] == "preview":
            has_preview = True
            self.element_names = self.element_names[1:]
        else:
            has_preview = False

        view = self.kwargs.get("view")
        if not view:
            view = "table"
        from pyasm.widget import WidgetConfigView
        search_type = sobject.get_search_type()
        self.config = WidgetConfigView.get_by_search_type(search_type, view)

        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator(div, 'DG_DROW_SMENU_CTX')
        #div.add_class("spt_table_row")
        #div.add_class("spt_table_row_%s" % self.table_id)
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

        table = Table()

        div.add(table)
        table.set_max_width()
        tr = table.add_row()

        width = self.kwargs.get("preview_width")
        if not width:
            width = "240px"

        if has_preview:
            td = table.add_cell()
            td.add_style("width: %s" % width)
            td.add_style("vertical-align: top")

            options = self.config.get_display_options("preview")
            redirect_expr = options.get("redirect_expr")
            if redirect_expr:
                parent = Search.eval(redirect_expr, sobject, single=True)
                #parent = sobject.get_parent()
                tile_wdg = self.tile_layout.get_tile_wdg(parent)
            else:
                tile_wdg = self.tile_layout.get_tile_wdg(sobject)

            td.add(tile_wdg)

        info_div = self.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")

        return div
Пример #35
0
    def get_container(my, xml):
        # handle the container

        element_node = xml.get_node("config/tmp/element")
        attrs = Xml.get_attributes(element_node)
        element_name = attrs.get("name")

        show_resize_scroll = attrs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = my.kwargs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = "false"


        # look for attributes in the element tag for specifying a title action button to plug
        # into the title bar of the custom section ...
        #
        title_action_icon = attrs.get("title_action_icon")
        title_action_script = attrs.get("title_action_script")
        title_action_label = attrs.get("title_action_label")
        if title_action_script and not title_action_label:
            title_action_label = '[action]'


        # get the width and height for the element content ...
        width = attrs.get("width")
        height = attrs.get("height")


        if width and height:
            container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll )
        else:
            container = ContainerWdg(show_resize_scroll=show_resize_scroll)

        # create the title
        title = attrs.get("title")
        if not title:
            title = Common.get_display_title(element_name)
        title_wdg = DivWdg()
        SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' )
        title_wdg.add_style("margin: 0px 0px 5px 0px")
        title_wdg.add_gradient("background", "background", 0)
        title_wdg.add_color("color", "color")
        title_wdg.add_style("padding", "5px")


        if title_action_script:
            # add an action button if an action script code was found in the attributes of the element
            proj = Project.get_project_code()
            script_search = Search("config/custom_script")
            script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" %
                                                           (proj, title_action_script) )
            script = script_sobj.get_value('script')
            icon_str = "HELP"
            if title_action_icon:
                icon_str = title_action_icon
            action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) )
            action_btn.set_attr('title',title_action_label)
            # action_btn = IconWdg( title_action_label, icon=icon)
            action_btn.add_behavior( {'type': 'click_up', 'cbjs_action':  script } )
            action_btn.add_styles( "cursor: pointer; float: right;" )

            title_wdg.add( action_btn )


        title_wdg.add(title)
        container.add(title_wdg)

        return container
Пример #36
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        my.process = my.kwargs.get("process")
        my.sobject = Search.get_by_search_key(my.search_key)
        my.pipeline_code = my.kwargs.get("pipeline_code")

        top = DivWdg()
        top.add_class("spt_file_selector")
        top.add_style("position: relative")


        hidden = HiddenWdg("mode")
        #hidden = TextWdg("mode")
        hidden.add_class("spt_mode")
        top.add(hidden)



        top.add_style("padding: 5px")
        top.add_style("min-width: 500px")
        top.add_style("min-height: 400px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        #top.add_border()


        logo_wdg = DivWdg()
        logo = HtmlElement.img(src="/context/icons/logo/perforce_logo.gif")
        logo_wdg.add(logo)
        top.add(logo_wdg)
        logo_wdg.add_style("opacity: 0.2")
        logo_wdg.add_style("position: absolute")
        logo_wdg.add_style("bottom: 0px")
        logo_wdg.add_style("right: 5px")



        # get some info from the config file
        """
        client_env_var = Config.get_value("perforce", "client_env_var")
        if not client_env_var:
            client_env_var = "P4Client"
        port_env_var = Config.get_value("perforce", "port_env_var")
        if not port_env_var:
            port_env_var = "P4Port"
        user_env_var = Config.get_value("perforce", "user_env_var")
        if not user_env_var:
            user_env_var = "P4User"
        password_env_var = Config.get_value("perforce", "password_env_var")
        if not password_env_var:
            password_env_var = "P4Passwd"
        """

        # {GET(sthpw/login)}_user
        host = ""
        client = ""
        user = ""
        password = ""
        port = ""

        project = my.sobject.get_project()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = ""


        top.add_behavior( {
            'type': 'load',
            #'client_env_var': client_env_var,
            #'port_env_var': port_env_var,
            #'user_env_var': user_env_var,
            #'password_env_var': password_env_var,
            'client': client,
            'user': user,
            'password': password,
            'host': host,
            'port': port,
            'depot': depot,
            'cbjs_action': get_onload_js()
        } )


        list_wdg = DivWdg()
        top.add(list_wdg)
        list_wdg.add_style("height: 32px")

        from tactic.ui.widget import SingleButtonWdg, ButtonNewWdg, ButtonRowWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: left")

        button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH, long=False)
        button_row.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.app_busy.show("Reading file system ...")
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        spt.app_busy.hide();
        '''
        } )



        button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT, long=False)
        button_row.add(button)

        my.sandbox_dir = my.kwargs.get("sandbox_dir")



        # what are we trying to do here???
        #my.root_sandbox_dir = Environment.get_sandbox_dir()
        #project = my.sobject.get_project()
        #my.root_sandbox_dir = "%s/%s" % (my.root_sandbox_dir, project.get_code())
        #repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")
        #repo_dir = "%s/%s" % (project.get_code(), repo_dir)




        # checkout command requires either starting with //<depot>/ or just
        # the relative path to the root.  The following removes
        # the root of the sandbox folder assuming that this is mapped
        # to the base of the depot
        my.root_sandbox_dir = Environment.get_sandbox_dir()
        repo_dir = my.sandbox_dir
        repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")



        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'repo_dir': repo_dir,
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.app_busy.show("Reading file system ...")

        var data = spt.scm.checkout(bvr.repo_dir)
        spt.panel.refresh(top);

        spt.app_busy.hide();
        '''
        } )





        button = ButtonNewWdg(title="Perforce Actions", icon=IconWdg.PERFORCE, show_arrow=True)
        #button.set_show_arrow_menu(True)
        button_row.add(button)

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='Perforce')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Show Workspaces')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.WorkspaceWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "workspace";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        } )





        menu_item = MenuItem(type='action', label='Show Changelists')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "changelist";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        } )



        menu_item = MenuItem(type='action', label='Show Branches')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "branch";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        } )


        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Add New Changelist')
        menu.add(menu_item)

        menu_item.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            spt.scm.run("add_changelist", ["New Changelist"]);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");
            spt.panel.load(content, class_name);

            '''
        } )


        menu_item = MenuItem(type='separator')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Sign Out of Perforce')
        menu.add(menu_item)

        menu_item.add_behavior( {
            'type': 'load',
            'cbjs_action': '''

            if (!confirm("Are you sure you wish to sign out of Perforce?")) {
                return;
            }
            spt.scm.host = null;
            spt.scm.user = null;
            spt.scm.password = null;

            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);


            '''
        } )



 
        #SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } )
        #SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True )

        SmartMenu.add_smart_menu_set( button.get_button_wdg(), { 'BUTTON_MENU': menu } )
        SmartMenu.assign_as_local_activator( button.get_button_wdg(), "BUTTON_MENU", True )




        # Perforce script editor. (nice because it should run as the user
        # in the appopriate environment
        """
        button = ButtonNewWdg(title="P4 Script Editor", icon=IconWdg.CREATE, show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")
        """



        button = ButtonNewWdg(title="Changelists Counter", icon=IconWdg.CHECK_OUT_SM, show_arrow=True)
        #button_row.add(button)
        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                // find any changelists that were missed
                var changelists = spt.scm.run("get_changelists", []);
                for (var i = 0; i < changelists.length; i++) {
                    var changelist = changelists[i];
                    var info = spt.scm.run("get_changelist_info",[changelist.change]);
                    console.log(info);
                }
                '''
            } )



        # Hiding this for now

        button = ButtonNewWdg(title="Create", icon=IconWdg.NEW, show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='New ...')
        menu.add(menu_item)


        menu_item = MenuItem(type='action', label='Text File')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'sandbox_dir': my.sandbox_dir,
        'cbjs_action': '''
        var path = bvr.sandbox_dir + "/" + "new_text_file.txt";
        var env = spt.Environment.get();
        var url = env.get_server_url() + "/context/VERSION_API";
        var applet = spt.Applet.get();
        applet.download_file(url, path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        } )


        #create_sobj = SObject.create("sthpw/virtual")
        #create_sobj.set_value("title", "Maya Project")
        #create_sobj.set_value("script_path", "create/maya_project")


        script_path = 'create/maya_project'
        menu_item = MenuItem(type='action', label='Maya Project')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'sandbox_dir': my.sandbox_dir,
        'process': my.process,
        'script_path': script_path,
        'cbjs_action': '''
        var script = spt.CustomProject.get_script_by_path(bvr.script_path);
        var options = {};
        options.script = script;

        // add some data to options
        options.sandbox_dir = bvr.sandbox_dir;
        options.process = bvr.process;
        spt.CustomProject.exec_custom_script({}, options);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        '''
        } )


        template_path = '/context/template/maya_project.zip'
        menu_item = MenuItem(type='action', label='Zipped Template')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'sandbox_dir': my.sandbox_dir,
        'template_path': template_path,
        'cbjs_action': '''
        var path = bvr.sandbox_dir + "/" + "_template.zip";
        var env = spt.Environment.get();
        var url = env.get_server_url() + bvr.template_path;
        var applet = spt.Applet.get();
        applet.download_file(url, path);
        applet.unzip_file(path, bvr.sandbox_dir);
        applet.rmtree(path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        } )



        SmartMenu.add_smart_menu_set( button, { 'BUTTON_MENU': menu } )
        SmartMenu.assign_as_local_activator( button, "BUTTON_MENU", True )



        # Browse button for browsing files and dirs directly
        """
        browse_div = DivWdg()
        list_wdg.add(browse_div)
        browse_div.add_style("float: left")

        button = ActionButtonWdg(title="Browse", tip="Select Files or Folder to Check-In")
        browse_div.add(button)

        behavior = {
        'type': 'click_up',
        'base_dir': my.sandbox_dir,
        'cbjs_action': '''
            var current_dir = bvr.base_dir;
            var is_sandbox = false;
            spt.checkin.browse_folder(current_dir, is_sandbox);
        '''
        }
        button.add_behavior( behavior )
        """

        from tactic.ui.widget import SandboxButtonWdg, CheckoutButtonWdg, ExploreButtonWdg, GearMenuButtonWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: right")

        #button = SandboxButtonWdg(base_dir=my.sandbox_dir, process=my.process)
        #button_row.add(button)

        #button = CheckoutButtonWdg(base_dir=my.sandbox_dir, sobject=my.sobject, proces=my.process)
        #button_row.add(button)

        button = ExploreButtonWdg(base_dir=my.sandbox_dir)
        button_row.add(button)

        button = GearMenuButtonWdg(base_dir=my.sandbox_dir, process=my.process, pipeline_code=my.pipeline_code)
        button_row.add(button)



        list_wdg.add("<br clear='all'/>")

        top.add("<hr/>")

        content_div = DivWdg()
        top.add(content_div)
        content_div.add_class("spt_checkin_content")

        content = my.get_content_wdg()
        content_div.add(content)

        return top
Пример #37
0
    def get_display(self):

        self.doc_mode = self.kwargs.get("doc_mode")
        path = self.kwargs.get("path")
        self.search_type = self.kwargs.get("search_type")

        self.last_path = None

        doc_key = self.kwargs.get("doc_key")
        if doc_key:
            self.doc = Search.get_by_search_key(doc_key)
            snapshot = Snapshot.get_latest_by_sobject(self.doc)
            if snapshot:
                self.last_path = snapshot.get_lib_path_by_type('main')

            path = self.doc.get_value("link")


        # TEST TEST TEST
        if not path:
            #path = "/home/apache/pdf/mongodb.txt"
            #path = "/home/apache/assets/google_docs.html"
            #path = "/home/apache/pdf/star_wars.txt"
            path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true"

            path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub"

            #path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html"
            path = "/home/apache/tactic/doc/alias.json"

        if not self.search_type:
            self.search_type = "test3/shot"


        self.column = "description"

        top = self.top
        top.add_class("spt_document_top")
        self.set_as_panel(top)

        #table = Table()
        table = ResizableTableWdg()

        top.add(table)
        table.add_row()
        table.set_max_width()

        left_td = table.add_cell()
        left_td.add_style("vertical-align: top")


        title = DivWdg()
        left_td.add(title)
        title.add_style("padding: 10px")
        title.add_color("background", "background3")

        button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        title.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.app_busy.show("Reloading Document");
            var top = bvr.src_el.getParent(".spt_document_top");
            spt.panel.refresh(top);
            spt.app_busy.hide();
            '''
        } )
        button.add_style("float: left")


        button = IconButtonWdg(title="Save", icon=IconWdg.SAVE)
        title.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            '''
        } )
        button.add_style("float: left")


        if not self.doc_mode:
            self.doc_mode = "text"
        select = SelectWdg("doc_mode")
        select.set_option("values", "text|formatted")
        title.add(select)
        select.set_value(self.doc_mode)
        select.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
            spt.app_busy.show("Reloading Document");
            var top = bvr.src_el.getParent(".spt_document_top");
            var value = bvr.src_el.value;
            top.setAttribute("spt_doc_mode", value);
            spt.panel.refresh(top);
            spt.app_busy.hide();
            '''
        } )


        title.add("<br clear='all'/>")

        #title.add(path)


        text_wdg = DivWdg()
        text_wdg.add_class("spt_document_content")
        left_td.add(text_wdg)

        #if path.startswith("https://docs.google.com/spreadsheet"):
        #    #path = "http://www.southpawtech.com.com"
        #    text_wdg.add('''
        #    <iframe class="spt_document_iframe" style="width: 100%%; height: auto; min-height: 600px; font-size: 1.0em" src="%s"></iframe>
        #    ''' % path)
        #    text_wdg.add_style("overflow-x: hidden")
        if True:

            if not self.last_path and self.doc:
                tmp_dir = Environment.get_tmp_dir()
                tmp_path = '%s/last_path.txt' % tmp_dir
                f = open(tmp_path, 'w')

                text = self.get_text(path, highlight=False)

                f.write(text)
                f.close()

                cmd = FileCheckin(self.doc, tmp_path)
                Command.execute_cmd(cmd)

            else:
                save = False
                if save:
                    # open up the last path
                    f = open(self.last_path, 'r')
                    last_text = f.read()
                    text = self.get_text(path, None, highlight=False)

                    if last_text != text:

                        tmp_dir = Environment.get_tmp_dir()
                        tmp_path = '%s/last_path.txt' % tmp_dir
                        f = open(tmp_path, 'w')
                        f.write(text)
                        f.write(text)
                        f.close()

                        cmd = FileCheckin(self.doc, tmp_path)
                        Command.execute_cmd(cmd)

                text = self.get_text(path, self.last_path)


            lines = text.split("\n") 

            if self.doc_mode == "text":

                num_lines = len(lines)

                """
                line_div = HtmlElement.pre()
                text_wdg.add(line_div)
                line_div.add_style("width: 20px")
                line_div.add_style("float: left")
                line_div.add_style("text-align: right")
                line_div.add_style("opacity: 0.3")
                line_div.add_style("padding-right: 10px")
                for i in range(0, num_lines*2):
                    line_div.add(i+1)
                    line_div.add("<br/>")
                """



            if self.doc_mode == "text":
                pre = HtmlElement.pre()
                pre.add_style("white-space: pre-wrap")
            else:
                pre = DivWdg()
            pre = DivWdg()
            text_wdg.add(pre)

            text_wdg.add_style("padding: 10px 5px")
            text_wdg.add_style("max-height: 600px")
            text_wdg.add_style("overflow-y: auto")
            text_wdg.add_style("width: 600px")
            text_wdg.add_class("spt_resizable")


            pre.add_style("font-family: courier")


            if self.doc_mode == "formatted":
                pre.add(text)

            else:
                line_table = Table()
                pre.add(line_table)
                line_table.add_style("width: 100%")
                count = 1
                for line in lines:
                    #line = line.replace(" ", "&nbsp;")
                    tr = line_table.add_row()
                    if count % 2 == 0:
                        tr.add_color("background", "background", -2)

                    td = line_table.add_cell()

                    # FIXME: hacky
                    if line.startswith('''<span style='background: #CFC'>'''):
                        is_new = True
                    else:
                        td.add_style("vertical-align: top")
                        text = TextWdg()
                        text.add_style("border", "none")
                        text.add_style("text-align", "right")
                        text.add_style("width", "25px")
                        text.add_style("margin", "0 10 0 0")
                        text.add_style("opacity", "0.5")
                        text.set_value(count)
                        td.add(text)
                        count += 1
                        is_new = False

                    td = line_table.add_cell()
                    if not is_new:
                        SmartMenu.assign_as_local_activator( td,'TEXT_CTX' )
                        tr.add_class("spt_line");
                    else:
                        SmartMenu.assign_as_local_activator( td,'TEXT_NEW_CTX' )
                        tr.add_class("spt_new_line");

                    td.add_class("spt_line_content");
                    td.add(line)




            #from tactic.ui.app import AceEditorWdg
            #editor = AceEditorWdg(code=text, show_options=False, readonly=True, height="600px")
             #text_wdg.add(editor)



        # add a click on spt_item
        text_wdg.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': 'spt_document_item',
            'search_type': self.search_type,
            'cbjs_action': '''

            var top = bvr.src_el.getParent(".spt_document_top");
            var data_el = top.getElement(".spt_document_data");

            var search_key = bvr.src_el.getAttribute("spt_search_key");

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': bvr.search_type,
                'search_key': search_key,
            }
            spt.panel.load(data_el, class_name, kwargs);
            '''
        } )


        # add a double click on spt_item
        bgcolor = text_wdg.get_color("background", -10)
        text_wdg.add_relay_behavior( {
            'type': 'mouseover',
            'bvr_match_class': 'spt_document_item',
            'search_type': self.search_type,
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("opacity", "1.0");
            //bvr.src_el.setStyle("font-weight", "normal");
            bvr.src_el.setStyle("background", bvr.bgcolor);
            '''
        } )

        # add a double click on spt_item
        text_wdg.add_relay_behavior( {
            'type': 'mouseout',
            'bvr_match_class': 'spt_document_item',
            'search_type': self.search_type,
            'cbjs_action': '''
            bvr.src_el.setStyle("opacity", "1.0");
            //bvr.src_el.setStyle("font-weight", "bold");
            bvr.src_el.setStyle("background", "");
            '''
        } )






        # add a context menu
        ctx_menu = self.get_text_context_menu()
        ctx_new_menu = self.get_text_new_context_menu()
        menus_in = {
            'TEXT_CTX': ctx_menu,
            'TEXT_NEW_CTX': ctx_new_menu,
        }
        SmartMenu.attach_smart_context_menu( text_wdg, menus_in, False )



        panel = ViewPanelWdg(
                search_type=self.search_type,
                layout="blah"
        )


        right_td = table.add_cell()
        right_td.add_style("vertical-align: top")

        panel_div = DivWdg()
        panel_div.add_class("spt_document_data")
        right_td.add(panel_div)
        panel_div.add(panel)


        text_wdg.add_behavior( {
            'type': 'load',
            'cbjs_action': r'''

spt.document = {};

spt.document.selected_text = null;

spt.document.get_selected_text = function(frame)
{

    var t = '';

    if (frame) {
        var rng = frame.contentWindow.getSelection().getRangeAt(0);
        spt.document.expandtoword(rng);
        t = rng.toString();
    }

    else if (window.getSelection) // FF4 with one tab open?
    {
        var rng = window.getSelection().getRangeAt(0);
        spt.document.expandtoword(rng);
        t = rng.toString();
    }
    else if (document.getSelection) // FF4 with multiple tabs open?
    {
        var rng = document.getSelection().getRangeAt(0);
        spt.document.expandtoword(rng);
        t = rng.toString();
    }
    else if (document.selection) // IE8
    {
        var rng = document.selection.createRange();
        // expand range to enclose any word partially enclosed in it
        rng.expand("word");
        t = rng.text;
    }

    // convert newline chars to spaces, collapse whitespace, and trim non-word chars
    return t.replace(/^\W+|\W+$/g, '');
    //return t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").replace(/^\W+|\W+$/g, '');
}

// expand FF range to enclose any word partially enclosed in it
spt.document.expandtoword = function(range)
{
    if (range.collapsed) {
        return;
    }

    while (range.startOffset > 0 && range.toString()[0].match(/\w/)) {
        range.setStart(range.startContainer, range.startOffset - 1);
    }

    while (range.endOffset < range.endContainer.length && range.toString()[range.toString().length - 1].match(/\w/))
    {
        range.setEnd(range.endContainer, range.endOffset + 1);
    }
}
            '''
        } )

        top.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': 'spt_document_content',
            'cbjs_action': r'''
            //spt.ace_editor.set_editor_top(bvr.src_el);
            //var text = spt.ace_editor.get_selection();
            var text = spt.document.get_selected_text();
            text = text.replace(/\n\n/mg, "\n");
            text = text.replace(/\n\n/mg, "\n");
            spt.document.selected_text = text + "";
            '''
        } )




        return top
Пример #38
0
    def get_display(my):

        web = WebContainer.get_web()

        
        tactic_header = Table()
        tactic_header.add_row()
        tactic_header.add_color("color", "color2")


        # tactic logo and release info
        skin = web.get_skin()
        src = '/context/skins/' + skin + '/images/tactic_logo.png'
        img = HtmlElement.img(src)
        img.add_class('hand')
        img.add_attr('title', 'Go to home page')
        img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"})

        rel_div = DivWdg()
        rel_div.add("&nbsp;"*3)
        rel_div.add("Release: %s" %Environment.get_release_version() )
        rel_div.add_style("font-size: 9px")
        # Need this to override the above color in add_looks
        rel_div.add_color("color", "color2")

        tactic_wdg = Table()

        tactic_wdg.add_style("width: 180px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( img )
        td.set_style("width:100px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( rel_div )
        td.set_style("text-align: left") 

        td = tactic_header.add_cell( tactic_wdg )
       
        # add the project thumb and title
        project = Project.get()

        if my.show_project:
            thumb_div = DivWdg()
            td = tactic_header.add_cell( thumb_div )
            thumb_div.add_style("height: 28px")
            thumb_div.add_style("overflow: hidden")
            thumb_div.add_border(modifier=-10)
            thumb_div.add_style("-moz-border-radius: 3px")

            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_sobject(project)
            thumb.set_icon_size("45")
            td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px")

            td = tactic_header.add_cell( project.get_value("title") )
            #td.add_looks( "fnt_title_1" )
            td.add_style("font-size: 20px")
            td.add_style("white-space: nowrap")
            td.add_style("padding-left: 14px")

            # project selection 
            td = tactic_header.add_cell()
            project_div = DivWdg()
            project_div.add_style("margin-top: -5px")
            project_div.add(ProjectSelectWdg() )
            td.add( project_div )
            td.set_style("padding-left: 14px")
             

            # Global Actions Gear Menu (contains links to Documentation) ...
            action_bar_btn_dd = PageHeaderGearMenuWdg()
            action_div = DivWdg(action_bar_btn_dd)
            action_div.add_style("margin-top: -5px")
            td = tactic_header.add_cell( action_div )

            if PrefSetting.get_value_by_key('subscription_bar') == 'true':
                from message_wdg import SubscriptionBarWdg
                sub = SubscriptionBarWdg(mode='popup')
                tactic_header.add_cell(sub)

        # user login

        # user
        user = Environment.get_login()
        full_name = user.get_full_name()
        user_div = SpanWdg( HtmlElement.b( "%s&nbsp;&nbsp;" % full_name) , css='hand')       
        user_div.set_style("padding-right:10px")

        # signout
        login = Environment.get_security().get_login()
        search_key = SearchKey.get_by_sobject(login)
        span = SpanWdg()
        span.add( user_div )
        user_div.add_attr('spt_nudge_menu_vert', '20')
       
        td = tactic_header.add_cell(span)       
        td.set_style("width:100%; text-align:right; white-space: nowrap")



        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True)
        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        button.add_attr('spt_nudge_menu_horiz', '-80')
        button.add_attr('spt_nudge_menu_vert', '10')

        td = tactic_header.add_cell(button_div)
    

        menus = my.get_smart_menu()
        # TODO: this part seems redundant to attach to both
        SmartMenu.add_smart_menu_set(user_div, [menus])
        SmartMenu.assign_as_local_activator(user_div, None, True)

        SmartMenu.add_smart_menu_set(button, [menus])
        SmartMenu.assign_as_local_activator(button, None, True)

   


        td.set_style("width:100%;")
        button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
        #button.add_behavior( {
        #'type': 'click_up',
        #'cbjs_action': '''
        #window.open("/doc/")
        #'''
        #} )

        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.named_events.fire_event("show_help")
        '''
        } )


        from tactic.ui.container import DialogWdg
        help_dialog = DialogWdg(z_index=900, show_pointer=False)
        td.add(help_dialog)
        help_dialog.add_title("Help")
        help_dialog.add_class("spt_help")


        # container for help
        help_div = DivWdg()
        help_dialog.add(help_div)

        from help_wdg import HelpWdg
        help_wdg = HelpWdg()
        help_div.add(help_wdg)


        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        td = tactic_header.add_cell(button_div)
        td.set_style("width:100%; text-align:right; white-space: nowrap")


        # Layout the Main Header Table
        main_div = DivWdg()

        # TEST: NEW LAYOUT
        if Config.get_value("install", "layout") == "fixed":
            main_div.add_style("position: fixed")
            main_div.add_style("z-index: 100")
            main_div.add_style("width: 100%")

        license = Environment.get_security().get_license()

        if not license.is_licensed():
            from tactic.ui.app import LicenseManagerWdg
            license_manager = LicenseManagerWdg(use_popup=True)
            main_div.add(license_manager)

        

        # create the header table
        tactic_header_div = DivWdg()
        tactic_header_div.add(tactic_header)
        tactic_header_div.add_gradient("background", "background2", 10, -10)

        main_div.add(tactic_header_div)

        main_div.add( my.get_js_popup() )


        """
        main_div.add( HelpPopupWdg() )

        # FIXME: is this even used at all?
        action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" )
        action_bar_popup.add_title( "TACTIC&trade; Action Bar" )
        action_bar_popup.add( ActionBarWdg() )
        main_div.add( action_bar_popup )
        """

        # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200
        popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 )
        popup.add('Tools', 'title')

        main_div.add( popup )

        
        return main_div
Пример #39
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()

        
        div.add_class("spt_tile_top")
        div.add_class("unselectable")
        div.add_style('margin', my.spacing)
        div.add_style('background-color','transparent')
        div.add_style('position','relative')

        div.add_class("spt_table_row")
        div.add_class("spt_table_row_%s" % my.table_id)

        if my.kwargs.get("show_title") not in ['false', False]:
            if my.title_wdg:
                my.title_wdg.set_sobject(sobject)
                div.add(my.title_wdg.get_buffer_display())
            else:
                title_wdg = my.get_title(sobject)
                div.add( title_wdg )

        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_key_v2", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        display_value = sobject.get_display_value(long=True)
        div.add_attr("spt_display_value", display_value)

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        
        if my.kwargs.get("show_drop_shadow") not in ['false', False]:
            div.set_box_shadow()
        div.add_color("background", "background", -3)
        
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        border_color = div.get_color('border', modifier=20)

        thumb_drag_div = DivWdg()
        div.add(thumb_drag_div)
        thumb_drag_div.add_class("spt_tile_drag")
        thumb_drag_div.add_style("width: auto")
        thumb_drag_div.add_style("height: auto")
        thumb_drag_div.add_behavior( {
            "type": "drag",
            #'drag_el': 'drag_ghost_copy',
            #//'use_copy': 'true',
            "drag_el": '@',
            'drop_code': 'DROP_ROW',
            'border_color': border_color,
            'search_type': my.search_type,
            "cb_set_prefix": 'spt.tile_layout.image_drag'
        } )

        thumb_div = DivWdg()
        thumb_drag_div.add(thumb_div)
        thumb_div.add_class("spt_tile_content")


        
        thumb_div.add_style("width: %s" % my.aspect_ratio[0])

        thumb_div.add_style("height: %s" % my.aspect_ratio[1])
        #thumb_div.add_style("overflow: hidden")

        kwargs = {'show_name_hover': my.show_name_hover}

        thumb = ThumbWdg2(**kwargs)
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)
        thumb_div.add_border()

        #bottom_view = my.kwargs.get("bottom_view")
        #if bottom_view:
        #    div.add( my.get_view_wdg(sobject, bottom_view) )
        if my.bottom:
            my.bottom.set_sobject(sobject)
            div.add(my.bottom.get_buffer_display())
        

        div.add_attr("ondragenter", "spt.thumb.noop_enter(event, this)")
        div.add_attr("ondragleave", "spt.thumb.noop_leave(event, this)")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")
        
        if my.overlay_expr:
            from tactic.ui.widget import OverlayStatsWdg
            stat_div = OverlayStatsWdg(expr = my.overlay_expr, sobject = sobject, bg_color = my.overlay_color)
            div.add(stat_div)


        return div
Пример #40
0
    def get_display(my):

        my.doc_mode = my.kwargs.get("doc_mode")
        path = my.kwargs.get("path")
        my.search_type = my.kwargs.get("search_type")

        my.last_path = None

        doc_key = my.kwargs.get("doc_key")
        if doc_key:
            my.doc = Search.get_by_search_key(doc_key)
            snapshot = Snapshot.get_latest_by_sobject(my.doc)
            if snapshot:
                my.last_path = snapshot.get_lib_path_by_type('main')

            path = my.doc.get_value("link")

        # TEST TEST TEST
        if not path:
            #path = "/home/apache/pdf/mongodb.txt"
            #path = "/home/apache/assets/google_docs.html"
            #path = "/home/apache/pdf/star_wars.txt"
            path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true"

            path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub"

            #path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html"
            path = "/home/apache/tactic/doc/alias.json"

        if not my.search_type:
            my.search_type = "test3/shot"

        my.column = "description"

        top = my.top
        top.add_class("spt_document_top")
        my.set_as_panel(top)

        #table = Table()
        table = ResizableTableWdg()

        top.add(table)
        table.add_row()
        table.set_max_width()

        left_td = table.add_cell()
        left_td.add_style("vertical-align: top")

        title = DivWdg()
        left_td.add(title)
        title.add_style("padding: 10px")
        title.add_color("background", "background3")

        button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        title.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.app_busy.show("Reloading Document");
            var top = bvr.src_el.getParent(".spt_document_top");
            spt.panel.refresh(top);
            spt.app_busy.hide();
            '''
        })
        button.add_style("float: left")

        button = IconButtonWdg(title="Save", icon=IconWdg.SAVE)
        title.add(button)
        button.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''
            '''
        })
        button.add_style("float: left")

        if not my.doc_mode:
            my.doc_mode = "text"
        select = SelectWdg("doc_mode")
        select.set_option("values", "text|formatted")
        title.add(select)
        select.set_value(my.doc_mode)
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
            spt.app_busy.show("Reloading Document");
            var top = bvr.src_el.getParent(".spt_document_top");
            var value = bvr.src_el.value;
            top.setAttribute("spt_doc_mode", value);
            spt.panel.refresh(top);
            spt.app_busy.hide();
            '''
        })

        title.add("<br clear='all'/>")

        #title.add(path)

        text_wdg = DivWdg()
        text_wdg.add_class("spt_document_content")
        left_td.add(text_wdg)

        #if path.startswith("https://docs.google.com/spreadsheet"):
        #    #path = "http://www.southpawtech.com.com"
        #    text_wdg.add('''
        #    <iframe class="spt_document_iframe" style="width: 100%%; height: auto; min-height: 600px; font-size: 1.0em" src="%s"></iframe>
        #    ''' % path)
        #    text_wdg.add_style("overflow-x: hidden")
        if True:

            if not my.last_path and my.doc:
                tmp_dir = Environment.get_tmp_dir()
                tmp_path = '%s/last_path.txt' % tmp_dir
                f = open(tmp_path, 'w')

                text = my.get_text(path, highlight=False)

                f.write(text)
                f.close()

                cmd = FileCheckin(my.doc, tmp_path)
                Command.execute_cmd(cmd)

            else:
                save = False
                if save:
                    # open up the last path
                    f = open(my.last_path, 'r')
                    last_text = f.read()
                    text = my.get_text(path, None, highlight=False)

                    if last_text != text:

                        tmp_dir = Environment.get_tmp_dir()
                        tmp_path = '%s/last_path.txt' % tmp_dir
                        f = open(tmp_path, 'w')
                        f.write(text)
                        f.write(text)
                        f.close()

                        cmd = FileCheckin(my.doc, tmp_path)
                        Command.execute_cmd(cmd)

                text = my.get_text(path, my.last_path)

            lines = text.split("\n")

            if my.doc_mode == "text":

                num_lines = len(lines)
                """
                line_div = HtmlElement.pre()
                text_wdg.add(line_div)
                line_div.add_style("width: 20px")
                line_div.add_style("float: left")
                line_div.add_style("text-align: right")
                line_div.add_style("opacity: 0.3")
                line_div.add_style("padding-right: 10px")
                for i in range(0, num_lines*2):
                    line_div.add(i+1)
                    line_div.add("<br/>")
                """

            if my.doc_mode == "text":
                pre = HtmlElement.pre()
                pre.add_style("white-space: pre-wrap")
            else:
                pre = DivWdg()
            pre = DivWdg()
            text_wdg.add(pre)

            text_wdg.add_style("padding: 10px 5px")
            text_wdg.add_style("max-height: 600px")
            text_wdg.add_style("overflow-y: auto")
            text_wdg.add_style("width: 600px")
            text_wdg.add_class("spt_resizable")

            pre.add_style("font-family: courier")

            if my.doc_mode == "formatted":
                pre.add(text)

            else:
                line_table = Table()
                pre.add(line_table)
                line_table.add_style("width: 100%")
                count = 1
                for line in lines:
                    #line = line.replace(" ", "&nbsp;")
                    tr = line_table.add_row()
                    if count % 2 == 0:
                        tr.add_color("background", "background", -2)

                    td = line_table.add_cell()

                    # FIXME: hacky
                    if line.startswith('''<span style='background: #CFC'>'''):
                        is_new = True
                    else:
                        td.add_style("vertical-align: top")
                        text = TextWdg()
                        text.add_style("border", "none")
                        text.add_style("text-align", "right")
                        text.add_style("width", "25px")
                        text.add_style("margin", "0 10 0 0")
                        text.add_style("opacity", "0.5")
                        text.set_value(count)
                        td.add(text)
                        count += 1
                        is_new = False

                    td = line_table.add_cell()
                    if not is_new:
                        SmartMenu.assign_as_local_activator(td, 'TEXT_CTX')
                        tr.add_class("spt_line")
                    else:
                        SmartMenu.assign_as_local_activator(td, 'TEXT_NEW_CTX')
                        tr.add_class("spt_new_line")

                    td.add_class("spt_line_content")
                    td.add(line)

            #from tactic.ui.app import AceEditorWdg
            #editor = AceEditorWdg(code=text, show_options=False, readonly=True, height="600px")
            #text_wdg.add(editor)

        # add a click on spt_item
        text_wdg.add_relay_behavior({
            'type':
            'mouseup',
            'bvr_match_class':
            'spt_document_item',
            'search_type':
            my.search_type,
            'cbjs_action':
            '''

            var top = bvr.src_el.getParent(".spt_document_top");
            var data_el = top.getElement(".spt_document_data");

            var search_key = bvr.src_el.getAttribute("spt_search_key");

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': bvr.search_type,
                'search_key': search_key,
            }
            spt.panel.load(data_el, class_name, kwargs);
            '''
        })

        # add a double click on spt_item
        bgcolor = text_wdg.get_color("background", -10)
        text_wdg.add_relay_behavior({
            'type':
            'mouseover',
            'bvr_match_class':
            'spt_document_item',
            'search_type':
            my.search_type,
            'bgcolor':
            bgcolor,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("opacity", "1.0");
            //bvr.src_el.setStyle("font-weight", "normal");
            bvr.src_el.setStyle("background", bvr.bgcolor);
            '''
        })

        # add a double click on spt_item
        text_wdg.add_relay_behavior({
            'type':
            'mouseout',
            'bvr_match_class':
            'spt_document_item',
            'search_type':
            my.search_type,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("opacity", "1.0");
            //bvr.src_el.setStyle("font-weight", "bold");
            bvr.src_el.setStyle("background", "");
            '''
        })

        # add a context menu
        ctx_menu = my.get_text_context_menu()
        ctx_new_menu = my.get_text_new_context_menu()
        menus_in = {
            'TEXT_CTX': ctx_menu,
            'TEXT_NEW_CTX': ctx_new_menu,
        }
        SmartMenu.attach_smart_context_menu(text_wdg, menus_in, False)

        panel = ViewPanelWdg(search_type=my.search_type, layout="blah")

        right_td = table.add_cell()
        right_td.add_style("vertical-align: top")

        panel_div = DivWdg()
        panel_div.add_class("spt_document_data")
        right_td.add(panel_div)
        panel_div.add(panel)

        text_wdg.add_behavior({
            'type':
            'load',
            'cbjs_action':
            r'''

spt.document = {};

spt.document.selected_text = null;

spt.document.get_selected_text = function(frame)
{

    var t = '';

    if (frame) {
        var rng = frame.contentWindow.getSelection().getRangeAt(0);
        spt.document.expandtoword(rng);
        t = rng.toString();
    }

    else if (window.getSelection) // FF4 with one tab open?
    {
        var rng = window.getSelection().getRangeAt(0);
        spt.document.expandtoword(rng);
        t = rng.toString();
    }
    else if (document.getSelection) // FF4 with multiple tabs open?
    {
        var rng = document.getSelection().getRangeAt(0);
        spt.document.expandtoword(rng);
        t = rng.toString();
    }
    else if (document.selection) // IE8
    {
        var rng = document.selection.createRange();
        // expand range to enclose any word partially enclosed in it
        rng.expand("word");
        t = rng.text;
    }

    // convert newline chars to spaces, collapse whitespace, and trim non-word chars
    return t.replace(/^\W+|\W+$/g, '');
    //return t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").replace(/^\W+|\W+$/g, '');
}

// expand FF range to enclose any word partially enclosed in it
spt.document.expandtoword = function(range)
{
    if (range.collapsed) {
        return;
    }

    while (range.startOffset > 0 && range.toString()[0].match(/\w/)) {
        range.setStart(range.startContainer, range.startOffset - 1);
    }

    while (range.endOffset < range.endContainer.length && range.toString()[range.toString().length - 1].match(/\w/))
    {
        range.setEnd(range.endContainer, range.endOffset + 1);
    }
}
            '''
        })

        top.add_relay_behavior({
            'type':
            'mouseup',
            'bvr_match_class':
            'spt_document_content',
            'cbjs_action':
            r'''
            //spt.ace_editor.set_editor_top(bvr.src_el);
            //var text = spt.ace_editor.get_selection();
            var text = spt.document.get_selected_text();
            text = text.replace(/\n\n/mg, "\n");
            text = text.replace(/\n\n/mg, "\n");
            spt.document.selected_text = text + "";
            '''
        })

        return top
Пример #41
0
    def get_display(my):

        search_type_obj = SearchType.get(my.search_type)
        sobj_title = search_type_obj.get_title()

        my.color_mode = my.kwargs.get("color_mode")
        if not my.color_mode:
            my.color_mode = "default"


        top_div = my.top
        top_div.add_class("spt_edit_top")

        if not my.is_refresh:
            my.set_as_panel(top_div)
        content_div = DivWdg()
        content_div.add_class("spt_edit_top")
        content_div.add_class("spt_edit_form_top")
        content_div.set_attr("spt_search_key", my.search_key)

        if not Container.get_dict("JSLibraries", "spt_edit"):
            content_div.add_behavior( {
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            } )



        layout_view = my.kwargs.get("layout_view")
        if layout_view:
            layout_wdg = my.get_custom_layout_wdg(layout_view)
            content_div.add(layout_wdg)

            return content_div



        # add close listener
        # NOTE: this is an absolute search, but is here for backwards
        # compatibility
        content_div.add_named_listener('close_EditWdg', '''
            var popup = bvr.src_el.getParent( ".spt_popup" );
            if (popup)
                spt.popup.close(popup);
        ''')


        attrs = my.config.get_view_attributes()
        default_access = attrs.get("access")

        if not default_access:
            default_access = "edit"

        project_code = Project.get_project_code()

        security = Environment.get_security()
        base_key =  search_type_obj.get_base_key()
        key = {
            'search_type': base_key,
            'project': project_code
        }
        access = security.check_access("sobject", key, "edit", default=default_access)
        if not access:
            my.is_disabled = True
        else:
            my.is_disabled = False

        disable_wdg = None
        if my.is_disabled:
            # TODO: This overlay doesn't work in IE, size, position, 
            # and transparency all fail. 
            disable_wdg = DivWdg(id='edit_wdg')
            disable_wdg.add_style("position: absolute")
            disable_wdg.add_style("height: 90%")
            disable_wdg.add_style("width: 100%")
            disable_wdg.add_style("left: 0px")
            #disable_wdg.add_style("bottom: 0px")
            #disable_wdg.add_style("top: 0px")

            disable_wdg.add_style("opacity: 0.2")
            disable_wdg.add_style("background: #fff")
            #disable_wdg.add_style("-moz-opacity: 0.2")
            disable_wdg.add_style("filter: Alpha(opacity=20)")
            disable_wdg.add("<center>EDIT DISABLED</center>")
            content_div.add(disable_wdg)


        attrs = my.config.get_view_attributes()

        #inner doesn't get styled. 
        inner = DivWdg()
        content_div.add(inner)
        menu = my.get_header_context_menu()
        menus = [menu.get_data()]
        menus_in = {
            'HEADER_CTX': menus,
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )

        #insert the header before body into inner
        show_header = my.kwargs.get("show_header")
        if show_header not in ['false', False]:
            my.add_header(inner, sobj_title)


        #insert table into a body container so styling gets applied
        table = Table()
        body_container = DivWdg()
        body_container.add_class("spt_popup_body")
        body_container.add(table)
        inner.add(body_container)


        if my.color_mode == "default":
            table.add_color("background", "background")
        elif my.color_mode == "transparent":
            table.add_style("background", "transparent")
        table.add_color("color", "color")



        width = attrs.get('width')
        if not width:
            width = my.kwargs.get("width")
        if not width:
            width = 600

        height = attrs.get('height')
        if height:
            table.add_style("height: %s" % height)


        tr = table.add_row()

        stype_type = search_type_obj.get_value("type", no_exception=True)
        if my.mode != 'insert' and stype_type in ['media'] and my.sobjects:

            td = table.add_cell()

            width += 300

            from tactic.ui.panel import ThumbWdg2
            thumb = ThumbWdg2()
            thumb.set_sobject(my.sobjects[0])
            td.add(thumb)
            thumb.add_style("margin: 0px 10px")
            path = thumb.get_lib_path()

            td.add_style("padding: 10px")
            td.add_attr("rowspan", len(my.widgets)+2)
            td.add_style("min-width: 250px")
            td.add_style("vertical-align: top")
            td.add_border(direction="right")

            if path:

                td.add("<h3>File Information</h3>")
                td.add("<br/>")

                from pyasm.checkin import BaseMetadataParser
                parser = BaseMetadataParser.get_parser_by_path(path)

                data = parser.get_tactic_metadata()
                data_table = Table()
                data_table.add_style("margin: 15px")
                td.add(data_table)
                for name, value in data.items():
                    data_table.add_row()
                    display_name = Common.get_display_title(name)
                    dtd = data_table.add_cell("%s: " % display_name)
                    dtd.add_style("width: 150px")
                    dtd.add_style("padding: 3px")
                    dtd = data_table.add_cell(value)
                    dtd.add_style("padding: 3px")

            else:
                td.add("<h3>No Image</h3>")
                td.add("<br/>")


        # set the width
        table.add_style("width: %s" % width)



        single = my.kwargs.get("single")
        if single in ['false', False] and my.mode == 'insert':
            multi_div = DivWdg()
            multi_div.add_style("text-align: left")
            multi_div.add_style("padding: 5px 10px")


            multi_div.add("<b>Specify number of new items to add: </b>")
            multi_div.add("&nbsp;"*4)


            multi_text = TextWdg("multiplier")
            multi_text.add_class("form-control")
            multi_div.add(multi_text)
            multi_text.add_style("display: inline-block")
            multi_text.add_style("width: 60px")

            tr, td = table.add_row_cell( multi_div )

            if my.color_mode == "defaultX":
                td.add_color("border-color", "table_border", default="border")
                td.add_style("border-width: 1px")
                td.add_style("border-style: solid")

            td.add_style("padding: 8 3 8 3")
            td.add_color("background", "background3")
            td.add_color("color", "color3")
        
        security = Environment.get_security()

        # break the widgets up in columns
        num_columns = attrs.get('num_columns')
        if not num_columns:
            num_columns = my.kwargs.get('num_columns')

        if not num_columns:
            num_columns = 1
        else:
            num_columns = int(num_columns)

        # go through each widget and draw it
        index =  0
        for i, widget in enumerate(my.widgets):

            # since a widget name called code doesn't necessariy write to code column, it is commented out for now
            """
            key = { 'search_type' : search_type_obj.get_base_key(),
                'column' : widget.get_name(),
                'project': project_code}
            # check security on widget
            if not security.check_access( "sobject_column",\
                key, "edit"):
                my.skipped_element_names.append(widget.get_name())
                continue
            """

            if not hasattr(widget, 'set_input_prefix'): 
                msg = DivWdg("Warning: The widget definition for [%s] uses [%s] and is not meant for use in Edit Layout. Please revise the edit_definition in widget config."% (widget.get_name(), widget.__class__.__name__ ))
                msg.add_style('color: orange')
                content_div.add(msg)
                content_div.add(HtmlElement.br())
                continue
            if my.input_prefix:
                widget.set_input_prefix(my.input_prefix)

            # Bootstrap
            widget.add_class("form-control")

            if not isinstance(widget, CheckboxWdg):
                widget.add_style("width: 100%")


            if isinstance(widget, EditTitleWdg):
                tr, td = table.add_row_cell()
                tr.add_color("background", "background", -5)
                td.add_style("height", "30px")
                td.add_style("padding", "0px 10px")

                td.add(widget)

                index = 0

                continue


           
            if isinstance(widget, HiddenWdg):
                content_div.add(widget)
                continue


            # Set up any validations configured on the widget ...
            from tactic.ui.app import ValidationUtil
            v_util = ValidationUtil( widget=widget )
            v_bvr = v_util.get_validation_bvr()
            if v_bvr:
                if (isinstance(widget, CalendarInputWdg)):
                    widget.set_validation( v_bvr.get('cbjs_validation'), v_bvr.get('validation_warning') );
                else:
                    widget.add_behavior( v_bvr )
                    widget.add_behavior( v_util.get_input_onchange_bvr() )
                  


            new_row = index % num_columns == 0
            if new_row:
                tr = table.add_row()


                if my.color_mode == "default":
                    if index % 2 == 0:
                        tr.add_color("background", "background")
                    else:
                        tr.add_color("background", "background", -1 )


            index += 1

           
            show_title = widget.get_option("show_title")
            if not show_title:
                show_title = my.kwargs.get("show_title")

            if show_title in ['false', False]:
                show_title = False
            else:
                show_title = True



            if show_title:
                title = widget.get_title()

                td = table.add_cell(title)
                td.add_style("padding: 15px 15px 10px 5px")
                td.add_style("vertical-align: top")

 
                title_width = my.kwargs.get("title_width")
                if title_width:
                    td.add_style("width: %s" % title_width)
                else:
                    td.add_style("width: 150px")

                security = Environment.get_security()
                if security.check_access("builtin", "view_site_admin", "allow"):
                    SmartMenu.assign_as_local_activator( td, 'HEADER_CTX' )

                if my.color_mode == "defaultX":
                    td.add_color("border-color", "table_border", default="border")
                    td.add_style("border-width: 1" )
                    td.add_style("border-style: solid" )

                td.add_style("text-align: right" )

                hint = widget.get_option("hint")
                if hint:
                    #hint_wdg = HintWdg(hint)
                    #hint_wdg.add_style("float: right")
                    #td.add( hint_wdg )
                    td.add_attr("title", hint)


            if not show_title:
                th, td = table.add_row_cell( widget )
                continue
            else:
                td = table.add_cell( widget )
                #td = table.add_cell( widget.get_value() )
                td.add_style("min-width: 300px")
                td.add_style("padding: 10px 25px 10px 5px")
                td.add_style("vertical-align: top")

                if my.color_mode == "defaultX":
                    td.add_color("border-color", "table_border", default="border")
                    td.add_style("border-width: 1" )
                    td.add_style("border-style: solid" )



        if not my.is_disabled and not my.mode == 'view':
            inner.add( my.get_action_html() )

        if my.input_prefix:
            prefix = HiddenWdg("input_prefix", my.input_prefix)
            tr, td = table.add_row_cell()
            td.add(prefix)

        top_div.add(content_div) 
        return top_div
Пример #42
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_tile_top")
        div.add_style('margin', my.spacing)
        div.add_style('background-color','transparent')

        div.add_class("spt_table_row")
        div.add_class("spt_table_row_%s" % my.table_id)

        if my.kwargs.get("show_title") not in ['false', False]:
            if my.title_wdg:
                my.title_wdg.set_sobject(sobject)
                div.add(my.title_wdg.get_buffer_display())
            else:
                title_wdg = my.get_title(sobject)
                div.add( title_wdg )

        div.add_attr("spt_search_key", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        
        if my.kwargs.get("show_drop_shadow") not in ['false', False]:
            div.set_box_shadow()
        div.add_color("background", "background", -3)
        
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        thumb_div = DivWdg()
        #thumb_div.add_styles('margin-left: auto; margin-right: auto')
        thumb_div.add_class("spt_tile_content")
        #thumb_div.add_class("spt_tile_detail")
        div.add(thumb_div)


        
        thumb_div.add_style("width: %s" % my.aspect_ratio[0])

        thumb_div.add_style("height: %s" % my.aspect_ratio[1])
        #thumb_div.add_style("overflow: hidden")

        thumb = ThumbWdg2()
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)
        thumb_div.add_border()

        #bottom_view = my.kwargs.get("bottom_view")
        #if bottom_view:
        #    div.add( my.get_view_wdg(sobject, bottom_view) )
        if my.bottom:
            my.bottom.set_sobject(sobject)
            div.add(my.bottom.get_buffer_display())


        div.add_attr("ondragenter", "return false")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")


        return div
Пример #43
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        inner = DivWdg()
        div.add(inner)


        # set up the context menus
        show_context_menu = my.kwargs.get("show_context_menu")
        if show_context_menu in ['false', False]:
            show_context_menu = False
        else:
            show_context_menu = True

        menus_in = {}
        if show_context_menu:
            menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
            menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
        if menus_in:
            SmartMenu.attach_smart_context_menu( inner, menus_in, False )


        temp = my.kwargs.get("temp")
        has_loading = False

        
        inner.add_style("margin-left: 20px")


        inner.add_attr("ondragenter", "return false")
        inner.add_attr("ondragover", "return false")
        inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")



        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for row, sobject in enumerate(my.sobjects):

                if False and not temp and row > 4: 
                    tile_wdg = DivWdg()
                    inner.add(tile_wdg)
                    tile_wdg.add_style("width: 120px")
                    tile_wdg.add_style("height: 120px")
                    tile_wdg.add_style("float: left")
                    tile_wdg.add_style("padding: 20px")
                    tile_wdg.add_style("text-align: center")
                    tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
                    tile_wdg.add(" Loading ...")
                    tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
                    tile_wdg.add_class("spt_loading")
                    has_loading = True
                    continue


                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        chunk_size = 5
        if has_loading:
            inner.add_behavior( {
            'type': 'load',
            'chunk': chunk_size,
            'cbjs_action': '''
            var layout = bvr.src_el.getParent(".spt_layout");
            spt.table.set_layout(layout);
            var rows = layout.getElements(".spt_loading");

            var jobs = [];
            var count = 0;
            var chunk = bvr.chunk;
            while (true) {
                var job_item = rows.slice(count, count+chunk);
                if (job_item.length == 0) {
                    break;
                }
                jobs.push(job_item);
                count += chunk;
            }

            var count = -1;
            var func = function() {
                count += 1;
                var rows = jobs[count];
                if (! rows || rows.length == 0) {
                    return;
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].removeClass("spt_loading");
                }
                spt.table.refresh_rows(rows, null, null, {on_complete: func});
            }
            func();

            '''
            } )





        inner.add("<br clear='all'/>")
        return div
Пример #44
0
    def get_display(self):

        top = self.top
        top.add_class("spt_panel_layout_top")
        self.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)

        self.view = self.kwargs.get("view")

        # Define some views that are pages.  Pages are views that are self
        # contained and do not require arguments.  They are often created
        # by users
        search = Search("config/widget_config")
        search.add_column("view")
        search.add_filter("category", "CustomLayoutWdg")
        search.add_filter("view", "pages.%", op="like")
        sobjects = search.get_sobjects()
        self.pages = SObject.get_values(sobjects, "view")

        config = None
        is_test = False
        if self.view:
            search = Search("config/widget_config")
            search.add_filter("category", "PanelLayoutWdg")
            search.add_filter("view", self.view)
            config = search.get_sobject()

        elif is_test:
            config_xml = '''
            <config>
            <elements>
              <element name="a">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>pages.test1</view>
                </display>
              </element>

              <element name="b">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>

              <element name="c">
                <display class="tactic.ui.panel.CustomLayoutWdg">
                  <view>test.search</view>
                </display>
              </element>

     
              <element name="d">
                <display class="tactic.ui.panel.StaticTableLayoutWdg">
                    <search_type>sthpw/login_group</search_type>
                    <element_names>login_group</element_names>
                    <show_shelf>false</show_shelf>
                </display>
              </element>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)

        if not config:
            config_xml = '''
            <config>
            <elements>
            </elements>
            </config>
            '''

            config = WidgetConfig.get(view="elements", xml=config_xml)

        grid = self.kwargs.get("grid")
        if not grid:
            grid = config.get_view_attribute("grid")

        if grid:
            if isinstance(grid, basestring):
                grid = [int(x) for x in grid.split("x")]

        else:
            grid = (3, 1)

        is_owner = True

        table = DivWdg()
        inner.add(table)
        table.add_style("margin: 20px")
        table.add_style("box-sizing: border-box")

        if is_owner:
            menu = self.get_action_menu()
            #SmartMenu.add_smart_menu_set( top, { 'BUTTON_MENU': menu } )

        element_names = config.get_element_names()

        index = 0
        for y in range(grid[1]):
            row = DivWdg()
            table.add(row)
            row.add_class("row")
            row.add_style("box-sizing: border-box")

            num_cols = grid[0]
            size = 12 / num_cols

            for x in range(grid[0]):
                col = DivWdg()
                row.add(col)
                col.add_class("col-sm-%s" % size)
                col.add_style("box-sizing: border-box")
                col.add_style("overflow: auto")

                col.add_class("spt_panel_top")

                if is_owner:
                    header = DivWdg()
                    col.add(header)

                    menu_wdg = DivWdg()
                    header.add(menu_wdg)
                    menu_wdg.add_style("float: right")
                    menu_wdg.add("<i class='fa fa-bars'> </i>")
                    menu_wdg.add_class("hand")

                    SmartMenu.add_smart_menu_set(menu_wdg,
                                                 {'BUTTON_MENU': menu})
                    SmartMenu.assign_as_local_activator(
                        menu_wdg, "BUTTON_MENU", True)

                element = None
                title = None
                if index < len(element_names):
                    element_name = element_names[index]
                    #element_name = "%s,%s" % (x,y)

                    element = config.get_display_widget(element_name)
                    title = config.get_element_title(element_name)
                    if not title:
                        title = Common.get_display_title(element_name)

                if not element:
                    element = DivWdg()
                    element.add("No content")
                    element.add_style("height: 100%")
                    element.add_style("width: 100%")
                    element.add_style("text-align: center")
                    element.add_border()
                else:
                    try:
                        element = element.get_buffer_display()
                    except:

                        element = DivWdg()
                        element.add("No content")
                        element.add_style("height: 100%")
                        element.add_style("width: 100%")
                        element.add_style("text-align: center")
                        element.add_border()

                if is_owner:
                    if title:
                        header.add(title)
                    else:
                        header.add("Panel: %s,%s" % (x, y))
                    col.add("<hr/>")

                content = DivWdg()
                col.add(content)
                content.add_class("spt_panel_content")
                content.add_style("min-height: 200px;")

                content.add(element)

                index += 1

        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
Пример #45
0
    def add_top_behaviors(self, top):
        if self.sobject:
            search_key = self.sobject.get_search_key()
        else:
            search_key = None

        bg_color = top.get_color("background")
        hilight_color = top.get_color("background", -20)

        top.add_behavior({
            'type': 'smart_click_up',
            'use_applet': self.use_applet,
            'bvr_match_class': 'spt_dir_list_item',
            'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.checkin_list.set_top(top);

        spt.checkin_list.unselect_all_rows();
        spt.checkin_list.select(bvr.src_el);


        var path = bvr.src_el.getAttribute("spt_path");
        var checkin_type = top.getElement(".spt_checkin_type");
        // try to disable applet

        if (bvr.use_applet) {
            var applet = spt.Applet.get();
            if (applet.is_dir(path)) {
                checkin_type.value = "dir_checkin";
            }
            else {
                checkin_type.value = "file_checkin";
            }
        }
        else
            checkin_type.value = "file_checkin";

        ''' % {
                'bg_color': bg_color,
                'hilight_color': hilight_color
            }
        })
        """
        top.add_behavior( {
        'type': 'smart_click_up',
        'bvr_match_class': 'spt_dir_list_item',
        'modkeys': 'CTRL',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.checkin_list.set_top(top);

        //spt.checkin_list.unselect_all_rows();
        spt.checkin_list.select(bvr.src_el);

        var applet = spt.Applet.get();

        var path = bvr.src_el.getAttribute("spt_path");
        var checkin_type = top.getElement(".spt_checkin_type");
        if (applet.is_dir(path)) {
            checkin_type.value = "dir_checkin";
        }
        else {
            checkin_type.value = "file_checkin";
        }

        ''' %{'bg_color': bg_color, 'hilight_color': hilight_color}
        } )


        """
        top.add_behavior({
            'type': 'load',
            'cbjs_action': '''

//for shift click feature
spt.checkin_list = {};
spt.checkin_list.top = null;
spt.checkin_list.last_selected = null;
spt.checkin_list.single_select = false;

spt.checkin_list.set_top = function(top) {
    spt.checkin_list.top = top;
}



spt.checkin_list.get_selected_paths = function() {
    // find the subcontext widget
    var rows = spt.checkin_list.get_all_rows();

    var paths = [];
    for (var i = 0; i < rows.length; i++) {
        var row = rows[i];
        if (row.is_selected == true) {
            var path = row.getAttribute("spt_path");
            paths.push(path);
        }
    }
    return paths;
} 


spt.checkin_list.get_all_rows = function() {
    var rows = spt.checkin_list.top.getElements(".spt_dir_list_item");
    return rows;
}

spt.checkin_list.unselect_all_rows = function() {

    var rows = spt.checkin_list.get_all_rows();
    for (var i = 0; i < rows.length; i++) {
        spt.checkin_list.unselect(rows[i]);
    }

}


spt.checkin_list.unselect = function(row) {
    var subcontext_el = row.getElement(".spt_subcontext");
    var context_el = row.getElement(".spt_context")
    row.is_selected = false;
    row.setStyle("background", '%(bg_color)s');
    row.setAttribute("spt_background", '%(bg_color)s');
    if (subcontext_el)
        subcontext_el.setStyle("display", "none");
    else if (context_el)
        context_el.setStyle("display", "none");

    spt.checkin_list.last_selected = null;

    spt.checkin_list.disable_checkin();
}



spt.checkin_list.select = function(row) {
    // find the subcontext widget
    var subcontext_el = row.getElement(".spt_subcontext")
    var context_el = row.getElement(".spt_context")

    if (row.is_selected == true) {
        row.is_selected = false;
        row.setStyle("background", '%(bg_color)s');
        row.setAttribute("spt_background", '%(bg_color)s');
        if (subcontext_el)
            subcontext_el.setStyle("display", "none");
        else if (context_el)
            context_el.setStyle("display", "none");

        spt.checkin_list.last_selected = null;

    }
    else {
        row.is_selected = true;
        row.setStyle("background", '%(hilight_color)s');
        row.setAttribute("spt_background", '%(hilight_color)s');
        if (subcontext_el)
            subcontext_el.setStyle("display", "");
		else if (context_el)
            context_el.setStyle("display", "");
        
        spt.checkin_list.last_selected = row;
    }
    var top = spt.checkin_list.top; 
    var paths = [];
    var els = top.getElements(".spt_dir_list_item");
    for (var i = 0; i < els.length; i++) {
        if (els[i].is_selected) {
            paths.push( els[i].getAttribute("spt_path") );
        }
    }

    var grey_el = top.getElement(".spt_publish_disable");
    if (paths.length == 0) {
        grey_el.setStyle("display", "");
        return;
    }

    grey_el.setStyle("display", "none");
}


spt.checkin_list.enable_checkin = function() {
    var top = spt.checkin_list.top; 
    var grey_el = top.getElement(".spt_publish_disable");
    grey_el.setStyle("display", "none");
} 


spt.checkin_list.disable_checkin = function() {
    var top = spt.checkin_list.top; 
    var grey_el = top.getElement(".spt_publish_disable");
    grey_el.setStyle("display", "");
} 





spt.checkin_list.select_preselected = function(){
    var top = spt.checkin_list.top; 
    var el = top.getElement(".spt_file_selector");
    if (el == null) {
        return;
    }

    var rows = spt.checkin_list.get_all_rows()
    //var cbs = top.getElements(".spt_dir_list_item");
    var paths = [];
    for (var k=0; k<rows.length; k++){
        var row = rows[k];
        if (spt.has_class(row, 'spt_preselected')) {
            var path = row.getAttribute("spt_path");
            paths.push(path); 
            spt.checkin_list.select(row);
        }
    }
    // reassign the new paths selection
    el.file_paths = paths;
}

// can explicitly specify a context, description
// this is similar to spt.checkin.html5_checkin()
spt.checkin.html5_strict_checkin = function(files, context, description) {
    var server = TacticServerStub.get();

    var options = spt.checkin.get_checkin_data();
    var search_key = options.search_key;
    var process = options.process;
    if (!description)
    	description = options.description;

    var is_current = true;
    var checkin_type = 'file';
    var mode = 'uploaded';
    
    var top = spt.checkin_list.top;
    var progress = top.getElement(".spt_checkin_progress");
    progress.setStyle("display", "");

    var upload_complete = function() {

        try {
            if (bvr.validate_script_path){
                var script = spt.CustomProject.get_script_by_path(bvr.validate_script_path);
                bvr['script'] = script;
                spt.app_busy.show("Running Validation", bvr.validate_script_path);
                spt.CustomProject.exec_custom_script(evt, bvr);
            } 
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                var file_path = file.name;
                if (!context)
                    context = process + '/' + file.name;
                snapshot = server.simple_checkin(search_key, context, file_path, {description: description, mode: mode, is_current: is_current, checkin_type: checkin_type});
                spt.notify.show_message("Check-in of ["+ file.name +"] successful", 4000);
            }
            progress.setStyle("display", "");

        }
        catch(e) {
            progress.setStyle("background", "#F00");
            progress.setStyle("display", "none");
            alert(e);
            throw(e);
            
        }

    }

    var upload_progress = function(evt) {

        var percent = Math.round(evt.loaded * 100 / evt.total);
        //spt.app_busy.show("Uploading ["+percent+"%% complete]");
        progress.setStyle("width", percent + "%%");
    }

    var upload_kwargs = {
        upload_complete: upload_complete,
        upload_progress: upload_progress,
        files: files
    }
    spt.html5upload.upload_file(upload_kwargs);

}

var top = bvr.src_el.getParent(".spt_checkin_top");
spt.checkin_list.set_top(top);
spt.checkin_list.select_preselected();


        ''' % {
                'bg_color': bg_color,
                'hilight_color': hilight_color
            }
        })

        top.add_behavior({
            'type':
            'smart_click_up',
            'modkeys':
            'SHIFT',
            'bvr_match_class':
            'spt_dir_list_item',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_checkin_top");

        spt.checkin_list.set_top(top);

        var rows = spt.checkin_list.get_all_rows();

        var last_selected = spt.checkin_list.last_selected;
        var last_index;
        var cur_index;
        for (var i = 0; i < rows.length; i++) {
            if (rows[i] == last_selected) {
                last_index = i;
            }
            if (rows[i] == bvr.src_el) {
                cur_index = i;
            }
        }
        var start_index;
        var end_index;
        if (last_index < cur_index) {
            start_index = last_index + 1;
            end_index = cur_index ;
        }
        else {
            start_index = cur_index;
            end_index = last_index -1 ;
        }

        for (var i = start_index; i < end_index+1; i++) {
            spt.checkin_list.select(rows[i]);
        }

        spt.checkin_list.last_selected = bvr.src_el;
        '''
        })

        # add a top menu
        menu = Menu(width=180)
        self.menu = menu
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)

        #menu_item = MenuItem(type='action', label='Revert to Latest')
        #menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Open File')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            applet.open_file(path);
            '''
        })

        menu_item = MenuItem(type='action', label='Open Containing Folder')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var parts = path.split("/");
            parts.pop()
            path = parts.join("/");
            applet.open_explorer(path);
            '''
        })

        menu_item = MenuItem(type='action', label='Copy File to Sandbox')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var selected_paths = spt.checkin_list.get_selected_paths();
            if (!selected_paths.length) {
                selected_paths = [path];
            }

            var top = activator.getParent(".spt_checkin_top");
            var default_sandbox_dir = top.getAttribute("spt_default_sandbox_dir");

            spt.app_busy.show("Copying files to Sandbox");
            for (var i = 0; i < selected_paths.length; i++) {
                var path = selected_paths[i];
                var parts = path.split("/");
                var filename = parts[parts.length-1];
                applet.copy_file(path, default_sandbox_dir + "/" + filename);
            }
            spt.app_busy.hide();

            spt.notify.show_message("Copied " + selected_paths.length + " files to sandbox");
            '''
        })

        #menu_item = MenuItem(type='action', label='Rename File')
        #menu.add(menu_item)

        # DISABLING until we actually have something that works better
        menu_item = MenuItem(type='action', label='Copy File')
        #menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var applet = spt.Applet.get();

            var parts = path.split("/");
            var basename = parts[parts.length-1];

            // FIXME: new to create new path
            var new_path = path + "_copy";
            var index = 1;
            while(1) {
                if (applet.exists(new_path)) {
                    new_path = path + "_copy" + index;
                    index += 1;
                }
                else {
                    break;
                }

                if (index > 100) {
                    spt.alert("More than 100 copies.  Exiting");
                    break;
                }
            }

            applet.copy_file(path, new_path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        })

        menu_item = MenuItem(type='separator')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Delete File')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var parts = path.split("/");
            var filename = parts[parts.length-1];

            var applet = spt.Applet.get();
            var label = applet.is_dir(path) ? 'directory': 'file';
            if (!confirm("Are you sure you wish to delete the local " + label + " ["+filename+"]?")) {
                return;
            }

            applet.rmtree(path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        })

        menu_item = MenuItem(type='separator')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Properties')
        menu.add(menu_item)

        menu_item.add_behavior({
            'type':
            'click_up',
            'search_key':
            search_key,
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var snapshot_code = activator.getAttribute("spt_snapshot_code");
            var path = activator.getAttribute("spt_path");
            var md5 = activator.getAttribute("spt_md5");

            var applet = spt.Applet.get();
            var cur_md5 = applet.get_md5(path);

            //if (md5 != cur_md5) {
            //    activator.setStyle("background", "#A77");
            //}


            var class_name = 'tactic.ui.checkin.FilePropertiesWdg';
            var kwargs = {
                path: path,
                md5: cur_md5,
                snapshot_code: snapshot_code,
                search_key: bvr.search_key
            };
            spt.panel.load_popup("File Properties", class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='action', label='Check in Preview Image')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'search_key':
            search_key,
            'cbjs_action':
            '''
            var server = TacticServerStub.get();

            var activator = spt.smenu.get_activator(bvr);

            var path = activator.getAttribute("spt_path");
            var tmps = path.split('/');
            var base_name = tmps[1];
            
            //server.simple_checkin( bvr.search_key, context, path);

            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");
            var files = content.files;
            var selected_file;

            //find selected file
            for (var k =0; k < files.length; k++){
                if (files[k].name == base_name) {
                    selected_file = files[k];
                    break;
                }
            }
            
            if (selected_file) {
                var context = "icon";
                spt.checkin.html5_strict_checkin(files, context, "Icon Check-in") 
                spt.panel.refresh(top);
                
            }
            else {
                spt.alert("Cannot determine chosen file. Please drag and drop to try again.");
            }
            '''
        })

        menus_in = {
            'FILE_MENU_CTX': menu,
        }
        SmartMenu.attach_smart_context_menu(top, menus_in, False)

        super(CheckinDirListWdg, self).add_top_behaviors(top)
Пример #46
0
    def handle_is_test(my, content):

        content.add_behavior( {
            'type': 'mouseover',
            'cbjs_action': '''
            bvr.src_el.setStyle("border", "solid 1px blue");
            bvr.src_el.setStyle("margin", "-1px");
            var els = bvr.src_el.getElements(".spt_test");
            for (var i = 0; i < els.length; i++) {
                els[i].setStyle("display", "");
                break;
            }

            '''
        } )


        content.add_behavior( {
            'type': 'mouseleave',
            'cbjs_action': '''

            bvr.src_el.setStyle("border", "none");
            bvr.src_el.setStyle("margin", "0px");
            var els = bvr.src_el.getElements(".spt_test");
            for (var i = 0; i < els.length; i++) {
                els[i].setStyle("display", "none");
                break;
            }
            '''
        } )


        div = DivWdg()
        content.add(div)
        div.add_style("position: absolute")
        div.add(my.view)
        div.add_class("spt_test")
        div.add_border()
        div.set_box_shadow("1px 1px 1px 1px")
        div.add_style("display: none")
        div.add_style("padding: 3px")
        div.add_style("left: 0px")
        div.add_style("top: -15px")
        #div.add_style("opacity: 0.5")
        div.add_style("inherit: false")
        div.add_style("z-index: 1000")
        div.add_style("background-color: white")
        div.add_class("hand")


        div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_custom_top");
            top.setAttribute("spt_is_test", "true");
            var size = top.getSize();
            top.innerHTML = "<div style='width: "+size.x+";height: "+size.y+";padding: 10px; font-weight: bold'>Loading ...</div>";
            spt.panel.refresh(top);
            '''
        } )


        # add in a context menu
        menu = my.get_test_context_menu()
        menus = [menu.get_data()]
        menus_in = {
            'TEST_CTX': menus,
        }
        SmartMenu.attach_smart_context_menu( div, menus_in, False )
        SmartMenu.assign_as_local_activator( div, 'TEST_CTX' )
Пример #47
0
    def get_display(my):

        my.view_editable = True

        if my.kwargs.get("do_search") != "false":
            my.handle_search()

        #my.kwargs['show_gear'] = 'false'


        # set the sobjects to all the widgets then preprocess
        for widget in my.widgets:
            widget.set_sobjects(my.sobjects)
            widget.set_parent_wdg(my)
            # preprocess the elements
            widget.preprocess()


        """
        # TEST code to return only the content
        temp = my.kwargs.get("temp")
        if temp:
            content = DivWdg()
            content.add( my.get_content_wdg() )
            return content
        """





        # extraneous variables inherited from TableLayoutWdg
        my.edit_permission = True

        top = DivWdg()
        my.set_as_panel(top)
        top.add_class("spt_sobject_top")

        inner = DivWdg()
        top.add(inner)
        inner.add_color("background", "background")
        inner.add_color("color", "color")
        inner.add_attr("spt_version", "2")
        inner.add_class("spt_table")
        inner.add_class("spt_layout")


        from tactic.ui.input import Html5UploadWdg
        upload_wdg = Html5UploadWdg()
        inner.add(upload_wdg)
        my.upload_id = upload_wdg.get_upload_id()

        # set up the context menus
        menus_in = {
            'DG_HEADER_CTX': [ my.get_smart_header_context_menu_data() ],
            'DG_DROW_SMENU_CTX': [ my.get_data_row_smart_context_menu_details() ]
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )


        thumb = ThumbWdg()
        thumb.handle_layout_behaviors(inner)

        is_refresh = my.kwargs.get("is_refresh")
        if my.kwargs.get("show_shelf") not in ['false', False]:
            action = my.get_action_wdg()
            inner.add(action)

        content = DivWdg()
        inner.add( content )
        content.add( my.get_content_wdg() )


        # NOTE: a lot of scaffolding to convince that search_cbk that this
        # is a proper layout
        top.add_class("spt_table_top");
        class_name = Common.get_full_class_name(my)
        top.add_attr("spt_class_name", class_name)


        # NOTE: adding a fake header to conform to a table layout.  Not
        # sure if this is the correct interface for this
        header_row_div = DivWdg()
        header_row_div.add_class("spt_table_header_row")
        content.add(header_row_div)
        content.add_class("spt_table_table")
        content.set_id(my.table_id)

        my.handle_load_behaviors(content)


        inner.add_class("spt_table_content");
        inner.add_attr("spt_search_type", my.kwargs.get('search_type'))
        inner.add_attr("spt_view", my.kwargs.get('view'))


        limit_span = DivWdg()
        inner.add(limit_span)
        limit_span.add_style("margin-top: 4px")
        limit_span.add_class("spt_table_search")
        limit_span.add_style("width: 250px")
        limit_span.add_style("margin: 5 auto")

        info = my.search_limit.get_info()
        if info.get("count") == None:
            info["count"] = len(my.sobjects)


        from tactic.ui.app import SearchLimitSimpleWdg
        limit_wdg = SearchLimitSimpleWdg(
            count=info.get("count"),
            search_limit=info.get("search_limit"),
            current_offset=info.get("current_offset"),
        )
        inner.add(limit_wdg)


        my.add_layout_behaviors(inner)

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Пример #48
0
    def get_container(my, xml):
        # handle the container

        element_node = xml.get_node("config/tmp/element")
        attrs = Xml.get_attributes(element_node)
        element_name = attrs.get("name")

        show_resize_scroll = attrs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = my.kwargs.get("show_resize_scroll")
        if not show_resize_scroll:
            show_resize_scroll = "false"


        # look for attributes in the element tag for specifying a title action button to plug
        # into the title bar of the custom section ...
        #
        title_action_icon = attrs.get("title_action_icon")
        title_action_script = attrs.get("title_action_script")
        title_action_label = attrs.get("title_action_label")
        if title_action_script and not title_action_label:
            title_action_label = '[action]'


        # get the width and height for the element content ...
        width = attrs.get("width")
        height = attrs.get("height")


        if width and height:
            container = ContainerWdg( inner_width=width, inner_height=height, show_resize_scroll=show_resize_scroll )
        else:
            container = ContainerWdg(show_resize_scroll=show_resize_scroll)

        # create the title
        title = attrs.get("title")
        if not title:
            title = Common.get_display_title(element_name)
        title_wdg = DivWdg()
        SmartMenu.assign_as_local_activator( title_wdg, 'HEADER_CTX' )
        title_wdg.add_style("margin: 0px 0px 5px 0px")
        title_wdg.add_gradient("background", "background", 0)
        title_wdg.add_color("color", "color")
        title_wdg.add_style("padding", "5px")


        if title_action_script:
            # add an action button if an action script code was found in the attributes of the element
            proj = Project.get_project_code()
            script_search = Search("config/custom_script")
            script_sobj = script_search.get_by_search_key( "config/custom_script?project=%s&code=%s" %
                                                           (proj, title_action_script) )
            script = script_sobj.get_value('script')
            icon_str = "HELP"
            if title_action_icon:
                icon_str = title_action_icon
            action_btn = HtmlElement.img( IconWdg.get_icon_path(icon_str) )
            action_btn.set_attr('title',title_action_label)
            # action_btn = IconWdg( title_action_label, icon=icon)
            action_btn.add_behavior( {'type': 'click_up', 'cbjs_action':  script } )
            action_btn.add_styles( "cursor: pointer; float: right;" )

            title_wdg.add( action_btn )


        title_wdg.add(title)
        container.add(title_wdg)

        return container
Пример #49
0
    def handle_is_test(my, content):

        content.add_behavior( {
            'type': 'mouseover',
            'cbjs_action': '''
            bvr.src_el.setStyle("border", "solid 1px blue");
            bvr.src_el.setStyle("margin", "-1px");
            var els = bvr.src_el.getElements(".spt_test");
            for (var i = 0; i < els.length; i++) {
                els[i].setStyle("display", "");
                break;
            }

            '''
        } )


        content.add_behavior( {
            'type': 'mouseleave',
            'cbjs_action': '''

            bvr.src_el.setStyle("border", "none");
            bvr.src_el.setStyle("margin", "0px");
            var els = bvr.src_el.getElements(".spt_test");
            for (var i = 0; i < els.length; i++) {
                els[i].setStyle("display", "none");
                break;
            }
            '''
        } )


        div = DivWdg()
        content.add(div)
        div.add_style("position: absolute")
        div.add(my.view)
        div.add_class("spt_test")
        div.add_border()
        div.set_box_shadow("1px 1px 1px 1px")
        div.add_style("display: none")
        div.add_style("padding: 3px")
        div.add_style("left: 0px")
        div.add_style("top: -15px")
        #div.add_style("opacity: 0.5")
        div.add_style("inherit: false")
        div.add_style("z-index: 1000")
        div.add_style("background-color: white")
        div.add_class("hand")


        div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_custom_top");
            top.setAttribute("spt_is_test", "true");
            var size = top.getSize();
            top.innerHTML = "<div style='width: "+size.x+";height: "+size.y+";padding: 10px; font-weight: bold'>Loading ...</div>";
            spt.panel.refresh(top);
            '''
        } )


        # add in a context menu
        menu = my.get_test_context_menu()
        menus = [menu.get_data()]
        menus_in = {
            'TEST_CTX': menus,
        }
        SmartMenu.attach_smart_context_menu( div, menus_in, False )
        SmartMenu.assign_as_local_activator( div, 'TEST_CTX' )
Пример #50
0
    def add_top_behaviors(my, top):

        # convert this to a repo directory
        asset_dir = Environment.get_asset_dir()

        # FIXME: not sure how general this
        #webdirname = "/assets/%s" % dirname.replace(asset_dir, "")

        web = WebContainer.get_web()
        browser = web.get_browser()


        if browser == 'Qt':
            top.add_relay_behavior( {
            'type': 'dblclick',
            'bvr_match_class': 'spt_dir_list_item',
            'cbjs_action': '''
            var path = bvr.src_el.getAttribute("spt_path");
            var asset_dir = '%s';
            var url = "/assets/" + path.replace(asset_dir, "");
            //window.open(url);

            var url_parts = url.split("/");
            var file = url_parts.pop();
            file = encodeURIComponent(file);
            url_parts.push(file);
            url = url_parts.join("/");

            var class_name = 'tactic.ui.widget.EmbedWdg';
            var kwargs = {
                src: url
            }

            var parts = path.split("/");
            var filename = parts[parts.length-1];
            spt.tab.set_main_body_tab()
            spt.tab.add_new(filename, filename, class_name, kwargs);
            ''' % asset_dir
            } )
        else:
            top.add_relay_behavior( {
            'type': 'dblclick',
            'bvr_match_class': 'spt_dir_list_item',
            'cbjs_action': '''
            var path = bvr.src_el.getAttribute("spt_path");
            
            if (path.indexOf('####') != -1) {
                spt.info('Cannot open the file sequence');
            } 
            else {
            var asset_dir = '%s';
            var url = "/assets/" + path.replace(asset_dir, "");

            var url_parts = url.split("/");
            var filename = url_parts.pop();
            filename = encodeURIComponent(filename);
            url_parts.push(filename);
            url = url_parts.join("/");

            window.open(url);
            }
            ''' % asset_dir
            } )

        # add a top menu
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Download to Folder')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var applet = spt.Applet.get();
            var select_dir = true;
            var dir = applet.open_file_browser('', select_dir);
            if (!dir) {
                dir = applet.get_current_dir();
            }
            if (!dir) {
                spt.alert("No folder selected to copy to");
                return;
            }
            
            var path = activator.getAttribute("spt_path");

            var asset_dir = '%s';
            var env = spt.Environment.get();
            var server_url = env.get_server_url();
            var url = server_url + "/assets/" + path.replace(asset_dir, "");
            var parts = path.split("/");
            var filename = parts[parts.length-1];
            spt.app_busy.show("Downloading file", filename);
            applet.download_file(url, dir + "/" + filename);
            spt.app_busy.hide();
            if (dir)
                spt.notify.show_message("Download to '" + dir + "' completed.")
            ''' % asset_dir
        } )
        #menu_item = MenuItem(type='action', label='Check-out To Sandbox')
        #menu.add(menu_item)
        #menu_item.add_behavior( {
        #'type': 'click_up',
        #'cbjs_action': '''spt.alert('Not implemented yet.')'''
        #} )
        menu_item = MenuItem(type='action', label='Copy to Clipboard')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var activator = spt.smenu.get_activator(bvr);
        var path = activator.getAttribute("spt_path");

        var search_key = activator.getAttribute("spt_file_search_key");

        var server = TacticServerStub.get();
        var class_name = 'tactic.command.clipboard_cmd.ClipboardCopyCmd';
        var search_keys = [search_key];
        var kwargs = {
            search_keys: search_keys
        }
        try {
            spt.app_busy.show("Copy to Clipboard ...");
            server.execute_cmd(class_name, kwargs);
            spt.app_busy.hide();
            }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }
        '''
        } )


        menu_item = MenuItem(type='action', label='View Metadata')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var activator = spt.smenu.get_activator(bvr);
        var path = activator.getAttribute("spt_path");

        var search_key = activator.getAttribute("spt_file_search_key");

        var server = TacticServerStub.get();
        var class_name = 'tactic.ui.checkin.SnapshotMetadataWdg';
        var kwargs = {
            search_key: search_key
        }
        spt.panel.load_popup("Metadata", class_name, kwargs);
        '''
        } )



        menus_in = {
            'FILE_MENU_CTX': menu,
        }
        SmartMenu.attach_smart_context_menu( top, menus_in, False )


        my.add_selection(top)
 
        super(SnapshotDirListWdg, my).add_top_behaviors(top)
Пример #51
0
    def add_base_dir_behaviors(my, div, base_dir):

        # add tooltip
        div.add_attr('title','This is the sandbox folder. Double-click to open and right-click for more options.')
        # add a top menu
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Explore sandbox folder')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'base_dir': base_dir,
            'cbjs_action': '''
            var applet = spt.Applet.get();
            var activator = spt.smenu.get_activator(bvr);
            var path = bvr.base_dir;
            applet.open_file(path);
            '''
        } )


        menu_item = MenuItem(type='action', label='Browse for sandbox folder')
        menu.add(menu_item)
        # FIXME: this code is identical to the one in checkin_wdg.py
        menu_item.add_behavior( {
        'type': 'click_up',
        'base_dir': base_dir,
        'cbjs_action': '''
            var current_dir = bvr.base_dir;
            var applet = spt.Applet.get();
            var file_paths = applet.open_file_browser(current_dir);

            // take the first one make sure it is a directory
            var dir = file_paths[0];
            if (!applet.is_dir(dir)) {
                spt.alert("Please Select a Folder");
                return;
            }
            dir = dir.replace(/\\\\/g, "/");

            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_checkin_top");
            top.setAttribute("spt_sandbox_dir", dir);
            spt.panel.refresh(top);

        '''
        } )


        menu_item = MenuItem(type='action', label='Download from clipboard')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'base_dir': base_dir,
        'cbjs_action': '''
        var current_dir = bvr.base_dir;
        var server = TacticServerStub.get();
        var base = spt.Environment.get().get_server_url();
        var user = spt.Environment.get().get_user();

        var expr = "@SOBJECT(sthpw/clipboard['login','"+user+"'].sthpw/file)";
        var items = server.eval(expr);

        var applet = spt.Applet.get();

        var urls = [];
        for (var i = 0; i < items.length; i++) {
            var url = base + "/assets/" + items[i].relative_dir + "/" + items[i].file_name;
            var file_name = items[i].file_name;
            applet.download_file(url, current_dir + "/" + file_name);
        }

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        } )

        menus_in = {
            'SANDBOX_MENU_CTX': menu,
        }
        SmartMenu.attach_smart_context_menu( div, menus_in, False )
        SmartMenu.assign_as_local_activator( div, 'SANDBOX_MENU_CTX' )


        super(CheckinDirListWdg, my).add_base_dir_behaviors(div,base_dir)
    def get_example_display(my):

        div = DivWdg()

        # Smart Menu data ...
        dog_menus = [
            my.get_sm_dog_main_menu_details(),
            my.get_sm_dog_submenu_one_details(),
            my.get_sm_dog_submenu_two_details()
        ]

        cat_menus = [my.get_sm_cat_main_menu_details()]

        SmartMenu.attach_smart_context_menu(div, {
            'DOG': dog_menus,
            'CAT': cat_menus
        }, False)

        table = Table(css="maq_view_table")
        table.set_id("main_body_table")
        table.add_class("spt_table")

        table.add_behavior({
            "type":
            "smart_drag",
            "bvr_match_class":
            "SPT_DO_RESIZE",
            "cbjs_setup":
            'spt.dg_table.resize_column_setup( evt, bvr, mouse_411 );',
            "cbjs_motion":
            'spt.dg_table.resize_column_motion( evt, bvr, mouse_411 );'
        })

        table.add_behavior({
            "type":
            "smart_drag",
            "bvr_match_class":
            "SPT_DO_DRAG",
            "use_copy":
            'true',
            "use_delta":
            'true',
            'dx':
            10,
            'dy':
            10,
            "drop_code":
            'TableExampleSwitchContents',
            "cbjs_action":
            "spt.ui_play.drag_cell_drop_action( evt, bvr );",
            "copy_styles":
            'background: blue; opacity: .5; border: 1px solid black; text-align: left;'
        })

        row = table.add_row()
        for c in range(10):
            th = table.add_header()
            th.set_attr('col_idx', str(c))
            th.add_class("cell_left")
            th.add_styles("width: 150px; cursor: default;")

            # @@@
            th.add_behavior({
                "type":
                "move",
                "cbjs_action":
                '''
                    // log.debug( "(x,y) = (" + mouse_411.curr_x + "," + mouse_411.curr_y + ")" );
                    spt.ui_play.header_half_move_cbk( evt, bvr, mouse_411 );
                ''',
                "cbjs_action_on":
                '''
                    // log.debug( "START MY MOVE!" );
                ''',
                "cbjs_action_off":
                '''
                    // log.debug( "DONE MY MOVE!" );
                    spt.ui_play.header_half_move_off_cbk( evt, bvr, mouse_411 );
                '''
            })

            if (c % 2):
                th.add("H%s (Cat)" % c)
            else:
                th.add("H%s (Dog)" % c)
            th_resize = table.add_cell()
            th_resize.set_attr('col_idx', str(c + 1))
            th_resize.add_class("SPT_DO_RESIZE cell_right")
            th_resize.add_styles("width: 4px; cursor: col-resize;")

        for r in range(19):
            row = table.add_row()
            for c in range(10):
                col = table.add_cell()
                col.set_attr('col_idx', str(c))
                col.set_attr('SPT_ACCEPT_DROP', 'TableExampleSwitchContents')
                col.add_class("SPT_DO_DRAG cell_left")
                col.add_styles("cursor: pointer;")
                col.add("(%s,%s)" % (r, c))
                if (c % 2) == 0:
                    SmartMenu.assign_as_local_activator(col, "DOG")
                else:
                    SmartMenu.assign_as_local_activator(col, "CAT")
                resize = table.add_cell()
                resize.set_attr('col_idx', str(c + 1))
                resize.add_class("SPT_DO_RESIZE cell_right")
                resize.add_styles("width: 6px; cursor: col-resize;")

        div.add(table)
        return div
Пример #53
0
    def add_top_behaviors(my, top):
        if my.sobject:
            search_key = my.sobject.get_search_key()
        else:
            search_key = None

        bg_color = top.get_color("background")
        hilight_color =  top.get_color("background", -20)

        top.add_behavior( {
        'type': 'smart_click_up',
        'bvr_match_class': 'spt_dir_list_item',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.checkin_list.set_top(top);

        spt.checkin_list.unselect_all_rows();
        spt.checkin_list.select(bvr.src_el);

        var applet = spt.Applet.get();

        var path = bvr.src_el.getAttribute("spt_path");
        var checkin_type = top.getElement(".spt_checkin_type");
        if (applet.is_dir(path)) {
            checkin_type.value = "dir_checkin";
        }
        else {
            checkin_type.value = "file_checkin";
        }

        ''' %{'bg_color': bg_color, 'hilight_color': hilight_color}
        } )


        top.add_behavior( {
        'type': 'smart_click_up',
        'bvr_match_class': 'spt_dir_list_item',
        'modkeys': 'CTRL',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.checkin_list.set_top(top);

        //spt.checkin_list.unselect_all_rows();
        spt.checkin_list.select(bvr.src_el);

        var applet = spt.Applet.get();

        var path = bvr.src_el.getAttribute("spt_path");
        var checkin_type = top.getElement(".spt_checkin_type");
        if (applet.is_dir(path)) {
            checkin_type.value = "dir_checkin";
        }
        else {
            checkin_type.value = "file_checkin";
        }

        ''' %{'bg_color': bg_color, 'hilight_color': hilight_color}
        } )



        top.add_behavior( {
        'type': 'load',
        'cbjs_action': '''

//for shift click feature
spt.checkin_list = {};
spt.checkin_list.top = null;
spt.checkin_list.last_selected = null;
spt.checkin_list.single_select = false;

spt.checkin_list.set_top = function(top) {
    spt.checkin_list.top = top;
}



spt.checkin_list.get_selected_paths = function() {
    // find the subcontext widget
    var rows = spt.checkin_list.get_all_rows();

    var paths = [];
    for (var i = 0; i < rows.length; i++) {
        var row = rows[i];
        if (row.is_selected == true) {
            var path = row.getAttribute("spt_path");
            paths.push(path);
        }
    }
    return paths;
} 


spt.checkin_list.get_all_rows = function() {
    var rows = spt.checkin_list.top.getElements(".spt_dir_list_item");
    return rows;
}

spt.checkin_list.unselect_all_rows = function() {

    var rows = spt.checkin_list.get_all_rows();
    for (var i = 0; i < rows.length; i++) {
        spt.checkin_list.unselect(rows[i]);
    }

}


spt.checkin_list.unselect = function(row) {
    var subcontext_el = row.getElement(".spt_subcontext");
    var context_el = row.getElement(".spt_context")
    row.is_selected = false;
    row.setStyle("background", '%(bg_color)s');
    row.setAttribute("spt_background", '%(bg_color)s');
    if (subcontext_el)
        subcontext_el.setStyle("display", "none");
    else if (context_el)
        context_el.setStyle("display", "none");

    spt.checkin_list.last_selected = null;

    spt.checkin_list.disable_checkin();
}



spt.checkin_list.select = function(row) {
    // find the subcontext widget
    var subcontext_el = row.getElement(".spt_subcontext")
    var context_el = row.getElement(".spt_context")

    if (row.is_selected == true) {
        row.is_selected = false;
        row.setStyle("background", '%(bg_color)s');
        row.setAttribute("spt_background", '%(bg_color)s');
        if (subcontext_el)
            subcontext_el.setStyle("display", "none");
        else if (context_el)
            context_el.setStyle("display", "none");

        spt.checkin_list.last_selected = null;

    }
    else {
        row.is_selected = true;
        row.setStyle("background", '%(hilight_color)s');
        row.setAttribute("spt_background", '%(hilight_color)s');
        if (subcontext_el)
            subcontext_el.setStyle("display", "");
		else if (context_el)
            context_el.setStyle("display", "");
        
        spt.checkin_list.last_selected = row;
    }
    var top = spt.checkin_list.top; 
    var paths = [];
    var els = top.getElements(".spt_dir_list_item");
    for (var i = 0; i < els.length; i++) {
        if (els[i].is_selected) {
            paths.push( els[i].getAttribute("spt_path") );
        }
    }

    var grey_el = top.getElement(".spt_publish_disable");
    if (paths.length == 0) {
        grey_el.setStyle("display", "");
        return;
    }

    grey_el.setStyle("display", "none");
}


spt.checkin_list.enable_checkin = function() {
    var top = spt.checkin_list.top; 
    var grey_el = top.getElement(".spt_publish_disable");
    grey_el.setStyle("display", "none");
} 


spt.checkin_list.disable_checkin = function() {
    var top = spt.checkin_list.top; 
    var grey_el = top.getElement(".spt_publish_disable");
    grey_el.setStyle("display", "");
} 





spt.checkin_list.select_preselected = function(){
    var top = spt.checkin_list.top; 
    var el = top.getElement(".spt_file_selector");
    if (el == null) {
        return;
    }

    var rows = spt.checkin_list.get_all_rows()
    //var cbs = top.getElements(".spt_dir_list_item");
    var paths = [];
    for (var k=0; k<rows.length; k++){
        var row = rows[k];
        if (spt.has_class(row, 'spt_preselected')) {
            var path = row.getAttribute("spt_path");
            paths.push(path); 
            spt.checkin_list.select(row);
        }
    }
    // reassign the new paths selection
    el.file_paths = paths;
}


var top = bvr.src_el.getParent(".spt_checkin_top");
spt.checkin_list.set_top(top);
spt.checkin_list.select_preselected();


        ''' %{'bg_color': bg_color, 'hilight_color': hilight_color}
        } )
 

        top.add_behavior( {
        'type': 'smart_click_up',
        'modkeys': 'SHIFT',
        'bvr_match_class': 'spt_dir_list_item',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");

        spt.checkin_list.set_top(top);

        var rows = spt.checkin_list.get_all_rows();

        var last_selected = spt.checkin_list.last_selected;
        var last_index;
        var cur_index;
        for (var i = 0; i < rows.length; i++) {
            if (rows[i] == last_selected) {
                last_index = i;
            }
            if (rows[i] == bvr.src_el) {
                cur_index = i;
            }
        }
        var start_index;
        var end_index;
        if (last_index < cur_index) {
            start_index = last_index + 1;
            end_index = cur_index ;
        }
        else {
            start_index = cur_index;
            end_index = last_index -1 ;
        }

        for (var i = start_index; i < end_index+1; i++) {
            spt.checkin_list.select(rows[i]);
        }

        spt.checkin_list.last_selected = bvr.src_el;
        '''
        } )




        # add a top menu
        menu = Menu(width=180)
        my.menu = menu
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)


        #menu_item = MenuItem(type='action', label='Revert to Latest')
        #menu.add(menu_item)




        menu_item = MenuItem(type='action', label='Open File')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            applet.open_file(path);
            '''
        } )



        menu_item = MenuItem(type='action', label='Open Containing Folder')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var parts = path.split("/");
            parts.pop()
            path = parts.join("/");
            applet.open_explorer(path);
            '''
        } )



        menu_item = MenuItem(type='action', label='Copy File to Sandbox')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var applet = spt.Applet.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var selected_paths = spt.checkin_list.get_selected_paths();
            if (!selected_paths.length) {
                selected_paths = [path];
            }

            var top = activator.getParent(".spt_checkin_top");
            var default_sandbox_dir = top.getAttribute("spt_default_sandbox_dir");

            spt.app_busy.show("Copying files to Sandbox");
            for (var i = 0; i < selected_paths.length; i++) {
                var path = selected_paths[i];
                var parts = path.split("/");
                var filename = parts[parts.length-1];
                applet.copy_file(path, default_sandbox_dir + "/" + filename);
            }
            spt.app_busy.hide();

            spt.notify.show_message("Copied " + selected_paths.length + " files to sandbox");
            '''
        } )


 


        #menu_item = MenuItem(type='action', label='Rename File')
        #menu.add(menu_item)

        # DISABLING until we actually have something that works better
        menu_item = MenuItem(type='action', label='Copy File')
        #menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var applet = spt.Applet.get();

            var parts = path.split("/");
            var basename = parts[parts.length-1];

            // FIXME: new to create new path
            var new_path = path + "_copy";
            var index = 1;
            while(1) {
                if (applet.exists(new_path)) {
                    new_path = path + "_copy" + index;
                    index += 1;
                }
                else {
                    break;
                }

                if (index > 100) {
                    spt.alert("More than 100 copies.  Exiting");
                    break;
                }
            }

            applet.copy_file(path, new_path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        } )



        menu_item = MenuItem(type='separator')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Delete File')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");
            var parts = path.split("/");
            var filename = parts[parts.length-1];

            var applet = spt.Applet.get();
            var label = applet.is_dir(path) ? 'directory': 'file';
            if (!confirm("Are you sure you wish to delete the local " + label + " ["+filename+"]?")) {
                return;
            }

            applet.rmtree(path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        } )


        menu_item = MenuItem(type='separator')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Properties')
        menu.add(menu_item)

        menu_item.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var snapshot_code = activator.getAttribute("spt_snapshot_code");
            var path = activator.getAttribute("spt_path");
            var md5 = activator.getAttribute("spt_md5");

            var applet = spt.Applet.get();
            var cur_md5 = applet.get_md5(path);

            //if (md5 != cur_md5) {
            //    activator.setStyle("background", "#A77");
            //}


            var class_name = 'tactic.ui.checkin.FilePropertiesWdg';
            var kwargs = {
                path: path,
                md5: cur_md5,
                snapshot_code: snapshot_code,
                search_key: bvr.search_key
            };
            spt.panel.load_popup("File Properties", class_name, kwargs);
            '''
        } )


        menu_item = MenuItem(type='action', label='Use as Preview Image')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'cbjs_action': '''
            var server = TacticServerStub.get();

            var activator = spt.smenu.get_activator(bvr);
            var path = activator.getAttribute("spt_path");

            var context = "icon";
            server.simple_checkin( bvr.search_key, context, path);

            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);
            '''
        } )

        menus_in = {
            'FILE_MENU_CTX': menu,
        }
        SmartMenu.attach_smart_context_menu( top, menus_in, False )
 
        super(CheckinDirListWdg, my).add_top_behaviors(top)
Пример #54
0
    def add_base_dir_behaviors(self, div, base_dir):

        # add tooltip
        if self.use_applet:
            div.add_attr(
                'title',
                'This is the sandbox folder. Double-click to open and right-click for more options.'
            )
        # add a top menu
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Explore sandbox folder')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'base_dir':
            base_dir,
            'cbjs_action':
            '''
            var applet = spt.Applet.get();
            var activator = spt.smenu.get_activator(bvr);
            var path = bvr.base_dir;
            if (applet)
                applet.open_file(path);
            '''
        })

        menu_item = MenuItem(type='action', label='Browse for sandbox folder')
        menu.add(menu_item)
        # FIXME: this code is identical to the one in checkin_wdg.py
        menu_item.add_behavior({
            'type':
            'click_up',
            'base_dir':
            base_dir,
            'cbjs_action':
            '''
            var current_dir = bvr.base_dir;
            var applet = spt.Applet.get();
            if (!applet) return;

            var file_paths = applet.open_file_browser(current_dir);

            // take the first one make sure it is a directory
            var dir = file_paths[0];
            if (!applet.is_dir(dir)) {
                spt.alert("Please Select a Folder");
                return;
            }
            dir = dir.replace(/\\\\/g, "/");

            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_checkin_top");
            top.setAttribute("spt_sandbox_dir", dir);
            spt.panel.refresh(top);

        '''
        })

        menu_item = MenuItem(type='action', label='Download from clipboard')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'base_dir':
            base_dir,
            'cbjs_action':
            '''
        var current_dir = bvr.base_dir;
        var server = TacticServerStub.get();
        var base = spt.Environment.get().get_server_url();
        var user = spt.Environment.get().get_user();

        var expr = "@SOBJECT(sthpw/clipboard['login','"+user+"'].sthpw/file)";
        var items = server.eval(expr);

        var applet = spt.Applet.get();
        if (!applet) return;

        var urls = [];
        for (var i = 0; i < items.length; i++) {
            var url = base + "/assets/" + items[i].relative_dir + "/" + items[i].file_name;
            var file_name = items[i].file_name;
            applet.download_file(url, current_dir + "/" + file_name);
        }

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        })

        menus_in = {
            'SANDBOX_MENU_CTX': menu,
        }
        SmartMenu.attach_smart_context_menu(div, menus_in, False)
        SmartMenu.assign_as_local_activator(div, 'SANDBOX_MENU_CTX')

        super(CheckinDirListWdg, self).add_base_dir_behaviors(div, base_dir)
Пример #55
0
    def get_display(my):

        search_type_obj = SearchType.get(my.search_type)
        sobj_title = search_type_obj.get_title()

        my.color_mode = my.kwargs.get("color_mode")
        if not my.color_mode:
            my.color_mode = "default"


        top_div = my.top
        top_div.add_class("spt_edit_top")

        if not my.is_refresh:
            my.set_as_panel(top_div)
        content_div = DivWdg()
        content_div.add_class("spt_edit_top")
        content_div.add_class("spt_edit_form_top")
        content_div.set_attr("spt_search_key", my.search_key)

        if not Container.get_dict("JSLibraries", "spt_edit"):
            content_div.add_behavior( {
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            } )



        layout_view = my.kwargs.get("layout_view")
        if layout_view:
            layout_wdg = my.get_custom_layout_wdg(layout_view)
            content_div.add(layout_wdg)

            return content_div



        # add close listener
        # NOTE: this is an absolute search, but is here for backwards
        # compatibility
        content_div.add_named_listener('close_EditWdg', '''
            var popup = bvr.src_el.getParent( ".spt_popup" );
            if (popup)
                spt.popup.close(popup);
        ''')


        attrs = my.config.get_view_attributes()
        default_access = attrs.get("access")

        if not default_access:
            default_access = "edit"

        project_code = Project.get_project_code()

        security = Environment.get_security()
        base_key =  search_type_obj.get_base_key()
        key = {
            'search_type': base_key,
            'project': project_code
        }
        access = security.check_access("sobject", key, "edit", default=default_access)
        if not access:
            my.is_disabled = True
        else:
            my.is_disabled = False

        disable_wdg = None
        if my.is_disabled:
            # TODO: This overlay doesn't work in IE, size, position, 
            # and transparency all fail. 
            disable_wdg = DivWdg(id='edit_wdg')
            disable_wdg.add_style("position: absolute")
            disable_wdg.add_style("height: 90%")
            disable_wdg.add_style("width: 100%")
            disable_wdg.add_style("left: 0px")
            #disable_wdg.add_style("bottom: 0px")
            #disable_wdg.add_style("top: 0px")

            disable_wdg.add_style("opacity: 0.2")
            disable_wdg.add_style("background: #fff")
            #disable_wdg.add_style("-moz-opacity: 0.2")
            disable_wdg.add_style("filter: Alpha(opacity=20)")
            disable_wdg.add("<center>EDIT DISABLED</center>")
            content_div.add(disable_wdg)


        attrs = my.config.get_view_attributes()

        inner = DivWdg()
        content_div.add(inner)
        menu = my.get_header_context_menu()
        menus = [menu.get_data()]
        menus_in = {
            'HEADER_CTX': menus,
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )






        table = Table()
        inner.add(table)
        if my.color_mode == "default":
            table.add_color("background", "background")
        elif my.color_mode == "transparent":
            table.add_style("background", "transparent")
        table.add_color("color", "color")



        width = attrs.get('width')
        if not width:
            width = my.kwargs.get("width")
        if not width:
            width = 600
        table.add_style("width: %s" % width)

        height = attrs.get('height')
        if height:
            table.add_style("height: %s" % height)

        
        tr = table.add_row()


        show_header = my.kwargs.get("show_header")
        if show_header not in ['false', False]:
            my.add_header(table, sobj_title)

        single = my.kwargs.get("single")
        if single in ['false', False] and my.mode == 'insert':
            multi_div = DivWdg()
            multi_div.add_style("text-align: left")

            multi_div.add("Specify the number of items that will be added with this form:<br/><br/>")


            multi_div.add("<b># of new items to add: </b>")
            multi_div.add("&nbsp;"*4)


            multi_text = TextWdg("multiplier")
            multi_text.add_style("width: 30px")
            multi_div.add(multi_text)

            tr, td = table.add_row_cell( multi_div )

            if my.color_mode == "default":
                td.add_color("border-color", "table_border", default="border")
                td.add_style("border-width: 1px")
                td.add_style("border-style: solid")

            td.add_style("padding: 8 3 8 3")
            td.add_color("background", "background3")
            td.add_color("color", "color3")
        
        security = Environment.get_security()

        # break the widgets up in columns
        num_columns = attrs.get('num_columns')
        if not num_columns:
            num_columns = my.kwargs.get('num_columns')

        if not num_columns:
            num_columns = 1
        else:
            num_columns = int(num_columns)

        # go through each widget and draw it
        for i, widget in enumerate(my.widgets):

            # since a widget name called code doesn't necessariy write to code column, it is commented out for now
            """
            key = { 'search_type' : search_type_obj.get_base_key(),
                'column' : widget.get_name(),
                'project': project_code}
            # check security on widget
            if not security.check_access( "sobject_column",\
                key, "edit"):
                my.skipped_element_names.append(widget.get_name())
                continue
            """

            if not hasattr(widget, 'set_input_prefix'): 
                msg = DivWdg("Warning: The widget definition for [%s] uses [%s] and is not meant for use in Edit Layout. Please revise the edit_definition in widget config."% (widget.get_name(), widget.__class__.__name__ ))
                msg.add_style('color: orange')
                content_div.add(msg)
                content_div.add(HtmlElement.br())
                continue
            if my.input_prefix:
                widget.set_input_prefix(my.input_prefix)

            # Bootstrap
            widget.add_class("form-control")
            widget.add_style("width: 100%")


            class EditTitleWdg(BaseRefreshWdg):
                pass

            #if isinstance(widget, EditTitleWdg):
            """
            has_title = True
            if has_title and i % 3 == 0:
                tr, td = table.add_row_cell()
                tr.add_color("background", "background", -5)
                td.add("TITLE")
                td.add_style("height", "30px")
                td.add_style("padding", "0px 10px")
            """


           
            if isinstance(widget, HiddenWdg):
                content_div.add(widget)
                continue


            # Set up any validations configured on the widget ...
            from tactic.ui.app import ValidationUtil
            v_util = ValidationUtil( widget=widget )
            v_bvr = v_util.get_validation_bvr()
            if v_bvr:
                if (isinstance(widget, CalendarInputWdg)):
                    widget.set_validation( v_bvr.get('cbjs_validation'), v_bvr.get('validation_warning') );
                else:
                    widget.add_behavior( v_bvr )
                    widget.add_behavior( v_util.get_input_onchange_bvr() )
                  


            new_row = i % num_columns == 0
            if new_row:
                tr = table.add_row()


                if my.color_mode == "default":
                    if i % 2 == 0:
                        tr.add_color("background", "background")
                    else:
                        tr.add_color("background", "background", -2 )



           
            show_title = widget.get_option("show_title")
            if not show_title:
                show_title = my.kwargs.get("show_title")

            if show_title in ['false', False]:
                show_title = False
            else:
                show_title = True



            if show_title:
                title = widget.get_title()

                td = table.add_cell(title)
                td.add_style("padding: 10px 15px 10px 5px")
                td.add_style("vertical-align: top")

 
                title_width = my.kwargs.get("title_width")
                if title_width:
                    td.add_style("width: %s" % title_width)
                else:
                    td.add_style("width: 150px")

                security = Environment.get_security()
                if security.check_access("builtin", "view_site_admin", "allow"):
                    SmartMenu.assign_as_local_activator( td, 'HEADER_CTX' )

                if my.color_mode == "default":
                    td.add_color("border-color", "table_border", default="border")
                    td.add_style("border-width: 1" )
                    td.add_style("border-style: solid" )

                td.add_style("text-align: right" )

                hint = widget.get_option("hint")
                if hint:
                    #hint_wdg = HintWdg(hint)
                    #hint_wdg.add_style("float: right")
                    #td.add( hint_wdg )
                    td.add_attr("title", hint)


            if not show_title:
                th, td = table.add_row_cell( widget )
                continue
            else:
                td = table.add_cell( widget )
                #td = table.add_cell( widget.get_value() )
                td.add_style("min-width: 300px")
                td.add_style("padding: 10px 15px 10px 5px")
                td.add_style("vertical-align: top")

                if my.color_mode == "default":
                    td.add_color("border-color", "table_border", default="border")
                    td.add_style("border-width: 1" )
                    td.add_style("border-style: solid" )



        if not my.is_disabled and not my.mode == 'view':
            tr, td = table.add_row_cell( my.get_action_html() )
        
        if my.input_prefix:
            prefix = HiddenWdg("input_prefix", my.input_prefix)
            tr, td = table.add_row_cell()
            td.add(prefix)

        top_div.add(content_div) 
        return top_div