当前位置: 首页>>代码示例>>Python>>正文


Python SmartMenu.attach_smart_context_menu方法代码示例

本文整理汇总了Python中tactic.ui.container.SmartMenu.attach_smart_context_menu方法的典型用法代码示例。如果您正苦于以下问题:Python SmartMenu.attach_smart_context_menu方法的具体用法?Python SmartMenu.attach_smart_context_menu怎么用?Python SmartMenu.attach_smart_context_menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tactic.ui.container.SmartMenu的用法示例。


在下文中一共展示了SmartMenu.attach_smart_context_menu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_content_wdg

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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
开发者ID:mincau,项目名称:TACTIC,代码行数:30,代码来源:tool_layout_wdg.py

示例2: get_content_wdg

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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
开发者ID:hellios78,项目名称:TACTIC,代码行数:19,代码来源:tool_layout_wdg.py

示例3: get_content_wdg

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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
开发者ID:blezek,项目名称:TACTIC,代码行数:45,代码来源:tile_layout_wdg.py

示例4: add_top_behaviors

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]

#.........这里部分代码省略.........
        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)
开发者ID:asmboom,项目名称:TACTIC,代码行数:104,代码来源:snapshot_files_wdg.py

示例5: get_display

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]

#.........这里部分代码省略.........
            '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) {
开发者ID:mincau,项目名称:TACTIC,代码行数:70,代码来源:doc_tool_wdg.py

示例6: handle_is_test

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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' )
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:72,代码来源:custom_layout_wdg.py

示例7: get_display

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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 )



#.........这里部分代码省略.........
开发者ID:funic,项目名称:TACTIC,代码行数:103,代码来源:edit_wdg.py

示例8: add_top_behaviors

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]

#.........这里部分代码省略.........
                    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)
开发者ID:lucasnemeth,项目名称:TACTIC,代码行数:104,代码来源:checkin_dir_list_wdg.py

示例9: add_base_dir_behaviors

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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)
开发者ID:lucasnemeth,项目名称:TACTIC,代码行数:90,代码来源:checkin_dir_list_wdg.py

示例10: get_display

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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")
#.........这里部分代码省略.........
开发者ID:funic,项目名称:TACTIC,代码行数:103,代码来源:tool_layout_wdg.py

示例11: get_example_display

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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
开发者ID:0-T-0,项目名称:TACTIC,代码行数:89,代码来源:efficient_table_example_wdg.py

示例12: get_content_wdg

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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();
#.........这里部分代码省略.........
开发者ID:funic,项目名称:TACTIC,代码行数:103,代码来源:tile_layout_wdg.py

示例13: get_example_display

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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
开发者ID:mincau,项目名称:TACTIC,代码行数:85,代码来源:menu_examples_wdg.py

示例14: get_display

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]
    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
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:edit_wdg.py

示例15: add_top_behaviors

# 需要导入模块: from tactic.ui.container import SmartMenu [as 别名]
# 或者: from tactic.ui.container.SmartMenu import attach_smart_context_menu [as 别名]

#.........这里部分代码省略.........
            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)
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:checkin_dir_list_wdg.py


注:本文中的tactic.ui.container.SmartMenu.attach_smart_context_menu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。