def get_display(my): my.example_count = 0 div = DivWdg() div.add( "<BR/>" ) ex_title_div = DivWdg() ex_title_div.add_looks( "fnt_title_2" ) ex_title_div.add( my.get_example_title() ) div.add( ex_title_div ) div.add( "<BR/>" ) ex_desc_div = DivWdg() ex_desc_div.add( my.get_example_description() ) ex_desc_div.add_looks( "fnt_title_5 fnt_italic" ) ex_desc_div.add_styles( "padding-left: 12px;" ) div.add( ex_desc_div ) div.add( "<BR/>" ) ex_div = my.get_example_display() ex_div.add_styles( "margin-left: 10px;" ) div.add( ex_div ) div.add( "<BR/>" ) return div
def get_example_display(self): div = DivWdg() dinfo_list = [{ 'class_name': 'SPT_GIZMO_ONE', 'bgcolor': '#669999', 'color': '#000000' }, { 'class_name': 'SPT_GIZMO_TWO', 'bgcolor': '#0099CC', 'color': '#000000' }, { 'class_name': 'SPT_GIZMO_THREE', 'bgcolor': '#996666', 'color': '#000000' }, { 'class_name': 'SPT_GIZMO_FOUR', 'bgcolor': '#CC9966', 'color': '#000000' }] for dinfo in dinfo_list: gizmo = DivWdg() gizmo.add_class(dinfo.get('class_name')) gizmo.add_looks('fnt_serif') gizmo.add_styles('background: %s; color: %s;' % (dinfo.get('bgcolor'), dinfo.get('color'))) gizmo.add_styles('width: 200px; border: 1px solid black;') gizmo.add(dinfo.get('class_name')) div.add(gizmo) div.add('<br/><br/>') return div
def get_display(self): self.example_count = 0 div = DivWdg() div.add("<BR/>") ex_title_div = DivWdg() ex_title_div.add_looks("fnt_title_2") ex_title_div.add(self.get_example_title()) div.add(ex_title_div) div.add("<BR/>") ex_desc_div = DivWdg() ex_desc_div.add(self.get_example_description()) ex_desc_div.add_looks("fnt_title_5 fnt_italic") ex_desc_div.add_styles("padding-left: 12px;") div.add(ex_desc_div) div.add("<BR/>") ex_div = self.get_example_display() ex_div.add_styles("margin-left: 10px;") div.add(ex_div) div.add("<BR/>") return div
def get_display(my): dd_activator = DivWdg() if my.style: dd_activator.add_styles( my.style ) dd_activator.add_style( "width: %spx" % my.width ) dd_activator.add_class("SPT_DTS"); if my.nudge_menu_horiz != 0: dd_activator.set_attr("spt_nudge_menu_horiz", my.nudge_menu_horiz) if my.nudge_menu_vert != 0: dd_activator.set_attr("spt_nudge_menu_vert", my.nudge_menu_vert) # Generate button ... # table = Table() table.add_row() table.add_styles("width: 100%; padding: 0px; margin: 0px;") td = table.add_cell() td.add_looks("menu border curs_default") td.add_styles( "padding: 0px; width: 100%; overflow: hidden; height: 12px; max-height: 12px;" ) title_div = DivWdg() title_div.add_styles( "padding: 0px; margin-left: 4px; margin-top: 1px;" ) if my.icon_path: img = HtmlElement.img() img.set_attr("src", my.icon_path) img.set_attr("title", my.title) img.add_styles("padding: 0px; padding-bottom: 1px; margin: 0px; text-decoration: none;") title_div.add(img) title_div.add_looks("menu") else: title_div.add(my.title) title_div.add_looks("menu fnt_text") td.add( title_div ) td = table.add_cell() # -- Example of setting only some of the borders with dotted style ... # td.add_looks( "menu_btn_icon clear_borders border_bottom border_right dotted" ) td.add_looks( "menu_btn_icon border curs_default" ) td.add_styles( "padding: 0px; text-align: center; overflow: hidden; " \ "width: 15px; min-width: 15px;" \ "height: 12px; max-height: 12px;" ) arrow_img = HtmlElement.img("/context/icons/silk/_spt_bullet_arrow_down_dark_8x8.png") arrow_img.add_styles( "border: 0px; margin-left: 1px; margin-top: 0px;" ) td.add( arrow_img ) dd_activator.add(table) dd_activator.add( my.kwargs.get("smart_menu_set") ) dd_activator.add_class("SPT_SMENU_ACTIVATOR") dd_activator.add_behavior( { 'type': 'click_up', 'activator_type' : 'smart_menu', 'cbjs_action': 'spt.smenu.show_on_dropdown_click_cbk( evt, bvr )' } ) return dd_activator
def get_display(self): dd_activator = DivWdg() if self.style: dd_activator.add_styles( self.style ) dd_activator.add_style( "width: %spx" % self.width ) dd_activator.add_class("SPT_DTS"); if self.nudge_menu_horiz != 0: dd_activator.set_attr("spt_nudge_menu_horiz", self.nudge_menu_horiz) if self.nudge_menu_vert != 0: dd_activator.set_attr("spt_nudge_menu_vert", self.nudge_menu_vert) # Generate button ... # table = Table() table.add_row() table.add_styles("width: 100%; padding: 0px; margin: 0px;") td = table.add_cell() td.add_looks("menu border curs_default") td.add_styles( "padding: 0px; width: 100%; overflow: hidden; height: 12px; max-height: 12px;" ) title_div = DivWdg() title_div.add_styles( "padding: 0px; margin-left: 4px; margin-top: 1px;" ) if self.icon_path: img = HtmlElement.img() img.set_attr("src", self.icon_path) img.set_attr("title", self.title) img.add_styles("padding: 0px; padding-bottom: 1px; margin: 0px; text-decoration: none;") title_div.add(img) title_div.add_looks("menu") else: title_div.add(self.title) title_div.add_looks("menu fnt_text") td.add( title_div ) td = table.add_cell() # -- Example of setting only some of the borders with dotted style ... # td.add_looks( "menu_btn_icon clear_borders border_bottom border_right dotted" ) td.add_looks( "menu_btn_icon border curs_default" ) td.add_styles( "padding: 0px; text-align: center; overflow: hidden; " \ "width: 15px; min-width: 15px;" \ "height: 12px; max-height: 12px;" ) arrow_img = HtmlElement.img("/context/icons/silk/_spt_bullet_arrow_down_dark_8x8.png") arrow_img.add_styles( "border: 0px; margin-left: 1px; margin-top: 0px;" ) td.add( arrow_img ) dd_activator.add(table) dd_activator.add( self.kwargs.get("smart_menu_set") ) dd_activator.add_class("SPT_SMENU_ACTIVATOR") dd_activator.add_behavior( { 'type': 'click_up', 'activator_type' : 'smart_menu', 'cbjs_action': 'spt.smenu.show_on_dropdown_click_cbk( evt, bvr )' } ) return dd_activator
def get_link_wdg(self, element_name, config, options): attributes = config.get_element_attributes(element_name) title = self._get_title(config, element_name) default_access = "view" path = options.get('path') security = Environment.get_security() if not security.check_access( "side_bar", element_name, "view", default=default_access): return # backwards compatibility?? #if not security.check_access("url", path, "view"): # return link_wdg = DivWdg(css="hand") link_wdg.add_style("padding-top: 4px") link_wdg.add_attr("spt_title", title) link_wdg.add_attr("spt_icon", attributes.get("icon")) link_wdg.add_class("spt_side_bar_link") link_wdg.add_attr("spt_view", config.get_view()) link_wdg.add_attr("spt_element_name", element_name) link_wdg.add_attr("spt_path", options['path']) # add the mouseover color change link_wdg.add_style("color: #292929") link_wdg.add_class("SPT_DTS") hover = link_wdg.get_color("background3", -10) link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover) link_wdg.add_event("onmouseout", "this.style.background=''") link_wdg.add_class("spt_side_bar_element") link_wdg.add_looks("fnt_text") link_wdg.add_attr("spt_view", config.get_view()) # add an invisible drop widget drop_wdg = self.get_drop_wdg() drop_wdg.add_style("margin-top: -3px") link_wdg.add(drop_wdg) span = SpanWdg() span.add_class("spt_side_bar_title") # add an icon icon = attributes.get("icon") if icon: icon = icon.upper() from pyasm.widget import IconWdg try: span.add(IconWdg(title, eval("IconWdg.%s" % icon))) except: pass span.add(title) link_wdg.add(span) return link_wdg
def get_display(my): if my.get_example_chooser == 'true': return my.get_example_chooser_content() div = DivWdg() div.set_id("UiPlaygroundPanelWdg") title = "UI Playground" title_wdg = DivWdg() title_wdg.add_looks("fnt_title_2") title_wdg.add(title) div.add(title_wdg) div.add(HtmlElement.hr()) div.add('<br/>') click_chooser = DivWdg() click_chooser.add_looks("fnt_text") click_chooser.add(" UI Examples List Popup") click_chooser.add_class("SPT_DTS") click_chooser.add_styles( "cursor: pointer; padding: 6px; width: 130px; background-color: black;" ) click_chooser.add_behavior( {'type': 'click_up', 'cbfn_action': 'spt.popup.get_widget', 'options': { 'title': 'TACTIC™ UI Examples', 'width': '400px', 'popup_id': 'UiExamplesChooserPopup', 'popup_parent_id': 'UiPlaygroundPanelWdg', 'class_name': 'tactic.ui.panel.ui_playground_panel_wdg.' \ 'UiPlaygroundPanelWdg' }, 'args': { 'get_example_chooser': 'true' } } ) div.add(click_chooser) div.add('<br/>') example_display_div = DivWdg() example_display_div.add_styles("padding: 10px;") example_display_div.set_id("UiExampleDisplayDiv") div.add(example_display_div) div.add('<br/>') div.add('<br/>') return div
def get_display(self): if self.get_example_chooser == 'true': return self.get_example_chooser_content() div = DivWdg() div.set_id("UiPlaygroundPanelWdg") title = "UI Playground" title_wdg = DivWdg() title_wdg.add_looks("fnt_title_2") title_wdg.add(title) div.add(title_wdg) div.add(HtmlElement.hr()) div.add( '<br/>' ) click_chooser = DivWdg() click_chooser.add_looks("fnt_text") click_chooser.add( " UI Examples List Popup" ) click_chooser.add_class("SPT_DTS") click_chooser.add_styles("cursor: pointer; padding: 6px; width: 130px; background-color: black;") click_chooser.add_behavior( {'type': 'click_up', 'cbfn_action': 'spt.popup.get_widget', 'options': { 'title': 'TACTIC™ UI Examples', 'width': '400px', 'popup_id': 'UiExamplesChooserPopup', 'popup_parent_id': 'UiPlaygroundPanelWdg', 'class_name': 'tactic.ui.panel.ui_playground_panel_wdg.' \ 'UiPlaygroundPanelWdg' }, 'args': { 'get_example_chooser': 'true' } } ) div.add( click_chooser ) div.add( '<br/>' ) example_display_div = DivWdg() example_display_div.add_styles( "padding: 10px;" ) example_display_div.set_id("UiExampleDisplayDiv") div.add( example_display_div ) div.add( '<br/>' ) div.add( '<br/>' ) return div
def get_example_display(self): div = DivWdg() dinfo_list = [ {'class_name': 'SPT_GIZMO_ONE', 'bgcolor': '#669999', 'color': '#000000'}, {'class_name': 'SPT_GIZMO_TWO', 'bgcolor': '#0099CC', 'color': '#000000'}, {'class_name': 'SPT_GIZMO_THREE', 'bgcolor': '#996666', 'color': '#000000'}, {'class_name': 'SPT_GIZMO_FOUR', 'bgcolor': '#CC9966', 'color': '#000000'} ] for dinfo in dinfo_list: gizmo = DivWdg() gizmo.add_class( dinfo.get('class_name') ) gizmo.add_looks( 'fnt_serif' ) gizmo.add_styles( 'background: %s; color: %s;' % (dinfo.get('bgcolor'), dinfo.get('color')) ) gizmo.add_styles( 'width: 200px; border: 1px solid black;' ) gizmo.add( dinfo.get('class_name') ) div.add( gizmo ) div.add( '<br/><br/>' ) return div
def get_display(my): dd_activator = DivWdg() dd_activator.set_id( my.id ) if my.style: dd_activator.add_styles( my.style ) dd_activator.add_style( "width: %spx" % my.width ) dd_activator.add_class("SPT_DTS"); if my.nudge_menu_horiz != 0: dd_activator.set_attr("spt_nudge_menu_horiz", my.nudge_menu_horiz) if my.nudge_menu_vert != 0: dd_activator.set_attr("spt_nudge_menu_vert", my.nudge_menu_vert) # Generate button ... # table = Table() table.add_row() table.add_styles("width: 100%; padding: 0px; margin: 0px;") td = table.add_cell() td.add_looks("menu border curs_default") td.add_styles( "padding: 0px; width: 100%; overflow: hidden; height: 12px; max-height: 12px;" ) title_div = DivWdg() title_div.add_styles( "padding: 0px; margin-left: 4px; margin-top: 1px;" ) title_div.add_looks("menu fnt_text") title_div.add(my.title) td.add( title_div ) td = table.add_cell() # -- Example of setting only some of the borders with dotted style ... # td.add_looks( "menu_btn_icon clear_borders border_bottom border_right dotted" ) td.add_looks( "menu_btn_icon border curs_default" ) td.add_styles( "padding: 0px; text-align: center; overflow: hidden; " \ "width: 15px; min-width: 15px;" \ "height: 12px; max-height: 12px;" ) arrow_img = HtmlElement.img("/context/icons/silk/_spt_bullet_arrow_down_dark_8x8.png") arrow_img.add_styles( "border: 0px; margin-left: 1px; margin-top: 0px;" ) td.add( arrow_img ) dd_activator.add(table) # Now generate the main drop down menu and any needed sub-menus ... # dd_map = my.menus[0] if not dd_map.has_key('allow_icons'): dd_map['allow_icons'] = True # default is to allow icons if my.match_width: dd_map['width'] = my.width dd_menu_wdg = DropdownMenuWdg( activator_wdg=dd_activator, menu_id=dd_map['menu_id'], width=dd_map['width'], opt_spec_list=dd_map['opt_spec_list'], allow_icons=dd_map['allow_icons'] ) dd_activator.add( dd_menu_wdg ) sm_map_list = my.menus[1:] for sm_map in sm_map_list: if not sm_map.has_key('allow_icons'): sm_map['allow_icons'] = True submenu_wdg = SubMenuWdg( menu_id=sm_map['menu_id'], width=sm_map['width'], opt_spec_list=sm_map['opt_spec_list'], allow_icons=sm_map['allow_icons'] ) dd_activator.add( submenu_wdg ) return dd_activator
def get_link_wdg(my, element_name, config, options): attributes = config.get_element_attributes(element_name) title = my._get_title(config, element_name) default_access = "view" path = options.get('path') security = Environment.get_security() if not security.check_access("side_bar", element_name, "view", default=default_access): return # backwards compatibility?? #if not security.check_access("url", path, "view"): # return link_wdg = DivWdg(css="hand") link_wdg.add_style( "padding-top: 4px" ) link_wdg.add_attr("spt_title", title) link_wdg.add_attr("spt_icon", attributes.get("icon")) link_wdg.add_class("spt_side_bar_link") link_wdg.add_attr("spt_view", config.get_view() ) link_wdg.add_attr("spt_element_name", element_name) link_wdg.add_attr("spt_path", options['path']) # add the mouseover color change link_wdg.add_style("color: #292929") link_wdg.add_class("SPT_DTS") hover = link_wdg.get_color("background3", -10) link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover) link_wdg.add_event("onmouseout", "this.style.background=''") link_wdg.add_class("spt_side_bar_element") link_wdg.add_looks("fnt_text") link_wdg.add_attr("spt_view", config.get_view() ) # add an invisible drop widget drop_wdg = my.get_drop_wdg() drop_wdg.add_style("margin-top: -3px") link_wdg.add(drop_wdg) span = SpanWdg() span.add_class("spt_side_bar_title") # add an icon icon = attributes.get("icon") if icon: icon = icon.upper() from pyasm.widget import IconWdg try: span.add( IconWdg(title, eval("IconWdg.%s" % icon) ) ) except: pass span.add(title) link_wdg.add(span) return link_wdg
def generate_section( my, config, subsection_div, info, base_path="" ): title = my.kwargs.get('title') view = my.kwargs.get('view') base_path_flag = True if not base_path: base_path = "/%s" % info.get('view').capitalize() base_path_flag = False current_path = base_path # add in the elements if config.get_view() == "definition": element_names = config.get_element_names() sort = False # not sorting for now if sort == True: element_names.sort() else: element_names = config.get_element_names() # if there are no elements, then just add a drop widget if not element_names: if my.mode == 'view': item_div = DivWdg() item_div.add_style("margin: 3px") item_div.add_style("color: #555") item_div.add("<i>-- No items --</i>") subsection_div.add(item_div) else: my.add_dummy(config, subsection_div) return for element_name in element_names: display_class = config.get_display_handler(element_name) if display_class == "SeparatorWdg": div = DivWdg() div.add_attr("spt_view", config.get_view() ) div.add_class("spt_side_bar_element") div.add_class("spt_side_bar_separator") div.add_attr("spt_element_name", element_name) hr = HtmlElement.hr() hr.add_style("size: 1px") div.add(hr) div.add_style("height", "5") subsection_div.add(div) options = config.get_display_options(element_name) my.add_separator_behavior(div, element_name, config, options) continue elif display_class in ["SideBarSectionLinkWdg","FolderWdg"]: security = Environment.get_security() default_access = "view" if not security.check_access("side_bar", element_name, "view", default=default_access): continue title = my._get_title(config, element_name) paths = [] if current_path in paths: is_open = True else: is_open = False options = config.get_display_options(element_name) config_view = config.get_view() current_path = "%s/%s" % (base_path, element_name) # create HTML elements for Section Link ... outer_div = DivWdg() outer_div.add_attr("spt_view", config_view ) outer_div.add_class("spt_side_bar_element") outer_div.add_class("spt_side_bar_section") outer_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") outer_div.add_attr("spt_element_name", element_name) outer_div.add_attr("spt_title", title) #if info.get('login') : # outer_div.add_attr("spt_login", info.get('login')) # add an invisible drop widget outer_div.add(my.get_drop_wdg()) # Create the link s_link_div = DivWdg() s_link_div.add_class("SPT_DTS") s_link_div.add_class("spt_side_bar_section_link") s_link_div.add_style("cursor: pointer") s_link_div.add_style( "padding-top: 4px" ) s_link_div.add_looks("navmenu_section fnt_text fnt_bold") # FIXME: currently 'is_open' is hardcoded to be False (see above) ... the state of open or close # of sections is currently stored in a cookie on the client machine. So, at some point if # we decide to store the open/close state of side bar sections then we need to fix this. # here ... # if is_open: s_link_div.add( "<img src='/context/icons/silk/_spt_bullet_arrow_down_dark.png' " \ "style='float: top left; margin-left: -5px; margin-top: -4px;' />" \ "<span style=''>%s</span>" % title ) else: s_link_div.add( "<img src='/context/icons/silk/_spt_bullet_arrow_right_dark.png' " \ "style='float: top left; margin-left: -5px; margin-top: -4px;' />" \ "<span style=''>%s</span>" % title ) # create the content of the link div s_content_div = DivWdg() info['counter'] = info['counter'] + 1 s_content_div.add_class("SPT_DTS") s_content_div.add_attr("spt_path", current_path) s_content_div.add_class("spt_side_bar_section_content") s_content_div.add_style( "padding-left: 11px" ) if is_open: s_content_div.add_style( "display: block" ) else: s_content_div.add_style( "display: none" ) # add the behaviors my.add_folder_behavior(s_link_div, element_name, config, options) # then get view name from options in order to read a new # config and recurse ... options_view_name = options.get('view') if options_view_name: sub_config = my.get_config( my.config_search_type, options_view_name, default=my.default) my.generate_section( sub_config, s_content_div, info, current_path ) outer_div.add(s_link_div) outer_div.add(s_content_div) subsection_div.add( outer_div ) else: # FIXME: specify LinkWdg, it's too loosely defined now options = config.get_display_options(element_name) options['path'] = '%s/%s' % (current_path, element_name) # put in a default class name if not options.get('class_name'): options['class_name'] = "tactic.ui.panel.ViewPanelWdg" #FIXME: this cause an error in xmlrpc #options['haha'] = False link_wdg = my.get_link_wdg(element_name, config, options) if link_wdg: my.add_link_behavior(link_wdg, element_name, config, options) subsection_div.add(link_wdg)
def get_display(self): self.config_search_type = self.kwargs.get("config_search_type") if not self.config_search_type: self.config_search_type = "SideBarWdg" title = self.kwargs.get('title') config = self.kwargs.get('config') view = self.kwargs.get('view') width = self.kwargs.get('width') #sortable = self.kwargs.get('sortable') if not width: width = "175" self.prefix = self.kwargs.get("prefix") if not self.prefix: self.prefix = "side_bar" self.mode = self.kwargs.get("mode") if not self.mode: self.mode = 'view' self.default = self.kwargs.get('default') == 'True' div = DivWdg() div.add_class("spt_section_top") div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") # create the top widgets label = SpanWdg() label.add(title) label.add_style("font-size: 1.1em") section_div = LabeledHidableWdg(label=label) div.add(section_div) section_div.set_attr('spt_class_name', Common.get_full_class_name(self)) for name, value in self.kwargs.items(): if name == "config": continue section_div.set_attr("spt_%s" % name, value) bgcolor = label.get_color("background3") project_div = RoundedCornerDivWdg(hex_color_code=bgcolor, corner_size="10") project_div.set_dimensions(width_str='%spx' % width, content_height_str='100px') content_div = project_div.get_content_wdg() #project_div = DivWdg() #content_div = project_div section_div.add(project_div) content_div.add_class("spt_side_bar_content") content_div.add_attr("spt_view", view) if type(view) in types.StringTypes: view = [view] view_margin_top = '4px' web = WebContainer.get_web() for viewx in view: config = self.get_config(self.config_search_type, viewx, default=self.default) if not config: continue # make up a title title = DivWdg() title.add_gradient("background", "side_bar_title", 0, -15, default="background") title.add_color("color", "side_bar_title_color", default="color") title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top) if not web.is_IE(): title.add_styles("margin-left: -5px; margin-right: -5px;") title.add_looks("navmenu_header") title.add_style("height: 18px") title.add_style("padding-top: 2px") """ title = DivWdg() title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top ) if not web.is_IE(): title.add_styles( "margin-left: -10px; margin-right: -10px;") title.add_looks( "navmenu_header" ) """ # FIXME: not sure if this logic should be here. It basically # makes special titles for certain view names view_attrs = config.get_view_attributes() title_str = view_attrs.get("title") if not title_str: if viewx.startswith("self_view_"): title_str = "My Views" else: title_str = viewx title_str = Common.get_display_title(title_str) title_label = SpanWdg() title_label.add_styles("margin-left: 6px; padding-bottom: 2px;") title_label.add_looks("fnt_title_5 fnt_bold") title_label.add(title_str) title.add(title_label) content_div.add(title) info = {'counter': 10, 'view': viewx} self.generate_section(config, content_div, info) error_list = Container.get_seq(self.ERR_MSG) if error_list: span = SpanWdg() span.add_style('background', 'red') span.add('<br/>'.join(error_list)) content_div.add(span) Container.clear_seq(self.ERR_MSG) self.add_dummy(config, content_div) return div
def get_schema_wdg(my, schema): web = WebContainer.get_web() div = DivWdg() div.add_style("margin: 10 0 10 0") if not schema: Environment.add_warning("No schema", "No schema found") return div schema_xml = schema.get_xml_value("schema") code = schema.get_code() schema_search_types = schema_xml.get_values("schema/search_type/@name") if not schema_search_types: return title = DivWdg() view_margin_top = '4px' title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top ) if not web.is_IE(): title.add_styles( "margin-left: -10px; margin-right: -10px;" ) title.add_looks( "navmenu_header" ) title_label = SpanWdg() title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" ) title_label.add_looks( "fnt_title_5 fnt_bold" ) title_label.add("%s Schema" % code.capitalize()) title.add(title_label) #title.add_style("margin-top: 7px") #title.add_style("font-weight: bold") #title.add_style("font-size: 1.1em") #title.add_style("color: black") #underline = HtmlElement.hr() #underline.add_style("color: black") #underline.add_style("size: 1px") #underline.add_style("margin-top: -3px") #title.add(underline) div.add( title ) for schema_search_type in schema_search_types: try: search_type_obj = SearchType.get(schema_search_type) except SearchException: title = "<span style='color: #F44'>? %s</span>" % schema_search_type else: title = search_type_obj.get_title() span = DivWdg() span.add_style("padding: 1px") options = { 'search_type': schema_search_type, 'view': 'table', 'schema_default_view': 'true', } link = my.get_link_wdg("schema", "main_body", title, options) # walk up the tree current_type = schema_search_type has_parent = False while 1: parent_type = schema.get_parent_type(current_type) if parent_type and parent_type != '*': span.add(" ") has_parent = True else: if has_parent: span.add("+ ") break current_type = parent_type span.add(link) div.add(span) return div
def get_display(my): my.config_search_type = my.kwargs.get("config_search_type") if not my.config_search_type: my.config_search_type = "SideBarWdg" title = my.kwargs.get('title') config = my.kwargs.get('config') view = my.kwargs.get('view') width = my.kwargs.get('width') #sortable = my.kwargs.get('sortable') if not width: width = "175" my.prefix = my.kwargs.get("prefix") if not my.prefix: my.prefix = "side_bar" my.mode = my.kwargs.get("mode") if not my.mode: my.mode = 'view' my.default = my.kwargs.get('default') == 'True' div = DivWdg() div.add_class("spt_section_top") div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") # create the top widgets label = SpanWdg() label.add(title) label.add_style("font-size: 1.1em") section_div = LabeledHidableWdg(label=label) div.add(section_div) section_div.set_attr('spt_class_name', Common.get_full_class_name(my)) for name, value in my.kwargs.items(): if name == "config": continue section_div.set_attr("spt_%s" % name, value) bgcolor = label.get_color("background3") project_div = RoundedCornerDivWdg(hex_color_code=bgcolor,corner_size="10") project_div.set_dimensions( width_str='%spx' % width, content_height_str='100px' ) content_div = project_div.get_content_wdg() #project_div = DivWdg() #content_div = project_div section_div.add( project_div ) content_div.add_class("spt_side_bar_content") content_div.add_attr("spt_view", view) if type(view) in types.StringTypes: view = [view] view_margin_top = '4px' web = WebContainer.get_web() for viewx in view: config = my.get_config(my.config_search_type, viewx, default=my.default) if not config: continue # make up a title title = DivWdg() title.add_gradient( "background", "side_bar_title", 0, -15, default="background" ) title.add_color( "color", "side_bar_title_color", default="color" ) title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top ) if not web.is_IE(): title.add_styles( "margin-left: -5px; margin-right: -5px;") title.add_looks( "navmenu_header" ) title.add_style( "height: 18px" ) title.add_style( "padding-top: 2px" ) """ title = DivWdg() title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top ) if not web.is_IE(): title.add_styles( "margin-left: -10px; margin-right: -10px;") title.add_looks( "navmenu_header" ) """ # FIXME: not sure if this logic should be here. It basically # makes special titles for certain view names view_attrs = config.get_view_attributes() title_str = view_attrs.get("title") if not title_str: if viewx.startswith("my_view_"): title_str = "My Views" else: title_str = viewx title_str = Common.get_display_title(title_str) title_label = SpanWdg() title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" ) title_label.add_looks( "fnt_title_5 fnt_bold" ) title_label.add( title_str ) title.add( title_label ) content_div.add( title ) info = { 'counter' : 10, 'view': viewx } my.generate_section( config, content_div, info ) error_list = Container.get_seq(my.ERR_MSG) if error_list: span = SpanWdg() span.add_style('background', 'red') span.add('<br/>'.join(error_list)) content_div.add(span) Container.clear_seq(my.ERR_MSG) my.add_dummy(config, content_div) return div
def generate_section(self, config, subsection_div, info, base_path=""): title = self.kwargs.get('title') view = self.kwargs.get('view') base_path_flag = True if not base_path: base_path = "/%s" % info.get('view').capitalize() base_path_flag = False current_path = base_path # add in the elements if config.get_view() == "definition": element_names = config.get_element_names() sort = False # not sorting for now if sort == True: element_names.sort() else: element_names = config.get_element_names() # if there are no elements, then just add a drop widget if not element_names: if self.mode == 'view': item_div = DivWdg() item_div.add_style("margin: 3px") item_div.add_style("color: #555") item_div.add("<i>-- No items --</i>") subsection_div.add(item_div) else: self.add_dummy(config, subsection_div) return for element_name in element_names: display_class = config.get_display_handler(element_name) if display_class == "SeparatorWdg": div = DivWdg() div.add_attr("spt_view", config.get_view()) div.add_class("spt_side_bar_element") div.add_class("spt_side_bar_separator") div.add_attr("spt_element_name", element_name) hr = HtmlElement.hr() hr.add_style("size: 1px") div.add(hr) div.add_style("height", "5") subsection_div.add(div) options = config.get_display_options(element_name) self.add_separator_behavior(div, element_name, config, options) continue elif display_class in ["SideBarSectionLinkWdg", "FolderWdg"]: security = Environment.get_security() default_access = "view" if not security.check_access( "side_bar", element_name, "view", default=default_access): continue title = self._get_title(config, element_name) paths = [] if current_path in paths: is_open = True else: is_open = False options = config.get_display_options(element_name) config_view = config.get_view() current_path = "%s/%s" % (base_path, element_name) # create HTML elements for Section Link ... outer_div = DivWdg() outer_div.add_attr("spt_view", config_view) outer_div.add_class("spt_side_bar_element") outer_div.add_class("spt_side_bar_section") outer_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") outer_div.add_attr("spt_element_name", element_name) outer_div.add_attr("spt_title", title) #if info.get('login') : # outer_div.add_attr("spt_login", info.get('login')) # add an invisible drop widget outer_div.add(self.get_drop_wdg()) # Create the link s_link_div = DivWdg() s_link_div.add_class("SPT_DTS") s_link_div.add_class("spt_side_bar_section_link") s_link_div.add_style("cursor: pointer") s_link_div.add_style("padding-top: 4px") s_link_div.add_looks("navmenu_section fnt_text fnt_bold") # FIXME: currently 'is_open' is hardcoded to be False (see above) ... the state of open or close # of sections is currently stored in a cookie on the client machine. So, at some point if # we decide to store the open/close state of side bar sections then we need to fix this. # here ... # if is_open: s_link_div.add( "<img src='/context/icons/silk/_spt_bullet_arrow_down_dark.png' " \ "style='float: top left; margin-left: -5px; margin-top: -4px;' />" \ "<span style=''>%s</span>" % title ) else: s_link_div.add( "<img src='/context/icons/silk/_spt_bullet_arrow_right_dark.png' " \ "style='float: top left; margin-left: -5px; margin-top: -4px;' />" \ "<span style=''>%s</span>" % title ) # create the content of the link div s_content_div = DivWdg() info['counter'] = info['counter'] + 1 s_content_div.add_class("SPT_DTS") s_content_div.add_attr("spt_path", current_path) s_content_div.add_class("spt_side_bar_section_content") s_content_div.add_style("padding-left: 11px") if is_open: s_content_div.add_style("display: block") else: s_content_div.add_style("display: none") # add the behaviors self.add_folder_behavior(s_link_div, element_name, config, options) # then get view name from options in order to read a new # config and recurse ... options_view_name = options.get('view') if options_view_name: sub_config = self.get_config(self.config_search_type, options_view_name, default=self.default) self.generate_section(sub_config, s_content_div, info, current_path) outer_div.add(s_link_div) outer_div.add(s_content_div) subsection_div.add(outer_div) else: # FIXME: specify LinkWdg, it's too loosely defined now options = config.get_display_options(element_name) options['path'] = '%s/%s' % (current_path, element_name) # put in a default class name if not options.get('class_name'): options['class_name'] = "tactic.ui.panel.ViewPanelWdg" #FIXME: this cause an error in xmlrpc #options['haha'] = False link_wdg = self.get_link_wdg(element_name, config, options) if link_wdg: self.add_link_behavior(link_wdg, element_name, config, options) subsection_div.add(link_wdg)
def get_schema_wdg(self, schema): web = WebContainer.get_web() div = DivWdg() div.add_style("margin: 10 0 10 0") if not schema: Environment.add_warning("No schema", "No schema found") return div schema_xml = schema.get_xml_value("schema") code = schema.get_code() schema_search_types = schema_xml.get_values("schema/search_type/@name") if not schema_search_types: return title = DivWdg() view_margin_top = '4px' title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top ) if not web.is_IE(): title.add_styles( "margin-left: -10px; margin-right: -10px;" ) title.add_looks( "navmenu_header" ) title_label = SpanWdg() title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" ) title_label.add_looks( "fnt_title_5 fnt_bold" ) title_label.add("%s Schema" % code.capitalize()) title.add(title_label) #title.add_style("margin-top: 7px") #title.add_style("font-weight: bold") #title.add_style("font-size: 1.1em") #title.add_style("color: black") #underline = HtmlElement.hr() #underline.add_style("color: black") #underline.add_style("size: 1px") #underline.add_style("margin-top: -3px") #title.add(underline) div.add( title ) for schema_search_type in schema_search_types: try: search_type_obj = SearchType.get(schema_search_type) except SearchException: title = "<span style='color: #F44'>? %s</span>" % schema_search_type else: title = search_type_obj.get_title() span = DivWdg() span.add_style("padding: 1px") options = { 'search_type': schema_search_type, 'view': 'table', 'schema_default_view': 'true', } link = self.get_link_wdg("schema", "main_body", title, options) # walk up the tree current_type = schema_search_type has_parent = False while 1: parent_type = schema.get_parent_type(current_type) if parent_type and parent_type != '*': span.add(" ") has_parent = True else: if has_parent: span.add("+ ") break current_type = parent_type span.add(link) div.add(span) return div
def get_display(self): dd_activator = DivWdg() dd_activator.set_id(self.id) if self.style: dd_activator.add_styles(self.style) dd_activator.add_style("width: %spx" % self.width) dd_activator.add_class("SPT_DTS") if self.nudge_menu_horiz != 0: dd_activator.set_attr("spt_nudge_menu_horiz", self.nudge_menu_horiz) if self.nudge_menu_vert != 0: dd_activator.set_attr("spt_nudge_menu_vert", self.nudge_menu_vert) # Generate button ... # table = Table() table.add_row() table.add_styles("width: 100%; padding: 0px; margin: 0px;") td = table.add_cell() td.add_looks("menu border curs_default") td.add_styles( "padding: 0px; width: 100%; overflow: hidden; height: 12px; max-height: 12px;" ) title_div = DivWdg() title_div.add_styles( "padding: 0px; margin-left: 4px; margin-top: 1px;") title_div.add_looks("menu fnt_text") title_div.add(self.title) td.add(title_div) td = table.add_cell() # -- Example of setting only some of the borders with dotted style ... # td.add_looks( "menu_btn_icon clear_borders border_bottom border_right dotted" ) td.add_looks("menu_btn_icon border curs_default") td.add_styles( "padding: 0px; text-align: center; overflow: hidden; " \ "width: 15px; min-width: 15px;" \ "height: 12px; max-height: 12px;" ) arrow_img = HtmlElement.img( "/context/icons/silk/_spt_bullet_arrow_down_dark_8x8.png") arrow_img.add_styles("border: 0px; margin-left: 1px; margin-top: 0px;") td.add(arrow_img) dd_activator.add(table) # Now generate the main drop down menu and any needed sub-menus ... # dd_map = self.menus[0] if not dd_map.has_key('allow_icons'): dd_map['allow_icons'] = True # default is to allow icons if self.match_width: dd_map['width'] = self.width dd_menu_wdg = DropdownMenuWdg(activator_wdg=dd_activator, menu_id=dd_map['menu_id'], width=dd_map['width'], opt_spec_list=dd_map['opt_spec_list'], allow_icons=dd_map['allow_icons']) dd_activator.add(dd_menu_wdg) sm_map_list = self.menus[1:] for sm_map in sm_map_list: if not sm_map.has_key('allow_icons'): sm_map['allow_icons'] = True submenu_wdg = SubMenuWdg(menu_id=sm_map['menu_id'], width=sm_map['width'], opt_spec_list=sm_map['opt_spec_list'], allow_icons=sm_map['allow_icons']) dd_activator.add(submenu_wdg) return dd_activator
def get_example_display(self): font_div = DivWdg() font_div.add_styles( "background: #CCCCCC; color: #000000; border: 3px solid black; width: 750px;" ) font_table = Table() font_table.add_styles( "margin-top: 6px;" ) font_table.add_row() ft_style = "border: 1px solid black; border-collapse: collapse; padding: 3px; " \ "color: #000000; cursor: pointer; %s" td = font_table.add_cell() td.add_styles( "border: 0px; border-collapse: collapse; padding: 0px; width: 6px; background: #CCCCCC;" ) td.add( " " ) td = font_table.add_cell() td.set_id("SPT_FONT_EXAMPLE_BTN") td.add_styles( ft_style % "background: #CCCCCC;" ) td.add( "normal" ) td.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("SPT_FONT_EXAMPLE").setStyle("display","block"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BOLD").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BTN").setStyle("background","#CCCCCC"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC_BTN").setStyle("background","#777777"); ' } ) td = font_table.add_cell() td.add_styles( "border: 0px; border-collapse: collapse; padding: 0px; width: 6px; background: #CCCCCC;" ) td.add( " " ) td = font_table.add_cell() td.set_id("SPT_FONT_EXAMPLE_ITALIC_BTN") td.add_styles( ft_style % "background: #777777;" ) td.add( "<i>italic</i>" ) td.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("SPT_FONT_EXAMPLE").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC").setStyle("display","block"); ' \ '$("SPT_FONT_EXAMPLE_BOLD").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC_BTN").setStyle("background","#CCCCCC"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC_BTN").setStyle("background","#777777"); ' } ) td = font_table.add_cell() td.add_styles( "border: 0px; border-collapse: collapse; padding: 0px; width: 6px; background: #CCCCCC;" ) td.add( " " ) td = font_table.add_cell() td.set_id("SPT_FONT_EXAMPLE_BOLD_BTN") td.add_styles( ft_style % "background: #777777;" ) td.add( "<b>bold</b>" ) td.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("SPT_FONT_EXAMPLE").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BOLD").setStyle("display","block"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_BTN").setStyle("background","#CCCCCC"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC_BTN").setStyle("background","#777777"); ' } ) td = font_table.add_cell() td.add_styles( "border: 0px; border-collapse: collapse; padding: 0px; width: 6px; background: #CCCCCC;" ) td.add( " " ) td = font_table.add_cell() td.set_id("SPT_FONT_EXAMPLE_BOLD_ITALIC_BTN") td.add_styles( ft_style % "background: #777777;" ) td.add( "<b><i>bold italic</i></b>" ) td.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("SPT_FONT_EXAMPLE").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BOLD").setStyle("display","none"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC").setStyle("display","block"); ' \ '$("SPT_FONT_EXAMPLE_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_ITALIC_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_BTN").setStyle("background","#777777"); ' \ '$("SPT_FONT_EXAMPLE_BOLD_ITALIC_BTN").setStyle("background","#CCCCCC"); ' } ) font_div.add( font_table ) font_palettes = [ 'fnt_title_1', 'fnt_title_2', 'fnt_title_3', 'fnt_title_4', 'fnt_title_5', 'fnt_text', 'fnt_text_small', 'fnt_serif', 'fnt_code' ] font_modifiers = [ 'fnt_italic', 'fnt_bold', 'fnt_bold fnt_italic' ] font_example_div = DivWdg() font_example_div.set_id( "SPT_FONT_EXAMPLE" ) for fnt_pal in font_palettes: font_palette_div = DivWdg() font_palette_div.add_looks( fnt_pal ) font_palette_div.add_styles( "color: black; padding-top: 10px; padding-left: 10px;" ) font_palette_div.add( 'Here is example TEXT showing text that is given font palette "' + fnt_pal + '"' ) font_example_div.add( font_palette_div ) font_div.add( font_example_div ) for fnt_mod in font_modifiers: fm_name = fnt_mod.replace(" ","_") font_example_div = DivWdg() font_example_div.set_id( "SPT_FONT_EXAMPLE_%s" % fm_name.upper().replace("FNT_","") ) font_example_div.add_styles( "display: none;" ) for fnt_pal in font_palettes: font_palette_div = DivWdg() font_palette_div.add_looks( "%s %s" % (fnt_pal,fnt_mod) ) font_palette_div.add_styles( "color: black; padding-top: 10px; padding-left: 10px;" ) font_palette_div.add( 'Here is example TEXT showing text that is given font palette "' + fnt_pal + '"' ) font_example_div.add( font_palette_div ) font_div.add( font_example_div ) font_div.add( '<br/><br/>' ) return font_div