parameters: (self)
return_statement: return top
docstring: # Save to Project View
          menu_item = MenuItem(type='action', label='xx Save to Project View')
          behavior = {
          'options': {
              'search_type': 'SideBarWdg',
              'view':        'project_view'
          },
          'cbjs_action': '''
          spt.panel.load_popup('SideBar Section', 'tactic.ui.manager.SideBarSectionWdg', bvr.options);
          '''}
          menu_item.add_behavior(behavior)
          menu.add(menu_item)
docstring_summary: # Save to Project View
          menu_item = MenuItem(type='action', label='xx Save to Project View')
          behavior = {
          'options': {
              'search_type': 'SideBarWdg',
              'view':        'project_view'
          },
          'cbjs_action': '''
          spt.panel.load_popup('SideBar Section', 'tactic.ui.manager.SideBarSectionWdg', bvr.options);
          '''}
          menu_item.add_behavior(behavior)
          menu.add(menu_item)
docstring_tokens: # Save to Project View menu_item = MenuItem ( type = action label = xx Save to Project View ) behavior = { options : { search_type : SideBarWdg view : project_view } cbjs_action : spt . panel . load_popup ( SideBar Section tactic . ui . manager . SideBarSectionWdg bvr . options ) ; } menu_item . add_behavior ( behavior ) menu . add ( menu_item )
function: def get_gear_menu(self):
  
          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': self.search_type,
            'view':        self.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': self.search_type,
          'view':        self.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': self.search_type,
          'view':        self.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': self.search_type,
              'cbjs_action': '''
              var top = bvr.src_el.getParent(".spt_view_manager_top");
              var new_view_wdg = bvr.src_el.getParent(".spt_new_view");
              var new_view_text = new_view_wdg.getElement(".spt_new_view_text");
              var view = new_view_text.value;
              if (view != '') {
                  var server = TacticServerStub.get()
                  server.update_config(bvr.search_type, view, []);
                  var values = {
                      search_type: bvr.search_type,
                      view: view
                  };
                  spt.panel.refresh(top, values);
                  spt.hide(new_view_wdg);
              }
              else {
                  alert("Must supply view name");
              }
  
              '''
          } )
          #new_view_cancel_button = ProdIconButtonWdg('Cancel')
          new_view_cancel_button = ActionButtonWdg(title='Cancel', tip='Cancel Save')
          new_view_cancel_button.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var new_view_wdg = bvr.src_el.getParent(".spt_new_view");
              spt.hide(new_view_wdg);
              '''
          } )
          new_view_wdg.add(new_view_cancel_button)
          top.add(new_view_wdg)
  
  
          #TODO: to be implemented.. no more xx please!
          """
          # Save to Project View
          menu_item = MenuItem(type='action', label='xx Save to Project View')
          behavior = {
          'options': {
              'search_type': 'SideBarWdg',
              'view':        'project_view'
          },
          'cbjs_action': '''
          spt.panel.load_popup('SideBar Section', 'tactic.ui.manager.SideBarSectionWdg', bvr.options);
          '''}
          menu_item.add_behavior(behavior)
          menu.add(menu_item)
          """
  
          # Create a new view
          menu_item = MenuItem(type='action', label='Create New View')
          behavior = {
          'search_type': self.search_type,
          'view':       self.view,
          'cbjs_action': '''
          var activator = spt.smenu.get_activator(bvr);
          var top = activator.getParent(".spt_view_manager_top");
          var new_view_wdg = top.getElement(".spt_new_view");
          spt.show(new_view_wdg);
  
          '''}
          menu_item.add_behavior(behavior)
          menu.add(menu_item)
  
  
          # Clear the current view
          menu_item = MenuItem(type='action', label='Clear View')
          behavior = {
          'options': {
            'is_insert': 'true',
            'search_type': self.search_type,
            'view':       self.view
          },
          'cbjs_action': '''
          if (confirm("Are you sure you wih to clear this view?")) {
              var activator = spt.smenu.get_activator(bvr);
              var top = activator.getParent(".spt_view_manager_top");
              var list_top = top.getElement(".spt_menu_item_list");
              var elements = spt.side_bar.get_elements(bvr.view,list_top);
              for (var i=0; i<elements.length; i++) {
                  var element = elements[i];
                  if (element.hasClass("spt_side_bar_dummy")) {
                      continue;
                  }
                  element.destroy();
  
              }
          }
          '''}
          menu_item.add_behavior(behavior)
          menu.add(menu_item)
  
  
  
          gear_menu = GearMenuWdg()
          gear_menu.add(menu)
  
          top.add(gear_menu)
          return top
function_tokens: def get_gear_menu ( self ) : 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' : self . search_type , 'view' : self . 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' : self . search_type , 'view' : self . 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' : self . search_type , 'view' : self . 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' : self . search_type , 'cbjs_action' : '''
              var top = bvr.src_el.getParent(".spt_view_manager_top");
              var new_view_wdg = bvr.src_el.getParent(".spt_new_view");
              var new_view_text = new_view_wdg.getElement(".spt_new_view_text");
              var view = new_view_text.value;
              if (view != '') {
                  var server = TacticServerStub.get()
                  server.update_config(bvr.search_type, view, []);
                  var values = {
                      search_type: bvr.search_type,
                      view: view
                  };
                  spt.panel.refresh(top, values);
                  spt.hide(new_view_wdg);
              }
              else {
                  alert("Must supply view name");
              }
  
              ''' } ) #new_view_cancel_button = ProdIconButtonWdg('Cancel') new_view_cancel_button = ActionButtonWdg ( title = 'Cancel' , tip = 'Cancel Save' ) new_view_cancel_button . add_behavior ( { 'type' : 'click_up' , 'cbjs_action' : '''
              var new_view_wdg = bvr.src_el.getParent(".spt_new_view");
              spt.hide(new_view_wdg);
              ''' } ) new_view_wdg . add ( new_view_cancel_button ) top . add ( new_view_wdg ) #TODO: to be implemented.. no more xx please! # Create a new view menu_item = MenuItem ( type = 'action' , label = 'Create New View' ) behavior = { 'search_type' : self . search_type , 'view' : self . view , 'cbjs_action' : '''
          var activator = spt.smenu.get_activator(bvr);
          var top = activator.getParent(".spt_view_manager_top");
          var new_view_wdg = top.getElement(".spt_new_view");
          spt.show(new_view_wdg);
  
          ''' } menu_item . add_behavior ( behavior ) menu . add ( menu_item ) # Clear the current view menu_item = MenuItem ( type = 'action' , label = 'Clear View' ) behavior = { 'options' : { 'is_insert' : 'true' , 'search_type' : self . search_type , 'view' : self . view } , 'cbjs_action' : '''
          if (confirm("Are you sure you wih to clear this view?")) {
              var activator = spt.smenu.get_activator(bvr);
              var top = activator.getParent(".spt_view_manager_top");
              var list_top = top.getElement(".spt_menu_item_list");
              var elements = spt.side_bar.get_elements(bvr.view,list_top);
              for (var i=0; i<elements.length; i++) {
                  var element = elements[i];
                  if (element.hasClass("spt_side_bar_dummy")) {
                      continue;
                  }
                  element.destroy();
  
              }
          }
          ''' } menu_item . add_behavior ( behavior ) menu . add ( menu_item ) gear_menu = GearMenuWdg ( ) gear_menu . add ( menu ) top . add ( gear_menu ) return top