def _get_swap_wdg(my, event_id=''): swap_wdg = SwapDisplayWdg(on_event_name='on_%s'%event_id, off_event_name='off_%s'%event_id) icon1 = IconWdg('open', IconWdg.INFO_CLOSED_SMALL) icon2 = IconWdg('close', IconWdg.INFO_OPEN_SMALL) swap_wdg.set_display_widgets(icon1, icon2) return swap_wdg
def _get_swap_wdg(self, event_id=''): swap_wdg = SwapDisplayWdg(on_event_name='on_%s' % event_id, off_event_name='off_%s' % event_id) icon1 = IconWdg('open', IconWdg.INFO_CLOSED_SMALL) icon2 = IconWdg('close', IconWdg.INFO_OPEN_SMALL) swap_wdg.set_display_widgets(icon1, icon2) return swap_wdg
def add_unassigned_instances(my, widget, shot_inst_names): ''' add the unassigned instances into a SwapDisplayWdg ''' info = [] session = SessionContents.get() if not session: return "" tactic_nodes = session.get_instance_names(is_tactic_node=True) non_tactic_nodes = session.get_node_names(is_tactic_node=False) """ title = HtmlElement.b('Unassigned instances') widget.add(title) # this is just a filler for now, can be any sobjects snapshots = [] for tactic_node in tactic_nodes: if tactic_node not in shot_inst_names: session_version = session.get_version(tactic_node) session_snap = session.get_snapshot(tactic_node) if session_snap: snapshots.append(session_snap) info.append({'session_version': session_version, 'instance':\ tactic_node}) div = DivWdg(id="unassigned_table") SwapDisplayWdg.create_swap_title( title, swap, div) table = TableWdg('sthpw/snapshot', 'session_items') table.set_show_property(False) table.set_aux_data(info) table.set_sobjects(snapshots) div.add(table) widget.add(div) widget.add(HtmlElement.br()) """ # Add other non-tactic nodes swap2 = SwapDisplayWdg.get_triangle_wdg() title2 = HtmlElement.b('Other Nodes') div2 = DivWdg(id="other_node_div") widget.add(swap2) widget.add(title2) SwapDisplayWdg.create_swap_title( title2, swap2, div2) hidden_table = Table(css='table') div2.add(hidden_table) hidden_table.set_max_width() for node in non_tactic_nodes: hidden_table.add_row() hidden_table.add_cell(node) hidden_table.add_blank_cell() widget.add(div2)
def add_unassigned_instances(self, widget, shot_inst_names): ''' add the unassigned instances into a SwapDisplayWdg ''' info = [] session = SessionContents.get() if not session: return "" tactic_nodes = session.get_instance_names(is_tactic_node=True) non_tactic_nodes = session.get_node_names(is_tactic_node=False) """ title = HtmlElement.b('Unassigned instances') widget.add(title) # this is just a filler for now, can be any sobjects snapshots = [] for tactic_node in tactic_nodes: if tactic_node not in shot_inst_names: session_version = session.get_version(tactic_node) session_snap = session.get_snapshot(tactic_node) if session_snap: snapshots.append(session_snap) info.append({'session_version': session_version, 'instance':\ tactic_node}) div = DivWdg(id="unassigned_table") SwapDisplayWdg.create_swap_title( title, swap, div) table = TableWdg('sthpw/snapshot', 'session_items') table.set_show_property(False) table.set_aux_data(info) table.set_sobjects(snapshots) div.add(table) widget.add(div) widget.add(HtmlElement.br()) """ # Add other non-tactic nodes swap2 = SwapDisplayWdg.get_triangle_wdg() title2 = HtmlElement.b('Other Nodes') div2 = DivWdg(id="other_node_div") widget.add(swap2) widget.add(title2) SwapDisplayWdg.create_swap_title(title2, swap2, div2) hidden_table = Table(css='table') div2.add(hidden_table) hidden_table.set_max_width() for node in non_tactic_nodes: hidden_table.add_row() hidden_table.add_cell(node) hidden_table.add_blank_cell() widget.add(div2)
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_new_tab_wdg(self): 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
class AppSObjectCheckinWdg(CheckinWdg): PUBLISH_BUTTON = 'Publish' ARGS_KEYS = { "search_type": { 'description': "search type that this panel works with", 'type': 'TextWdg', 'order': 0, 'category': '1. Required' }, "texture_search_type": { 'description': "texture search type that this panel works with", 'type': 'TextWdg', 'order': 1, 'category': '1. Required' }, "process": { 'description': "The process this panel is looking at e.g. {@GET(state.process)}", 'type': 'TextWdg', 'order': 1, 'category': '2. Options' } } def list_references(my): '''lists whether references can be checked in with this widget''' return False def get_context_data(my): process = my.process_select.get_value() labels, values = super(AppSObjectCheckinWdg,my).get_context_data(\ my.search_type, process) return labels, values def get_display(my): my.search_type = my.kwargs.get('search_type') my.texture_search_type = my.kwargs.get('texture_search_type') assert my.search_type app_name = WebContainer.get_web().get_selected_app() # add an outside box top = DivWdg(css='spt_view_panel') #div = DivWdg(css="maq_search_bar") div = DivWdg() div.add_color("background", "background2", -15) my.set_as_panel(top) top.add(div) div.add_style("margin: 5px") div.add_style("padding: 10px") div.add_style("font-style: bold") process_div = DivWdg() process_div.add_style("padding-left: 10px") div.add(process_div) process_div.add(my.get_process_wdg(my.search_type)) process_div.add(my.get_context_filter_wdg()) process_div.add(HtmlElement.br(clear="all")) div.add(HtmlElement.br()) checkin_options = DivWdg(css='spt_ui_options') checkin_options.add_style("padding: 10px") swap = SwapDisplayWdg() #swap.set_off() title = SpanWdg("Check in Options") SwapDisplayWdg.create_swap_title(title, swap, checkin_options, is_open=False) div.add(swap) div.add(title) checkin_options.add(my.get_file_type_wdg()) checkin_options.add(my.get_snapshot_type_wdg()) checkin_options.add(HtmlElement.br(1)) checkin_options.add(my.get_export_method_wdg()) checkin_options.add(my.get_checkin_as_wdg()) #my.add( my.get_render_icon_wdg() ) # For different export methods checkin_options.add(my.get_currency_wdg()) checkin_options.add(my.get_reference_option()) checkin_options.add(my.get_auto_version_wdg()) checkin_options.add(my.get_texture_option(app=app_name)) checkin_options.add(my.get_handoff_wdg()) if not my.context_select.get_value(for_display=True): my.add(DivWdg('A context must be selected.', css='warning')) return div.add(checkin_options) top.add(my.get_introspect_wdg()) top.add(HtmlElement.br(2)) # create the interface table = Table() table.set_max_width() #table.set_class("table") table.add_color('background', 'background2') #table.add_style('line-height','3.0em') #table.add_row(css='smaller') tr = table.add_row(css='smaller') tr.add_style('height', '3.5em') table.add_header(" ") table.add_header(" ") th = table.add_header("Instance") th.add_style('text-align: left') table.add_header(my.get_checkin()) table.add_header("Sandbox") tr.add_color('background', 'background2', -15) # get session and handle case where there is no session my.session = SessionContents.get() if my.session == None: instance_names = [] asset_codes = [] node_names = [] else: instance_names = my.session.get_instance_names() asset_codes = my.session.get_asset_codes() node_names = my.session.get_node_names() # get all of the possible assets based on the asset codes search = Search(my.search_type) search.add_filters("code", asset_codes) assets = search.get_sobjects() assets_dict = SObject.get_dict(assets, ["code"]) if my.session: my.add("Current Project: <b>%s</b>" % my.session.get_project_dir()) else: my.add("Current Project: Please press 'Introspect'") count = 0 for i in range(0, len(node_names)): node_name = node_names[i] if not my.session.is_tactic_node(node_name) and \ not my.session.get_node_type(node_name) in ['transform','objectSet']: continue instance_name = instance_names[i] # backwards compatible: try: asset_code = asset_codes[i] except IndexError, e: asset_code = instance_name # skip if this is a reference if my.list_references == False and \ my.session.is_reference(node_name): continue table.add_row() # check that this asset exists asset = assets_dict.get(asset_code) if not asset: continue # list items if it is a set if asset.get_value('asset_type', no_exception=True) in ["set", "section"]: my.current_sobject = asset my.handle_set(table, instance_name, asset, instance_names) count += 1 # if this asset is in the database, then allow it to checked in if asset: if my.session.get_snapshot_code(instance_name, snapshot_type='set'): continue # hack remember this my.current_sobject = asset my.handle_instance(table, instance_name, asset, node_name) else: table.add_blank_cell() table.add_cell(instance_name) count += 1 if count == 0: table.add_row_cell( "<center><h2>No assets in session to checkin</h2></center>") top.add(table) if not my.session: return non_tactic_nodes = my.session.get_instance_names(is_tactic_node=False) title = HtmlElement.b("Unknown List") swap = SwapDisplayWdg.get_triangle_wdg() div = DivWdg(id="unknown list") top.add(swap) top.add(title) SwapDisplayWdg.create_swap_title(title, swap, div) unknown_table = Table() unknown_table.add_color('background', 'background2') unknown_table.set_max_width() div.add(unknown_table) for instance in non_tactic_nodes: my.handle_unknown_instance(unknown_table, instance) top.add(div) return top
def get_display(my): data = my.kwargs.get('kwargs') if data: data = jsonloads(data) my.kwargs.update(data) my.search_type = my.kwargs.get("search_type") my.x_axis = my.kwargs.get("x_axis") if not my.x_axis: my.x_axis = 'code' my.y_axis = my.kwargs.get("y_axis") if type(my.y_axis) == types.ListType: my.y_axis = "|".join( my.y_axis ) my.chart_type = my.kwargs.get("chart_type") if not my.chart_type: my.chart_type = 'bar' # get any search keys if any are passed in my.search_keys = my.kwargs.get("search_keys") top = DivWdg() top.add_class("spt_chart_builder") top.add_color("background", "background") top.add_border() from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias='charting') top.add( help_button ) help_button.add_style("float: right") project = Project.get() search_types = project.get_search_types(include_sthpw=True) search_types = [x.get_value("search_type") for x in search_types] build_div = DivWdg() from pyasm.widget import SwapDisplayWdg swap_wdg = SwapDisplayWdg.get_triangle_wdg() swap_script = swap_wdg.get_swap_script() build_div.add(swap_wdg) build_div.add("<b>Chart Specifications</b>") build_div.add_style("margin-bottom: 5px") build_div.add_style("height: 25px") build_div.add_style("padding-top: 5px") build_div.add_gradient("background", "background", -10) build_div.add_color("color", "color") build_div.add_class("hand") build_div.add_class("SPT_DTS") top.add(build_div) build_div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var spec = top.getElement(".spt_chart_spec"); //spt.api.toggle_show_hide(spec); spt.toggle_show_hide(spec); %s; ''' % swap_script } ) spec_div = DivWdg() spec_div.add_color("color", "color3") spec_div.add_color("background", "background3") spec_div.add_class("spt_chart_spec") spec_div.add_border() spec_div.add_style("padding: 10px") spec_div.add_style("margin: 5px") spec_div.add_style("display: none") top.add(spec_div) table = Table() table.add_color("color", "color3") spec_div.add(table) # add the search type selector table.add_row() table.add_cell("Search Type: ") search_type_div = DivWdg() search_type_select = TextWdg("search_type") search_type_select.set_value(my.search_type) #search_type_select.set_option("values", search_types) search_type_div.add(search_type_select) table.add_cell(search_type_div) # add the chart type selector table.add_row() table.add_cell("Chart Type: ") type_div = DivWdg() #type_div.add_style("padding: 3px") type_select = SelectWdg("chart_type") type_select.set_option("values", "line|bar|area") if my.chart_type: type_select.set_value(my.chart_type) type_div.add(type_select) table.add_cell(type_div) # add the chart type selector table.add_row() table.add_cell("X-Axis: ") # need to find all expression widgets or use get_text_value()? x_axis_div = DivWdg() x_axis_text = TextWdg("x_axis") x_axis_text.set_value("code") x_axis_div.add(x_axis_text) table.add_cell(x_axis_div) # add the chart type selector table.add_row() td = table.add_cell("Y-Axis: ") td.add_style("vertical-align: top") y_axis_div = DivWdg() #y_axis_text = TextWdg("y_axis") #if my.y_axis: # y_axis_text.set_value(my.y_axis) #y_axis_div.add(y_axis_text) td = table.add_cell(y_axis_div) # add in a list of entries from tactic.ui.container import DynamicListWdg list_wdg = DynamicListWdg() for value in my.y_axis.split("|"): item = TextWdg("y_axis") item.set_value(value, set_form_value=False) list_wdg.add_item(item) y_axis_div.add(list_wdg) spec_div.add("<br/>") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Refresh") spec_div.add(button) spec_div.add(HtmlElement.br(2)) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); //var values = spt.api.Utility.get_input_values(top); spt.panel.refresh(chart, values); ''' } ) #TODO: provide a field for user to type in the chart name """ button = ActionButtonWdg(title="Save") spec_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); var login = '******'; var search_type = 'SideBarWdg'; var side_bar_view = 'project_view'; var unique_el_name = 'chart_test' var kwargs = {}; kwargs['login'] = null; //if (save_as_personal) // kwargs['login'] = login; kwargs['class_name'] = 'tactic.ui.chart.ChartBuilderWdg'; var display_options = {}; display_options['search_type'] = 'prod/asset' kwargs['display_options'] = display_options; kwargs['unique'] = true; //if (new_title) // kwargs['element_attrs'] = {'title': new_title}; var server = TacticServerStub.get() server.add_config_element(search_type, side_bar_view, unique_el_name, kwargs); spt.panel.refresh("side_bar"); ''' } ) """ width = '600px' kwargs = { 'y_axis': my.y_axis, 'chart_type': my.chart_type, 'search_type': my.search_type, 'width': width, 'search_keys': my.search_keys } chart_div = DivWdg() chart = BarChartWdg(**kwargs) chart_div.add(chart) top.add(chart_div) #from chart2_wdg import SampleSObjectChartWdg #chart = SampleSObjectChartWdg(**kwargs) #chart_div.add(chart) return top
def get_display(my): my.search_type = my.kwargs.get('search_type') my.texture_search_type = my.kwargs.get('texture_search_type') assert my.search_type app_name = WebContainer.get_web().get_selected_app() # add an outside box top = DivWdg(css='spt_view_panel') #div = DivWdg(css="maq_search_bar") div = DivWdg() div.add_color("background", "background2", -15) my.set_as_panel(top) top.add(div) div.add_style("margin: 5px") div.add_style("padding: 10px") div.add_style("font-style: bold") process_div = DivWdg() process_div.add_style("padding-left: 10px") div.add(process_div) process_div.add( my.get_process_wdg(my.search_type)) process_div.add( my.get_context_filter_wdg() ) process_div.add(HtmlElement.br(clear="all")) div.add( HtmlElement.br() ) checkin_options = DivWdg(css='spt_ui_options') checkin_options.add_style("padding: 10px") swap = SwapDisplayWdg() #swap.set_off() title = SpanWdg("Check in Options") SwapDisplayWdg.create_swap_title(title, swap, checkin_options, is_open=False) div.add(swap) div.add(title) checkin_options.add( my.get_file_type_wdg() ) checkin_options.add( my.get_snapshot_type_wdg() ) checkin_options.add(HtmlElement.br(1)) checkin_options.add( my.get_export_method_wdg() ) checkin_options.add( my.get_checkin_as_wdg() ) #my.add( my.get_render_icon_wdg() ) # For different export methods checkin_options.add( my.get_currency_wdg() ) checkin_options.add( my.get_reference_option()) checkin_options.add( my.get_auto_version_wdg()) checkin_options.add( my.get_texture_option(app=app_name)) checkin_options.add( my.get_handoff_wdg()) if not my.context_select.get_value(for_display=True): my.add(DivWdg('A context must be selected.', css='warning')) return div.add(checkin_options) top.add( my.get_introspect_wdg() ) top.add(HtmlElement.br(2)) # create the interface table = Table() table.set_max_width() #table.set_class("table") table.add_color('background','background2') #table.add_style('line-height','3.0em') #table.add_row(css='smaller') tr = table.add_row(css='smaller') tr.add_style('height', '3.5em') table.add_header(" ") table.add_header(" ") th = table.add_header("Instance") th.add_style('text-align: left') table.add_header(my.get_checkin()) table.add_header("Sandbox") tr.add_color('background','background2', -15) # get session and handle case where there is no session my.session = SessionContents.get() if my.session == None: instance_names = [] asset_codes = [] node_names = [] else: instance_names = my.session.get_instance_names() asset_codes = my.session.get_asset_codes() node_names = my.session.get_node_names() # get all of the possible assets based on the asset codes search = Search(my.search_type) search.add_filters("code", asset_codes) assets = search.get_sobjects() assets_dict = SObject.get_dict(assets, ["code"]) if my.session: my.add("Current Project: <b>%s</b>" % my.session.get_project_dir() ) else: my.add("Current Project: Please press 'Introspect'") count = 0 for i in range(0, len(node_names) ): node_name = node_names[i] if not my.session.is_tactic_node(node_name) and \ not my.session.get_node_type(node_name) in ['transform','objectSet']: continue instance_name = instance_names[i] # backwards compatible: try: asset_code = asset_codes[i] except IndexError, e: asset_code = instance_name # skip if this is a reference if my.list_references == False and \ my.session.is_reference(node_name): continue table.add_row() # check that this asset exists asset = assets_dict.get(asset_code) if not asset: continue # list items if it is a set if asset.get_value('asset_type', no_exception=True) in ["set", "section"]: my.current_sobject = asset my.handle_set( table, instance_name, asset, instance_names) count +=1 # if this asset is in the database, then allow it to checked in if asset: if my.session.get_snapshot_code(instance_name, snapshot_type='set'): continue # hack remember this my.current_sobject = asset my.handle_instance(table, instance_name, asset, node_name) else: table.add_blank_cell() table.add_cell(instance_name) count += 1
def get_display(my): # if no filters are defined, then display nothing if not my.filters: return Widget() #filter_top = DivWdg(css="maq_search_bar") filter_top = DivWdg() filter_top.add_color("color", "color") filter_top.add_color("background", "background", -5) filter_top.add_style("padding: 5px") filter_top.add_style("min-width: 700px") filter_top.add_border() my.set_as_panel(filter_top) # TEST link to help for search widget help_button = ActionButtonWdg(title="?", tip="Search Documentation", size='small') filter_top.add(help_button) help_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.help.set_top(); spt.help.load_alias("search-quickstart|what-is-searching|search-interface|search-compound|search-expressions"); ''' } ) help_button.add_style("float: right") # this id should be removed filter_top.set_id("%s_search" % my.prefix) filter_top.add_class("spt_search") for name, value in my.kwargs.items(): filter_top.set_attr("spt_%s" % name, value) #filter_top.add(my.statement) popup = my.get_retrieve_wdg() filter_top.add(popup) popup = my.get_save_wdg() filter_top.add(popup) display = my.kwargs.get('display') # Add a number of filters indicator div = DivWdg() div.add_class("spt_search_num_filters") div.add_style("float: right") div.add_style("font-size: 0.9em") div.add_style("margin: 0 10 0 10") #search_summary.add(div) filter_top.add(div) if my.num_filters_enabled: msg = "[%s] filter/s" % my.num_filters_enabled icon = IconWdg(msg, IconWdg.DOT_GREEN) div.add(icon) div.add("%s" % msg) filter_div = DivWdg() filter_div.set_id("search_filters") filter_div.add_class("spt_search_filters") # TODO: disabling for now # add the action buttons #action_wdg = my.get_action_wdg() #action_wdg.add_style("text-align: right") #filter_div.add( action_wdg ) # add the top display_str = 'block' if not display: display_str = 'none' filter_div.add_style("display: %s" % display_str) search_wdg = my.get_search_wdg() prefix = "filter_mode" if my.prefix_namespace: prefix = '%s_%s' %(my.prefix_namespace, prefix) hidden = HiddenWdg("prefix", prefix) match_div = DivWdg() match_div.add(hidden) match_div.add_class('spt_search_filter') palette = match_div.get_palette() bg_color = palette.color('background') light_bg_color = palette.color('background', modifier=+10) select = SelectWdg("filter_mode") select.add_class("spt_search_filter_mode") select.set_persist_on_submit(prefix) select.remove_empty_option() # for Local search, leave out compound search for now if my.kwargs.get('prefix_namespace'): select.set_option("labels", "Match all|Match any") select.set_option("values", "and|or") else: select.set_option("labels", "Match all|Match any|Compound search") select.set_option("values", "and|or|custom") #select.set_option("labels", "all|any") #select.set_option("values", "and|or") select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var display = bvr.src_el.value == 'custom';; var top = bvr.src_el.getParent(".spt_search"); var ops = top.getElements(".spt_op"); for (var i = 0; i < ops.length; i++) { var op = ops[i]; var element = op.getElement(".spt_op_display"); var value = op.getAttribute("spt_op"); if (display) { element.innerHTML = value; var level = op.getAttribute("spt_level"); if (level == 1) { element.setStyle("background", "%s") element.setStyle("padding", "4px") } } else { element.innerHTML = ' '; element.setStyle("background", "%s") element.setStyle("padding", "1px") } } ''' %(light_bg_color, bg_color) } ) match_div.add(select) match_div.add_color("color", "color2") match_div.add(" on the following") hint = HintWdg( "An 'AND' operation is always applied to each category below. " \ "This controls only the filters within each category." ) match_div.add(hint) match_div.add('<br/>') match_div.add_style("padding-top: 5px") filter_div.add( search_wdg) search_wdg.add_style("float: left") filter_div.add( match_div) filter_div.add(HtmlElement.br()) filters_div = DivWdg() filters_div.add_style("margin: 0 -6 0 -6") security = Environment.get_security() # add all the filters for filter in my.filters: element_name = filter.get_name() if not security.check_access("search", element_name, "view"): continue # no need to create it again #filter = my.config.get_display_widget(element_name) div = DivWdg() filters_div.add(div) div.add_class("hand") class_suffix = element_name.replace(' ', '_') cbjs_action = 'var el=spt.get_cousin(bvr.src_el,".spt_search",".spt_filter_%s");spt.simple_display_toggle(el);' % class_suffix div.add_behavior( { 'type': 'click_up', 'cbjs_action': cbjs_action } ) div.add_color("color", "color", +5) div.add_gradient("background", "background", -5, -5) div.add_style("margin-top: -1px") div.add_border() div.add_style("padding: 3px") div.add_style("whitespace: nowrap") if element_name in ["Parent", 'Children']: swap = SwapDisplayWdg.get_triangle_wdg() else: swap = SwapDisplayWdg.get_triangle_wdg() swap.set_off() swap.add_action_script(cbjs_action) div.add_event("onclick", swap.get_swap_script() ) div.add(swap) div.add_class("SPT_DTS") div.add(element_name) div = DivWdg() div.add_class("spt_filter_%s" % class_suffix) if element_name in ["Parent", 'Children']: div.add_style("display: none") else: div.add_style("display: block") #div.add_style("background-color: #333") div.add_color("background", "background") div.add_border() div.add_style("padding: 5px 3px 5px 3px") div.add_style("margin-top: -1px") #div.add_style("margin-left: 20px") #div.add_style("width: 660") div.add(filter) filters_div.add(div) filter_div.add(filters_div) buttons_div = DivWdg() buttons_div.add_style("margin-top: 7px") buttons_div.add_style("margin-bottom: 7px") buttons_div.add(my.get_search_wdg() ) filter_div.add(buttons_div) filter_top.add(filter_div) return filter_top
def get_display(my): data = my.kwargs.get('kwargs') if data: data = jsonloads(data) my.kwargs.update(data) my.search_type = my.kwargs.get("search_type") my.x_axis = my.kwargs.get("x_axis") if not my.x_axis: my.x_axis = 'code' my.y_axis = my.kwargs.get("y_axis") if type(my.y_axis) == types.ListType: my.y_axis = "|".join(my.y_axis) my.chart_type = my.kwargs.get("chart_type") if not my.chart_type: my.chart_type = 'bar' # get any search keys if any are passed in my.search_keys = my.kwargs.get("search_keys") top = DivWdg() top.add_class("spt_chart_builder") top.add_color("background", "background") top.add_border() from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias='charting') top.add(help_button) help_button.add_style("float: right") project = Project.get() search_types = project.get_search_types(include_sthpw=True) search_types = [x.get_value("search_type") for x in search_types] build_div = DivWdg() from pyasm.widget import SwapDisplayWdg swap_wdg = SwapDisplayWdg.get_triangle_wdg() swap_script = swap_wdg.get_swap_script() build_div.add(swap_wdg) build_div.add("<b>Chart Specifications</b>") build_div.add_style("margin-bottom: 5px") build_div.add_style("height: 25px") build_div.add_style("padding-top: 5px") build_div.add_gradient("background", "background", -10) build_div.add_color("color", "color") build_div.add_class("hand") build_div.add_class("SPT_DTS") top.add(build_div) build_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var spec = top.getElement(".spt_chart_spec"); //spt.api.toggle_show_hide(spec); spt.toggle_show_hide(spec); %s; ''' % swap_script }) spec_div = DivWdg() spec_div.add_color("color", "color3") spec_div.add_color("background", "background3") spec_div.add_class("spt_chart_spec") spec_div.add_border() spec_div.add_style("padding: 10px") spec_div.add_style("margin: 5px") spec_div.add_style("display: none") top.add(spec_div) table = Table() table.add_color("color", "color3") spec_div.add(table) # add the search type selector table.add_row() table.add_cell("Search Type: ") search_type_div = DivWdg() search_type_select = TextWdg("search_type") search_type_select.set_value(my.search_type) #search_type_select.set_option("values", search_types) search_type_div.add(search_type_select) table.add_cell(search_type_div) # add the chart type selector table.add_row() table.add_cell("Chart Type: ") type_div = DivWdg() #type_div.add_style("padding: 3px") type_select = SelectWdg("chart_type") type_select.set_option("values", "line|bar|area") if my.chart_type: type_select.set_value(my.chart_type) type_div.add(type_select) table.add_cell(type_div) # add the chart type selector table.add_row() table.add_cell("X-Axis: ") # need to find all expression widgets or use get_text_value()? x_axis_div = DivWdg() x_axis_text = TextWdg("x_axis") x_axis_text.set_value("code") x_axis_div.add(x_axis_text) table.add_cell(x_axis_div) # add the chart type selector table.add_row() td = table.add_cell("Y-Axis: ") td.add_style("vertical-align: top") y_axis_div = DivWdg() #y_axis_text = TextWdg("y_axis") #if my.y_axis: # y_axis_text.set_value(my.y_axis) #y_axis_div.add(y_axis_text) td = table.add_cell(y_axis_div) # add in a list of entries from tactic.ui.container import DynamicListWdg list_wdg = DynamicListWdg() for value in my.y_axis.split("|"): item = TextWdg("y_axis") item.set_value(value, set_form_value=False) list_wdg.add_item(item) y_axis_div.add(list_wdg) spec_div.add("<br/>") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Refresh") spec_div.add(button) spec_div.add(HtmlElement.br(2)) button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); //var values = spt.api.Utility.get_input_values(top); spt.panel.refresh(chart, values); ''' }) #TODO: provide a field for user to type in the chart name """ button = ActionButtonWdg(title="Save") spec_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); var login = '******'; var search_type = 'SideBarWdg'; var side_bar_view = 'project_view'; var unique_el_name = 'chart_test' var kwargs = {}; kwargs['login'] = null; //if (save_as_personal) // kwargs['login'] = login; kwargs['class_name'] = 'tactic.ui.chart.ChartBuilderWdg'; var display_options = {}; display_options['search_type'] = 'prod/asset' kwargs['display_options'] = display_options; kwargs['unique'] = true; //if (new_title) // kwargs['element_attrs'] = {'title': new_title}; var server = TacticServerStub.get() server.add_config_element(search_type, side_bar_view, unique_el_name, kwargs); spt.panel.refresh("side_bar"); ''' } ) """ width = '600px' kwargs = { 'y_axis': my.y_axis, 'chart_type': my.chart_type, 'search_type': my.search_type, 'width': width, 'search_keys': my.search_keys } chart_div = DivWdg() chart = BarChartWdg(**kwargs) chart_div.add(chart) top.add(chart_div) #from chart2_wdg import SampleSObjectChartWdg #chart = SampleSObjectChartWdg(**kwargs) #chart_div.add(chart) return top
def get_display(my): widget = Widget() div = DivWdg(css='spt_ui_options') div.set_unique_id() table = Table() div.add(table) table.add_style("margin: 5px 15px") table.add_color('color', 'color') swap = SwapDisplayWdg() #swap.set_off() app = WebContainer.get_web().get_selected_app() outer_span = SpanWdg() outer_span.add_style('float: right') span = SpanWdg(app, css='small') icon = IconWdg(icon=eval("IconWdg.%s" % app.upper()), width='13px') outer_span.add(span) outer_span.add(icon) title = SpanWdg("Loading Options") title.add(outer_span) SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) widget.add(swap) widget.add(title) widget.add(div) if not my.hide_instantiation: table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Instantiation: ")) table.add_cell(div) div = my.get_instantiation_wdg() table.add_cell(div) setting = my.get_default_setting() default_instantiation = setting.get('instantiation') default_connection = setting.get('connection') default_dependency = setting.get('texture_dependency') if not my.hide_connection: table.add_row() table.add_blank_cell() con_div = DivWdg(HtmlElement.b("Connection: ")) table.add_cell(con_div) td = table.add_cell() is_unchecked = True default_cb = None for value in ['http', 'file system']: name = my.get_element_name("connection") checkbox = CheckboxWdg(name) checkbox.set_option("value", value) checkbox.set_persistence() if value == default_connection: default_cb = checkbox if checkbox.is_checked(): is_unchecked = False checkbox.add_behavior({ 'type': 'click_up', 'propagate_evt': True, "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name }) span = SpanWdg(checkbox, css='small') span.add(value) td.add(span) if is_unchecked: default_cb.set_checked() if not my.hide_dependencies: table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Texture Dependencies: ")) table.add_cell(div) td = table.add_cell() is_unchecked = True default_cb = None for value in ['as checked in', 'latest', 'current']: name = my.get_element_name("dependency") checkbox = CheckboxWdg(name) checkbox.set_option("value", value) checkbox.set_persistence() checkbox.add_behavior({ 'type': 'click_up', 'propagate_evt': True, "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name }) if value == default_dependency: default_cb = checkbox if checkbox.is_checked(): is_unchecked = False span = SpanWdg(checkbox, css='small') span.add(value) td.add(span) if is_unchecked: default_cb.set_checked() from connection_select_wdg import ConnectionSelectWdg table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Connection Type: ")) table.add_cell(div) table.add_cell(ConnectionSelectWdg()) table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Connection Port: ")) table.add_cell(div) port_div = DivWdg() port_text = TextWdg("port") port_text.set_option('size', '6') port_div.add(port_text) port_div.add_style("padding-left: 7px") port_div.add_style("width: 40px") table.add_cell(port_div) from pyasm.prod.web import WidgetSettings value = WidgetSettings.get_value_by_key("CGApp:connection_port") if value: port_text.set_value(value) elif WebContainer.get_web().get_selected_app() == 'Houdini': port_text.set_value("13000") else: port_text.set_value("4444") port_text.add_behavior({ 'type': 'change', 'cbjs_action': ''' var value = bvr.src_el.value; value = parseInt(value); var kwargs = { 'data': value, 'key': 'CGApp:connection_port' } var cmd = "pyasm.web.WidgetSettingSaveCbk" var server = TacticServerStub.get(); server.execute_cmd(cmd, kwargs); // FIXME: this is dangerous use of a global var app.port = value; ''' }) return widget
def get_viewer(self): top = DivWdg(css='spt_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('main context') split_div = FloatDivWdg(css='spt_split_cb') div = DivWdg(css='spt_main_context_cb') content_div = DivWdg() content_div.add_color('color','color') content_div.add_style('padding: 10px') SwapDisplayWdg.create_swap_title(title, swap, content_div, is_open=False) div.add(swap) div.add(title) checkbox_name = 'split_screen' split_cb = CheckboxWdg(checkbox_name, label='Split View') split_cb.persistence = True split_cb.persistence_obj = split_cb key = split_cb.get_key() #cb.add_style('float: left') split_cb.add_behavior({'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top"); var table_top = top.getElement(".spt_note_viewer_table"); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_context_cb; var kwargs = { process_names: processes}; if (bvr.src_el.checked) { kwargs.split_view = 'true'; kwargs.show_context = 'true'; kwargs.left_process_names = processes; kwargs.right_process_names = processes; } spt.input.save_selected(bvr, '%s','%s'); spt.app_busy.show("Note Viewer", 'Loading') ; setTimeout(function(){ spt.panel.refresh(table_top, kwargs, false); if (bvr.src_el.checked) spt.hide(cbs); else spt.show(cbs); spt.app_busy.hide(); }, 50 ); ''' % ( checkbox_name, key) }) split_div.add(split_cb) top.add(split_div) top.add(div) div.add(content_div) top.add(HtmlElement.br()) checkbox_name = 'note_main_context_cb' cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb self.checked_process_names = cb.get_values() for value in self.process_names: #self.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in self.checked_process_names: self.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_main_context_cb; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, key) }) content_div.add(cb) table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(self.checked_processes) if split_cb.is_checked(): table = self.get_split_viewer() else: table_id = 'main_table1' 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 ) self.set_as_panel(table_top) table_top.add_style('float: left') top.add(table_top) table_top.add(table) return top
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): # if no filters are defined, then display nothing if not my.filters: return Widget() #filter_top = DivWdg(css="maq_search_bar") filter_top = DivWdg() filter_top.add_color("color", "color") filter_top.add_color("background", "background", -5) filter_top.add_style("padding: 5px") filter_top.add_style("min-width: 800px") filter_top.add_border() my.set_as_panel(filter_top) # TEST link to help for search widget help_button = ActionButtonWdg(title="?", tip="Search Documentation", size='small') filter_top.add(help_button) help_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.help.set_top(); spt.help.load_alias("search-quickstart|what-is-searching|search-interface|search-compound|search-expressions"); ''' }) help_button.add_style("float: right") # this id should be removed filter_top.set_id("%s_search" % my.prefix) filter_top.add_class("spt_search") for name, value in my.kwargs.items(): filter_top.set_attr("spt_%s" % name, value) #filter_top.add(my.statement) popup = my.get_retrieve_wdg() filter_top.add(popup) popup = my.get_save_wdg() filter_top.add(popup) display = my.kwargs.get('display') # Add a number of filters indicator div = DivWdg() div.add_class("spt_search_num_filters") div.add_style("float: right") div.add_style("font-size: 0.9em") div.add_style("margin: 0 10 0 10") #search_summary.add(div) filter_top.add(div) if my.num_filters_enabled: msg = "[%s] filter/s" % my.num_filters_enabled icon = IconWdg(msg, IconWdg.DOT_GREEN) div.add(icon) div.add("%s" % msg) filter_div = DivWdg() filter_div.set_id("search_filters") filter_div.add_class("spt_search_filters") # TODO: disabling for now # add the action buttons #action_wdg = my.get_action_wdg() #action_wdg.add_style("text-align: right") #filter_div.add( action_wdg ) # add the top display_str = 'block' if not display: display_str = 'none' filter_div.add_style("display: %s" % display_str) search_wdg = my.get_search_wdg() prefix = "filter_mode" if my.prefix_namespace: prefix = '%s_%s' % (my.prefix_namespace, prefix) hidden = HiddenWdg("prefix", prefix) match_div = DivWdg() match_div.add(hidden) match_div.add_class('spt_search_filter') palette = match_div.get_palette() bg_color = palette.color('background') light_bg_color = palette.color('background', modifier=+10) select = SelectWdg("filter_mode") select.add_style("width: 110px") select.add_class("spt_search_filter_mode") select.set_persist_on_submit(prefix) select.remove_empty_option() # for Local search, leave out compound search for now if my.kwargs.get('prefix_namespace'): select.set_option("labels", "Match all|Match any") select.set_option("values", "and|or") else: select.set_option("labels", "Match all|Match any|Compound") select.set_option("values", "and|or|custom") #select.set_option("labels", "all|any") #select.set_option("values", "and|or") select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var display = bvr.src_el.value == 'custom';; var top = bvr.src_el.getParent(".spt_search"); var ops = top.getElements(".spt_op"); for (var i = 0; i < ops.length; i++) { var op = ops[i]; var element = op.getElement(".spt_op_display"); var value = op.getAttribute("spt_op"); if (display) { element.innerHTML = value; var level = op.getAttribute("spt_level"); if (level == 1) { element.setStyle("background", "%s") element.setStyle("padding", "4px") } } else { element.innerHTML = ' '; element.setStyle("background", "%s") element.setStyle("padding", "1px") } } ''' % (light_bg_color, bg_color) }) match_div.add(select) match_div.add_color("color", "color2") #match_div.add(" on the following") #hint = HintWdg( "An 'AND' operation is always applied to each category below. " \ # "This controls only the filters within each category." ) #match_div.add(hint) #match_div.add('<br/>') #match_div.add_style("padding-top: 5px") filter_div.add(search_wdg) search_wdg.add_style("float: left") filter_div.add(match_div) filter_div.add(HtmlElement.br()) filters_div = DivWdg() filters_div.add_style("margin: 0 -6 0 -6") security = Environment.get_security() # add all the filters for filter in my.filters: element_name = filter.get_name() if not security.check_access("search", element_name, "view"): continue # no need to create it again #filter = my.config.get_display_widget(element_name) div = DivWdg() filters_div.add(div) div.add_class("hand") class_suffix = element_name.replace(' ', '_') cbjs_action = 'var el=spt.get_cousin(bvr.src_el,".spt_search",".spt_filter_%s");spt.simple_display_toggle(el);' % class_suffix div.add_behavior({'type': 'click_up', 'cbjs_action': cbjs_action}) div.add_color("color", "color", +5) #div.add_gradient("background", "background", -5, -5) div.add_style("margin-top: -1px") div.add_style("height: 18px") div.add_border() div.add_style("padding: 8px 5px") div.add_style("whitespace: nowrap") if element_name in ["Parent", 'Children']: swap = SwapDisplayWdg.get_triangle_wdg() else: swap = SwapDisplayWdg.get_triangle_wdg() swap.set_off() swap.add_action_script(cbjs_action) div.add_event("onclick", swap.get_swap_script()) div.add(swap) div.add_class("SPT_DTS") div.add(element_name) div = DivWdg() div.add_class("spt_filter_%s" % class_suffix) if element_name in ["Parent", 'Children']: div.add_style("display: none") else: div.add_style("display: block") #div.add_style("background-color: #333") div.add_color("background", "background") div.add_border() div.add_style("padding: 10px 8px") div.add_style("margin-top: -1px") #div.add_style("margin-left: 20px") #div.add_style("width: 660") div.add(filter) filters_div.add(div) filter_div.add(filters_div) buttons_div = DivWdg() buttons_div.add_style("margin-top: 7px") buttons_div.add_style("margin-bottom: 7px") search_wdg = my.get_search_wdg() search_wdg.add_style("margin: 15px auto") buttons_div.add(search_wdg) filter_div.add(buttons_div) filter_top.add(filter_div) return filter_top
def get_viewer(my): top = DivWdg(css='spt_single_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('context') title.add_color('color', 'color') div = DivWdg(css='spt_context_cb') div.add_color('color', 'color') SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) checkbox_name = 'split_screen' checked_process_names = [] if my.show_context: top.add(swap) top.add(title) top.add(div) #checkbox_name = 'note_context_cb' checkbox_name = my.checkbox_name cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb checked_process_names = cb.get_values() for value in my.process_names: #my.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in checked_process_names: my.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_single_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.%s; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, checkbox_name, key) }) div.add(cb) else: web = WebContainer.get_web() checked_process_names = web.get_form_values('process_names') table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( checked_process_names) table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) if my.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(table) table_top.add(inner_wdg) else: table_top.add(table) my.set_as_panel(table_top) top.add(table_top) return top
def get_display(my): my.init_kwargs() sobject = my.get_current_sobject() table = Table(css='minimal') table.add_color("color", "color") table.add_style("font-size: 0.9em") snapshots = my.get_snapshot(my.mode) for snapshot in snapshots: table.add_row() value = my.get_input_value(sobject, snapshot) current_version = snapshot.get_value("version") current_context = snapshot.get_value("context") current_revision = snapshot.get_value("revision", no_exception=True) current_snapshot_type = snapshot.get_value("snapshot_type") # hack hard coded type translation if current_snapshot_type == "anim_export": current_snapshot_type = "anim" # ignore icon context completely if current_context == "icon": table.add_blank_cell() table.add_cell("(---)") return table checkbox = CheckboxWdg('%s_%s' %(my.search_type, my.CB_NAME)) # this is added back in for now to work with 3.7 Fast table checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True}) checkbox.add_class('spt_latest_%s' %my.mode) checkbox.set_option("value", value ) table.add_cell( checkbox ) load_all = False if load_all: checkbox.set_checked() # add the file type icon xml = snapshot.get_snapshot_xml() file_name = xml.get_value("snapshot/file/@name") icon_link = ThumbWdg.find_icon_link(file_name) image = HtmlElement.img(icon_link) image.add_style("width: 15px") table.add_cell(image) namespace = my.get_namespace(sobject, snapshot) asset_code = my.get_asset_code() # force asset mode = True my.session.set_asset_mode(asset_mode=my.get_session_asset_mode()) node_name = my.get_node_name(snapshot, asset_code, namespace) # get session info session_context = session_version = session_revision = None if my.session: session_context = my.session.get_context(node_name, asset_code, current_snapshot_type) session_version = my.session.get_version(node_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision(node_name, asset_code,current_snapshot_type) # Maya Specific: try with namespace in front of it for referencing referenced_name = '%s:%s' %(namespace, node_name) if not session_context or not session_version: session_context = my.session.get_context(referenced_name, asset_code, current_snapshot_type) session_version = my.session.get_version(referenced_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision(referenced_name, asset_code, current_snapshot_type) from version_wdg import CurrentVersionContextWdg, SubRefWdg version_wdg = CurrentVersionContextWdg() data = {'session_version': session_version, \ 'session_context': session_context, \ 'session_revision': session_revision, \ 'current_context': current_context, \ 'current_version': current_version, \ 'current_revision': current_revision } version_wdg.set_options(data) table.add_cell(version_wdg, "no_wrap") td = table.add_cell(HtmlElement.b("(%s)" %current_context)) td.add_tip("Snapshot code: %s" % snapshot.get_code()) #table.add_cell(snapshot.get_code() ) #if snapshot.is_current(): # current = IconWdg("current", IconWdg.CURRENT) # table.add_cell(current) #else: # table.add_blank_cell() # handle subreferences has_subreferences = True xml = snapshot.get_xml_value("snapshot") refs = xml.get_nodes("snapshot/file/ref") if my.mode == "output" and refs: table.add_row() td = table.add_cell() swap = SwapDisplayWdg.get_triangle_wdg() td.add(swap) td.add("[ %s reference(s)" % len(refs)) #td.add_style("text-align: right") sub_ref_wdg = SubRefWdg() sub_ref_wdg.set_info(snapshot, my.session, namespace) swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id() ) status = sub_ref_wdg.get_overall_status() td.add(SpanWdg(VersionWdg.get(status), css='small_left')) td.add(']') td.add( sub_ref_wdg ) td.add_style('padding-left: 10px') #else: if not snapshots: table.add_row() table.add_blank_cell() table.add_cell("(---)") return table
def get_display(my): my.init_kwargs() sobject = my.get_current_sobject() table = Table(css='minimal') table.add_color("color", "color") table.add_style("font-size: 0.9em") snapshots = my.get_snapshot(my.mode) for snapshot in snapshots: table.add_row() value = my.get_input_value(sobject, snapshot) current_version = snapshot.get_value("version") current_context = snapshot.get_value("context") current_revision = snapshot.get_value("revision", no_exception=True) current_snapshot_type = snapshot.get_value("snapshot_type") # hack hard coded type translation if current_snapshot_type == "anim_export": current_snapshot_type = "anim" # ignore icon context completely if current_context == "icon": table.add_blank_cell() table.add_cell("(---)") return table checkbox = CheckboxWdg('%s_%s' % (my.search_type, my.CB_NAME)) # this is added back in for now to work with 3.7 Fast table checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True}) checkbox.add_class('spt_latest_%s' % my.mode) checkbox.set_option("value", value) table.add_cell(checkbox) load_all = False if load_all: checkbox.set_checked() # add the file type icon xml = snapshot.get_snapshot_xml() file_name = xml.get_value("snapshot/file/@name") icon_link = ThumbWdg.find_icon_link(file_name) image = HtmlElement.img(icon_link) image.add_style("width: 15px") table.add_cell(image) namespace = my.get_namespace(sobject, snapshot) asset_code = my.get_asset_code() # force asset mode = True my.session.set_asset_mode(asset_mode=my.get_session_asset_mode()) node_name = my.get_node_name(snapshot, asset_code, namespace) # get session info session_context = session_version = session_revision = None if my.session: session_context = my.session.get_context( node_name, asset_code, current_snapshot_type) session_version = my.session.get_version( node_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision( node_name, asset_code, current_snapshot_type) # Maya Specific: try with namespace in front of it for referencing referenced_name = '%s:%s' % (namespace, node_name) if not session_context or not session_version: session_context = my.session.get_context( referenced_name, asset_code, current_snapshot_type) session_version = my.session.get_version( referenced_name, asset_code, current_snapshot_type) session_revision = my.session.get_revision( referenced_name, asset_code, current_snapshot_type) from version_wdg import CurrentVersionContextWdg, SubRefWdg version_wdg = CurrentVersionContextWdg() data = {'session_version': session_version, \ 'session_context': session_context, \ 'session_revision': session_revision, \ 'current_context': current_context, \ 'current_version': current_version, \ 'current_revision': current_revision } version_wdg.set_options(data) table.add_cell(version_wdg, "no_wrap") td = table.add_cell(HtmlElement.b("(%s)" % current_context)) td.add_tip("Snapshot code: %s" % snapshot.get_code()) #table.add_cell(snapshot.get_code() ) #if snapshot.is_current(): # current = IconWdg("current", IconWdg.CURRENT) # table.add_cell(current) #else: # table.add_blank_cell() # handle subreferences has_subreferences = True xml = snapshot.get_xml_value("snapshot") refs = xml.get_nodes("snapshot/file/ref") if my.mode == "output" and refs: table.add_row() td = table.add_cell() swap = SwapDisplayWdg.get_triangle_wdg() td.add(swap) td.add("[ %s reference(s)" % len(refs)) #td.add_style("text-align: right") sub_ref_wdg = SubRefWdg() sub_ref_wdg.set_info(snapshot, my.session, namespace) swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id()) status = sub_ref_wdg.get_overall_status() td.add(SpanWdg(VersionWdg.get(status), css='small_left')) td.add(']') td.add(sub_ref_wdg) td.add_style('padding-left: 10px') #else: if not snapshots: table.add_row() table.add_blank_cell() table.add_cell("(---)") return table
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(my): my.search_type = my.kwargs.get('search_type') my.texture_search_type = my.kwargs.get('texture_search_type') assert my.search_type app_name = WebContainer.get_web().get_selected_app() # add an outside box top = DivWdg(css='spt_view_panel') #div = DivWdg(css="maq_search_bar") div = DivWdg() div.add_color("background", "background2", -15) my.set_as_panel(top) top.add(div) div.add_style("margin: 5px") div.add_style("padding: 10px") div.add_style("font-style: bold") process_div = DivWdg() process_div.add_style("padding-left: 10px") div.add(process_div) process_div.add(my.get_process_wdg(my.search_type)) process_div.add(my.get_context_filter_wdg()) process_div.add(HtmlElement.br(clear="all")) div.add(HtmlElement.br()) checkin_options = DivWdg(css='spt_ui_options') checkin_options.add_style("padding: 10px") swap = SwapDisplayWdg() #swap.set_off() title = SpanWdg("Check in Options") SwapDisplayWdg.create_swap_title(title, swap, checkin_options, is_open=False) div.add(swap) div.add(title) checkin_options.add(my.get_file_type_wdg()) checkin_options.add(my.get_snapshot_type_wdg()) checkin_options.add(HtmlElement.br(1)) checkin_options.add(my.get_export_method_wdg()) checkin_options.add(my.get_checkin_as_wdg()) #my.add( my.get_render_icon_wdg() ) # For different export methods checkin_options.add(my.get_currency_wdg()) checkin_options.add(my.get_reference_option()) checkin_options.add(my.get_auto_version_wdg()) checkin_options.add(my.get_texture_option(app=app_name)) checkin_options.add(my.get_handoff_wdg()) if not my.context_select.get_value(for_display=True): my.add(DivWdg('A context must be selected.', css='warning')) return div.add(checkin_options) top.add(my.get_introspect_wdg()) top.add(HtmlElement.br(2)) # create the interface table = Table() table.set_max_width() #table.set_class("table") table.add_color('background', 'background2') #table.add_style('line-height','3.0em') #table.add_row(css='smaller') tr = table.add_row(css='smaller') tr.add_style('height', '3.5em') table.add_header(" ") table.add_header(" ") th = table.add_header("Instance") th.add_style('text-align: left') table.add_header(my.get_checkin()) table.add_header("Sandbox") tr.add_color('background', 'background2', -15) # get session and handle case where there is no session my.session = SessionContents.get() if my.session == None: instance_names = [] asset_codes = [] node_names = [] else: instance_names = my.session.get_instance_names() asset_codes = my.session.get_asset_codes() node_names = my.session.get_node_names() # get all of the possible assets based on the asset codes search = Search(my.search_type) search.add_filters("code", asset_codes) assets = search.get_sobjects() assets_dict = SObject.get_dict(assets, ["code"]) if my.session: my.add("Current Project: <b>%s</b>" % my.session.get_project_dir()) else: my.add("Current Project: Please press 'Introspect'") count = 0 for i in range(0, len(node_names)): node_name = node_names[i] if not my.session.is_tactic_node(node_name) and \ not my.session.get_node_type(node_name) in ['transform','objectSet']: continue instance_name = instance_names[i] # backwards compatible: try: asset_code = asset_codes[i] except IndexError, e: asset_code = instance_name # skip if this is a reference if my.list_references == False and \ my.session.is_reference(node_name): continue table.add_row() # check that this asset exists asset = assets_dict.get(asset_code) if not asset: continue # list items if it is a set if asset.get_value('asset_type', no_exception=True) in ["set", "section"]: my.current_sobject = asset my.handle_set(table, instance_name, asset, instance_names) count += 1 # if this asset is in the database, then allow it to checked in if asset: if my.session.get_snapshot_code(instance_name, snapshot_type='set'): continue # hack remember this my.current_sobject = asset my.handle_instance(table, instance_name, asset, node_name) else: table.add_blank_cell() table.add_cell(instance_name) count += 1
def get_info_wdg(my): widget = Widget() table = Table() table.set_class("minimal") table.add_style("font-size: 0.8em") context_option = my.kwargs.get('context') context_expr_option = my.kwargs.get('context_expr') pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True'] setting_option = my.kwargs.get('setting') context_name = "%s|context" % my.get_input_name() text = None span1 = SpanWdg("Context", id='context_mode') span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode') span2.add_style('display', 'none') table.add_cell(span1) table.add_data(span2) if context_expr_option or context_option or setting_option: # add swap display for subcontext only if there is setting or context option swap = SwapDisplayWdg() table.add_data(SpanWdg(swap, css='small')) swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]')) subcontext_name = "%s|subcontext" % my.get_input_name() subcontext = SpanWdg('/ ', css='small') subcontext.add(TextWdg(subcontext_name)) subcontext.add_style('display', 'none') subcontext.set_id(subcontext_name) on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')" % subcontext_name off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\ "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name) swap.add_action_script(on_script, off_script) text = SelectWdg(context_name) if my.sobjects: text.set_sobject(my.sobjects[0]) if context_expr_option: text.set_option('values_expr', context_expr_option) elif context_option: text.set_option('values', context_option) elif setting_option: text.set_option('setting', setting_option) td = table.add_cell(text) table.add_data(subcontext) elif pipeline_option: from pyasm.biz import Pipeline sobject = my.sobjects[0] pipeline = Pipeline.get_by_sobject(sobject) context_names = [] process_names = pipeline.get_process_names(recurse=True) for process in process_names: context_names.append(pipeline.get_output_contexts(process)) text = SelectWdg(context_name) text.set_option('values', process_names) table.add_cell(text) else: text = TextWdg(context_name) table.add_cell(text) hint = HintWdg('If not specified, the default is [publish]') table.add_data(hint) revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\ label='is revision', css='med') table.add_data(revision_cb) table.add_row() table.add_cell("Comment") textarea = TextAreaWdg("%s|description" % my.get_input_name()) table.add_cell(textarea) widget.add(table) return widget
def get_info_wdg(my): widget = Widget() table = Table() table.set_class("minimal") table.add_style("font-size: 0.8em") context_option = my.kwargs.get('context') context_expr_option = my.kwargs.get('context_expr') pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True'] setting_option = my.kwargs.get('setting') context_name = "%s|context" % my.get_input_name() text = None span1 = SpanWdg("Context", id='context_mode') span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode') span2.add_style('display','none') table.add_cell(span1) table.add_data(span2) if context_expr_option or context_option or setting_option: # add swap display for subcontext only if there is setting or context option swap = SwapDisplayWdg() table.add_data(SpanWdg(swap, css='small')) swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]')) subcontext_name = "%s|subcontext" % my.get_input_name() subcontext = SpanWdg('/ ', css='small') subcontext.add(TextWdg(subcontext_name)) subcontext.add_style('display','none') subcontext.set_id(subcontext_name) on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')"%subcontext_name off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\ "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name) swap.add_action_script(on_script, off_script) text = SelectWdg(context_name) if my.sobjects: text.set_sobject(my.sobjects[0]) if context_expr_option: text.set_option('values_expr', context_expr_option) elif context_option: text.set_option('values', context_option) elif setting_option: text.set_option('setting', setting_option) td = table.add_cell(text) table.add_data(subcontext) elif pipeline_option: from pyasm.biz import Pipeline sobject = my.sobjects[0] pipeline = Pipeline.get_by_sobject(sobject) context_names = [] process_names = pipeline.get_process_names(recurse=True) for process in process_names: context_names.append(pipeline.get_output_contexts(process)) text = SelectWdg(context_name) text.set_option('values', process_names) table.add_cell(text) else: text = TextWdg(context_name) table.add_cell(text) hint = HintWdg('If not specified, the default is [publish]') table.add_data(hint) revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\ label='is revision', css='med') table.add_data(revision_cb) table.add_row() table.add_cell("Comment") textarea = TextAreaWdg("%s|description"% my.get_input_name()) table.add_cell(textarea) widget.add(table) return widget
def get_viewer(self): top = DivWdg(css='spt_single_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('context') title.add_color('color','color') div = DivWdg(css='spt_context_cb') div.add_color('color','color') SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) checkbox_name = 'split_screen' checked_process_names = [] if self.show_context: top.add(swap) top.add(title) top.add(div) #checkbox_name = 'note_context_cb' checkbox_name = self.checkbox_name cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb checked_process_names = cb.get_values() for value in self.process_names: #self.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in checked_process_names: self.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_single_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.%s; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, checkbox_name, key) }) div.add(cb) else: web = WebContainer.get_web() checked_process_names = web.get_form_values('process_names') table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(checked_process_names) table_id = 'main_table1' 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(table) table_top.add(inner_wdg) else: table_top.add(table) self.set_as_panel(table_top) top.add(table_top) return top
def get_viewer(my): top = DivWdg(css='spt_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('main context') split_div = FloatDivWdg(css='spt_split_cb') div = DivWdg(css='spt_main_context_cb') content_div = DivWdg() content_div.add_color('color', 'color') content_div.add_style('padding: 10px') SwapDisplayWdg.create_swap_title(title, swap, content_div, is_open=False) div.add(swap) div.add(title) checkbox_name = 'split_screen' split_cb = CheckboxWdg(checkbox_name, label='Split View') split_cb.persistence = True split_cb.persistence_obj = split_cb key = split_cb.get_key() #cb.add_style('float: left') split_cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top"); var table_top = top.getElement(".spt_note_viewer_table"); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_context_cb; var kwargs = { process_names: processes}; if (bvr.src_el.checked) { kwargs.split_view = 'true'; kwargs.show_context = 'true'; kwargs.left_process_names = processes; kwargs.right_process_names = processes; } spt.input.save_selected(bvr, '%s','%s'); spt.app_busy.show("Note Viewer", 'Loading') ; setTimeout(function(){ spt.panel.refresh(table_top, kwargs, false); if (bvr.src_el.checked) spt.hide(cbs); else spt.show(cbs); spt.app_busy.hide(); }, 50 ); ''' % (checkbox_name, key) }) split_div.add(split_cb) top.add(split_div) top.add(div) div.add(content_div) top.add(HtmlElement.br()) checkbox_name = 'note_main_context_cb' cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb my.checked_process_names = cb.get_values() for value in my.process_names: #my.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in my.checked_process_names: my.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_main_context_cb; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, key) }) content_div.add(cb) table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( my.checked_processes) if split_cb.is_checked(): table = my.get_split_viewer() else: table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) my.set_as_panel(table_top) table_top.add_style('float: left') top.add(table_top) table_top.add(table) return top
def get_display(self): widget = Widget() div = DivWdg(css='spt_ui_options') div.set_unique_id() table = Table() div.add(table) table.add_style("margin: 5px 15px") table.add_color('color','color') swap = SwapDisplayWdg() #swap.set_off() app = WebContainer.get_web().get_selected_app() outer_span = SpanWdg() outer_span.add_style('float: right') span = SpanWdg(app, css='small') icon = IconWdg(icon=eval("IconWdg.%s"%app.upper()), width='13px') outer_span.add(span) outer_span.add(icon) title = SpanWdg("Loading Options") title.add(outer_span) SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) widget.add(swap) widget.add(title) widget.add(div) if not self.hide_instantiation: table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Instantiation: ")) table.add_cell(div) div = self.get_instantiation_wdg() table.add_cell(div) setting = self.get_default_setting() default_instantiation = setting.get('instantiation') default_connection = setting.get('connection') default_dependency = setting.get('texture_dependency') if not self.hide_connection: table.add_row() table.add_blank_cell() con_div = DivWdg(HtmlElement.b("Connection: ")) table.add_cell(con_div) td = table.add_cell() is_unchecked = True default_cb = None for value in ['http', 'file system']: name = self.get_element_name("connection") checkbox = CheckboxWdg( name ) checkbox.set_option("value", value) checkbox.set_persistence() if value == default_connection: default_cb = checkbox if checkbox.is_checked(): is_unchecked = False checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True, "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) span = SpanWdg(checkbox, css='small') span.add(value) td.add(span) if is_unchecked: default_cb.set_checked() if not self.hide_dependencies: table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Texture Dependencies: ")) table.add_cell(div) td = table.add_cell() is_unchecked = True default_cb = None for value in ['as checked in', 'latest', 'current']: name = self.get_element_name("dependency") checkbox = CheckboxWdg( name ) checkbox.set_option("value", value) checkbox.set_persistence() checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True, "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) if value == default_dependency: default_cb = checkbox if checkbox.is_checked(): is_unchecked = False span = SpanWdg(checkbox, css='small') span.add(value) td.add(span) if is_unchecked: default_cb.set_checked() from connection_select_wdg import ConnectionSelectWdg table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Connection Type: ")) table.add_cell(div) table.add_cell( ConnectionSelectWdg() ) table.add_row() table.add_blank_cell() div = DivWdg(HtmlElement.b("Connection Port: ")) table.add_cell(div) port_div = DivWdg() port_text = TextWdg("port") port_text.set_option('size','6') port_div.add(port_text) port_div.add_style("padding-left: 7px") port_div.add_style("width: 40px") table.add_cell( port_div ) from pyasm.prod.web import WidgetSettings value = WidgetSettings.get_value_by_key("CGApp:connection_port") if value: port_text.set_value(value) elif WebContainer.get_web().get_selected_app() == 'Houdini': port_text.set_value("13000") else: port_text.set_value("4444") port_text.add_behavior( { 'type': 'change', 'cbjs_action': ''' var value = bvr.src_el.value; value = parseInt(value); var kwargs = { 'data': value, 'key': 'CGApp:connection_port' } var cmd = "pyasm.web.WidgetSettingSaveCbk" var server = TacticServerStub.get(); server.execute_cmd(cmd, kwargs); // FIXME: this is dangerous use of a global var app.port = value; ''' } ) return widget
def get_group_wdg(self): div = DivWdg() title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") title_wdg.add_gradient("background", "background") title_wdg.add("Users") title_wdg.add_style("min-width: 200px") filtered_groups = self.kwargs.get("groups") if isinstance(filtered_groups, basestring): filtered_groups = filtered_groups.split("|") search = Search("sthpw/login_group") if filtered_groups: search.add_filters("login_group", filtered_groups) security = Environment.get_security() if not security.check_access("builtin", "view_site_admin", "allow"): search.add_filter("login_group", "admin", op="!=") search.add_project_filter() groups = search.get_sobjects() groups_div = DivWdg() div.add(groups_div) for group in groups: group_div = DivWdg() groups_div.add(group_div) title_div = DivWdg() group_div.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("margin-top: 5px") title_div.add_style("padding: 2px") swap = SwapDisplayWdg() title_div.add(swap) swap.add_style("float: left") title = DivWdg(group.get_value("login_group")) title_div.add(title) #title.add_style("float: left") title.add_style("font-weight: bold") title.add_style("padding-top: 2px") content_div = DivWdg() group_div.add(content_div) SwapDisplayWdg.create_swap_title(title, swap, div=content_div, is_open=True, action_script=None) logins = group.get_logins() logins_div = self.get_logins_wdg(logins) content_div.add(logins_div) content_div.add_style("padding-left: 15px") return div
def get_group_wdg(my): div = DivWdg() title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") title_wdg.add_gradient("background", "background") title_wdg.add("Users") title_wdg.add_style("min-width: 200px") filtered_groups = my.kwargs.get("groups") if isinstance(filtered_groups, basestring): filtered_groups = filtered_groups.split("|") search = Search("sthpw/login_group") if filtered_groups: search.add_filters("login_group", filtered_groups) security = Environment.get_security() if not security.check_access("builtin", "view_site_admin", "allow"): search.add_filter("login_group", "admin", op="!=") search.add_project_filter() groups = search.get_sobjects() groups_div = DivWdg() div.add(groups_div) for group in groups: group_div = DivWdg() groups_div.add(group_div) title_div = DivWdg() group_div.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("margin-top: 5px") title_div.add_style("padding: 2px") swap = SwapDisplayWdg() title_div.add(swap) swap.add_style("float: left") title = DivWdg(group.get_value("login_group")) title_div.add(title) # title.add_style("float: left") title.add_style("font-weight: bold") title.add_style("padding-top: 2px") content_div = DivWdg() group_div.add(content_div) SwapDisplayWdg.create_swap_title(title, swap, div=content_div, is_open=True, action_script=None) logins = group.get_logins() logins_div = my.get_logins_wdg(logins) content_div.add(logins_div) content_div.add_style("padding-left: 15px") return div