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


Python Menu.add方法代码示例

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


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

示例1: get_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_context_menu(my):

        menu = Menu(width=180)
        menu.set_allow_icons(False)

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


        menu_item = MenuItem(type='action', label='Remove Share')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''
            if (!confirm("Delete share?") ) {
                return;
            }

            var activator = spt.smenu.get_activator(bvr);
            var code = activator.getAttribute("spt_share_code");

            var class_name = 'tactic.ui.startup.ShareItemCbk';
            var kwargs = {
                'action': 'delete',
                'code': code
            };
            var server = TacticServerStub.get();
            server.execute_cmd(class_name, kwargs);
            
            var top = activator.getParent(".spt_share_top");
            spt.panel.refresh(top);

            '''
        })
        return menu
开发者ID:blezek,项目名称:TACTIC,代码行数:37,代码来源:share_wdg.py

示例2: get_extra_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_extra_menu(my):

        menu = Menu(width=180)
        menu.set_allow_icons(False)

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

        menu_item = MenuItem(type='action', label='Edit Tab Config')
        menu_item.add_behavior( {
        'cbjs_action': '''
        var activator = spt.smenu.get_activator(bvr);
        spt.tab.top = activator.getParent(".spt_tab_top");
        var element_name = 'edit_tab_config';
        var title = 'Edit Tab Config';
        var class_name = 'tactic.ui.manager.ViewManagerWdg';
        var kwargs = {
            search_type: 'prod/asset',
            view: 'tab_config_model'
        }
        spt.tab.add_new(element_name, title, class_name, kwargs);

        '''
        } )
        menu.add(menu_item)


        return menu
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:30,代码来源:sobject_wdg.py

示例3: get_add_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_add_menu(self):
        from tactic.ui.container import Menu, MenuItem
        menu = Menu(width=180)
        menu.set_allow_icons(False)
        #menu.set_setup_cbfn( 'spt.smenu_ctx.setup_cbk' )


        menu_item = MenuItem(type='title', label='Add Item')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Label')
        menu_item.add_behavior( {
            'element_name': 'label',
            'cbjs_action': self.get_add_bvr_action()
        } )
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Text')
        menu_item.add_behavior( {
            'element_name': 'text',
            'cbjs_action': self.get_add_bvr_action()
        } )
        menu.add(menu_item)


        menu_item = MenuItem(type='action', label='TextArea')
        menu_item.add_behavior( {
            'element_name': 'textarea',
            'cbjs_action': self.get_add_bvr_action()
        } )
        menu.add(menu_item)


        return menu
开发者ID:mincau,项目名称:TACTIC,代码行数:36,代码来源:freeform_layout_wdg.py

示例4: get_node_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_node_context_menu(my):

        menu = Menu(width=180)
        menu.set_allow_icons(False)
        menu.set_setup_cbfn( 'spt.dg_table.smenu_ctx.setup_cbk' )


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


        menu_item = MenuItem(type='action', label='Load Detail Report')
        menu_item.add_behavior( {
            'cbjs_action': '''
            var node = spt.smenu.get_activator(bvr);
            var name = node.getAttribute("spt_element_name");

            var top = node.getParent(".spt_detail_top");
            spt.tab.top = top.getElement(".spt_tab_top");

            var search_key = top.getAttribute("spt_parent_key");
            if (!search_key) {
                search_key = top.getAttribute("spt_search_key");
            }

            var class_name = 'tactic.ui.tools.sobject_wdg.SObjectSingleProcessDetailWdg';
            var kwargs = {
                search_key: search_key,
                process: name
            }

            var title = "Detail ["+name+"]";
            var element_name = "detail_"+name;
            spt.tab.add_new(element_name, title, class_name, kwargs);
            '''
        } )
        menu.add(menu_item)


        return menu
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:42,代码来源:sobject_wdg.py

示例5: get_text_new_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_text_new_context_menu(self):

        search_type_obj = SearchType.get(self.search_type)
        title = search_type_obj.get_title()


        menu = Menu(width=180)
        menu.set_allow_icons(False)

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

        menu_item = MenuItem(type='action', label="Update line")
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var line_el = activator.getParent(".spt_new_line");
            var prev_line_el = line_el.getPrevious(".spt_line");
            prev_line_el.setStyle("border", "solid 1px red");

            var content = prev_line_el.getElement(".spt_line_content");
            alert(content.innerHTML);



            var prev_line_el = prev_line_el.getPrevious(".spt_line");
            prev_line_el.setStyle("border", "solid 1px red");

            var next_line_el = line_el.getNext(".spt_line");
            next_line_el.setStyle("border", "solid 1px red");

            var next_line_el = next_line_el.getNext(".spt_line");
            next_line_el.setStyle("border", "solid 1px red");
            '''
        } )

        return menu
开发者ID:mincau,项目名称:TACTIC,代码行数:41,代码来源:doc_tool_wdg.py

示例6: get_header_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_header_context_menu(my):

        menu = Menu(width=180)
        menu.set_allow_icons(False)
        menu.set_setup_cbfn( 'spt.dg_table.smenu_ctx.setup_cbk' )

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


        menu_item = MenuItem(type='action', label='Edit Column Definition')
        menu_item.add_behavior( {
            'args' : {
                'search_type': my.search_type,
                'options': {
                    'class_name': 'tactic.ui.manager.ElementDefinitionWdg',
                    'popup_id': 'edit_column_defn_wdg',
                    'title': 'Edit Column Definition'
                }
            },
            'cbjs_action': '''
            spt.alert("Not yet implemented");
            return


            var activator = spt.smenu.get_activator(bvr);
            bvr.args.element_name = activator.getProperty("spt_element_name");
            bvr.args.view = activator.getAttribute('spt_view');
            var popup = spt.popup.get_widget(evt,bvr);
            popup.activator = activator;
            '''
        } )
        menu.add(menu_item)


        return menu
开发者ID:funic,项目名称:TACTIC,代码行数:38,代码来源:edit_wdg.py

示例7: get_test_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_test_context_menu(my):

        menu = Menu(width=180)
        menu.set_allow_icons(False)

        menu_item = MenuItem(type="title", label="Actions")
        menu.add(menu_item)

        menu_item = MenuItem(type="action", label="Refresh")
        menu.add(menu_item)
        menu_item.add_behavior(
            {
                "type": "click_up",
                "view": my.view,
                "cbjs_action": """
            var activator = spt.smenu.get_activator(bvr);
            var top = activator.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);
 

            """,
            }
        )

        menu_item = MenuItem(type="action", label="Edit")
        menu.add(menu_item)
        menu_item.add_behavior(
            {
                "type": "click_up",
                "view": my.view,
                "cbjs_action": """
            var activator = spt.smenu.get_activator(bvr);
            var popup_top = activator.getParent(".spt_popup");
            var top = popup_top.top;
            if (top) {
                top.setAttribute("spt_view", bvr.view);
                spt.app_busy.show("Loading view: " + bvr.view);
                spt.panel.refresh(top);
                spt.app_busy.hide();
            }
            """,
            }
        )

        return menu
开发者ID:hellios78,项目名称:TACTIC,代码行数:50,代码来源:custom_layout_wdg.py

示例8: get_add_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_add_menu(my):
        from tactic.ui.container import Menu, MenuItem

        menu = Menu(width=180)
        menu.set_allow_icons(False)
        # menu.set_setup_cbfn( 'spt.dg_table.smenu_ctx.setup_cbk' )

        menu_item = MenuItem(type="title", label="Add Item")
        menu.add(menu_item)

        menu_item = MenuItem(type="action", label="Label")
        menu_item.add_behavior({"element_name": "label", "cbjs_action": my.get_add_bvr_action()})
        menu.add(menu_item)

        menu_item = MenuItem(type="action", label="Text")
        menu_item.add_behavior({"element_name": "text", "cbjs_action": my.get_add_bvr_action()})
        menu.add(menu_item)

        menu_item = MenuItem(type="action", label="TextArea")
        menu_item.add_behavior({"element_name": "textarea", "cbjs_action": my.get_add_bvr_action()})
        menu.add(menu_item)

        return menu
开发者ID:hellios78,项目名称:TACTIC,代码行数:25,代码来源:freeform_layout_wdg.py

示例9: get_test_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_test_context_menu(my):

        menu = Menu(width=180)
        menu.set_allow_icons(False)

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


        menu_item = MenuItem(type='action', label='Refresh')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'view': my.view,
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var top = activator.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);
 

            '''
        } )

        menu_item = MenuItem(type='action', label='Edit')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'view': my.view,
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var popup_top = activator.getParent(".spt_popup");
            var top = popup_top.top;
            if (top) {
                top.setAttribute("spt_view", bvr.view);
                spt.app_busy.show("Loading view: " + bvr.view);
                spt.panel.refresh(top);
                spt.app_busy.hide();
            }
            '''
        } )

        return menu
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:47,代码来源:custom_layout_wdg.py

示例10: get_display

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

示例11: get_text_context_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_text_context_menu(self):

        search_type_obj = SearchType.get(self.search_type)
        title = search_type_obj.get_title()


        menu = Menu(width=180)
        menu.set_allow_icons(False)

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



        label = 'Create New "%s"' % title
        menu_item = MenuItem(type='action', label=label)
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'search_type': self.search_type,
            'column': self.column,
            'cbjs_action': r'''
            var activator = spt.smenu.get_activator(bvr);

            var selection = spt.document.selected_text;
            if (!selection) {
                alert("Nothing selected");
                return;
            }

            spt.app_busy.show("Adding " + bvr.search_type);


            var data = {}
            data[bvr.column] = selection;

            var server = TacticServerStub.get();
            server.insert(bvr.search_type, data);

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


        label = '%s (Detail)' % label
        menu_item = MenuItem(type='action', label=label)
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'search_type': self.search_type,
            'cbjs_action': r'''
            var activator = spt.smenu.get_activator(bvr);

            var selection = spt.document.selected_text;
            if (!selection) {
                alert("Nothing selected");
                return;
            }

            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: bvr.search_type,
                default: {
                  description: selection
                }
            }


            spt.panel.load_popup("Add", class_name, kwargs);
            '''
        } )



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

        menu_item = MenuItem(type='action', label='Search')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'search_type': self.search_type,
            'cbjs_action': r'''
            var activator = spt.smenu.get_activator(bvr);
            var selection = spt.document.selected_text;
            if (!selection) {
                alert("Nothing selected");
                return;
            }

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

            spt.app_busy.show("Searching " + selection);

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': bvr.search_type,
                'keywords': selection,
                'simple_search_view': 'simple_filter',
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:doc_tool_wdg.py

示例12: get_gear_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_gear_menu(my):

        top = DivWdg()

        # FIXME: the gear menu widget should be here
        from tactic.ui.container import GearMenuWdg, Menu, MenuItem

        menu = Menu(width=180)

        menu_item = MenuItem(type="title", label="Actions")
        menu.add(menu_item)

        # create a new element
        menu_item = MenuItem(type="action", label="New Element")
        behavior = {
            "options": {"is_insert": "true", "search_type": my.search_type, "view": my.view},
            "cbjs_action": """

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_view_manager_top");
        var detail_panel = top.getElement(".spt_view_manager_detail");

        var class_name = 'tactic.ui.manager.ElementDefinitionWdg';
        var options = bvr.options
        var values = {};
        spt.panel.load(detail_panel, class_name, options, values, false);
        """,
        }
        menu_item.add_behavior(behavior)
        menu.add(menu_item)

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

        # Show preview of the view
        menu_item = MenuItem(type="action", label="Show Preview")
        behavior = {
            "search_type": my.search_type,
            "view": my.view,
            "cbjs_action": """
        var kwargs = {
          search_type: bvr.search_type,
          view: bvr.view
        };
        var title = "Search Type: [" + bvr.search_type + "], View [" + bvr.view + "]";
        spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs);
        """,
        }
        menu_item.add_behavior(behavior)
        menu.add(menu_item)

        # Show preview of the view
        menu_item = MenuItem(type="action", label="Show Full XML Config")
        behavior = {
            "search_type": my.search_type,
            "view": my.view,
            "cbjs_action": """
        var kwargs = {
          search_type: 'config/widget_config',
          view: 'table',
          expression: "@SOBJECT(config/widget_config['search_type','"+bvr.search_type+"']['view','"+bvr.view+"'])",
          filter: [{}]
        };
        var title = "Widget Config - ["+bvr.search_type+"] ["+bvr.view+"]";
        spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs);
        """,
        }
        menu_item.add_behavior(behavior)
        menu.add(menu_item)

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

        # New view popup
        new_view_wdg = DivWdg()
        new_view_wdg.add_class("spt_new_view")
        new_view_wdg.add_style("display: none")
        new_view_wdg.add_style("position: absolute")
        new_view_wdg.add_color("background", "background")
        new_view_wdg.add_style("z-index: 100")
        new_view_wdg.add_border()
        new_view_wdg.set_round_corners()
        new_view_wdg.set_box_shadow()
        new_view_wdg.add_style("padding: 30px")
        new_view_wdg.add("New View Name: ")
        new_view_text = TextWdg("new_view")
        new_view_text.add_class("spt_new_view_text")
        new_view_wdg.add(new_view_text)
        new_view_wdg.add(HtmlElement.br(2))

        # new_view_button = ProdIconButtonWdg('Save New View')
        new_view_button = ActionButtonWdg(title="Save", tip="Save New View")
        new_view_button.add_style("float: left")
        new_view_wdg.add(new_view_button)
        new_view_button.add_behavior(
            {
                "type": "click_up",
                "search_type": my.search_type,
                "cbjs_action": """
            var top = bvr.src_el.getParent(".spt_view_manager_top");
#.........这里部分代码省略.........
开发者ID:hellios78,项目名称:TACTIC,代码行数:103,代码来源:view_manager_wdg.py

示例13: get_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_menu(my):
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)


        menu_item = MenuItem(type='action', label='View')
        menu_item.add_behavior( {
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var report_top = activator.getParent(".spt_report_top");
            var kwargs = report_top.kwargs;
            var class_name = report_top.class_name;
            var element_name = report_top.element_name;

            spt.tab.set_main_body_tab();
            spt.tab.add_new(element_name, element_name, class_name, kwargs);
            '''
        } )
        menu.add(menu_item)



        menu_item = MenuItem(type='action', label='Show Definition')
        menu_item.add_behavior( {
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var report_top = activator.getParent(".spt_report_top");
            var xml = report_top.xml;
            console.log(xml);
            alert(xml);
            '''
        } )
        menu.add(menu_item)


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


        menu_item = MenuItem(type='action', label='Add to Side Bar')
        menu_item.add_behavior( {
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_tab_top");
            spt.tab.top = top;

            var header = activator;
            var title = header.getAttribute("spt_title");

            var report_top = activator.getParent(".spt_report_top");
            var kwargs = report_top.kwargs;
            var class_name = report_top.class_name;
            var element_name = report_top.element_name;

            var element_name = element_name.replace(/ /g, "_");
            element_name = element_name.replace(/\//g, "_");

            var kwargs = {
                class_name: 'LinkWdg',
                display_options: kwargs,
                element_attrs: {
                    title: title
                }
            }

            try {
                spt.app_busy.show("Adding Side Bar Link ["+element_name+"]");
                var server = TacticServerStub.get();
                server.start({description:"Added Side Bar Link ["+element_name+"]"});
                var info = server.add_config_element("SideBarWdg", "definition", element_name, kwargs);
                var info = server.add_config_element("SideBarWdg", "project_view", element_name, {});

                server.finish();
                spt.panel.refresh("side_bar");
                spt.app_busy.hide();
            }
            catch(e) {
                server.abort();
                alert(e);
                spt.app_busy.hide();
                throw(e);
            }

            '''
        } )
        menu.add(menu_item)

        return menu
开发者ID:0-T-0,项目名称:TACTIC,代码行数:91,代码来源:reports_wdg.py

示例14: get_menu

# 需要导入模块: from tactic.ui.container import Menu [as 别名]
# 或者: from tactic.ui.container.Menu import add [as 别名]
    def get_menu(self):
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)

        
        menu_item = MenuItem(type='action', label='View')
        menu_item.add_behavior( {
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var report_top = activator.getParent(".spt_report_top");
            var kwargs = report_top.kwargs;
            var class_name = report_top.class_name;
            var element_name = report_top.element_name;

            spt.tab.set_main_body_tab();
            spt.tab.add_new(element_name, element_name, class_name, kwargs);
            '''
        } )
        menu.add(menu_item)



        menu_item = MenuItem(type='action', label='Show Definition')
        menu_item.add_behavior( {
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var report_top = activator.getParent(".spt_report_top");
            var xml = report_top.xml;
            alert(xml);
            '''
        } )
        menu.add(menu_item)


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



        widget_def = '''
<element name='index' palette="BLACK">
  <display class='tactic.ui.panel.CustomLayoutWdg'>
    <view>VIEW</view>
  </display>
</element>
        '''


        menu_item = MenuItem(type='action', label='Set as Project Theme')
        menu_item.add_behavior( {
            'type': 'click_up',
            'widget_def': widget_def,
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var report_top = activator.getParent(".spt_report_top");
            var kwargs = report_top.kwargs;
            var class_name = report_top.class_name;
            var element_name = report_top.element_name;
            var view = report_top.view;

            if (!confirm("Change theme to ["+view+"]?")) {
                return;
            }

            var widget_def = bvr.widget_def;
            widget_def = widget_def.replace(/VIEW/, view);

            var data = {
                url: '/index',
                description: 'Index Page',
                widget: widget_def
            }

            var server = TacticServerStub.get();
            var url = server.eval("@SOBJECT(config/url['url','/index'])", {single:true});
            if (url) {
                server.update(url, data);
            }
            else {
                server.insert('config/url', data);
            }

            '''
        } )
        menu.add(menu_item)

        return menu
开发者ID:mincau,项目名称:TACTIC,代码行数:90,代码来源:themes_wdg.py

示例15: add_top_behaviors

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

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


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