def init(my): my.top = DivWdg() my.content_wdg = DivWdg() is_IE = WebContainer.get_web().is_IE() # get the width and height of the contents (the inner part of the container) ... my.inner_width = my.kwargs.get('inner_width') my.inner_height = my.kwargs.get('inner_height') if my.inner_width: my.inner_width = int(my.inner_width) if is_IE: my.inner_width -= 20 # adjust for rounded corner wrapper else: my.inner_width = 600 if my.inner_height: my.inner_height = int(my.inner_height) if is_IE: my.inner_height -= 20 # adjust for rounded corner wrapper else: my.inner_height = 200 # Now place a ResizeScrollWdg within a RoundedCornerDivWdg ... the ResizeScrollWdg will contain # the actual contents of this container, so that the contents can be scrolled and resized ... # from tactic.ui.container import RoundedCornerDivWdg color = my.top.get_color("background") my.rc_wdg = RoundedCornerDivWdg(hex_color_code=color,corner_size=10) #show_scrollbars = my.kwargs.get("show_resize_scroll") #if show_scrollbars in ['', 'false']: # my.inner_wdg = DivWdg() #else: # from tactic.ui.container import ResizeScrollWdg # my.inner_wdg = ResizeScrollWdg( width=my.inner_width, height=my.inner_height, scroll_bar_size_str='medium', scroll_expansion='inside' ) my.inner_wdg = DivWdg() my.inner_wdg.add_style("width: %s" % my.inner_width) my.inner_wdg.add_style("height: %s" % my.inner_height) my.inner_wdg.add_style("overflow-y: auto") my.inner_wdg.add_style("overflow-x: hidden") my.rc_wdg.add( my.inner_wdg ) my.content_wdg.add(my.rc_wdg) my.table = Table(css="minimal") my.table.add_row() my.content_td = my.table.add_cell() my.content_td.add_class("spt_content") my.content_td.add_style('padding: 2px')
def get_display(my): from pyasm.biz import Project security = Environment.get_security() if not security.check_access("builtin", "side_bar_schema", "allow", default="deny"): return DivWdg() section_div = LabeledHidableWdg(label="Schema Views") section_div.set_attr('spt_class_name', Common.get_full_class_name(my) ) palette = Palette.get() color = palette.color("background3") project_div = RoundedCornerDivWdg(hex_color_code=color,corner_size="10") project_div.set_dimensions( width_str='175px', content_height_str='100px' ) project = Project.get() project_code = project.get_code() project_type = project.get_type() div = DivWdg() section_div.add(project_div) project_div.add(div) # get project type schema schema = Schema.get_by_code(project_code) if schema: div.add( my.get_schema_wdg(schema) ) #if not project_type: # raise SetupException("Project type not found for this [%s]" %project_code) if project_type: schema = Schema.get_predefined_schema(project_type) if schema: div.add( my.get_schema_wdg(schema) ) schema = Schema.get_predefined_schema('config') div.add( my.get_schema_wdg(schema) ) schema = Schema.get_admin_schema() div.add( my.get_schema_wdg(schema) ) return section_div # create a fake schema project = Project.get() db_name = project.get_database() sql = DbContainer.get(db_name) tables = sql.get_tables() tables.sort() tables_str = "\n".join( ['<search_type name="%s"/>'%x for x in tables] ) # look at all of the search objects for mapped tables search = Search("sthpw/search_object") #search.add_where('''"namespace" = 'MMS' or namespace = '{project}' ''') search.add_filter("namespace", 'MMS') search.add_filter("namespace", '{project}') search.add_where("or") search_types = search.get_sobjects() #for search_type in search_types: # print "hhhh: ", search_type schema_xml = ''' <schema> %s </schema> ''' % tables_str schema = SearchType.create("sthpw/schema") schema.set_value("code", "table") schema.set_value("schema", schema_xml) #div.add( my.get_schema_wdg(schema) ) return section_div
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_display(self): top = DivWdg() self.set_as_panel(top) title_div = DivWdg() title_div.add_class("maq_search_bar") title_div.add("Diagnostics") top.add(title_div) tool_div = DivWdg() top.add(tool_div) refresh = IconButtonWdg("Refresh", IconWdg.REFRESH) refresh.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel"); spt.panel.refresh(top); ''' } ) tool_div.add(refresh) content = RoundedCornerDivWdg(hex_color_code="2F2F2F",corner_size="10") content.set_dimensions( width_str='300px', content_height_str=None ) top.add(content) server_title_div = DivWdg() server_title_div.add_class("maq_search_bar") content.add(server_title_div) server_title_div.add("Server") server_content_div = DivWdg() server_content_div.add_style("padding: 10px") server_content_div.add(self.get_ping_wdg()) server_content_div.add(self.get_load_balance_wdg()) content.add(server_content_div) database_title_div = DivWdg() database_title_div.add_class("maq_search_bar") content.add(database_title_div) database_title_div.add("Database") database_content_div = DivWdg() database_content_div.add_style("padding: 10px") database_content_div.add(self.get_database_wdg()) content.add(database_content_div) checkin_title_div = DivWdg() checkin_title_div.add_class("maq_search_bar") content.add(checkin_title_div) checkin_title_div.add("Database") checkin_content_div = DivWdg() checkin_content_div.add_style("padding: 10px") checkin_content_div.add(self.get_asset_dir_wdg() ) checkin_content_div.add(self.get_asset_management_wdg()) content.add(checkin_content_div) return top
def get_display(self): if self.is_popup: icon_chooser_popup_id = "IconChooserPopup" icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id, allow_page_activity=False, width="760px") icon_chooser_popup.add("Icon Chooser", "title") orig_icon_list = IconWdg.icons.keys() icon_list = ['-- No Icon --'] do_not_list = [ 'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE', 'CHECK_OUT_LG', 'CHECK_OUT', 'PUBLISH_LG' ] for k in orig_icon_list: if k in do_not_list: continue icon_list.append(k) icon_list.sort() icon_list_len = float(len(icon_list)) num_cols = 5 num_rows = int(math.ceil(icon_list_len / float(num_cols))) chooser_wrapper_div = DivWdg() chooser_wrapper_div.add_class("SPT_ICON_CHOOSER_WRAPPER_DIV") chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494", corner_size="10") chooser_bkg_rc.set_dimensions(width_str='740px', content_height_str='520px') table = Table() for r in range(num_rows): table.add_row() for c in range(num_cols): td = table.add_cell() td.add_styles( "color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;" ) td.add_styles( "border: 1px solid transparent; cursor: pointer;") td.add_behavior({ 'type': 'hover', 'mod_styles': 'background-color: #555555;' }) if c > 0: td.add_styles("border-left-color: black;") idx = int(c * num_rows + r) if idx < icon_list_len: icon_name = icon_list[idx] icon_path = '' if icon_name != '-- No Icon --': icon_path = IconWdg.get_icon_path(icon_name) icon = IconWdg(icon_name, icon_path) td.add(icon) text_span = SpanWdg() text_span.add_looks("fnt_code") text_span.add_styles("font-size: 10px") if len(icon_name) > 16: text_span.add("%s..." % icon_name[:15]) else: text_span.add(icon_name) td.add(text_span) if icon_name == '-- No Icon --': icon_name = '' td.add_class("SPT_ICON_SELECT_%s" % icon_name) if self.is_popup: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.popup.close( spt.popup.get_popup( bvr.src_el ) ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path, "ICON_CHOOSER_SELECTION_MADE") else: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.hide( cwd ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path, "ICON_CHOOSER_SELECTION_MADE") pass td.add_behavior({ 'type': 'click_up', 'cbjs_action': cbjs_action }) chooser_bkg_rc.add(table) chooser_wrapper_div.add(chooser_bkg_rc) if self.is_popup: icon_chooser_popup.add(chooser_wrapper_div, "content") return icon_chooser_popup return div
def get_display(my): top = DivWdg() my.set_as_panel(top) title_div = DivWdg() title_div.add_class("maq_search_bar") title_div.add("Diagnostics") top.add(title_div) tool_div = DivWdg() top.add(tool_div) refresh = IconButtonWdg("Refresh", IconWdg.REFRESH) refresh.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel"); spt.panel.refresh(top); ''' } ) tool_div.add(refresh) content = RoundedCornerDivWdg(hex_color_code="2F2F2F",corner_size="10") content.set_dimensions( width_str='300px', content_height_str=None ) top.add(content) server_title_div = DivWdg() server_title_div.add_class("maq_search_bar") content.add(server_title_div) server_title_div.add("Server") server_content_div = DivWdg() server_content_div.add_style("padding: 10px") server_content_div.add(my.get_ping_wdg()) server_content_div.add(my.get_load_balance_wdg()) content.add(server_content_div) database_title_div = DivWdg() database_title_div.add_class("maq_search_bar") content.add(database_title_div) database_title_div.add("Database") database_content_div = DivWdg() database_content_div.add_style("padding: 10px") database_content_div.add(my.get_database_wdg()) content.add(database_content_div) checkin_title_div = DivWdg() checkin_title_div.add_class("maq_search_bar") content.add(checkin_title_div) checkin_title_div.add("Database") checkin_content_div = DivWdg() checkin_content_div.add_style("padding: 10px") checkin_content_div.add(my.get_asset_dir_wdg() ) checkin_content_div.add(my.get_asset_management_wdg()) content.add(checkin_content_div) return top
def get_display(self): from tactic.ui.report import MMSUtility import datetime date = datetime.datetime.now() start_wday, end_wday = MMSUtility.get_week_range(date) self.prefix = 'week' top = DivWdg() top.add_class("spt_table_search") self.set_as_panel(top) from tactic.ui.container import RoundedCornerDivWdg inner = RoundedCornerDivWdg(corner_size=10, hex_color_code='949494') inner.set_dimensions(width_str="95%", content_height_str='95%', height_str="100%") inner.add_style("margin: 20px") top.add(inner) hidden = HiddenWdg("prefix", self.prefix) top.add(hidden) filter_data = FilterData.get() values = filter_data.get_values_by_index("week", 0) date_string = values.get("calendar") if not date_string: date_string = WebContainer.get_web().get_form_value("calendar") if date_string: date = parser.parse(date_string) else: date = datetime.datetime.now() week = 1 table = Table() table.add_style("color: black") table.add_style("width: 600px") table.add_row() inner.add(table) #inner.add("Range: %s - %s<br/><br/>" % (start_wday, end_wday)) table.add_cell("Week Of Date: <br/>") calendar = CalendarInputWdg('calendar') day_cbk = ''' var top = spt.get_parent(bvr.src_el, '.spt_table_search'); var week_el = top.getElement('.spt_calendar_week'); var input_el = top.getElement('.spt_calendar_input'); var value = input_el.value; var week = spt.date_util.ymd.get_week( value ) week_el.innerHTML = week + ''; ''' calendar.add_day_cbk(day_cbk) #calendar.set_option("first_day_of_week", 4) calendar.set_value(date.strftime("%Y-%m-%d")) # TODO: set default table.add_cell( calendar ) week = int(date.strftime("%W")) + 1 table.add_cell("Week: ") #select = SelectWdg("week") #select.add_class("action inputfield") #select.set_option("values", range(1,53) ) #select.set_value(week) #select.set_option( "size", "2" ) text = DivWdg() text.add_class("spt_calendar_week") text.add_style("width", "25px") text.add(week) table.add_cell(text) table.add_cell( self.get_search_wdg() ) return top
def get_example_display(my): div = DivWdg() div.add_styles("background: grey; padding: 10px; width: 450px;") div.add("<br/><br/>") from tactic.ui.container import RoundedCornerDivWdg rc_wdg = RoundedCornerDivWdg(corner_size=10) # rc_wdg.set_dimensions(width_str="100%", content_height_str='100%', height_str="100%") rs0_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside', # max_content_w=500, max_content_h=400, set_max_to_content_size=True, min_content_w=100, min_content_h=50) rs0_wdg.add(my.get_popwin_oversize_content()) rc_wdg.add(rs0_wdg) div.add(rc_wdg) div.add("<br/><br/>") div.add( "<p style='color: black;'>Resize/Scroll Widget example ...</p>") rs_wdg = ResizeScrollWdg(width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside') rs_wdg.add(my.get_popwin_oversize_content()) div.add(rs_wdg) div.add("<br/><br/>") div.add( "<p style='color: black;'>Resize/Scroll Widget example WITH NO RESIZE CAPABILITY" \ " (just scroll bars) ...</p>" ) rs2_wdg = ResizeScrollWdg(width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside', no_resize=True) rs2_wdg.add(my.get_popwin_oversize_content()) div.add(rs2_wdg) div.add("<br/><br/>") popwin_id = "NewPopupWindowTest" popwin_title = "New Popup Window Widget Test" popwin = PopWindowWdg(top_id=popwin_id, title=popwin_title, width=150, height=150) popwin.add(my.get_popwin_oversize_content()) div.add(popwin) pwin_launch = DivWdg() pwin_launch.add_styles( "cursor: pointer; background-color: red; color: black; border: 1px solid black; width: 100px; height: 50px;" ) pwin_launch.add_behavior({ 'type': 'click_up', 'cbjs_action': 'spt.popup.open("' + popwin_id + '");' }) pwin_launch.add("Click to launch New Popup Window") div.add(pwin_launch) div.add("<br/><br/>") test_div = DivWdg() test_div.add_styles( "background: black; padding: 10px; width: 350px; text-align: center;" ) test_div.add( SpanWdg("This black DIV has<br/>text-align set to center")) my_table = Table() my_table.add_row() my_table.add_cell("This").add_styles( "border: 1px solid white; padding: 4px;") my_table.add_cell("that").add_styles( "border: 1px solid white; padding: 4px;") my_table.add_cell("and").add_styles( "border: 1px solid white; padding: 4px;") my_table.add_cell("The").add_styles( "border: 1px solid white; padding: 4px;") my_table.add_cell("other").add_styles( "border: 1px solid white; padding: 4px;") test_div.add("<br/><br/>") test_div.add(my_table) test_div.add("<br/><br/>") tmp_div = DivWdg() tmp_div.add_styles( "width: 200px; background-color: green; color: black; padding: 10px;" ) tmp_div.add("I am a DIV without my margins set") test_div.add(tmp_div) test_div.add("<br/><br/>") tmp_div = DivWdg() tmp_div.add_styles( "width: 200px; background-color: green; color: black; padding: 10px;" ) tmp_div.center() tmp_div.add( "I am a DIV with my margins<br/>set using HtmlElement.center()") test_div.add(tmp_div) test_div.add("<br/><br/>") buttons_list = [{ 'label': "Insert", 'tip': "This is an insert", 'bvr': { 'cbjs_action': 'alert("Insert!");' } }, { 'label': 'Cancel', 'tip': 'Cancel', 'bvr': { 'cbjs_action': 'alert("Cancel!");' } }] buttons = TextBtnSetWdg(float="", align="center", buttons=buttons_list, spacing=6, size='medium', side_padding=4) test_div.add(buttons) div.add(test_div) div.add("<br/><br/>") div.add("<br/><br/>") buttons_list = [ { 'label': 'One', 'tip': 'Button One', 'bvr': { 'cbjs_action': 'alert("First button!");' } }, { 'label': 'Two', 'tip': 'Button Two', 'bvr': { 'cbjs_action': 'alert("Second button!");' } }, { 'label': 'Three', 'tip': 'Button Three', 'bvr': { 'cbjs_action': 'alert("Third button!");' } }, { 'label': 'Four', 'tip': 'Button Four', 'bvr': { 'cbjs_action': 'alert("Fourth button!");' } }, ] txt_btn_set = TextBtnSetWdg(float='right', buttons=buttons_list, spacing=6, size='large', side_padding=4) txt_btn_set.get_btn_by_label('Three').add_behavior({ 'type': 'click_up', 'modkeys': 'SHIFT', 'cbjs_action': 'alert("SHIFT happened!");' }) div.add(txt_btn_set) div.add("<br/><br/>") div.add("<br/><br/>") d1 = my.get_simple_div( "Drop Zone (runs cbjs_action of drag-drop element on drop)", None) d1.set_attr("SPT_ACCEPT_DROP", "Qweejibo") d1.add_behavior({ 'type': 'hover', 'mod_styles': 'background-color: green;' }) table1 = Table() tr = table1.add_row() tr.add_behavior({ 'type': 'hover', 'mod_styles': 'background-color: #f11; color: green' }) td = table1.add_cell('what') #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: orange;' } ) td = table1.add_cell('is') #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: green;' } ) div.add(table1) # d2 = my.get_simple_div( "Pick Up!", "white" ) d2 = my.get_simple_div("Override with 'accept_drop' behavior!", None) d2.add_looks("menu") # NOTE: with 'accept_drop' behavior you do not need to set the "SPT_ACCEPT_DROP" attribute on the # given drop-on element, just need to add the same value to a 'drop_code' attribute in the # 'accept_drop' bvr spec (doing this will automatically add it to the SPT_ACCEPT_DROP at # behavior construction time # so we do not need this here --> d2.set_attr("SPT_ACCEPT_DROP","Qweejibo") d2.add_behavior({ 'type': 'accept_drop', 'cbjs_action': 'log.debug("Override #1 on Qweejibo");', 'drop_code': 'Qweejibo' }) d2.add_behavior({ 'type': 'accept_drop', 'cbjs_action': ''' log.debug("Override #2 on Qweejibo"); var el = bvr._drop_source_bvr.src_el; el.setStyle("background-color", "white"); ''', 'drop_code': 'Qweejibo' }) d2.add_behavior({'type': 'hover', 'add_looks': 'menu_hover'}) d2.add_behavior({ 'type': 'hover', 'mod_styles': 'border: 1px solid red;', 'drag_drop_codes': 'Qweejibo', }) div.add(d1) div.add("<br/>") div.add(d2) div.add("<br/><br/>") div.add("<br/><br/>") btn = DivWdg() btn.add("TEST JS LOG TIME") btn.add_styles( "padding: 4px; width: 150px; cursor: pointer; background: red; color: white; " + "border: 1px solid white;") btn.add_behavior({ 'type': 'click', 'cbjs_action': 'spt.js_log.test_perf();' }) div.add(btn) div.add("<br/><br/>") dragme = DivWdg() dragme.add_styles( "background: blue; padding: 10px; width: 200px; border: 1px solid black; " \ "position: absolute; top: 200px; left: 400px; cursor: default;" ) dragme.add("Click me OR Drag me!") # dragme.add_behavior( { 'type': 'drag', 'drag_el': '@', 'use_default_cbs': 'true', # 'cbjs_action_onnomotion': 'alert("I\'ve been clicked!");' } ) dragme.add_behavior({ 'type': 'smart_drag', 'drag_el': '@', 'use_copy': 'true', 'use_delta': 'true', 'dx': 1, 'dy': 1, 'drop_code': 'Qweejibo', 'copy_styles': 'background: red; opacity: .3;', 'cbjs_action': 'alert("Got Qweejibo");', 'cbjs_action_onnomotion': 'alert("I\'ve been clicked!");' }) div.add(dragme) div.add("<br/><br/>") select = SelectWdg("OnChangeTestSelectWidget") select.add_behavior({ 'type': 'change', 'cbjs_preaction': ''' alert("Click OK then see Web Client Output Log for 'change' behavior activity"); log.debug("[preaction] My value is now: "+bvr.src_el.value); ''', 'cbjs_action': 'log.debug("[action] My value is now: "+bvr.src_el.value);', 'cbjs_postaction': 'log.debug("[postaction] My value is now: "+bvr.src_el.value);' }) select.add_behavior({ 'type': 'change', 'cbjs_action': 'log.debug("ORIG - stacked change behavior #2!");' }) select.add_behavior({ 'type': 'change', 'cbjs_action': 'log.debug("ORIG - stacked change behavior #3!");' }) select.add_behavior({ 'type': 'change', 'cbjs_action': 'log.debug("ORIG - stacked change behavior #4!");' }) select.set_option("values", "One|Day|In|Your|Life") select.set_value("Life") # Test for set_behavior override with stacked onchange behaviors ... ''' select.set_behavior( {'type': 'change', 'cbjs_action': 'alert("This is what me gots: "+bvr.src_el.value);'} ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #5!");'} ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #6!");'} ); ''' div.add(select) div.add("<br/><br/>") click_core_div = DivWdg() click_core_div.add_styles( "background-color: blue; color: white; border: 1px solid black; padding: 10px" ) click_core_div.add_styles("cursor: pointer;") click_core_div.add("Click me for preaction, action, postaction test") click_core_div.add_behavior({ 'type': 'click', 'cbjs_preaction': ''' alert("Click OK then see Web output log for 'click' behavior activity"); log.debug("Click pre-action"); ''', 'cbjs_action': 'log.debug("Click action");', 'cbjs_postaction': 'log.debug("Click post-action");' }) div.add(click_core_div) div.add("<br/><br/>") override = DivWdg() override.add_styles( "padding: 4px; background: white; color: black; border: 1px solid black; cursor: pointer;" ) override.add("Set Behavior Override Test") bvr = { 'type': 'click', 'modkeys': 'SHIFT', 'cbjs_action': 'alert("Load ONE");' } override.add_behavior(bvr) bvr = { 'type': 'click', 'modkeys': 'SHIFT', 'cbjs_action': 'alert("Load ONE OVERRIDDEN!");' } override.set_behavior(bvr) div.add(override) div.add("<br/><br/>") div1 = DivWdg() div1.add_styles( "background: #444477; border: solid 1px black; padding: 10px;") div1.add("Div1") div1.set_id("Div_1") div2 = DivWdg() div2.add_styles( "background: #4444BB; border: solid 1px black; padding: 10px; cursor: pointer;" ) div2.add("Div2") div2.set_id("Div_2") # div2.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("Div_3").inject("Div_2","after");' } ) div2.add_behavior({ 'type': 'click_up', 'cbjs_action': '$("Div_3").inject("Div_1","bottom");' }) div1.add(div2) div.add(div1) div.add("<br/><br/>") div3 = DivWdg() div3.add_styles( "background: #4444FF; border: solid 1px black; padding: 10px;") div3.add("Div3") div3.set_id("Div_3") div.add(div3) return div
def get_display(self): from pyasm.biz import Project security = Environment.get_security() if not security.check_access("builtin", "side_bar_schema", "allow", default="deny"): return DivWdg() section_div = LabeledHidableWdg(label="Schema Views") section_div.set_attr('spt_class_name', Common.get_full_class_name(self) ) palette = Palette.get() color = palette.color("background3") project_div = RoundedCornerDivWdg(hex_color_code=color,corner_size="10") project_div.set_dimensions( width_str='175px', content_height_str='100px' ) project = Project.get() project_code = project.get_code() project_type = project.get_type() div = DivWdg() section_div.add(project_div) project_div.add(div) # get project type schema schema = Schema.get_by_code(project_code) if schema: div.add( self.get_schema_wdg(schema) ) #if not project_type: # raise SetupException("Project type not found for this [%s]" %project_code) if project_type: schema = Schema.get_predefined_schema(project_type) if schema: div.add( self.get_schema_wdg(schema) ) schema = Schema.get_predefined_schema('config') div.add( self.get_schema_wdg(schema) ) schema = Schema.get_admin_schema() div.add( self.get_schema_wdg(schema) ) return section_div # create a fake schema project = Project.get() db_name = project.get_database() sql = DbContainer.get(db_name) tables = sql.get_tables() tables.sort() tables_str = "\n".join( ['<search_type name="%s"/>'%x for x in tables] ) # look at all of the search objects for mapped tables search = Search("sthpw/search_object") #search.add_where('''"namespace" = 'MMS' or namespace = '{project}' ''') search.add_filter("namespace", 'MMS') search.add_filter("namespace", '{project}') search.add_where("or") search_types = search.get_sobjects() schema_xml = ''' <schema> %s </schema> ''' % tables_str schema = SearchType.create("sthpw/schema") schema.set_value("code", "table") schema.set_value("schema", schema_xml) #div.add( self.get_schema_wdg(schema) ) return section_div
def get_display(self): top = DivWdg() search_type = self.kwargs.get("search_type") view = self.kwargs.get("view") element_name = self.kwargs.get("element_name") config_view = WidgetConfigView.get_by_search_type(search_type, view) #inner_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10") inner_div = RoundedCornerDivWdg(hex_color_code="272727", corner_size="10") inner_div.set_dimensions(width_str='400px', content_height_str='600px') top.add(inner_div) # add the save button buttons_list = [] buttons_list.append({ 'label': 'Save as View', 'tip': 'Save as View', 'bvr': { 'cbjs_action': "alert('Not Implemented')" } }) buttons_list.append({ 'label': 'Save as Def', 'tip': 'Save as Definition', 'bvr': { 'cbjs_action': "alert('Not Implemented')" } }) buttons = TextBtnSetWdg(float="right", buttons=buttons_list, spacing=6, size='small', side_padding=4) inner_div.add(buttons) title_div = DivWdg() title_div.add_style("margin-bottom: 10px") title_div.add_class("maq_search_bar") title_div.add("Element Definition") inner_div.add(title_div) test = SimpleElementDefinitionWdg(config_view=config_view, element_name=element_name) inner_div.add(test) config_title_wdg = DivWdg() inner_div.add(config_title_wdg) config_title_wdg.add("<b>Definitions in config</b>") config_title_wdg.add_style("margin: 15px 0px 5px 0px") for config in config_view.get_configs(): view = config.get_view() xml = config.get_element_xml(element_name) config_div = DivWdg() inner_div.add(config_div) # add the title from pyasm.widget import SwapDisplayWdg, IconWdg view_div = DivWdg() view_div.add_class("spt_view") config_div.add(view_div) if not xml: icon_wdg = IconWdg("Nothing defined", IconWdg.DOT_RED) icon_wdg.add_style("float: right") view_div.add(icon_wdg) else: icon_wdg = IconWdg("Is defined", IconWdg.DOT_GREEN) icon_wdg.add_style("float: right") view_div.add(icon_wdg) swap = SwapDisplayWdg() view_div.add(swap) swap.add_action_script(''' var info_wdg = bvr.src_el.getParent('.spt_view').getElement('.spt_info'); spt.toggle_show_hide(info_wdg); ''') mode = "predefined" file_path = config.get_file_path() if not file_path: mode = "database" elif file_path == 'generated': mode = 'generated' # display the title view_div.add("%s" % view) view_div.add(" - [%s]" % mode) info_div = DivWdg() info_div.add_class("spt_info") info_div.add_style("margin-left: 20px") info_div.add_style("display: none") #if not xml: # info_div.add_style("display: none") #else: # swap.set_off() view_div.add(info_div) path_div = DivWdg() if not file_path: file_path = mode path_div.add("Defined in: %s" % file_path) info_div.add(path_div) text_wdg = TextAreaWdg() text_wdg.set_option("rows", 15) text_wdg.set_option("cols", 80) text_wdg.set_value(xml) info_div.add(text_wdg) #view_div.add("<hr/>") return top
def get_display(self): web = WebContainer.get_web() palette = web.get_palette() widget = DivWdg() widget.add_style("width: 100%") widget.add_style("text-align: center") from tactic.ui.app import PageHeaderWdg header = PageHeaderWdg(show_project=False) widget.add(header) security = Environment.get_security() search = Search("sthpw/project") search.add_where("\"code\" not in ('sthpw', 'admin', 'unittest')") search.add_where("\"type\" not in ('resource')") # hide template projects if security.check_access("builtin", "view_site_admin", "allow") or security.check_access( "builtin", "view_template_projects", "allow"): pass else: search.add_op("begin") search.add_filter("is_template", True, op='!=') search.add_filter("is_template", 'NULL', quoted=False, op='is') search.add_op("or") search.add_order_by("category") projects = search.get_sobjects() num = len(projects) # sort by project if num < 5: columns = 1 icon_size = 90 width = 500 elif num < 15: columns = 2 icon_size = 60 width = 700 else: columns = 3 icon_size = 45 width = 800 div = DivWdg() div.add_style("margin-left: auto") div.add_style("margin-right: auto") #div.add_style("width: 520px") div.center() widget.add(div) #logo = TacticLogoWdg() #div.add(logo) div.add("<br/>" * 3) bg_color = palette.color("background") #div.add_color("color", "color") from tactic.ui.container import RoundedCornerDivWdg div = RoundedCornerDivWdg(hex_color_code=bg_color, corner_size="10") div.set_dimensions(width_str='%spx' % width, content_height_str='50px') div.add_border() div.add_style("overflow: hidden") div.set_box_shadow() div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("width: %spx" % width) table = Table() table.set_max_width() table.add_style("margin-left: auto") table.add_style("margin-right: auto") table.add_style("background-color: %s" % bg_color) table.add_color("color", "color") tr, td = table.add_row_cell() logo_div = DivWdg() logo_div.add_gradient("background", "background3", -5, -10) td.add(logo_div) logo = TacticLogoWdg() logo_div.add(logo) logo_div.add_style("margin: -6 -6 6 -6") app_name = WebContainer.get_web().get_app_name() security = Environment.get_security() last_category = None has_category = False index = 0 # if TACTIC has not been set up, show the configuration page # FIXME: what is the requirement for is_installed? config_path = Config.get_config_path() if not os.path.exists(config_path): is_installed = False else: is_installed = True #is_installed = True # filter out projects due to security filtered = [] for i, project in enumerate(projects): from pyasm.security import get_security_version security_version = get_security_version() if security_version >= 2: key = {"code": project.get_code()} key2 = {"code": "*"} keys = [key, key2] default = "deny" if not security.check_access( "project", keys, "allow", default=default): continue else: if not security.check_access( "project", project.get_code(), "view", default="allow"): continue filtered.append(project) projects = filtered if not is_installed: tr, td = table.add_row_cell() #from tactic.ui.startup import DbConfigWdg #td.add(DbConfigWdg()) title_div = DivWdg() td.add(title_div) title_div.add_style("padding: 5px") title_div.add_style("font-weight: bold") title_div.add("Getting Started ...") title_div.add_gradient("background", "background", -10) projects_div = DivWdg() projects_div.add_style("padding: 20px") td.add(projects_div) projects_div.add_style("text-align: center") projects_div.add("Welcome to TACTIC ...<br/>") projects_div.add_style("font-size: 22px") msg_div = DivWdg() td.add(msg_div) msg_div.add( "Configure TACTIC to connect to an external database and set up asset folders.<br/><br/>" ) msg_div.add_style("text-align: center") action = ActionButtonWdg(title='Confgure', size='medium') action.add_style("margin-left: auto") action.add_style("margin-right: auto") td.add(action) action.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic/admin/#/link/configure"; ''' }) msg_div = DivWdg() td.add(msg_div) msg_div.add( "<br/><br/>Or start using TACTIC with default configuration with an internal database.<br/><br/>" ) msg_div.add_style("text-align: center") action = ActionButtonWdg(title='Start >>', size='medium') action.add_style("margin-left: auto") action.add_style("margin-right: auto") td.add(action) action.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic"; ''' }) msg_div = DivWdg() td.add(msg_div) msg_div.add("<br/><br/><br/>") msg_div.add_style("text-align: center") elif projects: num_projets = 0 for i, project in enumerate(projects): category = project.get_value("category") if category is not None and category != last_category: table.add_row() tr, td = table.add_row_cell() category_div = DivWdg() td.add(category_div) if has_category and not category: category_div.add(" ") else: category_div.add(category) category_div.add_style("padding: 8px") category_div.add_style("font-size: 16px") category_div.add_style("font-weight: bold") category_div.add_color("color", "color") category_div.add_gradient("background", "background3", 0, -10) category_div.add_color("color", "color3") #category_div.set_round_corners() if last_category == None: category_div.add_style("margin: -6 -6 6 -6") else: category_div.add_style("margin: 15 -6 0 -6") table.add_row() has_category = True index = 0 index += 1 last_category = category thumb = ThumbWdg() thumb.set_name("snapshot") thumb.set_sobject(project) thumb.set_show_clipboard(False) thumb.set_has_img_link(False) thumb.set_icon_size(icon_size) code = project.get_code() title = project.get_value("title") # Restrict the length of project name if len(title) >= 36: title = title[:36] + "..." if app_name != 'Browser': href = HtmlElement.href(HtmlElement.h2(title), ref='/tactic/%s/%s'\ %(code, app_name)) img_href = HtmlElement.href(thumb, ref='/tactic/%s/%s'\ %(code, app_name)) link = '/tactic/%s/%s' % (code, app_name) else: href = HtmlElement.href(HtmlElement.h2(title), ref="/tactic/%s/" % code) img_href = DivWdg(thumb) img_href.add_behavior({ 'type': 'click_up', 'code': code, 'cbjs_action': ''' document.location = '/tactic/'+bvr.code+'/'; ''' }) link = '/tactic/%s/' % code href = href.get_buffer_display() if (index - 1) % columns == 0: table.add_row() td = table.add_cell() img_div = DivWdg() img_div.add(img_href) img_div.add_style("margin-right: 20px") img_div.add_style("float: left") img_div.add_border() #img_div.set_round_corners() img_div.set_box_shadow("0px 1px 5px") project_div = DivWdg() td.add(project_div) td.add_style("width: 230px") project_div.add_style("font-size: 16px") project_div.add_style("font-weight: bold") project_div.add_style("vertical-align: middle") project_div.add(img_div) #project_div.add(href) project_div.add(title) if project.get_value("is_template") == True: project_div.add( "<br/><i style='opacity: 0.5; font-size: 12px'>(template)</i>" ) project_div.add_style("height: %spx" % (icon_size - 10)) project_div.add_style("padding: 8px 10px 2px 20px") project_div.add_color("background", "background") project_div.add_behavior({ 'type': 'hover', 'add_color_modifier': -3, 'cb_set_prefix': 'spt.mouse.table_layout_hover', }) project_div.set_round_corners() project_div.add_class("hand") project_div.add_behavior({ 'type': 'click_up', 'link': link, 'title': title, 'cbjs_action': ''' document.location = bvr.link; ''' }) elif not security.check_access( "builtin", "view_site_admin", "allow", default="deny") and not security.check_access( "builtin", "create_projects", "allow", default="deny"): tr, td = table.add_row_cell() msg_div = DivWdg() td.add(msg_div) from pyasm.widget import IconWdg icon = IconWdg("WARNING", IconWdg.WARNING) msg_div.add(icon) msg_div.add("You are not permitted to view any projects") msg_div.add_style("font-size: 16px") msg_div.add_style("text-align: center") msg_div.add_style("font-weight: bold") msg_div.add_style("margin: 50px") msg_div.add("<br/>" * 2) msg_div.add("Please click to Sign Out:<br/>") action = ActionButtonWdg(title='Sign Out >>', size='m') msg_div.add(action) action.add_style('margin: 5px auto') action.add_style('text-align: center') web = WebContainer.get_web() action.add_behavior({ 'type': 'click_up', 'login': web.get_user_name(), 'cbjs_action': ''' var server = TacticServerStub.get(); server.execute_cmd("SignOutCmd", {login: bvr.login} ); window.location.href='/'; ''' }) else: tr, td = table.add_row_cell() title_div = DivWdg() td.add(title_div) title_div.add_style("padding: 10px") title_div.add_style("margin: -8px -6px 20px -6px") title_div.add_style("font-weight: bold") title_div.add("Getting Started ...") title_div.add_gradient("background", "background", -10) projects_div = DivWdg() projects_div.add_style("padding: 20px") td.add(projects_div) projects_div.add_style("text-align: center") projects_div.add("No Projects have been created ...<br/><br/>") projects_div.add_style("font-size: 22px") action = ActionButtonWdg(title='Create Project >>', size='large') action.add_style("margin-left: auto") action.add_style("margin-right: auto") projects_div.add(action) action.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = "/tactic/admin/link/create_project"; ''' }) if security.check_access("builtin", "view_site_admin", "allow"): admin_div = DivWdg() #href = HtmlElement.href(HtmlElement.h2('Admin Site'), ref='/tactic/admin/') #admin_div.add(href) #admin_div.add_border() admin_div.add_style("font-size: 16px") admin_div.add_style("font-weight: bold") admin_div.add_style("height: 30px") link_div = DivWdg() link_div.add_class("hand") admin_div.add(link_div) link_div.add("Go to Admin Site") link_div.add_style("text-align: center") link_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' document.location = '/tactic/admin/'; ''' }) tr, td = table.add_row_cell() td.add("<hr/><br/>") td.add(admin_div) div.add(table) widget.add(div) # Note sure what this is for #BaseAppServer.add_onload_script('spt.first_load=false') div.add_behavior({ 'type': 'load', 'cbjs_action': '''spt.first_load=false''' }) return widget
def get_display(my): top = DivWdg() search_type = my.kwargs.get("search_type") view = my.kwargs.get("view") element_name = my.kwargs.get("element_name") config_view = WidgetConfigView.get_by_search_type(search_type, view) #inner_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10") inner_div = RoundedCornerDivWdg(hex_color_code="272727",corner_size="10") inner_div.set_dimensions( width_str='400px', content_height_str='600px' ) top.add(inner_div) # add the save button buttons_list = [] buttons_list.append( {'label': 'Save as View', 'tip': 'Save as View', 'bvr': { 'cbjs_action': "alert('Not Implemented')" } }) buttons_list.append( {'label': 'Save as Def', 'tip': 'Save as Definition', 'bvr': { 'cbjs_action': "alert('Not Implemented')" } }) buttons = TextBtnSetWdg( float="right", buttons=buttons_list, spacing=6, size='small', side_padding=4 ) inner_div.add(buttons) title_div = DivWdg() title_div.add_style("margin-bottom: 10px") title_div.add_class("maq_search_bar") title_div.add("Element Definition") inner_div.add(title_div) test = SimpleElementDefinitionWdg(config_view=config_view, element_name=element_name) inner_div.add(test) config_title_wdg = DivWdg() inner_div.add(config_title_wdg) config_title_wdg.add("<b>Definitions in config</b>") config_title_wdg.add_style("margin: 15px 0px 5px 0px") for config in config_view.get_configs(): view = config.get_view() xml = config.get_element_xml(element_name) config_div = DivWdg() inner_div.add(config_div) # add the title from pyasm.widget import SwapDisplayWdg, IconWdg view_div = DivWdg() view_div.add_class("spt_view") config_div.add(view_div) if not xml: icon_wdg = IconWdg( "Nothing defined", IconWdg.DOT_RED ) icon_wdg.add_style("float: right") view_div.add(icon_wdg) else: icon_wdg = IconWdg( "Is defined", IconWdg.DOT_GREEN ) icon_wdg.add_style("float: right") view_div.add(icon_wdg) swap = SwapDisplayWdg() view_div.add(swap) swap.add_action_script(''' var info_wdg = bvr.src_el.getParent('.spt_view').getElement('.spt_info'); spt.toggle_show_hide(info_wdg); ''') mode = "predefined" file_path = config.get_file_path() if not file_path: mode = "database" elif file_path == 'generated': mode = 'generated' # display the title view_div.add("%s" % view) view_div.add(" - [%s]" % mode) info_div = DivWdg() info_div.add_class("spt_info") info_div.add_style("margin-left: 20px") info_div.add_style("display: none") #if not xml: # info_div.add_style("display: none") #else: # swap.set_off() view_div.add(info_div) path_div = DivWdg() if not file_path: file_path = mode path_div.add("Defined in: %s" % file_path) info_div.add(path_div) text_wdg = TextAreaWdg() text_wdg.set_option("rows", 15) text_wdg.set_option("cols", 80) text_wdg.set_value(xml) info_div.add(text_wdg) #view_div.add("<hr/>") return top
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 get_display(self): from tactic.ui.report import MMSUtility import datetime date = datetime.datetime.now() start_wday, end_wday = MMSUtility.get_week_range(date) self.prefix = 'week' top = DivWdg() top.add_class("spt_table_search") self.set_as_panel(top) from tactic.ui.container import RoundedCornerDivWdg inner = RoundedCornerDivWdg(corner_size=10, hex_color_code='949494') inner.set_dimensions(width_str="95%", content_height_str='95%', height_str="100%") inner.add_style("margin: 20px") top.add(inner) hidden = HiddenWdg("prefix", self.prefix) top.add(hidden) filter_data = FilterData.get() values = filter_data.get_values_by_index("week", 0) date_string = values.get("calendar") if not date_string: date_string = WebContainer.get_web().get_form_value("calendar") if date_string: date = parser.parse(date_string) else: date = datetime.datetime.now() week = 1 table = Table() table.add_style("color: black") table.add_style("width: 600px") table.add_row() inner.add(table) #inner.add("Range: %s - %s<br/><br/>" % (start_wday, end_wday)) table.add_cell("Week Of Date: <br/>") calendar = CalendarInputWdg('calendar') day_cbk = ''' var top = spt.get_parent(bvr.src_el, '.spt_table_search'); var week_el = top.getElement('.spt_calendar_week'); var input_el = top.getElement('.spt_calendar_input'); var value = input_el.value; var week = spt.date_util.ymd.get_week( value ) week_el.innerHTML = week + ''; ''' calendar.add_day_cbk(day_cbk) #calendar.set_option("first_day_of_week", 4) calendar.set_value(date.strftime("%Y-%m-%d")) # TODO: set default table.add_cell(calendar) week = int(date.strftime("%W")) + 1 table.add_cell("Week: ") #select = SelectWdg("week") #select.add_class("action inputfield") #select.set_option("values", range(1,53) ) #select.set_value(week) #select.set_option( "size", "2" ) text = DivWdg() text.add_class("spt_calendar_week") text.add_style("width", "25px") text.add(week) table.add_cell(text) table.add_cell(self.get_search_wdg()) return top
def get_display(my): if my.is_popup: icon_chooser_popup_id = "IconChooserPopup" icon_chooser_popup = PopupWdg(id=icon_chooser_popup_id, allow_page_activity=False, width="760px") icon_chooser_popup.add("Icon Chooser", "title") orig_icon_list = IconWdg.icons.keys() icon_list = ['-- No Icon --'] do_not_list = [ 'MAYA', 'HOUDINI', 'PROGRESS', 'CLIP_PLAY', 'XSI', 'CLIP_PAUSE', 'CHECK_OUT_LG','CHECK_OUT','PUBLISH_LG' ] for k in orig_icon_list: if k in do_not_list: continue icon_list.append(k) icon_list.sort() icon_list_len = float(len(icon_list)) num_cols = 5 num_rows = int( math.ceil( icon_list_len / float(num_cols) ) ) chooser_wrapper_div = DivWdg() chooser_wrapper_div.add_class( "SPT_ICON_CHOOSER_WRAPPER_DIV" ) chooser_bkg_rc = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10") chooser_bkg_rc.set_dimensions( width_str='740px', content_height_str='520px' ) table = Table() for r in range(num_rows): table.add_row() for c in range(num_cols): td = table.add_cell() td.add_styles("color: black; overflow: hidden; width: 140px; max-width: 140px; height: 20px;") td.add_styles("border: 1px solid transparent; cursor: pointer;") td.add_behavior( {'type': 'hover', 'mod_styles': 'background-color: #555555;'} ) if c > 0: td.add_styles("border-left-color: black;") idx = int( c * num_rows + r ) if idx < icon_list_len: icon_name = icon_list[ idx ] icon_path = '' if icon_name != '-- No Icon --': icon_path = IconWdg.get_icon_path(icon_name) icon = IconWdg( icon_name, icon_path ) td.add(icon) text_span = SpanWdg() text_span.add_looks( "fnt_code" ) text_span.add_styles( "font-size: 10px" ) if len(icon_name) > 16: text_span.add( "%s..." % icon_name[:15] ) else: text_span.add( icon_name ) td.add( text_span ) if icon_name == '-- No Icon --': icon_name = '' td.add_class( "SPT_ICON_SELECT_%s" % icon_name ) if my.is_popup: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.popup.close( spt.popup.get_popup( bvr.src_el ) ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE") else: cbjs_action = ''' var cwd = bvr.src_el.getParent(".SPT_ICON_CHOOSER_WRAPPER_DIV"); cwd.setProperty("spt_icon_selected", "%s"); cwd.setProperty("spt_icon_path", "%s"); spt.hide( cwd ); spt.named_events.fire_event("%s",bvr); ''' % (icon_name, icon_path,"ICON_CHOOSER_SELECTION_MADE") pass td.add_behavior( {'type': 'click_up', 'cbjs_action': cbjs_action} ) chooser_bkg_rc.add( table ) chooser_wrapper_div.add( chooser_bkg_rc ) if my.is_popup: icon_chooser_popup.add(chooser_wrapper_div, "content") return icon_chooser_popup return div
def get_example_display(self): div = DivWdg() div.add_styles("background: grey; padding: 10px; width: 450px;") div.add( "<br/><br/>" ) from tactic.ui.container import RoundedCornerDivWdg rc_wdg = RoundedCornerDivWdg(corner_size=10) # rc_wdg.set_dimensions(width_str="100%", content_height_str='100%', height_str="100%") rs0_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside', # max_content_w=500, max_content_h=400, set_max_to_content_size=True, min_content_w=100, min_content_h=50 ) rs0_wdg.add( self.get_popwin_oversize_content() ) rc_wdg.add( rs0_wdg ) div.add( rc_wdg ) div.add( "<br/><br/>" ) div.add( "<p style='color: black;'>Resize/Scroll Widget example ...</p>" ) rs_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside' ) rs_wdg.add( self.get_popwin_oversize_content() ) div.add( rs_wdg ) div.add( "<br/><br/>" ) div.add( "<p style='color: black;'>Resize/Scroll Widget example WITH NO RESIZE CAPABILITY" \ " (just scroll bars) ...</p>" ) rs2_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside', no_resize=True ) rs2_wdg.add( self.get_popwin_oversize_content() ) div.add( rs2_wdg ) div.add( "<br/><br/>" ) popwin_id = "NewPopupWindowTest" popwin_title = "New Popup Window Widget Test" popwin = PopWindowWdg(top_id=popwin_id, title=popwin_title, width=150, height=150) popwin.add( self.get_popwin_oversize_content() ) div.add( popwin ) pwin_launch = DivWdg() pwin_launch.add_styles("cursor: pointer; background-color: red; color: black; border: 1px solid black; width: 100px; height: 50px;") pwin_launch.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open("' + popwin_id + '");'} ) pwin_launch.add("Click to launch New Popup Window") div.add( pwin_launch ) div.add( "<br/><br/>" ) test_div = DivWdg() test_div.add_styles("background: black; padding: 10px; width: 350px; text-align: center;") test_div.add( SpanWdg("This black DIV has<br/>text-align set to center") ) my_table = Table() my_table.add_row() my_table.add_cell("This").add_styles("border: 1px solid white; padding: 4px;") my_table.add_cell("that").add_styles("border: 1px solid white; padding: 4px;") my_table.add_cell("and").add_styles("border: 1px solid white; padding: 4px;") my_table.add_cell("The").add_styles("border: 1px solid white; padding: 4px;") my_table.add_cell("other").add_styles("border: 1px solid white; padding: 4px;") test_div.add( "<br/><br/>" ) test_div.add( my_table ) test_div.add( "<br/><br/>" ) tmp_div = DivWdg() tmp_div.add_styles("width: 200px; background-color: green; color: black; padding: 10px;") tmp_div.add("I am a DIV without self margins set") test_div.add(tmp_div) test_div.add( "<br/><br/>" ) tmp_div = DivWdg() tmp_div.add_styles("width: 200px; background-color: green; color: black; padding: 10px;") tmp_div.center() tmp_div.add("I am a DIV with self margins<br/>set using HtmlElement.center()") test_div.add(tmp_div) test_div.add( "<br/><br/>" ) buttons_list = [ { 'label': "Insert", 'tip': "This is an insert", 'bvr': {'cbjs_action': 'alert("Insert!");'} }, { 'label': 'Cancel', 'tip': 'Cancel', 'bvr': {'cbjs_action': 'alert("Cancel!");'} } ] buttons = TextBtnSetWdg( float="", align="center", buttons=buttons_list, spacing=6, size='medium', side_padding=4 ) test_div.add( buttons ) div.add(test_div) div.add( "<br/><br/>" ) div.add( "<br/><br/>" ) buttons_list = [ {'label': 'One', 'tip': 'Button One', 'bvr': {'cbjs_action': 'alert("First button!");'} }, {'label': 'Two', 'tip': 'Button Two', 'bvr': {'cbjs_action': 'alert("Second button!");'} }, {'label': 'Three', 'tip': 'Button Three', 'bvr': {'cbjs_action': 'alert("Third button!");'} }, {'label': 'Four', 'tip': 'Button Four', 'bvr': {'cbjs_action': 'alert("Fourth button!");'} }, ] txt_btn_set = TextBtnSetWdg( float='right', buttons=buttons_list, spacing=6, size='large', side_padding=4 ) txt_btn_set.get_btn_by_label('Three').add_behavior( {'type': 'click_up', 'modkeys': 'SHIFT', 'cbjs_action': 'alert("SHIFT happened!");'} ) div.add( txt_btn_set ) div.add( "<br/><br/>" ) div.add( "<br/><br/>" ) d1 = self.get_simple_div( "Drop Zone (runs cbjs_action of drag-drop element on drop)", None ) d1.set_attr("SPT_ACCEPT_DROP","Qweejibo") d1.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: green;' } ) table1 = Table() tr = table1.add_row() tr.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: #f11; color: green' } ) td = table1.add_cell('what') #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: orange;' } ) td = table1.add_cell('is') #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: green;' } ) div.add(table1) # d2 = self.get_simple_div( "Pick Up!", "white" ) d2 = self.get_simple_div( "Override with 'accept_drop' behavior!", None ) d2.add_looks("menu"); # NOTE: with 'accept_drop' behavior you do not need to set the "SPT_ACCEPT_DROP" attribute on the # given drop-on element, just need to add the same value to a 'drop_code' attribute in the # 'accept_drop' bvr spec (doing this will automatically add it to the SPT_ACCEPT_DROP at # behavior construction time # so we do not need this here --> d2.set_attr("SPT_ACCEPT_DROP","Qweejibo") d2.add_behavior( { 'type': 'accept_drop', 'cbjs_action': 'log.debug("Override #1 on Qweejibo");', 'drop_code': 'Qweejibo' } ) d2.add_behavior( { 'type': 'accept_drop', 'cbjs_action': ''' log.debug("Override #2 on Qweejibo"); var el = bvr._drop_source_bvr.src_el; el.setStyle("background-color", "white"); ''', 'drop_code': 'Qweejibo' } ) d2.add_behavior( { 'type': 'hover', 'add_looks': 'menu_hover' } ) d2.add_behavior( { 'type': 'hover', 'mod_styles': 'border: 1px solid red;', 'drag_drop_codes': 'Qweejibo', } ) div.add( d1 ) div.add( "<br/>" ) div.add( d2 ) div.add( "<br/><br/>" ) div.add( "<br/><br/>" ) btn = DivWdg() btn.add("TEST JS LOG TIME") btn.add_styles("padding: 4px; width: 150px; cursor: pointer; background: red; color: white; " + "border: 1px solid white;") btn.add_behavior( { 'type': 'click', 'cbjs_action': 'spt.js_log.test_perf();' } ) div.add( btn ) div.add( "<br/><br/>" ) dragme = DivWdg() dragme.add_styles( "background: blue; padding: 10px; width: 200px; border: 1px solid black; " \ "position: absolute; top: 200px; left: 400px; cursor: default;" ) dragme.add( "Click me OR Drag me!" ) # dragme.add_behavior( { 'type': 'drag', 'drag_el': '@', 'use_default_cbs': 'true', # 'cbjs_action_onnomotion': 'alert("I\'ve been clicked!");' } ) dragme.add_behavior( { 'type': 'smart_drag', 'drag_el': '@', 'use_copy': 'true', 'use_delta': 'true', 'dx': 1, 'dy': 1, 'drop_code': 'Qweejibo', 'copy_styles': 'background: red; opacity: .3;', 'cbjs_action': 'alert("Got Qweejibo");', 'cbjs_action_onnomotion': 'alert("I\'ve been clicked!");' } ) div.add( dragme ) div.add( "<br/><br/>" ) select = SelectWdg("OnChangeTestSelectWidget") select.add_behavior( {'type': 'change', 'cbjs_preaction': ''' alert("Click OK then see Web Client Output Log for 'change' behavior activity"); log.debug("[preaction] My value is now: "+bvr.src_el.value); ''', 'cbjs_action': 'log.debug("[action] My value is now: "+bvr.src_el.value);', 'cbjs_postaction': 'log.debug("[postaction] My value is now: "+bvr.src_el.value);' } ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("ORIG - stacked change behavior #2!");'} ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("ORIG - stacked change behavior #3!");'} ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("ORIG - stacked change behavior #4!");'} ); select.set_option("values", "One|Day|In|Your|Life") select.set_value("Life") # Test for set_behavior override with stacked onchange behaviors ... ''' select.set_behavior( {'type': 'change', 'cbjs_action': 'alert("This is what me gots: "+bvr.src_el.value);'} ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #5!");'} ); select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #6!");'} ); ''' div.add(select) div.add( "<br/><br/>" ) click_core_div = DivWdg() click_core_div.add_styles( "background-color: blue; color: white; border: 1px solid black; padding: 10px" ) click_core_div.add_styles( "cursor: pointer;" ) click_core_div.add( "Click me for preaction, action, postaction test" ) click_core_div.add_behavior( {'type': 'click', 'cbjs_preaction': ''' alert("Click OK then see Web output log for 'click' behavior activity"); log.debug("Click pre-action"); ''', 'cbjs_action': 'log.debug("Click action");', 'cbjs_postaction': 'log.debug("Click post-action");' } ) div.add( click_core_div ) div.add( "<br/><br/>" ) override = DivWdg() override.add_styles( "padding: 4px; background: white; color: black; border: 1px solid black; cursor: pointer;" ) override.add( "Set Behavior Override Test" ) bvr = { 'type': 'click', 'modkeys': 'SHIFT', 'cbjs_action': 'alert("Load ONE");' } override.add_behavior( bvr ) bvr = { 'type': 'click', 'modkeys': 'SHIFT', 'cbjs_action': 'alert("Load ONE OVERRIDDEN!");' } override.set_behavior( bvr ) div.add(override) div.add( "<br/><br/>" ) div1 = DivWdg() div1.add_styles("background: #444477; border: solid 1px black; padding: 10px;") div1.add("Div1") div1.set_id("Div_1") div2 = DivWdg() div2.add_styles("background: #4444BB; border: solid 1px black; padding: 10px; cursor: pointer;") div2.add("Div2") div2.set_id("Div_2") # div2.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("Div_3").inject("Div_2","after");' } ) div2.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("Div_3").inject("Div_1","bottom");' } ) div1.add( div2 ) div.add(div1) div.add("<br/><br/>") div3 = DivWdg() div3.add_styles("background: #4444FF; border: solid 1px black; padding: 10px;") div3.add("Div3") div3.set_id("Div_3") div.add(div3) return div