def get_save_wdg(my): # add the popup popup = PopupWdg(id="save_search_wdg") popup.add("Save Search", "title") div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = {"type": "click", "mouse_btn": "LMB", "cbjs_action": "spt.dg_table.save_search_cbk(evt, bvr);"} save_button.add_behavior(behavior) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) popup.add(div, "content") return popup
def get_predefined_wdg(self): project = Project.get() project_type = project.get_type() from tactic.ui.container import PopupWdg popup = PopupWdg(id="predefined_db_columns", allow_page_activity=True, width="320px") popup.add_title("Predefined Database Columns") popup.add( self.get_section_wdg(view='predefined', default=True)) return popup
def get_predefined_wdg(my): project = Project.get() project_type = project.get_type() from tactic.ui.container import PopupWdg popup = PopupWdg(id="predefined_db_columns", allow_page_activity=True, width="320px") popup.add_title("Predefined Database Columns") popup.add(my.get_section_wdg(view='predefined', default=True)) return popup
def get_display(self): sbox_popup_id = 'SearchBoxPopupWdg' search_container = DivWdg() search_container.set_id( "%s_search" % sbox_popup_id) search_container.add_style("display", "block") search_container.set_attr("spt_search_type", self.search_type) search_container.set_attr("spt_search_view", self.search_view) search_container.add(self.search_wdg) sbox_popup = PopupWdg(id=sbox_popup_id, allow_page_activity=True, width="720px") sbox_popup.add("TACTIC Search Box Window", "title") sbox_popup.add( search_container, 'content' ) return sbox_popup
def get_display(my): sbox_popup_id = 'SearchBoxPopupWdg' search_container = DivWdg() search_container.set_id( "%s_search" % sbox_popup_id) search_container.add_style("display", "block") search_container.set_attr("spt_search_type", my.search_type) search_container.set_attr("spt_search_view", my.search_view) search_container.add(my.search_wdg) sbox_popup = PopupWdg(id=sbox_popup_id, allow_page_activity=True, width="720px") sbox_popup.add("TACTIC Search Box Window", "title") sbox_popup.add( search_container, 'content' ) return sbox_popup
def get_display(my): use_popup = my.kwargs.get("use_popup") if use_popup in [True, 'true']: use_popup = True else: use_popup = False div = DivWdg() content = my.get_content() content.add_style("width: 600px") content.add_style("margin-left: auto") content.add_style("margin-right: auto") from tactic.ui.container import PopupWdg if use_popup: popup = PopupWdg(id="LicenseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close=my.allow_close) popup.add("License Manager", "title") popup.add(content, "content") div.add(popup) behavior = { 'type': 'load', 'cbjs_action': ''' var el = $(LicenseManagerWdg); el.setStyle("display",""); //var parent = el.getParent(".spt_panel"); //parent.setStyle("left: 0px"); //parent.setStyle("margin-right: auto"); ''' } div.add_behavior(behavior) else: div.add(content) content.add_style("height: 500px") return div
def get_display(my): popup = PopupWdg( id="HelpPopupWdg", allow_page_activity=True, width="600px" ) popup.add("TACTIC™ Help", "title") content_div = DivWdg() inner_div = DivWdg() inner_div.set_style("background: #2f2f2f; color: #000000; border: 1px solid #000000; padding: 2px;") # TEMP ... inner_div.add( "Under Construction!" ); # Finished generating tools for Action Bar ... content_div.add(inner_div) popup.add(content_div, 'content') return popup
def get_display(self): popup = PopupWdg( id="HelpPopupWdg", allow_page_activity=True, width="600px" ) popup.add("TACTIC™ Help", "title") content_div = DivWdg() inner_div = DivWdg() inner_div.set_style("background: #2f2f2f; color: #000000; border: 1px solid #000000; padding: 2px;") # TEMP ... inner_div.add( "Under Construction!" ); # Finished generating tools for Action Bar ... content_div.add(inner_div) popup.add(content_div, 'content') return popup
def get_retrieve_wdg(my): # add the popup popup = PopupWdg(id='retrieve_search_wdg') popup.add("Retrieve Saved Search", "title") div = DivWdg() div.add("List of Saved Searches: ") div.add(HtmlElement.br(2)) try: search = Search("config/widget_config") search.add_where("\"view\" like 'saved_search:%'") search.add_filter("search_type", my.search_type) configs = search.get_sobjects() except SearchException, e: print "WARNING: ", e configs = []
def get_retrieve_wdg(my): # add the popup popup = PopupWdg(id='retrieve_search_wdg') popup.add("Retrieve Saved Search", "title") div = DivWdg() div.add("List of Saved Searches: ") div.add(HtmlElement.br(2)) try: search = Search("config/widget_config") search.add_where("\"view\" like 'saved_search:%'") search.add_filter("search_type", my.search_type) configs = search.get_sobjects() except SearchException, e: print "WARNING: ", e configs = []
def get_display(self): use_popup = self.kwargs.get("use_popup") if use_popup in [True, 'true']: use_popup = True else: use_popup = False div = DivWdg() content = self.get_content() content.add_style("width: 600px") content.add_style("margin-left: auto") content.add_style("margin-right: auto") from tactic.ui.container import PopupWdg if use_popup: popup = PopupWdg(id="LicenseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close=self.allow_close) popup.add("License Manager", "title") popup.add(content, "content") div.add(popup) behavior = { 'type': 'load', 'cbjs_action': ''' var el = $("LicenseManagerWdg"); el.setStyle("display",""); ''' } div.add_behavior(behavior) else: div.add(content) content.add_style("height: 500px") return div
def get_js_popup(my): # Add in javascript logger console pop-up ... # This is particularly useful for being able to print out debug info in javascript when testing # and debugging in IE or in FF without Firebug (where console.log is not defined) # js_popup_id = "WebClientOutputLogPopupWdg" js_popup = PopupWdg(id=js_popup_id, allow_page_activity=True, width="630px") js_popup.add("TACTIC™ Web Client Output Log", "title") js_content_div = DivWdg() button = ButtonWdg("Clear") button.add_style("margin: 5 10") button.add_event("onclick", "$('spt_js_log_output_div').innerHTML = ''") js_content_div.add(button) js_content_div.add( HtmlElement.hr() ) js_div = DivWdg(id="spt_js_log_output_div") js_div.add_style("background: #000000") js_div.add_style("font-family: Courier, Fixed, serif") js_div.add_style("font-size: 11px") js_div.add_style("padding: 3px") js_div.add_style("color: #929292") js_div.add_style("width: 600px") js_div.add_style("height: 400px") js_div.add_style("overflow: auto") # Get user preference for the Web Client Output Console logging level ... log_level = PrefSetting.get_value_by_key("js_logging_level") if not log_level: log_level = "WARNING" # set js logging level to 'WARNING' as a default! PrefSetting.create("js_logging_level",log_level) js_div.set_attr("spt_log_level", log_level) js_content_div.add( js_div ) js_popup.add( js_content_div, 'content' ) return js_popup
def get_save_wdg(my): # add the popup popup = PopupWdg(id='save_search_wdg') popup.add("Save Search", "title") div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = { 'type': 'click', 'mouse_btn': 'LMB', 'cbjs_action': 'spt.dg_table.save_search_cbk(evt, bvr);' } save_button.add_behavior(behavior) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) popup.add(div, "content") return popup
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): web = WebContainer.get_web() tactic_header = Table() tactic_header.add_row() tactic_header.add_color("color", "color2") # tactic logo and release info skin = web.get_skin() src = '/context/skins/' + skin + '/images/tactic_logo.png' img = HtmlElement.img(src) img.add_class('hand') img.add_attr('title', 'Go to home page') img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"}) rel_div = DivWdg() rel_div.add(" "*3) rel_div.add("Release: %s" %Environment.get_release_version() ) rel_div.add_style("font-size: 9px") # Need this to override the above color in add_looks rel_div.add_color("color", "color2") tactic_wdg = Table() tactic_wdg.add_style("width: 180px") tactic_wdg.add_row() td = tactic_wdg.add_cell( img ) td.set_style("width:100px") tactic_wdg.add_row() td = tactic_wdg.add_cell( rel_div ) td.set_style("text-align: left") td = tactic_header.add_cell( tactic_wdg ) # add the project thumb and title project = Project.get() if my.show_project: thumb_div = DivWdg() td = tactic_header.add_cell( thumb_div ) thumb_div.add_style("height: 28px") thumb_div.add_style("overflow: hidden") thumb_div.add_border(modifier=-10) thumb_div.add_style("-moz-border-radius: 3px") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(project) thumb.set_icon_size("45") td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px") td = tactic_header.add_cell( project.get_value("title") ) #td.add_looks( "fnt_title_1" ) td.add_style("font-size: 20px") td.add_style("white-space: nowrap") td.add_style("padding-left: 14px") # project selection td = tactic_header.add_cell() project_div = DivWdg() project_div.add_style("margin-top: -5px") project_div.add(ProjectSelectWdg() ) td.add( project_div ) td.set_style("padding-left: 14px") # Global Actions Gear Menu (contains links to Documentation) ... action_bar_btn_dd = PageHeaderGearMenuWdg() action_div = DivWdg(action_bar_btn_dd) action_div.add_style("margin-top: -5px") td = tactic_header.add_cell( action_div ) if PrefSetting.get_value_by_key('subscription_bar') == 'true': from message_wdg import SubscriptionBarWdg sub = SubscriptionBarWdg(mode='popup') tactic_header.add_cell(sub) # user login # user user = Environment.get_login() full_name = user.get_full_name() user_div = SpanWdg( HtmlElement.b( "%s " % full_name) , css='hand') user_div.set_style("padding-right:10px") # signout login = Environment.get_security().get_login() search_key = SearchKey.get_by_sobject(login) span = SpanWdg() span.add( user_div ) user_div.add_attr('spt_nudge_menu_vert', '20') td = tactic_header.add_cell(span) td.set_style("width:100%; text-align:right; white-space: nowrap") from tactic.ui.widget import SingleButtonWdg button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") button.add_attr('spt_nudge_menu_horiz', '-80') button.add_attr('spt_nudge_menu_vert', '10') td = tactic_header.add_cell(button_div) menus = my.get_smart_menu() # TODO: this part seems redundant to attach to both SmartMenu.add_smart_menu_set(user_div, [menus]) SmartMenu.assign_as_local_activator(user_div, None, True) SmartMenu.add_smart_menu_set(button, [menus]) SmartMenu.assign_as_local_activator(button, None, True) td.set_style("width:100%;") button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False) #button.add_behavior( { #'type': 'click_up', #'cbjs_action': ''' #window.open("/doc/") #''' #} ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_help") ''' } ) from tactic.ui.container import DialogWdg help_dialog = DialogWdg(z_index=900, show_pointer=False) td.add(help_dialog) help_dialog.add_title("Help") help_dialog.add_class("spt_help") # container for help help_div = DivWdg() help_dialog.add(help_div) from help_wdg import HelpWdg help_wdg = HelpWdg() help_div.add(help_wdg) button_div = DivWdg(button) button_div.add_style("margin-top: -5px") td = tactic_header.add_cell(button_div) td.set_style("width:100%; text-align:right; white-space: nowrap") # Layout the Main Header Table main_div = DivWdg() # TEST: NEW LAYOUT if Config.get_value("install", "layout") == "fixed": main_div.add_style("position: fixed") main_div.add_style("z-index: 100") main_div.add_style("width: 100%") license = Environment.get_security().get_license() if not license.is_licensed(): from tactic.ui.app import LicenseManagerWdg license_manager = LicenseManagerWdg(use_popup=True) main_div.add(license_manager) # create the header table tactic_header_div = DivWdg() tactic_header_div.add(tactic_header) tactic_header_div.add_gradient("background", "background2", 10, -10) main_div.add(tactic_header_div) main_div.add( my.get_js_popup() ) """ main_div.add( HelpPopupWdg() ) # FIXME: is this even used at all? action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" ) action_bar_popup.add_title( "TACTIC™ Action Bar" ) action_bar_popup.add( ActionBarWdg() ) main_div.add( action_bar_popup ) """ # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200 popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 ) popup.add('Tools', 'title') main_div.add( popup ) return main_div
def get_example_display(self): div = DivWdg() div.add_class("SPT_SEARCH_CLASS_TAG_EXAMPLE") div.add("<br/><br/>") tt_div = DivWdg() tt_div.add_styles( "padding: 4px; width: 250px; text-align: center; border: 1px solid white;" ) tt_div.add("DIV in page with class 'SPT_FIND_ME_DIV'") tt_div.add_class("SPT_FIND_ME_DIV") tt_popup = PopupWdg(id="test_popup", allow_page_activity=True, width="600px") tt_popup.add_title("Test Popup") tt_div_p = DivWdg() tt_div_p.add_class("SPT_FIND_ME_POPUP") tt_div_p.add("DIV in POPUP with class 'SPT_FIND_ME_POPUP'") tt_btn_p = DivWdg() tt_btn_p.add_styles( "border: solid 1px white; padding: 4px; width: 200px; text-align: center; cursor: pointer;" ) tt_btn_p.add("find 'SPT_FIND_ME_DIV'") tt_btn_p.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_DIV", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) tt_popup.add(tt_div_p) tt_popup.add("<br/><br/>") tt_popup.add(tt_btn_p) tt_div.add(tt_popup) div.add(tt_div) div.add("<br/><br/>") tt_div2 = DivWdg() tt_div2.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div2.add("launch popup") tt_div2.add_behavior({ 'type': 'click_up', 'cbjs_action': 'spt.popup.open( "%s" );' % 'test_popup' }) div.add(tt_div2) div.add("<br/><br/>") tt_div3 = DivWdg() tt_div3.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div3.add("find in popup") tt_div3.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_POPUP", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) div.add(tt_div3) div.add("<br/><br/>") return div
def get_display(self): try: cmd = DatabaseManagerCbk() cmd.execute() except CommandException as e: error = str(e) else: error = None div = DivWdg() div.add_class("spt_database_manager_top") """ security = Environment.get_security() if not security.is_logged_in(): # if there is no database connection, then a user must login as # admin div.add( self.get_login_wdg() ) return div #security = Environment.get_security().get_login() #print(security) error_for_user = DatabaseErrorWdg() div.add(error_for_user) return div """ from tactic.ui.container import PopupWdg popup = PopupWdg(id="DatabaseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close='false') popup.add("Database Manager", "title") content = DivWdg() content.add_style("background: #333") content.add_style("padding: 10px") content.add_style("border: solid 1px black") content.add_style("font-size: 1.2em") icon = IconWdg("Setup Manager", IconWdg.CREATE) content.add(icon) content.add("<b>TACTIC Database Manager</b>") content.add("<hr/>") content.add("<br/>") if not error: error = self.kwargs.get("error") if error: error_div = DivWdg() error_div.add_style("border: solid 1px #000") error_div.add_style("padding: 20px") icon = IconWdg("Setup Manager", IconWdg.ERROR) error_div.add(icon) error_div.add("ERROR: ") error_div.add(error) content.add(error_div) content.add("<br/>") content.add("<br/>") content.add( "<b>Please contact your Adminstrator.</b>" ) """ vendor = Config.get_value("database", "vendor") server = Config.get_value("database", "server") user = Config.get_value("database", "user") from pyasm.search import DbPasswordUtil password = DbPasswordUtil.get_password() table = Table(css="table") table.add_style("width: 100%") table.add_row() table.add_cell("Vendor: ") select = SelectWdg("database_vendor") select.set_option("values", "PostgreSQL|Oracle") select.set_value(server) table.add_cell(select) table.add_row() table.add_cell("Server: ") text = TextWdg("database_server") text.set_value(server) table.add_cell(text) table.add_row() table.add_cell("User: :") text = TextWdg("database_user") text.set_value(user) table.add_cell(text) table.add_row() table.add_cell("Password: :") td = table.add_cell() password = PasswordWdg("database_password") td.add(password) table.add_row() table.add_cell("Confirm Password :"******"password2") td.add(password) content.add(table) content.add("<hr/>") from pyasm.widget import ProdIconSubmitWdg, ProdIconButtonWdg test = ProdIconButtonWdg("Test") test.add_event("onclick", "var top=$(this).getParent('.spt_database_manager_top');var values=spt.api.Utility.get_input_values();var server=TacticServerStub.get();var user=values.database_user[0];var result=server.test_database_connection('localhost', {user:user})") #test.add_behavior( { # 'type': 'click_up', # 'cbjs_action': "alert('cow')" #} ) submit = ProdIconSubmitWdg("Save") submit.add_event("onclick", "document.form.submit()") cancel = ProdIconSubmitWdg("Cancel") cancel.add_event("onclick", "document.form.cancel()") button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(test) button_div.add(submit) button_div.add(cancel) content.add(button_div) """ popup.add(content, "content") div.add(popup) #div.add(content) return div
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_class("SPT_SEARCH_CLASS_TAG_EXAMPLE") div.add( "<br/><br/>" ) tt_div = DivWdg() tt_div.add_styles("padding: 4px; width: 250px; text-align: center; border: 1px solid white;") tt_div.add("DIV in page with class 'SPT_FIND_ME_DIV'") tt_div.add_class( "SPT_FIND_ME_DIV" ) tt_popup = PopupWdg( id="test_popup", allow_page_activity=True, width="600px" ) tt_popup.add_title("Test Popup") tt_div_p = DivWdg() tt_div_p.add_class("SPT_FIND_ME_POPUP") tt_div_p.add( "DIV in POPUP with class 'SPT_FIND_ME_POPUP'" ) tt_btn_p = DivWdg() tt_btn_p.add_styles( "border: solid 1px white; padding: 4px; width: 200px; text-align: center; cursor: pointer;" ) tt_btn_p.add( "find 'SPT_FIND_ME_DIV'" ) tt_btn_p.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_DIV", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) tt_popup.add( tt_div_p ) tt_popup.add( "<br/><br/>" ) tt_popup.add( tt_btn_p ) tt_div.add( tt_popup ) div.add( tt_div ) div.add( "<br/><br/>" ) tt_div2 = DivWdg() tt_div2.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div2.add( "launch popup" ) tt_div2.add_behavior( { 'type': 'click_up', 'cbjs_action': 'spt.popup.open( "%s" );' % 'test_popup' } ) div.add( tt_div2 ) div.add( "<br/><br/>" ) tt_div3 = DivWdg() tt_div3.add_styles( "border: solid 1px white; padding: 4px; width: 100px; text-align: center; cursor: pointer;" ) tt_div3.add( "find in popup" ) tt_div3.add_behavior( { 'type': 'click_up', 'cbjs_action': 'var tmp_el = spt.get_cousin( bvr.src_el, ' \ '".SPT_SEARCH_CLASS_TAG_EXAMPLE", ".SPT_FIND_ME_POPUP", [] ); ' \ 'spt.ui_play.set_bg_to_next_basic_color( tmp_el ); ' } ) div.add( tt_div3 ) div.add( "<br/><br/>" ) return div
def get_display(self): try: cmd = DatabaseManagerCbk() cmd.execute() except CommandException as e: error = str(e) else: error = None div = DivWdg() div.add_class("spt_database_manager_top") """ security = Environment.get_security() if not security.is_logged_in(): # if there is no database connection, then a user must login as # admin div.add( self.get_login_wdg() ) return div #security = Environment.get_security().get_login() #print(security) error_for_user = DatabaseErrorWdg() div.add(error_for_user) return div """ from tactic.ui.container import PopupWdg popup = PopupWdg(id="DatabaseManagerWdg", width="500px", allow_page_activity="false", display='true', zstart=10000, allow_close='false') popup.add("Database Manager", "title") content = DivWdg() content.add_style("background: #333") content.add_style("padding: 10px") content.add_style("border: solid 1px black") content.add_style("font-size: 1.2em") icon = IconWdg("Setup Manager", IconWdg.CREATE) content.add(icon) content.add("<b>TACTIC Database Manager</b>") content.add("<hr/>") content.add("<br/>") if not error: error = self.kwargs.get("error") if error: error_div = DivWdg() error_div.add_style("border: solid 1px #000") error_div.add_style("padding: 20px") icon = IconWdg("Setup Manager", IconWdg.ERROR) error_div.add(icon) error_div.add("ERROR: ") error_div.add(error) content.add(error_div) content.add("<br/>") content.add("<br/>") content.add("<b>Please contact your Adminstrator.</b>") """ vendor = Config.get_value("database", "vendor") server = Config.get_value("database", "server") user = Config.get_value("database", "user") from pyasm.search import DbPasswordUtil password = DbPasswordUtil.get_password() table = Table(css="table") table.add_style("width: 100%") table.add_row() table.add_cell("Vendor: ") select = SelectWdg("database_vendor") select.set_option("values", "PostgreSQL|Oracle") select.set_value(server) table.add_cell(select) table.add_row() table.add_cell("Server: ") text = TextWdg("database_server") text.set_value(server) table.add_cell(text) table.add_row() table.add_cell("User: :") text = TextWdg("database_user") text.set_value(user) table.add_cell(text) table.add_row() table.add_cell("Password: :") td = table.add_cell() password = PasswordWdg("database_password") td.add(password) table.add_row() table.add_cell("Confirm Password :"******"password2") td.add(password) content.add(table) content.add("<hr/>") from pyasm.widget import ProdIconSubmitWdg, ProdIconButtonWdg test = ProdIconButtonWdg("Test") test.add_event("onclick", "var top=$(this).getParent('.spt_database_manager_top');var values=spt.api.Utility.get_input_values();var server=TacticServerStub.get();var user=values.database_user[0];var result=server.test_database_connection('localhost', {user:user})") #test.add_behavior( { # 'type': 'click_up', # 'cbjs_action': "alert('cow')" #} ) submit = ProdIconSubmitWdg("Save") submit.add_event("onclick", "document.form.submit()") cancel = ProdIconSubmitWdg("Cancel") cancel.add_event("onclick", "document.form.cancel()") button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(test) button_div.add(submit) button_div.add(cancel) content.add(button_div) """ popup.add(content, "content") div.add(popup) #div.add(content) return div