def execute(my): web = WebContainer.get_web() #element_name = web.get_form_value("element_name") #key = web.get_form_value("key") key = my.kwargs.get('key') value = my.kwargs.get('value') PrefSetting.create(key, value) my.description = "Set Preference '%s' to '%s'" % (key, value)
def execute(my): web = WebContainer.get_web() #element_name = web.get_form_value("element_name") #key = web.get_form_value("key") key = my.kwargs.get('key') value = my.kwargs.get('value') PrefSetting.create(key,value) my.description = "Set Preference '%s' to '%s'" % (key,value)
def get_sandbox_dir(alias=None): from pyasm.biz import PrefSetting base_dir = PrefSetting.get_value_by_key("sandbox_base_dir") if not base_dir: if alias: if Environment.get_env_object().get_client_os() =='nt': alias_dict = Config.get_value("checkin", "win32_snapshot_dir_alias", sub_key=alias) else: alias_dict = Config.get_value("checkin", "linux_snapshot_dir_alias", sub_key=alias) if not alias_dict: alias_dict = Config.get_value("checkin", "snapshot_dir_alias", sub_key=alias) base_dir = alias_dict.get("default") if not base_dir: if Environment.get_env_object().get_client_os() =='nt': base_dir = Config.get_value("checkin","win32_sandbox_dir") if base_dir == "": base_dir = Config.get_value("checkin","win32_local_base_dir") base_dir += "/sandbox" else: base_dir = Config.get_value("checkin","linux_sandbox_dir") if base_dir == "": base_dir = Config.get_value("checkin","linux_local_base_dir") base_dir += "/sandbox" return base_dir
def install(language=""): # get from preferences if not language: from pyasm.biz import PrefSetting language = PrefSetting.get_value_by_key("language") # else get from project setting #if not language: # from pyasm.prod.biz import ProdSetting # language = ProdSetting.get_by_key("language") if os.environ.get("LC_MESSAGES"): language = os.environ.get("LC_MESSAGES") if os.environ.get("TACTIC_LANG"): language = os.environ.get("TACTIC_LANG") # else it is english if not language: language = "en" Container.put("language", language) # add some localization code #gettext.install("messages", unicode=True) #path = "%s/src/locale" % Environment.get_install_dir() #lang = gettext.translation("messages", localedir=path, languages=[language]) #lang.install() # override the _ function import __builtin__ __builtin__._ = Translation._translate
def init(my): help = HelpItemWdg('Loader', 'The Loader lets you load 3D assets into your 3D applications. Among many options, you can choose to either reference, import, or open the asset through http or the internal file system.') my.add(help) pref = PrefSetting.get_value_by_key("use_java_maya") app = WebContainer.get_web().get_app_name_by_uri() if app == "Maya": if not Container.get('GeneralAppletWdg'): my.add( GeneralAppletWdg() ) Container.put('GeneralAppletWdg', True) site_menu = SiteMenuWdg() site_menu.add_style("float", "right") site_menu.add_style("margin-top", "-2px") my.add(site_menu) WebContainer.add_js('MayaWebTools.js') WebContainer.add_js('PyMaya.js') tab = MayaTabWdgImpl() tab_value = tab.set_tab_key("maya_tab") #my.handle_tab(tab) #my.add(tab,"tab") my.setup_tab("maya_tab", tab=tab) my.add( ProgressWdg() )
def init(self): help = HelpItemWdg( 'Loader', 'The Loader lets you load 3D assets into your 3D applications. Among many options, you can choose to either reference, import, or open the asset through http or the internal file system.' ) self.add(help) pref = PrefSetting.get_value_by_key("use_java_maya") app = WebContainer.get_web().get_app_name_by_uri() if app == "Maya": if not Container.get('GeneralAppletWdg'): self.add(GeneralAppletWdg()) Container.put('GeneralAppletWdg', True) site_menu = SiteMenuWdg() site_menu.add_style("float", "right") site_menu.add_style("margin-top", "-2px") self.add(site_menu) WebContainer.add_js('MayaWebTools.js') WebContainer.add_js('PyMaya.js') tab = MayaTabWdgImpl() tab_value = tab.set_tab_key("maya_tab") #self.handle_tab(tab) #self.add(tab,"tab") self.setup_tab("maya_tab", tab=tab) self.add(ProgressWdg())
def get_skin(my): # DEPRECATED: replaced by palettes # TODO: prod setting shouldn't be in prod!!! from pyasm.prod.biz import ProdSetting web = WebContainer.get_web() skin = web.get_form_value("skin") # look at users preferences if not skin: skin = PrefSetting.get_value_by_key("skin") # if skin isn't found in user preference settings then look for it # in the projects/config XML file ... if not skin: skin = Config.get_value("look", "skin") if not skin: skin = "dark" # MMS-TACTIC ... allow for 'MMS' skin to be returned for use in overriding some colors (MMS is a copy of # 'dark' skin) if skin == 'MMS': return 'MMS' return "dark"
def get_sandbox_dir(alias=None): from pyasm.biz import PrefSetting base_dir = PrefSetting.get_value_by_key("sandbox_base_dir") client_os = Environment.get_env_object().get_client_os() if not base_dir: if alias: if client_os == "nt": alias_dict = Config.get_dict_value("checkin", "win32_sandbox_dir") else: alias_dict = Config.get_dict_value("checkin", "linux_sandbox_dir") if not alias_dict: alias_dict = Config.get_dict_value("checkin", "sandbox_dir") base_dir = alias_dict.get("default") if not base_dir: if client_os == "nt": base_dir = "C:/tactic/sandbox" else: base_dir = "/tmp/snadbox" return base_dir
def init(my): if not my.pref: my.pref = PrefSetting.get_value_by_key("select_filter") super(UserFilterWdg, my).init() my.navigator.set_persistence() # has to set default here, not relying on the default_user option my.navigator.set_option("default", Environment.get_user_name()) my.navigator.add_empty_option('-- Any Users --') """
def init(my): if not my.pref: my.pref = PrefSetting.get_value_by_key("select_filter") super(UserFilterWdg, my).init() my.navigator.set_persistence() # has to set default here, not relying on the default_user option my.navigator.set_option("default", Environment.get_user_name()) my.navigator.add_empty_option("-- Any Users --") """
def init(my): my.pref = PrefSetting.get_value_by_key("select_filter") super(ProjectFilterWdg, my).init() my.navigator.set_persistence() my.navigator.add_empty_option(label='-- Any Projects --', value='') if my.pref == "multi": my.navigator.set_attr("multiple", "1") my.navigator.set_attr("size", "4") else: my.navigator.set_submit_onchange()
def init(my): my.pref = PrefSetting.get_value_by_key("select_filter") super(ProjectFilterWdg, my).init() my.navigator.set_persistence() my.navigator.add_empty_option(label="-- Any Projects --", value="") if my.pref == "multi": my.navigator.set_attr("multiple", "1") my.navigator.set_attr("size", "4") else: my.navigator.set_submit_onchange()
def get_timezone_value(self, value): '''given a datetime value, try to convert to timezone specified in the widget. If not specified, use the My Preferences time zone''' timezone = self.get_option('timezone') if not timezone: timezone = PrefSetting.get_value_by_key('timezone') if timezone in ["local", '']: value = SPTDate.convert_to_local(value) else: value = SPTDate.convert_to_timezone(value, timezone) return value
def get_timezone_value(my, value): '''given a datetime value, try to convert to timezone specified in the widget. If not specified, use the My Preferences time zone''' timezone = my.get_option('timezone') if not timezone: timezone = PrefSetting.get_value_by_key('timezone') if timezone in ["local", '']: value = SPTDate.convert_to_local(value) else: value = SPTDate.convert_to_timezone(value, timezone) return value
def get_sandbox_dir(): from pyasm.biz import PrefSetting base_dir = PrefSetting.get_value_by_key("sandbox_base_dir") if not base_dir: if Environment.get_env_object().get_client_os() =='nt': base_dir = Config.get_value("checkin","win32_sandbox_dir") if base_dir == "": base_dir = Config.get_value("checkin","win32_local_base_dir") base_dir += "/sandbox" else: base_dir = Config.get_value("checkin","linux_sandbox_dir") if base_dir == "": base_dir = Config.get_value("checkin","linux_local_base_dir") base_dir += "/sandbox" return base_dir
def __init__(my, **kwargs): my.kwargs = kwargs my.colors = my.kwargs.get("colors") palette = my.kwargs.get("palette") if palette: my.set_palette(palette) else: # look at the project from pyasm.biz import Project project = Project.get(no_exception=True) if project: value = project.get_value("palette") my.set_palette(value) # otherwise look at the user if not my.colors: from pyasm.biz import PrefSetting value = PrefSetting.get_value_by_key("palette") my.set_palette(value) # look in the config if not my.colors: value = Config.get_value("look", "palette") my.set_palette(value) if not my.colors: my.colors = my.COLORS # make sure all of the colors are defined for name, value in my.DEFAULT.items(): # make a special provision for theme! if name == 'theme': continue if not my.colors.get(name): my.colors[name] = value
def get_action_wdg(self, name): '''get the action widget for ui option of note entry''' note_wdg = DivWdg() note_wdg.add_style("padding-top: 3px") # note options option = DivWdg(css='spt_uber_note_option') cb = CheckboxWdg('is_private') #cb.set_default_checked() checkbox_name = 'note_master_private_cb' master_cb = CheckboxWdg(checkbox_name) if master_cb.is_checked(): cb.set_default_checked() option.add_style('margin-right','5px') option.add_style('float','right') option.add(cb) option.add('private') #commit = TextBtnWdg(label='save', size='small') commit = ActionButtonWdg(title='save', tip="Save Changes") commit.add_style('margin-top: -5px') commit.add_style('margin-bottom: 5px') commit.add_style('float: right') commit.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var td = bvr.src_el.getParent(".spt_table_td"); var text = td.getElement(".spt_note_text"); text.blur(); spt.dg_table.update_row(evt, bvr); td.setStyle('background-color',''); ''', 'cell_only': True }) #commit.set_scale("0.75") # do some gynastics to handle a refresh. if self.parent_wdg: info = self.parent_wdg.get_aux_info() sobject_dict = info.get('sobjects') sobject = sobject_dict.get(self.get_name()) parent = info.get('parent') else: sobject = None parent = None if not sobject: if self.parent_key: parent = SearchKey.get_by_search_key(self.parent_key) # get the latest note #search_key = self.kwargs.get("search_key") #if search_key: # sobject = SearchKey.get_by_search_key(search_key) search = Search('sthpw/note') search.add_parent_filter(parent) search.add_filter('context', name) # Make the assumption that the last one entered is by timestamp search.add_order_by('timestamp desc') sobject = search.get_sobject() # Show a history of notes if sobject: history = ActionButtonWdg(title='history', tip="Show note history") #history = TextBtnWdg(label='history', size='small') #history.get_top_el().add_style("margin-left: 4px") #history.get_top_el().add_style('float: left') history.add_style("float: left") history.add_style("margin-top: -5px") history.add_style("margin-bottom: 5px") note_wdg.add(history) self.parent_key = SearchKey.get_by_sobject(parent) context = name filter = '[{"prefix":"main_body","main_body_enabled":"on","main_body_column":"context","main_body_relation":"is","main_body_value":"%s"}]' % context history.add_behavior( { 'type': 'click_up', 'cbjs_action': "spt.popup.get_widget(evt, bvr)", 'options': { 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'title': 'Notes History', 'popup_id': 'Notes_History_%s'%context }, 'args': { 'search_type': 'sthpw/note', 'view': 'summary', 'parent_key': self.parent_key, 'filter': filter, } } ) note_wdg.add(commit) note_wdg.add(option) note_wdg.add("<br clear='all'/>") from pyasm.biz import PrefSetting quick_text = PrefSetting.get_value_by_key('quick_text') if quick_text: quick_sel = SelectWdg('quick_text', label='quick: ') quick_sel.set_option('values',quick_text) quick_sel.add_empty_option('-- text --', '') quick_sel.add_behavior({'type': 'change', 'cbjs_action': '''var val = bvr.src_el.value; var text=bvr.src_el.getParent('.spt_note_top').getElement('.spt_note_text') text.value = text.value + val; '''}) note_wdg.add(SpanWdg(quick_sel, css='small')) note_wdg.add(HtmlElement.br(2)) # Show the last note note_wdg.add("<i>Last note</i> ") if sobject: timestamp = sobject.get_value("timestamp") timestamp = parser.parse(timestamp) timestamp = timestamp.strftime("%m/%d %H:%M") timestamp_div = SpanWdg() timestamp_div.add( "(%s)" % timestamp) note_wdg.add( timestamp_div) timestamp_div.add_style("font-size: 11px") timestamp_div.add_style("font-style: italic") # add a private tag access = sobject.get_value("access") if access == 'private': private = SpanWdg() #private.add_style('float: right') private.add(" <i>-- private --</i>") note_wdg.add(private) hr = DivWdg("<hr/>") hr.add_style("height: 1px") hr.add_style("margin-top: -5px") note_wdg.add(hr) div = DivWdg() note_wdg.add(div) div.add_style("max-height", "50px") div.add_style("overflow", "auto") div.add_style("padding: 3px") if sobject: value = sobject.get_value('note') from pyasm.web import WikiUtil value = WikiUtil().convert(value) div.add(value) else: no_notes = DivWdg() div.add(no_notes) no_notes.add('<i> -- No Notes --</i>') no_notes.add_style("font-size: 11px") no_notes.add_style("opacity: 0.7") return note_wdg
def get_action_wdg(my, name): '''get the action widget for ui option of note entry''' note_wdg = DivWdg() note_wdg.add_style("padding-top: 3px") # note options option = DivWdg(css='spt_uber_note_option') cb = CheckboxWdg('is_private') #cb.set_default_checked() checkbox_name = 'note_master_private_cb' master_cb = CheckboxWdg(checkbox_name) if master_cb.is_checked(): cb.set_default_checked() option.add_style('margin-right', '5px') option.add_style('float', 'right') option.add(cb) option.add('private') #commit = TextBtnWdg(label='save', size='small') commit = ActionButtonWdg(title='save', tip="Save Changes") commit.add_style('margin-top: -5px') commit.add_style('margin-bottom: 5px') commit.add_style('float: right') commit.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var td = bvr.src_el.getParent(".spt_table_td"); var text = td.getElement(".spt_note_text"); text.blur(); spt.dg_table.update_row(evt, bvr); td.setStyle('background-color',''); ''', 'cell_only': True }) #commit.set_scale("0.75") # do some gynastics to handle a refresh. if my.parent_wdg: info = my.parent_wdg.get_aux_info() sobject_dict = info.get('sobjects') sobject = sobject_dict.get(my.get_name()) parent = info.get('parent') else: sobject = None parent = None if not sobject: if my.parent_key: parent = SearchKey.get_by_search_key(my.parent_key) # get the latest note #search_key = my.kwargs.get("search_key") #if search_key: # sobject = SearchKey.get_by_search_key(search_key) search = Search('sthpw/note') search.add_parent_filter(parent) search.add_filter('context', name) # Make the assumption that the last one entered is by timestamp search.add_order_by('timestamp desc') sobject = search.get_sobject() # Show a history of notes if sobject: history = ActionButtonWdg(title='history', tip="Show note history") #history = TextBtnWdg(label='history', size='small') #history.get_top_el().add_style("margin-left: 4px") #history.get_top_el().add_style('float: left') history.add_style("float: left") history.add_style("margin-top: -5px") history.add_style("margin-bottom: 5px") note_wdg.add(history) my.parent_key = SearchKey.get_by_sobject(parent) context = name filter = '[{"prefix":"main_body","main_body_enabled":"on","main_body_column":"context","main_body_relation":"is","main_body_value":"%s"}]' % context history.add_behavior({ 'type': 'click_up', 'cbjs_action': "spt.popup.get_widget(evt, bvr)", 'options': { 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'title': 'Notes History', 'popup_id': 'Notes_History_%s' % context }, 'args': { 'search_type': 'sthpw/note', 'view': 'summary', 'parent_key': my.parent_key, 'filter': filter, } }) note_wdg.add(commit) note_wdg.add(option) note_wdg.add("<br clear='all'/>") from pyasm.biz import PrefSetting quick_text = PrefSetting.get_value_by_key('quick_text') if quick_text: quick_sel = SelectWdg('quick_text', label='quick: ') quick_sel.set_option('values', quick_text) quick_sel.add_empty_option('-- text --', '') quick_sel.add_behavior({ 'type': 'change', 'cbjs_action': '''var val = bvr.src_el.value; var text=bvr.src_el.getParent('.spt_note_top').getElement('.spt_note_text') text.value = text.value + val; ''' }) note_wdg.add(SpanWdg(quick_sel, css='small')) note_wdg.add(HtmlElement.br(2)) # Show the last note note_wdg.add("<i>Last note</i> ") if sobject: timestamp = sobject.get_value("timestamp") timestamp = parser.parse(timestamp) timestamp = timestamp.strftime("%m/%d %H:%M") timestamp_div = SpanWdg() timestamp_div.add("(%s)" % timestamp) note_wdg.add(timestamp_div) timestamp_div.add_style("font-size: 11px") timestamp_div.add_style("font-style: italic") # add a private tag access = sobject.get_value("access") if access == 'private': private = SpanWdg() #private.add_style('float: right') private.add(" <i>-- private --</i>") note_wdg.add(private) hr = DivWdg("<hr/>") hr.add_style("height: 1px") hr.add_style("margin-top: -5px") note_wdg.add(hr) div = DivWdg() note_wdg.add(div) div.add_style("max-height", "50px") div.add_style("overflow", "auto") div.add_style("padding: 3px") if sobject: value = sobject.get_value('note') from pyasm.web import WikiUtil value = WikiUtil().convert(value) div.add(value) else: no_notes = DivWdg() div.add(no_notes) no_notes.add('<i> -- No Notes --</i>') no_notes.add_style("font-size: 11px") no_notes.add_style("opacity: 0.7") return note_wdg