def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() # FIXME: this logic should not be located here. # no reason to have the edit_area_full.js if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"): if "edit_area/edit_area_full.js" in third_party: third_party.remove("edit_area/edit_area_full.js") for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists( all_js_path ): Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js") #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js") #widget = DivWdg() #widget.set_id("javascript") #my.set_as_panel(widget) widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) ) return widget
def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists( all_js_path ): Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) # custom js files to include includes = Config.get_value("install", "include_js") includes = includes.split(",") for include in includes: include = include.strip() if include: print "include: ", include Container.append_seq("Page:js", include) widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) ) return widget
def get_checkin(my): '''the button which initiates the checkin''' # create the button with the javascript function widget = Widget() #button = TextBtnWdg(label=my.PUBLISH_BUTTON, size='large', width='100', side_padding='20', vert_offset='-5') #button.get_top_el().add_class('smaller') button = ActionButtonWdg(title=my.PUBLISH_BUTTON, tip='Publish the selected assets') button.add_style('margin-bottom: 10px') #button.add_color("background", "background") hidden = HiddenWdg(my.PUBLISH_BUTTON, '') button.add(hidden) ''' status_sel = SelectWdg('checkin_status', label='Status: ') status_sel.set_option('setting', 'checkin_status') status_sel.set_persist_on_submit() status_sel.add_empty_option('-- Checkin Status --') widget.add(status_sel) ''' widget.add(button) # custom defined server_cbk = "pyasm.prod.web.AssetCheckinCbk" #TODO: make other Publish Buttons call their own handle_input function exec(Common.get_import_from_class_path(server_cbk)) exec( "%s.handle_input(button, my.search_type, my.texture_search_type)" % server_cbk) return widget
def get_tool_bar(my): widget = Widget() trash_div = SpanWdg() # reset some global variables on load trash_div.add_behavior({'type':'load', 'cbjs_action':'spt.side_bar.trashed_items=[]; spt.side_bar.changed_views={}'}) trash_div.set_id('trash_me') trash_div.add(IconWdg('Trash', IconWdg.TRASH)) trash_div.add("TRASH!") trash_div.add_class("hand") trash_div.add_class("spt_side_bar_trash") trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") bvr = { "type": "click_up",\ 'cbjs_action': "alert('Drag and drop link or folder here to remove it.')"} trash_div.add_behavior(bvr) widget.add(trash_div) save_div = SpanWdg(css='med hand spt_side_bar_trash') save_div.add(IconWdg('Save Ordering', IconWdg.SAVE)) # FIXME: is_personal??? is_personal = 'false' bvr = { "type": "click_up",\ 'cbjs_action': "spt.side_bar.manage_section_action_cbk({'value':'save'},'%s',%s);" % (my.view, is_personal)} save_div.add_behavior(bvr) widget.add(save_div) return widget
def get_display(my): my.view = my.kwargs.get('view') if not my.view: my.view = 'publish' widget = Widget() sobject = my.get_current_sobject() search_type = sobject.get_search_type() search_id = sobject.get_id() if my.get_option('preview') != 'false': my.thumb.set_current_index(my.get_current_index()) widget.add(my.thumb) publish_link = PublishLinkWdg(search_type,search_id, config_base=my.view) div = DivWdg(publish_link) div.set_style('clear: left; padding-top: 6px') widget.add(div) # build a popup link to show publish browsing browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS) browse_link.add_behavior({'type': 'click_up', 'cbjs_action': 'spt.popup.get_widget(evt, bvr)', 'options': {'popup_id' : 'publish_browser', 'class_name' : 'pyasm.prod.web.PublishBrowserWdg' , 'title': 'Publish Browser'}, 'args' : { 'search_type': search_type, 'search_id' : search_id } }) div.add(browse_link) div.set_style('padding-top: 6px') return widget
def get_display(self): sobject = self.get_current_sobject() sobject = sobject.get_parent() if not sobject: return Widget() # get all of the sobject_logs search = Search("sthpw/sobject_log") search.add_sobject_filter(sobject) logs = search.get_sobjects() search = Search("sthpw/transaction_log") search.add_filters("id", [x.get_value("transaction_log_id") for x in logs]) search.set_limit(200) logs = search.get_sobjects() from layout_wdg import TableWdg widget = Widget() table = TableWdg("sthpw/transaction_log") table.add_class("minimal") table.set_header_flag(False) table.set_show_property(False) table.set_no_results_wdg(" ") table.set_sobjects(logs) widget.add(table) return widget
def get_css_wdg(my): widget = Widget() web = WebContainer.get_web() context_url = web.get_context_url().to_string() skin = web.get_skin() # first load context css Container.append_seq("Page:css", "%s/style/layout.css" % context_url) # add the color wheel css Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url) # TEST Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url) # get all of the registered css file css_files = Container.get_seq("Page:css") for css_file in css_files: widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file ) return widget
def get_display(self): sobject = self.get_current_sobject() sobject = sobject.get_parent() if not sobject: return Widget() # get all of the sobject_logs search = Search("sthpw/sobject_log") search.add_sobject_filter(sobject) logs = search.get_sobjects() search = Search("sthpw/transaction_log") search.add_filters("id", [x.get_value("transaction_log_id") for x in logs] ) search.set_limit(200) logs = search.get_sobjects() from layout_wdg import TableWdg widget = Widget() table = TableWdg("sthpw/transaction_log") table.add_class("minimal") table.set_header_flag(False) table.set_show_property(False) table.set_no_results_wdg( " " ) table.set_sobjects(logs) widget.add(table) return widget
def get_display(my): widget = Widget() app = "Maya" widget.add("<h3>Application Setup Wizard</h3>") block = HtmlElement.blockquote() block.add("<p>Step 1: Launch %s (or start with a new session)</p>" % app) # sphere test block.add("<p>Step 2: Sphere test</p>") sphere_button = ProdIconButtonWdg("Sphere") sphere_button.add_event("onclick", "app.mel('sphere')") block.add( sphere_button) block.add( "If a sphere appears when clicking on this button, then the Maya connector is functiioning") block.add("<p>Step 3: Introspection</p>") introspect_button = ProdIconButtonWdg("Introspect") introspect_button.add_event("onclick", "introspect()") block.add( introspect_button) block.add("<p>Step 4: Create C:/temp/sthpw</p>") block.add("<p>Step 5: Check in Sphere</p>") block.add("<p>Step 6: Load Sphere</p>") widget.add(block) return widget
def get_tool_bar(self): widget = Widget() trash_div = SpanWdg() trash_div.set_id('trash_me') trash_div.add(IconWdg('Trash', IconWdg.TRASH)) trash_div.add("TRASH!") trash_div.add_class("hand") trash_div.add_class("spt_side_bar_trash") trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") bvr = { "type": "click_up",\ 'cbjs_action': "alert('Drag and drop element name here to remove it.')"} trash_div.add_behavior(bvr) widget.add(trash_div) save_div = SpanWdg(css='med hand spt_side_bar_trash') save_div.add(IconWdg('Save', IconWdg.SAVE)) bvr = { "type": "click_up",\ 'cbjs_action': "spt.custom_project.manage_action_cbk({'value':'save'},'%s');" % self.view} save_div.add_behavior(bvr) widget.add(save_div) return widget
def get_camera_wdg(self): widget = Widget() div = DivWdg(css="filter_box") sequence_filter = SequenceFilterWdg() epi_code, sequence_code = sequence_filter.get_value() div.add(sequence_filter) search = Search("prod/camera") columns = ['shot_code', 'description'] search_filter = SearchFilterWdg("camera_search", columns=columns,\ has_persistence=False) search_filter.alter_search(search) div.add(search_filter) widget.add(div) if sequence_code: search.add_where("shot_code in (select code from shot where sequence_code = '%s')" % sequence_code) table = TableWdg("prod/camera") table.set_search(search) widget.add(table) return widget
def get_display(self): if self.is_refresh: top = Widget() self.add(top) web = WebContainer.get_web() self.checked_processes = web.get_form_values('process_names') left_checked_processes = web.get_form_values('left_process_names') right_checked_processes = web.get_form_values('right_process_names') is_split_view = web.get_form_values('split_view') == 'true' else: top = self.get_viewer() self.process_names = [x for x in self.process_names if x ] if self.is_refresh: if self.process_names: table = Table() table.add_row() td = table.add_cell() expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(self.process_names) table_id = 'main_table_left' left_table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=self.view,\ show_row_select=True, show_insert=False, state={'parent_key': self.parent_key}, inline_search=False, show_refresh=True, expression=expression ) if self.resize: from tactic.ui.container import ResizeScrollWdg inner_wdg = ResizeScrollWdg( width='500px', height='500px', scroll_bar_size_str='thick', scroll_expansion='inside' ) inner_wdg.add(left_table) td.add(inner_wdg) else: td.add(left_table) top.add(table) return top
def get_pipeline_wdg(self): search = Search("sthpw/pipeline") widget = Widget() widget.set_search(search) table = TableWdg("sthpw/pipeline", "manage") widget.add(table) return widget
def get_art_reference(self): widget = Widget() help = HelpItemWdg('References', 'References tab lets the user organize art references. Each reference can be [related] to one or more assets defined in TACTIC. It can be set up when you [Edit] the reference.') self.add(help) div = DivWdg(css="filter_box") widget.add(div) columns = ['description','keywords'] search_filter = SearchFilterWdg("art_ref_search", columns=columns,\ has_persistence=False) div.add(search_filter) select = FilterSelectWdg("art_ref_category", label='Category: ', css='snall') select.set_option("setting", "art_reference_category") select.add_empty_option('-- Any --') div.add( select ) table = TableWdg("prod/art_reference") search = Search("prod/art_reference") search_filter.alter_search(search) value = select.get_value() if value != "": search.add_filter("category", value) table.set_search(search) widget.add(table) return widget
def get_css_wdg(my): widget = Widget() web = WebContainer.get_web() context_url = web.get_context_url().to_string() skin = web.get_skin() # first load context css Container.append_seq("Page:css", "%s/style/layout.css" % context_url) # add the color wheel css Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url) # get all of the registered css file css_files = Container.get_seq("Page:css") for css_file in css_files: widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file ) # TEST TEST TEST widget.add('<link rel="stylesheet" href="/assets/_video/video-js.min.css" type="text/css" />\n') return widget
def init_widget(my, widget, title=None): ''' instantiate the widget if selected. This can be called externally to instantiate any widgets added to a TabWdg''' try: # if a method was passed in, then execute it if my.mode == "check": from base_tab_wdg import BaseTabWdg try: if not issubclass(widget, BaseTabWdg): return Widget() except: return Widget() if type(widget) == types.MethodType: widget = widget() elif isinstance(widget, basestring): widget = Common.create_from_class_path(widget) elif not isinstance(widget, Widget): widget = widget() # handle docs for the help widget """ from header_wdg import DocMapping from web_wdg import HelpItemWdg help_url = ProdSetting.get_value_by_key("project_doc_url") if help_url: widget.add(HelpItemWdg('SOOT Docs', help_url)) # add the help item automatically doc = DocMapping() widget.add(HelpItemWdg('%s Tab' % title, doc.get_mapping(title))) """ # catch all exceptions and log them except Exception, e: my.handle_exception(e)
def get_display(my): widget = Widget() thumb = super(ThumbPublishWdg, my).get_display() widget.add(thumb) sobject = my.get_current_sobject() search_type = sobject.get_search_type() search_id = sobject.get_id() publish_link = PublishLinkWdg(search_type,search_id) div = DivWdg(publish_link) div.set_style('clear: left; padding-top: 6px') widget.add(div) # build an iframe to show publish browsing browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS) iframe = WebContainer.get_iframe() iframe.set_width(100) url = WebContainer.get_web().get_widget_url() url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg") url.set_option("search_type", search_type) url.set_option("search_id", search_id) script = iframe.get_on_script(url.to_string()) browse_link.add_event("onclick", script) div.add(browse_link) div.set_style('padding-top: 6px') return widget
def get_display(self): if self.is_refresh: top = Widget() self.add(top) web = WebContainer.get_web() self.checked_processes = web.get_form_values('process_names') left_checked_processes = web.get_form_values('left_process_names') right_checked_processes = web.get_form_values('right_process_names') is_split_view = web.get_form_value('split_view') == 'true' else: top = self.get_viewer() if self.is_refresh: if is_split_view: viewer = self.get_split_viewer() top.add(viewer) else: inner_wdg = SingleNoteViewerWdg(processes_names=self.process_names, parent_key=self.kwargs.get('parent_key'), resize='false', append_context=self.append_context, view=self.view) top.add(inner_wdg) return top
def get_display(self): web = WebContainer.get_web() widget = Widget() search_type = web.get_form_value("parent_search_type") search_id = web.get_form_value("parent_search_id") if not search_type: widget.add("RenderSubmitInfo: parent type not found") return widget hidden = HiddenWdg("parent_search_type", search_type) widget.add(hidden) hidden = HiddenWdg("parent_search_id", search_id) widget.add(hidden) sobject = Search.get_by_id(search_type, search_id) table = TableWdg(search_type, css="embed") table.set_show_property(False) table.set_sobject(sobject) table.remove_widget("render") table.remove_widget("description") widget.add(table) return widget
def get_checkin(my): '''the button which initiates the checkin''' # create the button with the javascript function widget = Widget() #button = TextBtnWdg(label=my.PUBLISH_BUTTON, size='large', width='100', side_padding='20', vert_offset='-5') #button.get_top_el().add_class('smaller') button = ActionButtonWdg(title=my.PUBLISH_BUTTON, tip='Publish the selected assets') button.add_style('margin-bottom: 10px') #button.add_color("background", "background") hidden = HiddenWdg(my.PUBLISH_BUTTON, '') button.add( hidden ) ''' status_sel = SelectWdg('checkin_status', label='Status: ') status_sel.set_option('setting', 'checkin_status') status_sel.set_persist_on_submit() status_sel.add_empty_option('-- Checkin Status --') widget.add(status_sel) ''' widget.add(button) # custom defined server_cbk = "pyasm.prod.web.AssetCheckinCbk" #TODO: make other Publish Buttons call their own handle_input function exec( Common.get_import_from_class_path(server_cbk) ) exec( "%s.handle_input(button, my.search_type, my.texture_search_type)" % server_cbk) return widget
def get_title(self): widget = Widget() if not Container.get('GeneralAppletWdg'): widget.add( GeneralAppletWdg() ) Container.put('GeneralAppletWdg', True) widget.add(super(LayerTableElementWdg, self).get_title()) return widget
def get_display(self): web = WebContainer.get_web() response = web.get_response() # get info from url site_obj = Site.get() path = web.get_request_path() path_info = site_obj.break_up_request_path(path) site = path_info.get("site") project_code = path_info.get("project_code") # find the relative path hash = self.kwargs.get("hash") parts = hash[1:] rel_path = "/".join(parts) #rel_path = "asset/Fantasy/Castle/54d45150c61251f65687d716cc3951f1_v001.jpg" # construct all of the paths asset_dir = web.get_asset_dir() base_dir = "%s/%s" % (asset_dir, project_code) path = "%s/%s" % (base_dir, rel_path) filename = os.path.basename(rel_path) print "path: ", path # determine the mimetype automatically import mimetypes base, ext = os.path.splitext(path) ext = ext.lower() mimetype = mimetypes.types_map[ext] headers = response.headers response.headers['Content-Type'] = mimetype response.headers['Content-Disposition'] = 'inline; filename={0}'.format(filename) use_xsendfile = True if use_xsendfile: response.headers['X-Sendfile'] = path return Widget(path) else: response.headers['Content-Transfer-Encoding'] = 'BINARY' widget = Widget() f = open(path, 'rb') data = f.read() f.close() widget.add(data) return widget
def handle_exception(self, e): '''The tab widget is a special widget concerning exceptions because it usually represents the outer skin of the content of the web page. The titles of the tab must be displayed in order for the site to remain functional in the case of an exception''' from web_wdg import ExceptionWdg widget = ExceptionWdg(e) self.error_wdg = Widget() self.error_wdg.add(widget)
def get_display(my): sobject = my.get_current_sobject() bins = sobject.get_bins() widget = Widget() bins_str = ", ".join( ["%s" % bin.get_label() for bin in bins] ) widget.add( bins_str ) return widget
def get_display(my): sobject = my.get_current_sobject() bins = sobject.get_bins() widget = Widget() bins_str = ", ".join(["%s" % bin.get_label() for bin in bins]) widget.add(bins_str) return widget
def get_display(my): top = Widget() from tactic.ui.panel import CustomLayoutWdg #widget = CustomLayoutWdg(view="bootstrap.basic.test_mootools", is_top=True) widget = CustomLayoutWdg(view="bootstrap.themes.jumbotron.main2", is_top=True) #widget = CustomLayoutWdg(view="bootstrap.basic.test2", is_top=True) top.add(widget) return top
def get_display(my): web = WebContainer.get_web() if not my.view: view = web.get_form_value("filter|view") # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) # create_popup.add( HtmlElement.br(2) ) # create_popup.add( "Copy from template: " ) # template_select = SelectWdg("copy_from_template") # template_select.add_empty_option("-- None --") # template_select.set_option("values", "list|summary|task") # create_popup.add( template_select ) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg("Create") ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", my.search_type) ajax.set_option("project", Project.get_project_code()) if my.view: ajax.set_option("template_view", my.view) create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)"), ) cancel_icon = ProdIconButtonWdg("Cancel") cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) # Browser does not have create # widget.add(create) return widget
def get_milestone_wdg(self): widget = Widget() search = Search("sthpw/milestone") table = TableWdg("sthpw/milestone") table.set_search(search) widget.add(table) return widget
def get_project_settings_wdg(self): widget = Widget() search = Search("prod/prod_setting") table = TableWdg("prod/prod_setting") table.set_search(search) widget.add(table) return widget
def get_milestone_wdg(my): widget = Widget() search = Search("sthpw/milestone") table = TableWdg("sthpw/milestone") table.set_search(search) widget.add(table) return widget
def get_project_settings_wdg(my): widget = Widget() search = Search("prod/prod_setting") table = TableWdg("prod/prod_setting") table.set_search(search) widget.add(table) return widget
def get_display(my): web = WebContainer.get_web() if not my.view: view = web.get_form_value("filter|view") # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) #create_popup.add( HtmlElement.br(2) ) #create_popup.add( "Copy from template: " ) #template_select = SelectWdg("copy_from_template") #template_select.add_empty_option("-- None --") #template_select.set_option("values", "list|summary|task") #create_popup.add( template_select ) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg('Create') ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", my.search_type) ajax.set_option("project", Project.get_project_code()) if my.view: ajax.set_option("template_view", my.view) create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)" )) cancel_icon = ProdIconButtonWdg('Cancel') cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) # Browser does not have create #widget.add(create) return widget
def init(my): div_main = DivWdg(css='module') if my.width != None: widthstr="width: %sem" % (my.width) div_main.add_style(widthstr) # reset my.name, create the content widget if not my.shad_name: my.shad_name = "ShadowBox%s" % (my.generate_unique_id()) div_main.set_id(my.shad_name) div_main.center() div_head = DivWdg(css='boxhead') # HACK to compensate for IE weird handling of CSS if WebContainer.get_web().is_IE() and 'password' in my.shad_name: div_head.add_style('left','-242px') div_head.add_style('padding-bottom: 2px') empty_header = Widget(name=my.HEADER) div_head.add(empty_header, empty_header.get_name()) div_head.add(my.title_wdg, my.title_wdg.get_name()) div_control = DivWdg(css='control') empty_control = Widget(name=my.CONTROL) div_control.add(empty_header, empty_control.get_name()) div_container = DivWdg(css='container') ie_rect = HtmlElement('v:roundrect') ie_rect.set_attr("arcsize", "1966f") ie_rect.set_attr("fillcolor", "white") ie_rect.set_attr("strokecolor", "#555") ie_rect.set_attr("strokeweight", "2pt") div_body = DivWdg(css='content') div_body.set_id("%s_cont" % my.shad_name) div_body.center() div_body.add(div_head) div_body.add(div_control) my.content = div_main my.head = div_head my.control = div_control my.body = div_body div_container.add(ie_rect) ie_rect.add(div_body) #div_main.add(div_head) div_main.add(div_container)
def get_display(self): web = WebContainer.get_web() response = web.get_response() # get info from url site_obj = Site.get() path = web.get_request_path() path_info = site_obj.break_up_request_path(path) site = path_info.get("site") project_code = path_info.get("project_code") # find the relative path hash = self.kwargs.get("hash") parts = hash[1:] rel_path = "/".join(parts) #rel_path = "asset/Fantasy/Castle/54d45150c61251f65687d716cc3951f1_v001.jpg" # construct all of the paths asset_dir = web.get_asset_dir() base_dir = "%s/%s" % (asset_dir, project_code) path = "%s/%s" % (base_dir, rel_path) filename = os.path.basename(rel_path) print "path: ", path # determine the mimetype automatically import mimetypes base, ext = os.path.splitext(path) ext = ext.lower() mimetype = mimetypes.types_map[ext] headers = response.headers response.headers['Content-Type'] = mimetype response.headers[ 'Content-Disposition'] = 'inline; filename={0}'.format(filename) use_xsendfile = True if use_xsendfile: response.headers['X-Sendfile'] = path return Widget(path) else: response.headers['Content-Transfer-Encoding'] = 'BINARY' widget = Widget() f = open(path, 'rb') data = f.read() f.close() widget.add(data) return widget
def get_display(self): clipboards = Clipboard.get_all("select") from layout_wdg import TableWdg widget = Widget() widget.add( "<h3>Clipboard</h3>") table = TableWdg("sthpw/clipboard", self.view) table.set_sobjects(clipboards) widget.add(table) return widget
def get_display(self): widget = Widget() checkbox = CheckboxWdg(self.get_input_name()) widget.add(checkbox) where = self.get_option("where") count = Clipboard.get_count(where=where) widget.add("Copy from clipboard: ( %s items )" % count) return widget
def get_render_policy_wdg(my): widget = Widget() #div = DivWdg(css="filter_box") #widget.add(div) table = TableWdg("prod/render_policy") search = Search("prod/render_policy") sobjects = search.get_sobjects() table.set_sobjects(sobjects) widget.add(table) return widget
def get_naming_wdg(self): widget = Widget() #div = DivWdg(css="filter_box") #widget.add(div) table = TableWdg("prod/naming") search = Search("prod/naming") sobjects = search.get_sobjects() table.set_sobjects(sobjects) widget.add(table) return widget
def handle_unknown_instance(my, table, instance): '''handle unassigned or non-tactic nodes''' table.add_row() table.add_blank_cell() icon = IconWdg("unknown", icon=IconWdg.UNKNOWN) table.add_cell(icon) info_wdg = Widget() info_wdg.add("<b>%s</b>" % instance) table.add_cell(info_wdg) table.add_blank_cell() table.add_blank_cell()
def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url, include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists(all_js_path): Container.append_seq( "Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url, include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url, include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url, include)) # custom js files to include includes = Config.get_value("install", "include_js") includes = includes.split(",") for include in includes: include = include.strip() if include: print "include: ", include Container.append_seq("Page:js", include) widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file, version)) return widget
def get_display(self): widget = Widget() if not self.select: return widget if not self.schema: Environment.add_warning("No schema defined") widget.add("No schema defined") return widget if not self.search_type: Environment.add_warning("HierarchicalFilterWdg: Cannot find current search_type") widget.add("Cannot find current search_type") return widget span = SpanWdg(css="med") parent_type = self.get_parent_type() if parent_type: parent_type_obj = SearchType.get(parent_type) span.add("%s: " % parent_type_obj.get_value("title")) # assume that there is a code in the parent self.select.add_empty_option("-- Select --") self.select.set_option("query", "%s|code|code" % self.parent_type) span.add(self.select) widget.add(span) return widget
def get_display(self): widget = Widget() project = self.get_current_sobject() table = Table() widget.add(table) table.add_style("width: 140px") table.add_row() table.add_cell("Exists: ") table.add_cell(" ") try: exists = project.database_exists() except: #print "Error checking if database exists for project [%s]" % project.get_code() exists = False if exists: table.add_cell( IconWdg("database", IconWdg.DOT_GREEN) ) else: table.add_cell( IconWdg("database", IconWdg.DOT_RED) ) table.add_row() table.add_cell("Version: ") last_version_update = project.get_value("last_version_update") table.add_cell( last_version_update) if last_version_update >= self.version: table.add_cell( IconWdg("database", IconWdg.DOT_GREEN) ) else: table.add_cell( IconWdg("database", IconWdg.DOT_RED) ) widget.add("<br/>") """ widget.add("Schema: ") widget.add("<br/>") widget.add("Context: ") widget.add("<br/>") widget.add("Data: ") widget.add("<br/>") """ return widget
def get_display(my): web = WebContainer.get_web() context_url = web.get_context_url().to_string() js_url = "%s/javascript" % context_url spt_js_url = "%s/spt_js" % context_url # adding new core "spt" javascript library folder version = Environment.get_release_version() # add some third party libraries third_party = js_includes.third_party security = Environment.get_security() # FIXME: this logic should not be located here. # no reason to have the edit_area_full.js #if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"): # if "edit_area/edit_area_full.js" in third_party: # third_party.remove("edit_area/edit_area_full.js") for include in js_includes.third_party: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) all_js_path = js_includes.get_compact_js_filepath() if os.path.exists( all_js_path ): Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix())) else: for include in js_includes.legacy_core: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) for include in js_includes.spt_js: Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include)) for include in js_includes.legacy_app: Container.append_seq("Page:js", "%s/%s" % (js_url,include)) #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js") #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js") widget = Widget() js_files = Container.get("Page:js") for js_file in js_files: widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) ) return widget
def _get_sobject_history_wdg(self): ''' this method is called thru ajax ''' args = WebContainer.get_web().get_form_args() # get the args in the URL search_type = args['search_type'] search_id = args['search_id'] #sobject = Search.get_by_id(search_type, search_id) div = Widget() search = Search("sthpw/sobject_log") search.add_filter("search_type", search_type) search.add_filter("search_id", search_id) sobjects = search.get_sobjects() search = Search("sthpw/transaction_log") search.add_filters( "id", [x.get_value("transaction_log_id") for x in sobjects]) sobjects = search.get_sobjects() table = TableWdg("sthpw/transaction_log", "table", css='table') table.set_show_property(False) table.set_sobjects(sobjects) div.add(table) div.add(HtmlElement.br(2)) return div div.add(assigned_shot_wdg) div.add(HtmlElement.br(2)) return div
def get_display(my): #parent_class = "TabWdg" my.parent_class = my.parent_wdg.__class__.__name__ if my.parent_class == "TbodyWdg": my.parent_class = "TableWdg" elif my.parent_class == "MayaTabWdgImpl": my.parent_class = "TabWdg" # get the key if my.parent_class == "TabWdg": key = my.parent_wdg.get_tab_path() elif my.parent_class == "TableWdg": key = "%s|%s" % (my.search_type, my.parent_wdg.get_view()) else: key = my.parent_wdg.get_name() # set sobjects from the parent, if there are any my.sobjects = my.parent_wdg.get_sobjects() # search for these from pyasm.search import Search search = Search("sthpw/widget_extend") search.add_project_filter() search.add_filter("type", my.parent_class) search.add_filter("key", key) extends = search.get_sobjects() for extend in extends: xml = extend.get_xml_value("data") index = xml.get_value("widget/@index") if index: index = int(index) else: index = None title = xml.get_value("widget/@name") nodes = xml.get_nodes("widget/widget") if nodes: widget = Widget() for node in nodes: node_string = Xml.get_node_xml(node) child_widget = CustomXmlWdg(node_string) if not child_widget: continue if my.sobjects: child_widget.set_sobjects(my.sobjects) widget.add(child_widget) else: widget = CustomXmlWdg(xml.to_string()) if my.sobjects: widget.set_sobjects(my.sobjects) if my.parent_class == 'TableWdg': table_element = widget.get_display_widget() table_element.set_parent_wdg(my.parent_wdg) my.parent_wdg.add(widget, title, index=index)
def get_display(my): sobject = my.get_current_sobject() mode = my.get_option('mode') if not mode: mode = 'sandbox' widget = Widget() sobject_dir = '' sobject_lib_dir = '' # find the path to open explorer if sobject.is_insert(): button = IconWdg("No Path Found", IconWdg.CROSS, long=False) else: try: if mode == 'sandbox': sobject_dir = my.get_base_dir(sobject) elif mode in ['client_repo', 'repository']: sobject_dir = my.get_client_repo_dir(sobject) sobject_lib_dir = my.get_lib_dir(sobject) sobject_dir = sobject_dir.strip() sobject_dir = Common.process_unicode_string(sobject_dir) except TacticException, e: print "WARNING: ", str(e) button = IconWdg("No Path Found", IconWdg.CROSS, long=False) else:
def get_display(my): widget = DivWdg(id='link_view_select') widget.add_class("link_view_select") if my.refresh: widget = Widget() else: my.set_as_panel(widget) views = [] if my.search_type: from pyasm.search import WidgetDbConfig search = Search(WidgetDbConfig.SEARCH_TYPE) search.add_filter("search_type", my.search_type) search.add_regex_filter("view", "link_search:|saved_search:", op="NEQI") search.add_order_by('view') widget_dbs = search.get_sobjects() views = SObject.get_values(widget_dbs, 'view') labels = [view for view in views] views.insert(0, 'table') labels.insert(0, 'table (Default)') st_select = SelectWdg('new_link_view', label='View: ') st_select.set_option('values', views) st_select.set_option('labels', labels) widget.add(st_select) return widget
def get_copyright_wdg(my): widget = Widget() # add the copyright information widget.add( "<!-- -->\n") widget.add( "<!-- Copyright (c) 2005-2013, Southpaw Technology - All Rights Reserved -->\n") widget.add( "<!-- -->\n") return widget
def _get_planned_wdg(self): ''' this method is called thru ajax ''' args = WebContainer.get_web().get_form_args() # get the args in the URL search_type = args['search_type'] search_id = args['search_id'] sobject = Search.get_by_id(search_type, search_id) assigned_shot_wdg = AssignedShotWdg() assigned_shot_wdg.set_sobject(sobject) div = Widget() div.add(assigned_shot_wdg) div.add(HtmlElement.br(2)) return div
def get_instance_wdg(my, instance_type): sorted_instances = my._get_sorted_instances() content_div = Widget() for instance in sorted_instances: item_div = my.get_item_div(instance) item_div.add_attr( "spt_search_key", SearchKey.get_by_sobject(instance) ) item_div.add_class("spt_drop_item") # no need for that #item_div.add(' ') content_div.add(item_div) value_wdg = my.get_value_wdg() json = jsondumps(my.values) json = json.replace('"', '"') value_wdg.set_value(json) return content_div
def get_new_tab_wdg(my): widget = Widget() span = SpanWdg() swap = SwapDisplayWdg.get_triangle_wdg() title = SpanWdg("Tab Creation") span.add(swap) span.add(title) span.add_style("float: left") widget.add(span) widget.add(HtmlElement.br()) # add the tab selector div = DivWdg() SwapDisplayWdg.create_swap_title(title, swap, div) tab_text = TextWdg("tab") tab_text.set_persistence() span = SpanWdg(css="med") span.add("Tab: ") span.add(tab_text) div.add(span) # parent index_text = TextWdg("parent_tab") index_text.set_persistence() span = SpanWdg(css="med") span.add("Parent Tab: ") span.add(index_text) span.add( HintWdg( "Enter the name of the tab that this will fall under. Leave empty to put on the main tab" )) div.add(span) # index index_text = TextWdg("index") index_text.set_attr("size", "4") index_text.set_persistence() span = SpanWdg(css="med") span.add("Index: ") span.add(index_text) span.add( HintWdg("Enter the numeric location for this tab to be placed")) div.add(span) WebContainer.register_cmd("CreateTabCmd") button = IconSubmitWdg("Create Tab", IconWdg.CREATE, True) div.add(button) widget.add(div) return widget
def get_display(self): widget = Widget() project = self.get_current_sobject() table = Table() table.set_class("minimal") for setting in ('dir_naming_cls', 'file_naming_cls', 'code_naming_cls', 'node_naming_cls', 'sobject_mapping_cls'): table.add_row() td = table.add_cell("<i>%s</i>: " % setting) td.add_style("text-align: right") value = project.get_value(setting) table.add_cell(value) widget.add(table) return widget
def get_create_view_wdg(my, search_type): # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) #create_popup.add( HtmlElement.br(2) ) #create_popup.add( "Copy from template: " ) #template_select = SelectWdg("copy_from_template") #template_select.add_empty_option("-- None --") #template_select.set_option("values", "list|summary|task") #create_popup.add( template_select ) create_popup.add(HtmlElement.br(2)) create_popup.add( CheckboxWdg('auto_create_edit', label='Auto Create Edit View')) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg('Create') ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", search_type) ajax.set_option("project", Project.get_project_code()) div = ajax.generate_div() div.set_post_ajax_script('document.form.submit()') create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')")) cancel_icon = ProdIconButtonWdg('Cancel') cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) widget.add(create) widget.add(div) return widget
def get_display(my): box = DivWdg(css='login') box.add_style("margin-top: auto") box.add_style("margin-bottom: auto") box.add_style("text-align: center") script = HtmlElement.script('''function login(e) { if (!e) var e = window.event; if (e.keyCode == 13) { submit_icon_button('Submit'); }} ''') div = DivWdg() div.add_style("margin: 0px 0px") div.add_class("centered") div.add(HtmlElement.br(6)) sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw") sthpw.add_style("color: #333") div.add(sthpw) div.add(HtmlElement.br(2)) div.add(my.get_error_wdg()) box.add(div) widget = Widget() #widget.add( HtmlElement.br(3) ) table = Table() table.add_style("width: 100%") table.add_style("height: 85%") table.add_row() td = table.add_cell() td.add_style("vertical-align: middle") td.add_style("text-align: center") td.add_style("background: transparent") td.add(box) widget.add(table) return widget
def get_tool_bar(my): widget = Widget() trash_div = SpanWdg() # reset some global variables on load trash_div.add_behavior({ 'type': 'load', 'cbjs_action': 'spt.side_bar.trashed_items=[]; spt.side_bar.changed_views={}' }) trash_div.set_id('trash_me') trash_div.add(IconWdg('Trash', IconWdg.TRASH)) trash_div.add("TRASH!") trash_div.add_class("hand") trash_div.add_class("spt_side_bar_trash") trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") bvr = { "type": "click_up",\ 'cbjs_action': "alert('Drag and drop link or folder here to remove it.')"} trash_div.add_behavior(bvr) widget.add(trash_div) save_div = SpanWdg(css='med hand spt_side_bar_trash') save_div.add(IconWdg('Save Ordering', IconWdg.SAVE)) # FIXME: is_personal??? is_personal = 'false' bvr = { "type": "click_up",\ 'cbjs_action': "spt.side_bar.manage_section_action_cbk({'value':'save'},'%s',%s);" % (my.view, is_personal)} save_div.add_behavior(bvr) widget.add(save_div) return widget