def get_context_wdg(self, search_type): '''drop down which selects which context to checkin''' # add a filter # use a regular SelectWdg with submit instead of FilterSelectWdg filter_div = FloatDivWdg("Context / subcontext:") select = SelectWdg("publish_context") labels, values = self.get_context_data(search_type, self.process) select.set_option("values", "|".join(values)) select.set_option("labels", "|".join(labels)) select.append_option('publish','publish') select.add_style("font-size: 0.8em") select.add_style("margin: 0px 3px") # explicitly set the value current = select.get_value() if current in values: context = current elif values: context = values[0] else: context = "" web = WebContainer.get_web() web.set_form_value("publish_context", context) select.set_value( context ) # set it to a instance variable self.context_select = select filter_div.add(select) # if specified, add a sub_context base_search_type = SearchType(search_type).get_base_key() settings = ProdSetting.get_value_by_key("%s/sub_context" % context,\ base_search_type) filter_div.add( "/ ") sub_context = None if settings: sub_context = SelectWdg("publish_sub_context") sub_context.set_option("values", settings) sub_context.set_submit_onchange() sub_context.add_empty_option("<- Select ->") else: # provide a text field sub_context = TextWdg("publish_sub_context") sub_context.set_attr('size','10') sub_context.set_persistence() filter_div.add( sub_context ) self.sub_context_select = sub_context #filter_div.add_style('padding-right','10px') return filter_div
def get_context_wdg(my, search_type): '''drop down which selects which context to checkin''' # add a filter # use a regular SelectWdg with submit instead of FilterSelectWdg filter_div = FloatDivWdg("Context / subcontext:") select = SelectWdg("publish_context") labels, values = my.get_context_data(search_type, my.process) select.set_option("values", "|".join(values)) select.set_option("labels", "|".join(labels)) select.append_option('publish','publish') select.add_style("font-size: 0.8em") select.add_style("margin: 0px 3px") # explicitly set the value current = select.get_value() if current in values: context = current elif values: context = values[0] else: context = "" web = WebContainer.get_web() web.set_form_value("publish_context", context) select.set_value( context ) # set it to a instance variable my.context_select = select filter_div.add(select) # if specified, add a sub_context base_search_type = SearchType(search_type).get_base_key() settings = ProdSetting.get_value_by_key("%s/sub_context" % context,\ base_search_type) filter_div.add( "/ ") sub_context = None if settings: sub_context = SelectWdg("publish_sub_context") sub_context.set_option("values", settings) sub_context.set_submit_onchange() sub_context.add_empty_option("<- Select ->") else: # provide a text field sub_context = TextWdg("publish_sub_context") sub_context.set_attr('size','10') sub_context.set_persistence() filter_div.add( sub_context ) my.sub_context_select = sub_context #filter_div.add_style('padding-right','10px') return filter_div
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(my): sobject = my.get_current_sobject() if isinstance(sobject, Shot): frame_range = sobject.get_frame_range() frame_in, frame_out = sobject.get_frame_handles() frame_notes = sobject.get_frame_notes() else: from pyasm.prod.biz import FrameRange frame_start = my._get_frame_num(sobject, "tc_frame_start") frame_end = my._get_frame_num(sobject, "tc_frame_end") frame_range = FrameRange(frame_start, frame_end, 1 ) frame_in, frame_out = my._get_frame_handles(sobject) frame_notes = sobject.get_value("frame_note", no_exception=True) frame_notes = WikiUtil().convert(frame_notes) if frame_range.frame_end == frame_range.frame_start == 0: return 'n/a' widget = SpanWdg() widget.set_attr("nowrap", "1") offset = 2 label_width = 16 if frame_range.frame_start > 99: label_width = 20 # start / end frame duration_color = '#969353' div = DivWdg() div.add_tip('START -- END (TOTAL)') wdg_width = 150 div.add_style('width', wdg_width) total = frame_range.frame_end - frame_range.frame_start + 1 start_frame = SpanWdg(str(frame_range.frame_start)) end_frame = SpanWdg(str(frame_range.frame_end)) end_div = FloatDivWdg(end_frame) duration_width = wdg_width * 0.2 - offset #spacer_width = float('%.2f' %((duration_width + offset) * (frame_range.frame_start -1 ) /\ # frame_range.frame_end)) spacer_width = 0 start_div = FloatDivWdg(start_frame, width=label_width+spacer_width ) start_div.add_class('right_content') duration = FloatDivWdg( width=duration_width ) duration.add_style("border: 1px dotted %s" % duration_color) duration.add_style("margin-top: 3px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("height: 3px") duration.add_style("line-height: 3px") div.add(start_div) div.add(duration) div.add(end_div) dur_text = FloatDivWdg('<i>(%s)</i>' %total) dur_text.add_style("opacity", "0.3") div.add(dur_text) widget.add(div) widget.add(HtmlElement.br()) if frame_in: # in / out frame duration_color = '#b8b365' div = DivWdg() div.add_tip('IN -- OUT') div.add_style('width', wdg_width) handle_total = frame_out - frame_in + 1 in_frame = SpanWdg(str(frame_in)) out_frame = SpanWdg(str(frame_out)) if frame_range.frame_start == 0: frame_range.frame_start = 0.001 spacer_width = float('%.2f' % ((spacer_width) * \ float(frame_in) /frame_range.frame_start )) in_div = FloatDivWdg(in_frame, width=label_width + spacer_width) in_div.add_class('right_content') out_div = FloatDivWdg(out_frame) factor = float(handle_total) / total if factor > 1: factor = 1 duration_width = (duration_width + offset) * factor - offset duration = FloatDivWdg( width=duration_width ) duration.add_style("border: 1px solid %s" % duration_color) duration.add_style("background", duration_color) duration.add_style("margin-top: 5px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("line-height: 1px") duration.add(' ') # IE needs that to draw a 1px wide div bar = FloatDivWdg('<!-- -->', width=1) bar.add_style("margin-top: 1px") bar.add_style("line-height: 10px") bar.add_style("background", duration_color) div.add(in_div) div.add(bar) div.add(duration) div.add(bar) div.add(out_div) dur_text = SpanWdg('<i>(%s)</i>' %handle_total) dur_text.add_style("opacity", "0.3") div.add(dur_text) widget.add(div) if frame_notes: widget.add(HtmlElement.br()) widget.add(frame_notes) return widget
def get_display(self): self.check() if self.is_refresh: div = Widget() else: div = DivWdg() self.set_as_panel(div) div.add_style('padding', '6px') min_width = '400px' div.add_style('min-width', min_width) div.add_color('background', 'background') div.add_class('spt_add_task_panel') div.add_style("padding: 20px") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="creating-tasks") div.add(help_button) help_button.add_style("float: right") help_button.add_style("margin-top: -5px") if not self.search_key_list: msg_div = DivWdg() msg_table = Table() msg_div.add(msg_table) msg_table.add_row() msg_table.add_cell(IconWdg("No items selected", IconWdg.WARNING)) msg_table.add_cell( 'Please select at least 1 item to add tasks to.') msg_div.add_style('margin: 10px') msg_table.add_style("font-weight: bold") div.add(msg_div) return div msg_div = DivWdg() msg_div.add_style('margin-left: 4px') div.add(msg_div, 'info') msg_div.add('Total: %s item/s to add tasks to' % len(self.search_key_list)) div.add(HtmlElement.br()) hint = HintWdg('Tasks are added according to the assigned pipeline.') msg_div.add(" ") msg_div.add(hint) msg_div.add(HtmlElement.br()) option_div = DivWdg(css='spt_ui_options') #option_div.add_style('margin-left: 12px') sel = SelectWdg('pipeline_mode', label='Create tasks by: ') sel.set_option('values', ['simple process', 'context', 'standard']) sel.set_option('labels', ['process', 'context', 'all contexts in process']) sel.set_persistence() sel.add_behavior({ 'type': 'change', 'cbjs_action': 'spt.panel.refresh(bvr.src_el)' }) option_div.add(sel) value = sel.get_value() # default to simple process if not value: value = 'simple process' msg = '' if value not in ['simple process', 'context', 'standard']: value = 'simple process' if value == 'context': msg = 'In context mode, a single task will be created for each selected context.' elif value == 'simple process': msg = 'In process mode, a single task will be created for each selected process.' elif value == 'standard': msg = 'In this mode, a task will be created for all contexts of each selected process.' option_div.add(HintWdg(msg)) div.add(option_div) div.add(HtmlElement.br()) title = DivWdg('Assigned Pipelines') title.add_style('padding: 6px') title.add_color('background', 'background2') title.add_color('color', 'color', +120) div.add(title) content_div = DivWdg() content_div.add_style('min-height', '150px') div.add(content_div) content_div.add_border() filtered_search_key_list = [] for sk in self.search_key_list: id = SearchKey.extract_id(sk) if id == '-1': continue filtered_search_key_list.append(sk) sobjects = SearchKey.get_by_search_keys(filtered_search_key_list) skipped = [] pipeline_codes = [] for sobject in sobjects: if isinstance(sobject, Task): msg_div = DivWdg( 'WARNING: Creation of task for [Task] is not allowed.') msg_div.add_style('margin-left: 10px') div.add(msg_div, 'info') return div pipeline_code = sobject.get_value('pipeline_code', no_exception=True) if not pipeline_code: skipped.append(sobject) if pipeline_code not in pipeline_codes: pipeline_codes.append(pipeline_code) pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes) if pipelines == None: pipelines = [] #if not pipelines: # msg_div = DivWdg('WARNING: No Pipelines found for selected.') # msg_div.add_style('margin-left: 10px') # div.add(msg_div, 'info') # return div # expand the width according to num of pipelines content_div.add_style('min-width', len(pipelines) * 250) mode_cb = SelectWdg('pipeline_mode') mode_cb.set_persistence() mode = mode_cb.get_value() if 'context' == mode: mode = 'context' else: mode = 'process' show_subpipeline = True min_height = '150px' # create a temp default pipeline if not pipelines: pipeline = SearchType.create("sthpw/pipeline") pipeline.set_value("code", "__default__") pipeline.set_value( "pipeline", ''' <pipeline> <process name='publish'/> </pipeline> ''') # FIXME: HACK to initialize virtual pipeline pipeline.set_pipeline(pipeline.get_value("pipeline")) pipelines = [pipeline] for pipeline in pipelines: name = pipeline.get_value("name") if not name: name = pipeline.get_code() span = SpanWdg("Pipeline: %s" % name) span.add_style('font-weight: bold') v_div = FloatDivWdg(span) v_div.add_style('margin: 20px') v_div.add_style('min-height', min_height) v_div.add(HtmlElement.br(2)) content_div.add(v_div) processes = pipeline.get_processes(recurse=show_subpipeline, type=['manual', 'approval']) cb_name = '%s|task_process' % pipeline.get_code() master_cb = CheckboxWdg('master_control') master_cb.set_checked() master_cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; ''' % cb_name }) toggle_div = DivWdg() toggle_div.add(SpanWdg(master_cb, css='small')) label = HtmlElement.i('toggle all') label.add_style('color: #888') toggle_div.add_styles( 'border-bottom: 1px solid #888; width: 170px') toggle_div.add(label) v_div.add(toggle_div) process_names = [] for process in processes: process_labels = [] if process.is_from_sub_pipeline(): process_name = process.get_full_name() else: process_name = process.get_name() process_label = process.get_label() if not process_label: process_label = '' if mode == 'context': contexts = pipeline.get_output_contexts(process.get_name()) labels = contexts if process.is_from_sub_pipeline(): labels = [ '%s/%s' % (process.parent_pipeline_code, x) for x in contexts ] for x in labels: process_labels.append(process_label) # prepend process to contexts in this mode to ensure uniqueness contexts = ['%s:%s' % (process_name, x) for x in contexts] else: contexts = [process_name] labels = contexts process_labels.append(process_label) for idx, context in enumerate(contexts): cb = CheckboxWdg(cb_name) cb.set_checked() cb.set_option('value', context) v_div.add(SpanWdg(cb, css='small')) if mode == 'context': span = SpanWdg(process_name, css='med') #span.add_color('color','color') v_div.add(span) v_div.add(SpanWdg(labels[idx])) process_label = process_labels[idx] if process_label: v_div.add(SpanWdg("(%s)" % process_label, css='small')) v_div.add(HtmlElement.br()) content_div.add("<br clear='all'/>") skipped = [] if True: div.add("<br/>") btn = ActionButtonWdg(title='Add Tasks') btn.add_behavior({ 'type': 'click_up', 'post_event': 'search_table_%s' % self.table_id, 'cbjs_action': ''' spt.dg_table.add_task_selected(bvr); ''', 'search_key_list': self.search_key_list }) cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates') cb.set_checked() option_div = DivWdg(cb) option_div.add_style('width', '130px') option_div.add_style('align: left') div.add(option_div) div.add(HtmlElement.br()) btn.add_style("float: right") div.add(btn) div.add(HtmlElement.br(clear="all")) if skipped: content_div.add(HtmlElement.br()) skip_div = DivWdg('Missing pipeline code (Skipped)') skip_div.add_style('text-decoration: underline') content_div.add(skip_div) content_div.add(HtmlElement.br()) item_div = DivWdg() item_div.add_style('margin-left: 10px') content_div.add(item_div) for skip in skipped: item_div.add(skip.get_code()) item_div.add(HtmlElement.br()) return div
def get_display(my): #content.add_event("oncontextmenu", "spt.side_bar.manage_context_menu_action_cbk(); return false") context_menu = DivWdg() context_menu.add_class('spt_menu_top') context_menu.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.finger_menu = {}; spt.finger_menu.timeout_id = -1; ''' }) context_menu.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' if (spt.finger_menu.timeout_id != -1) { clearTimeout(spt.finger_menu.timeout_id); spt.finger_menu.timeout_id = -1; } ''' }) #context_menu.set_box_shadow(color='#fff') # this may not be needed as it is set in JS context_menu.add_style("z-index: 200") # set up what happens when the mouse leaves the actual menu my._set_menu_out(context_menu) width = my.kwargs.get('width') height = my.kwargs.get('height') if not height: height = 20 if not width: width = 35 font_size = my.kwargs.get('font_size') if not font_size: font_size = 'smaller' force = my.kwargs.get("force") if my.mode == 'horizontal': div = DivWdg(css='spt_finger_menu') if force: div.add_attr("spt_finger_force", force) div.add_style("border-color: #aaa") div.add_style("border-style: solid") if force == "left": div.add_style("border-width: 1px 0px 1px 1px") div.add_style("border-radius: 12px 0px 0px 12px") else: div.add_style("border-width: 1px 1px 1px 0px") div.add_style("border-radius: 0px 12px 12px 0px") div.set_box_shadow(value="0px 0px 2px 1px") #div.add_style("z-index: 1000") total_width = width * len(my.items) + 15 div.add_style('width', total_width) div.add_styles('height: %spx; padding: 2px;' % height) context_menu.add(div) div.add_color('background', 'background', -10) palette = div.get_palette() sb_title_bg = palette.color('side_bar_title') bg_color = div.get_color('background', -10) color = div.get_color('color') for item in my.items: mouse_enter_bvr = { 'type': 'mouseenter', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': 'white'})''' % sb_title_bg } mouse_leave_bvr = { 'type': 'mouseleave', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': '%s'})''' % (bg_color, color) } menu_item = FloatDivWdg(css='unselectable hand') menu_item.add_color('background', 'background', -10) menu_item.add(item.get_option('label')) menu_item.add_behavior(mouse_enter_bvr) menu_item.add_behavior(mouse_leave_bvr) # add the passed-in bvr bvr = item.get_option('bvr_cb') menu_item.add_behavior(bvr) menu_item.add_styles( 'margin: 0px 0 0 0; padding: 2px 0 2px 0; text-align: center; font-size: %s; width: %s; height: %spx' % (font_size, width, height - 4)) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);''' }) div.add(menu_item) else: # this width only matters in vertical mode context_menu.add_style("width: %s" % width) menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 4px; border-collapse: collapse; cell-padding: 8px; border-radius: 32px;" ) context_menu.add(menu_table) my._add_spacer_row(menu_table, 3, width) for widget in my.widgets: tbody = menu_table.add_tbody() tbody.add_style("display", "table-row-group") tr = menu_table.add_row() tr.add_looks("smenu") #tr.add_class( "SPT_SMENU_ENTRY" ) hover_bvr = {'type': 'hover', 'add_looks': 'smenu_hilite'} #'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', #'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } tr.add_behavior(hover_bvr) menu_item = menu_table.add_cell() font_size = '4px' menu_item.add_styles( 'padding: 0px 0 0 6px; font-size: %s; width: %s; height: 16px' % (font_size, width)) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);''' }) menu_item.add(widget) my._add_spacer_row(menu_table, 3, width) return context_menu
def get_display(self): self.check() if self.is_refresh: div = Widget() else: div = DivWdg() self.set_as_panel(div) div.add_style('padding','6px') min_width = '400px' div.add_style('min-width', min_width) div.add_color('background','background') div.add_class('spt_add_task_panel') div.add_style("padding: 20px") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="creating-tasks") div.add(help_button) help_button.add_style("float: right") help_button.add_style("margin-top: -5px") if not self.search_key_list: msg_div = DivWdg() msg_table = Table() msg_div.add(msg_table) msg_table.add_row() msg_table.add_cell( IconWdg("No items selected", IconWdg.WARNING) ) msg_table.add_cell('Please select at least 1 item to add tasks to.') msg_div.add_style('margin: 10px') msg_table.add_style("font-weight: bold") div.add(msg_div) return div msg_div = DivWdg() msg_div.add_style('margin-left: 4px') div.add(msg_div, 'info') msg_div.add('Total: %s item/s to add tasks to' %len(self.search_key_list)) div.add(HtmlElement.br()) hint = HintWdg('Tasks are added according to the assigned pipeline.') msg_div.add(" ") msg_div.add(hint) msg_div.add(HtmlElement.br()) option_div = DivWdg(css='spt_ui_options') #option_div.add_style('margin-left: 12px') sel = SelectWdg('pipeline_mode', label='Create tasks by: ') sel.set_option('values', ['simple process','context', 'standard']) sel.set_option('labels', ['process','context', 'all contexts in process']) sel.set_persistence() sel.add_behavior({'type':'change', 'cbjs_action': 'spt.panel.refresh(bvr.src_el)'}) option_div.add(sel) value = sel.get_value() # default to simple process if not value: value = 'simple process' msg = '' if value not in ['simple process','context','standard']: value = 'simple process' if value == 'context': msg = 'In context mode, a single task will be created for each selected context.' elif value == 'simple process': msg = 'In process mode, a single task will be created for each selected process.' elif value == 'standard': msg = 'In this mode, a task will be created for all contexts of each selected process.' option_div.add(HintWdg(msg)) div.add(option_div) div.add(HtmlElement.br()) title = DivWdg('Assigned Pipelines') title.add_style('padding: 6px') title.add_color('background','background2') title.add_color('color','color', +120) div.add(title) content_div = DivWdg() content_div.add_style('min-height', '150px') div.add(content_div) content_div.add_border() filtered_search_key_list = [] for sk in self.search_key_list: id = SearchKey.extract_id(sk) if id=='-1': continue filtered_search_key_list.append(sk) sobjects = SearchKey.get_by_search_keys(filtered_search_key_list) skipped = [] pipeline_codes = [] for sobject in sobjects: if isinstance(sobject, Task): msg_div = DivWdg('WARNING: Creation of task for [Task] is not allowed.') msg_div.add_style('margin-left: 10px') div.add(msg_div, 'info') return div pipeline_code = sobject.get_value('pipeline_code', no_exception=True) if not pipeline_code: skipped.append(sobject) if pipeline_code not in pipeline_codes: pipeline_codes.append(pipeline_code) pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes) if pipelines == None: pipelines = [] #if not pipelines: # msg_div = DivWdg('WARNING: No Pipelines found for selected.') # msg_div.add_style('margin-left: 10px') # div.add(msg_div, 'info') # return div # expand the width according to num of pipelines content_div.add_style('min-width', len(pipelines)*250) mode_cb = SelectWdg('pipeline_mode') mode_cb.set_persistence() mode = mode_cb.get_value() if 'context' == mode: mode = 'context' else: mode = 'process' show_subpipeline = True min_height = '150px' # create a temp default pipeline if not pipelines: pipeline = SearchType.create("sthpw/pipeline") pipeline.set_value("code", "__default__") pipeline.set_value("pipeline", ''' <pipeline> <process name='publish'/> </pipeline> ''') # FIXME: HACK to initialize virtual pipeline pipeline.set_pipeline(pipeline.get_value("pipeline")) pipelines = [pipeline] for pipeline in pipelines: name = pipeline.get_value("name") if not name: name = pipeline.get_code() span = SpanWdg("Pipeline: %s" % name) span.add_style('font-weight: bold') v_div = FloatDivWdg(span) v_div.add_style('margin: 20px') v_div.add_style('min-height', min_height) v_div.add(HtmlElement.br(2)) content_div.add(v_div) processes = pipeline.get_processes(recurse=show_subpipeline, type=['manual','approval']) cb_name = '%s|task_process' %pipeline.get_code() master_cb = CheckboxWdg('master_control') master_cb.set_checked() master_cb.add_behavior({'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; ''' %cb_name}) toggle_div = DivWdg() toggle_div.add(SpanWdg(master_cb, css='small')) label = HtmlElement.i('toggle all') label.add_style('color: #888') toggle_div.add_styles('border-bottom: 1px solid #888; width: 170px') toggle_div.add(label) v_div.add(toggle_div) process_names = [] for process in processes: process_labels = [] if process.is_from_sub_pipeline(): process_name = process.get_full_name() else: process_name = process.get_name() process_label = process.get_label() if not process_label: process_label = '' if mode =='context': contexts = pipeline.get_output_contexts(process.get_name()) labels = contexts if process.is_from_sub_pipeline(): labels = ['%s/%s'%(process.parent_pipeline_code, x) for x in contexts] for x in labels: process_labels.append(process_label) # prepend process to contexts in this mode to ensure uniqueness contexts = ['%s:%s' %(process_name, x) for x in contexts] else: contexts = [process_name] labels = contexts process_labels.append(process_label) for idx, context in enumerate(contexts): cb = CheckboxWdg(cb_name) cb.set_checked() cb.set_option('value', context) v_div.add(SpanWdg(cb, css='small')) if mode == 'context': span = SpanWdg(process_name, css='med') #span.add_color('color','color') v_div.add(span) v_div.add(SpanWdg(labels[idx])) process_label = process_labels[idx] if process_label: v_div.add(SpanWdg("(%s)" %process_label, css='small')) v_div.add(HtmlElement.br()) content_div.add("<br clear='all'/>") skipped = [] if True: div.add("<br/>") btn = ActionButtonWdg(title='Add Tasks') btn.add_behavior({'type' : 'click_up', 'post_event': 'search_table_%s'% self.table_id, 'cbjs_action': ''' spt.dg_table.add_task_selected(bvr); ''', 'search_key_list': self.search_key_list }) cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates') cb.set_checked() option_div =DivWdg(cb) option_div.add_style('width', '130px') option_div.add_style('align: left') div.add(option_div) div.add(HtmlElement.br()) btn.add_style("float: right") div.add(btn) div.add(HtmlElement.br(clear="all")) if skipped: content_div.add(HtmlElement.br()) skip_div = DivWdg('Missing pipeline code (Skipped)') skip_div.add_style('text-decoration: underline') content_div.add(skip_div) content_div.add(HtmlElement.br()) item_div = DivWdg() item_div.add_style('margin-left: 10px') content_div.add(item_div) for skip in skipped: item_div.add(skip.get_code()) item_div.add(HtmlElement.br()) return div
def get_display(my): #content.add_event("oncontextmenu", "spt.side_bar.manage_context_menu_action_cbk(); return false") context_menu = DivWdg() context_menu.add_class('spt_menu_top') context_menu.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.finger_menu = {}; spt.finger_menu.timeout_id = -1; ''' } ) context_menu.add_behavior( { 'type': 'mouseover', 'cbjs_action': ''' if (spt.finger_menu.timeout_id != -1) { clearTimeout(spt.finger_menu.timeout_id); spt.finger_menu.timeout_id = -1; } ''' } ) #context_menu.set_box_shadow(color='#fff') # this may not be needed as it is set in JS context_menu.add_style("z-index: 200") # set up what happens when the mouse leaves the actual menu my._set_menu_out(context_menu) width = my.kwargs.get('width') height = my.kwargs.get('height') if not height: height = 20 if not width: width = 35 font_size = my.kwargs.get('font_size') if not font_size: font_size = 'smaller' force = my.kwargs.get("force") if my.mode == 'horizontal': div = DivWdg(css='spt_finger_menu') if force: div.add_attr("spt_finger_force", force) div.add_style("border-color: #aaa") div.add_style("border-style: solid") if force == "left": div.add_style("border-width: 1px 0px 1px 1px") div.add_style("border-radius: 12px 0px 0px 12px") else: div.add_style("border-width: 1px 1px 1px 0px") div.add_style("border-radius: 0px 12px 12px 0px") div.set_box_shadow(value="0px 0px 2px 1px") #div.add_style("z-index: 1000") total_width = width * len(my.items) + 15 div.add_style('width', total_width) div.add_styles('height: %spx; padding: 2px;' %height) context_menu.add(div) div.add_color('background','background', -10) palette = div.get_palette() sb_title_bg = palette.color('side_bar_title') bg_color = div.get_color('background', -10) color = div.get_color('color') for item in my.items: mouse_enter_bvr = {'type':'mouseenter', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': 'white'})''' %sb_title_bg} mouse_leave_bvr = {'type':'mouseleave', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': '%s'})''' %(bg_color, color)} menu_item = FloatDivWdg(css='unselectable hand') menu_item.add_color('background','background', -10) menu_item.add(item.get_option('label')) menu_item.add_behavior( mouse_enter_bvr ) menu_item.add_behavior( mouse_leave_bvr ) # add the passed-in bvr bvr = item.get_option('bvr_cb') menu_item.add_behavior(bvr ) menu_item.add_styles('margin: 0px 0 0 0; padding: 2px 0 2px 0; text-align: center; font-size: %s; width: %s; height: %spx'%(font_size, width, height-4)) menu_item.add_behavior({'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''}) div.add(menu_item) else: # this width only matters in vertical mode context_menu.add_style("width: %s" %width) menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 4px; border-collapse: collapse; cell-padding: 8px; border-radius: 32px;" ) context_menu.add(menu_table) my._add_spacer_row(menu_table, 3, width) for widget in my.widgets: tbody = menu_table.add_tbody() tbody.add_style("display","table-row-group") tr = menu_table.add_row() tr.add_looks( "smenu" ) #tr.add_class( "SPT_SMENU_ENTRY" ) hover_bvr = {'type':'hover', 'add_looks': 'smenu_hilite'} #'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', #'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } tr.add_behavior( hover_bvr ) menu_item = menu_table.add_cell() font_size = '4px' menu_item.add_styles('padding: 0px 0 0 6px; font-size: %s; width: %s; height: 16px'%(font_size, width)) menu_item.add_behavior({'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''}) menu_item.add(widget) my._add_spacer_row(menu_table, 3, width) return context_menu
def get_display(my): search_key = my.kwargs.get("search_key") msg = None base_search_type = SearchKey.extract_search_type(search_key) sobject = SearchKey.get_by_search_key(search_key) process_div = DivWdg() process_div.add_style('padding-top: 10px') if base_search_type in ['sthpw/task', 'sthpw/note']: my.process = sobject.get_value('process') my.context = sobject.get_value('context') if not my.process: my.process = '' parent = sobject.get_parent() if parent: search_key = SearchKey.get_by_sobject(parent) else: msg = "Parent for [%s] not found"%search_key else: my.process = my.kwargs.get('process') top = my.top top.add_class('spt_simple_checkin') top.add_color("background", "background") top.add_styles("position: relative") content = DivWdg(msg) top.add(content) #content.add_border() #content.add_color("background", "background3") #content.add_color("color", "background3") content.add_style("width: 600px") content.add_styles("margin-left: auto; margin-right: auto;") content.add_style("height: 200px") from tactic.ui.widget import CheckinWdg content.add_behavior( { 'type': 'load', 'cbjs_action': CheckinWdg.get_onload_js() } ) button_div = DivWdg() content.add(process_div) content.add(button_div) button = IconWdg(title="Check-In", icon=IconWdg.CHECK_IN_3D_LG) title = Common.get_display_title(my.checkin_action) button.add_attr('title', title) button_div.add(button) button_div.set_box_shadow("1px 1px 1px 1px") button_div.add_style("width: 60px") button_div.add_style("height: 60px") button_div.add_style("float: left") button_div.add_style("background: white") button_div.add_class("hand") button_div.add_style("padding: 2px 3px 0 0") button_div.add_style("margin: 20px 60px 20px 200px") button_div.add_style("text-align: center") button_div.add("Check-in") # to be consistent with Check-in New File if my.process: checkin_process = my.process else: # Dont' specify, the user can choose later in check-in widget checkin_process = '' button.add_behavior( { 'type': 'click_up', 'search_key': search_key, 'process': checkin_process, 'context': my.context, 'cbjs_action': ''' var class_name = 'tactic.ui.widget.CheckinWdg'; var applet = spt.Applet.get(); spt.app_busy.show("Choose file(s) to check in") var current_dir = null; var is_sandbox = false; var refresh = false var values = spt.checkin.browse_folder(current_dir, is_sandbox, refresh); if (!values) { spt.app_busy.hide(); return; } var file_paths = values.file_paths; if (file_paths.length == 0) { spt.alert("You need to select files(s) to check in."); spt.app_busy.hide(); return; } spt.app_busy.hide(); var args = { 'search_key': bvr.search_key, 'show_links': false, 'show_history': false, 'close_on_publish': true } if (bvr.process) args.process = bvr.process; if (bvr.context) args.context = bvr.context; var kwargs = {}; kwargs.values = values; spt.panel.load_popup("Check-in", class_name, args, kwargs); /* var options= { title: "Check-in Widget", class_name: 'tactic.ui.widget.CheckinWdg', popup_id: 'checkin_widget' }; var bvr2 = {}; bvr2.options = options; bvr2.values = values; bvr2.args = args; spt.popup.get_widget({}, bvr2) */ ''' } ) button_div = DivWdg() content.add(button_div) button = IconWdg(title="Check-Out", icon=IconWdg.CHECK_OUT_3D_LG) button_div.add(button) button_div.set_box_shadow("1px 1px 1px 1px") button_div.add_style("width: 60px") button_div.add_style("height: 60px") button_div.add_style("float: left") button_div.add_style("margin: 20px") button_div.add_style("padding: 2px 3px 0 0") button_div.add_style("background: white") button_div.add_class("hand") button_div.add_style("text-align: center") button_div.add("Check-out") sobject = SearchKey.get_by_search_key(search_key) # snapshot is retrieved for getting the process informatoin, they are not being used # for loading as real_time snapshot query option is used. search = Search("sthpw/snapshot") search.add_sobject_filter(sobject) if my.process: search.add_filter("process", my.process) search.add_filter("is_latest", True) snapshot = search.get_sobject() if not my.process and snapshot: my.process = snapshot.get_value('process') # for old process-less snapshots if not my.process: my.process = snapshot.get_value('context') process_wdg = DivWdg(HtmlElement.b(checkin_process)) if checkin_process: width = len(checkin_process)*10 else: width = 10 process_wdg.add_styles('margin-left: auto; margin-right: auto; text-align: center; width: %s'%width) process_div.add(process_wdg) # DO NOT pass in snapshot_code, get it in real time snapshot_codes = [] show_status = True if my.checkout_action == 'latest': cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status) bvr = {'snapshot_codes': snapshot_codes, 'real_time': True, 'file_types': ['main'], 'filename_mode': 'repo', 'cbjs_action': cbjs_action} elif my.checkout_action == 'latest (version_omitted)': cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status) bvr = {'snapshot_codes':snapshot_codes, 'real_time': True, 'file_types': ['main'], 'filename_mode': 'versionless', 'cbjs_action': cbjs_action} elif my.checkout_action == 'latest versionless': cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status) bvr = {'snapshot_codes':snapshot_codes, 'real_time': True, 'versionless': True, 'file_types': ['main'], 'filename_mode': 'versionless', 'cbjs_action': cbjs_action} elif my.checkout_action == 'open file browser': bvr = { 'cbjs_action': ''' var class_name = 'tactic.ui.checkin.SObjectDirListWdg'; var kwargs = { search_keys: [bvr.search_key], process: '%s' }; spt.panel.load_popup("Check-out", class_name, kwargs); '''%my.process } bvr.update({ 'type': 'click_up', 'search_key': search_key}) button.add_behavior(bvr) title = Common.get_display_title(my.checkout_action) button.add_attr('title', title) #TODO: remove these margin-top which is used to compensate all the ButtonNewWdg top extra white space content.add("<br clear='all'/>") status_div = DivWdg() status_div.add_style('margin: 20px 0 0 10px') status_div.add_style('width: 100%') text_info = FloatDivWdg() text_info.add_styles('padding: 4px; width: 500px') text_info.add_style('margin-top: 8px') text_info.add_attr('title','Displays the last checked out file path') text_info.add_border() text_info.set_round_corners() text_content = DivWdg() text_content.add(' ') text_content.add_class('spt_status_area') text_info.add(text_content) label = FloatDivWdg('path:') label.add_style('margin: 12px 6px 0 6px') # button button = ButtonNewWdg(title="Explore", icon=IconWdg.FOLDER_GO) button.add_style('padding-bottom: 15px') button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var status_div = bvr.src_el.getParent('.spt_simple_checkin').getElement('.spt_status_area'); var value = status_div.get('text'); var dir_name = spt.path.get_dirname(value); if (dir_name) applet.open_explorer(dir_name); ''' } ) status_div.add(label) status_div.add(text_info) content.add(status_div) content.add(button) content.add_behavior({'type':'load', 'cbjs_action': ''' if (!spt.Applet.applet) { spt.api.app_busy_show('Initializing Java', 'Please wait...'); var exec = function() {var applet = spt.Applet.get()}; spt.api.app_busy_hide(exec); }'''}) return top
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): sobject = my.get_current_sobject() if isinstance(sobject, Shot): frame_range = sobject.get_frame_range() frame_in, frame_out = sobject.get_frame_handles() frame_notes = sobject.get_frame_notes() else: from pyasm.prod.biz import FrameRange frame_start = my._get_frame_num(sobject, "tc_frame_start") frame_end = my._get_frame_num(sobject, "tc_frame_end") frame_range = FrameRange(frame_start, frame_end, 1) frame_in, frame_out = my._get_frame_handles(sobject) frame_notes = sobject.get_value("frame_note", no_exception=True) frame_notes = WikiUtil().convert(frame_notes) if frame_range.frame_end == frame_range.frame_start == 0: return 'n/a' widget = SpanWdg() widget.set_attr("nowrap", "1") offset = 2 label_width = 16 if frame_range.frame_start > 99: label_width = 20 # start / end frame duration_color = '#969353' div = DivWdg() div.add_tip('START -- END (TOTAL)') wdg_width = 100 div.add_style('width', wdg_width) total = frame_range.frame_end - frame_range.frame_start + 1 start_frame = SpanWdg(str(frame_range.frame_start)) end_frame = SpanWdg(str(frame_range.frame_end)) end_div = FloatDivWdg(end_frame) duration_width = wdg_width * 0.2 - offset spacer_width = float('%.2f' %((duration_width + offset) * (frame_range.frame_start -1 ) /\ frame_range.frame_end)) start_div = FloatDivWdg(start_frame, width=label_width + spacer_width) start_div.add_class('right_content') duration = FloatDivWdg(width=duration_width) duration.add_style("border: 1px dotted %s" % duration_color) duration.add_style("margin-top: 3px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("height: 3px") duration.add_style("line-height: 3px") div.add(start_div) div.add(duration) div.add(end_div) dur_text = FloatDivWdg('(%s)' % total) dur_text.add_style("opacity", "0.5") div.add(dur_text) widget.add(div) widget.add(HtmlElement.br()) if frame_in: # in / out frame duration_color = '#b8b365' div = DivWdg() div.add_tip('IN -- OUT') div.add_style('width', wdg_width) handle_total = frame_out - frame_in + 1 in_frame = SpanWdg(str(frame_in)) out_frame = SpanWdg(str(frame_out)) if frame_range.frame_start == 0: frame_range.frame_start = 0.001 spacer_width = float('%.2f' % ((spacer_width) * \ float(frame_in) /frame_range.frame_start )) in_div = FloatDivWdg(in_frame, width=label_width + spacer_width) in_div.add_class('right_content') out_div = FloatDivWdg(out_frame) factor = float(handle_total) / total if factor > 1: factor = 1 duration_width = (duration_width + offset) * factor - offset duration = FloatDivWdg(width=duration_width) duration.add_style("border: 1px solid %s" % duration_color) duration.add_style("background", duration_color) duration.add_style("margin-top: 5px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("line-height: 1px") duration.add(' ') # IE needs that to draw a 1px wide div bar = FloatDivWdg('<!-- -->', width=1) bar.add_style("margin-top: 1px") bar.add_style("height: 10px") bar.add_style("line-height: 10px") bar.add_style("background", duration_color) div.add(in_div) div.add(bar) div.add(duration) div.add(bar) div.add(out_div) dur_text = SpanWdg('(%s)' % handle_total) div.add(dur_text) widget.add(div) if frame_notes: widget.add(HtmlElement.br()) widget.add(frame_notes) return widget