Example #1
0
    def get_display(my):
        assert my.load_script

        widget = DivWdg()
        widget.add_style('float', 'right')

        load_button = TextOptionBtnWdg(label='   Load   ', size='medium')
        load_button.get_top_el().add_style('float', 'left')
        load_button.get_top_el().set_id(my.LOAD_BUTTON_ID)
        load_button.add_behavior(
                {'type': "click_up",
                "cbjs_action":
                "setTimeout(function() {%s}, 200) "% my.load_script
                })
        widget.add(load_button)
        arrow_button = load_button.get_option_widget()
        #widget.add(arrow_button)
        suffix = "ASSET_LOADER_FUNCTIONS"
        menus_in = [ my.smart_menu_data ]


        SmartMenu.add_smart_menu_set( arrow_button,  menus_in)
        SmartMenu.assign_as_local_activator(arrow_button, None, True)

        #SmartMenu.attach_smart_context_menu( load_button, menus_in, False )
        x_div = FloatDivWdg("x")
        x_div.add_color('color','color')
        x_div.add_style('margin-right: 6px')
        widget.add(x_div)
        multiplier = TextWdg()
        multiplier.set_id("load_multiplier")
        multiplier.set_option("size", "1.5")
        multiplier.add_style("font-size: 0.8em")
        multiplier.add_style("float: left")
        multiplier.add_class("load_multiplier")
        widget.add( multiplier )
        return widget
Example #2
0
    def handle_item_div(my, item_div, dirname, basename):

        table = Table()
        item_div.add(table)
        table.add_row()
        table.add_style("width: 100%")

        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")

        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg("No Changes", IconWdg.CHECK, width=12)
        elif status == 'added':
            check = IconWdg("Added", IconWdg.NEW, width=16)
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg("Unversioned", IconWdg.HELP, width=12)
        elif status == 'missing':
            check = IconWdg("Missing", IconWdg.WARNING, width=12)
        elif status == 'editable':
            check = IconWdg("Editable", IconWdg.EDIT, width=12)
        elif status == 'modified':
            check = IconWdg("Modified", IconWdg.WARNING, width=12)
        else:
            check = IconWdg("Error (unknown status)", IconWdg.ERROR, width=12)

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")

        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" %
                         status)

        spath = path.replace(" ", "_")

        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')

        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")

        subcontext.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            False,
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })

        subcontext.add_style("display: none")
        item_div.add(subcontext)
Example #3
0
    def get_display(my):

        web = WebContainer.get_web()
        naming_util = NamingUtil()

        if not my.widget_name:
            my.widget_name = my.get_name()

        # get the sobject required by this input
        sobject = my.get_current_sobject()
        if not sobject:
            sobject = Search.get_by_id(my.search_type, my.search_id)

        if my.new_sample_name:
            my.new_sample_name.replace("//", "/")
        else:
            my.new_sample_name = sobject.get_value(my.widget_name)

        widget = DivWdg()
        widget.set_id("naming")
        widget.add_style("display: block")

        # set the sample text
        div = DivWdg()
        div.add("Sample name: <i>%s</i>" % my.new_sample_name)
        div.add(HtmlElement.br(2))

        new_sample_wdg = ProdIconButtonWdg("Set New Sample")
        new_sample_wdg.add_event("onclick", "toggle_display('generate')")
        div.add(new_sample_wdg)

        generate = DivWdg()
        generate.add(HtmlElement.br())
        generate.set_id("generate")
        generate.add_style("display: none")
        sample_text = TextWdg("new_sample_name")
        sample_text.set_option("size", "30")
        # sample_text.set_persist_on_submit()
        # if my.new_sample_name:
        #    sample_text.set_value(my.new_sample_name)
        generate.add(sample_text)

        button = IconButtonWdg("Generate", IconWdg.REFRESH, long=True)
        on_script = my.setup_ajax("naming")
        button.add_event("onclick", on_script)
        generate.add(button)
        generate.add(HtmlElement.br(2))

        div.add(generate)
        widget.add(div)

        hidden = TextWdg(my.widget_name)
        value = my.naming
        hidden.set_value(my.new_sample_name)
        widget.add(my.widget_name)
        widget.add(hidden)

        # get all of the parts

        # TODO: not sure if this should be dictated by the sample name
        # break up the name into parts
        import re

        if my.new_sample_name:
            tmp = my.new_sample_name.strip("/")
            parts = re.split("[\\/._]", tmp)
            print "parts: ", parts
        else:
            return widget

        # if there is a naming, then populate that
        if my.edit_search_type:
            options = naming_util.get_options(my.edit_search_type)
        else:
            options = naming_util.get_options(sobject.get_value("search_type"))

        table = Table()
        type_values = []
        padding_values = []
        for idx, part in enumerate(parts):
            table.add_row()
            table.add_cell(part)

            type_select = SelectWdg("type_%s" % idx)
            type_select.add_empty_option("-- Explicit --")
            type_select.set_persist_on_submit()
            type_select.set_option("values", "|".join(options))
            type_values.append(type_select.get_value())
            td = table.add_cell(type_select)

        widget.add(table)

        return widget
Example #4
0
    def get_default_display_wdg(cls, element_name, display_options, element_type, kbd_handler=False):

        from pyasm.widget import TextAreaWdg, CheckboxWdg, SelectWdg, TextWdg
        if element_type in ["integer", "smallint", "bigint", "int"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableIntegerTextEdit'
            }
            input = TextWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["float"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableFloatTextEdit'
            }
            input = TextAreaWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["string", "link", "varchar", "character", "timecode"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)


        elif element_type in ["text"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextAreaWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type == "boolean":
            input = CheckboxWdg('main')
            input.set_options(display_options)
            input.add_behavior(
             {"type" : "click_up",
                    'propagate_evt': True})

        elif element_type in  ["timestamp", "date", "time", "datetime2"]:
            from tactic.ui.widget import CalendarInputWdg, CalendarWdg, TimeInputWdg
            # FIXME: take wild guess for the time
            if element_name.endswith("_time"):
                #input = TimeInputWdg()
                behavior = {
                    'type': 'keyboard',
                    'kbd_handler_name': 'DgTableMultiLineTextEdit'
                }
                input = TextWdg('main')
                input.set_options(display_options)
                if kbd_handler:
                    input.add_behavior(behavior)

            else:
                #input = CalendarWdg()
                input = CalendarInputWdg()
                input.set_option('show_activator', False)
            #input.set_options(display_options)

        elif element_type == 'datetime':
            from tactic.ui.widget import CalendarInputWdg
            input = CalendarInputWdg()
            input.set_option('show_time', 'true')

        elif element_type == "color":
            from tactic.ui.widget import ColorInputWdg
            input = ColorInputWdg()
            input.set_options(display_options)

        elif element_type =="sqlserver_timestamp":
            # better then set it to None
            input = TextWdg()
            input.add_attr('disabled','disabled')
        else:
            # else try to instantiate it as a class
            print "WARNING: EditWdg handles type [%s] as default TextWdg" %element_type
            input = TextWdg()
            input.add("No input defined")

        return input 
Example #5
0
    def handle_item_div(my, item_div, dirname, basename):


        table = Table()
        item_div.add(table)
        table.add_row()
        table.add_style("width: 100%")



        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")



        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg( "No Changes", IconWdg.CHECK, width=12 )
        elif status == 'added':
            check = IconWdg( "Added", IconWdg.NEW, width=16 )
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg( "Unversioned", IconWdg.HELP, width=12 )
        elif status == 'missing':
            check = IconWdg( "Missing", IconWdg.WARNING, width=12 )
        elif status == 'editable':
            check = IconWdg( "Editable", IconWdg.EDIT, width=12 )
        elif status == 'modified':
            check = IconWdg( "Modified", IconWdg.WARNING, width=12 )
        else:
            check = IconWdg( "Error (unknown status)", IconWdg.ERROR, width=12 )

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")


        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" % status)

        spath = path.replace(" ", "_")


        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')



        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")


        subcontext.add_behavior( {
            'type': 'click_up',
            'propagate_evt': False,
            'cbjs_action': '''
            bvr.src_el.focus();
            '''
        } )

        subcontext.add_style("display: none")
        item_div.add(subcontext)
Example #6
0
    def get_display(self):
        top = DivWdg()
        top.add_class("ad_input_top")

        name = self.get_name()
        text = TextWdg(self.get_input_name())

        # get the login
        sobject = self.get_current_sobject()
        client = sobject.get_value("contact_name")
        print "client: ", client
        if client:
            login_sobj = Login.get_by_code(client)
        else:
            login_sobj = Environment.get_login()

        # build the display_name
        login = login_sobj.get_value("login")
        display_name = login_sobj.get_value("display_name")
        if not display_name:
            display_name = "%s %s" % (user.get('first_name'),
                                      user.get('last_name'))
        display_name = display_name.replace('"', "'")

        print "login: "******"spt_ad_input")
        if login:
            hidden.set_value(login)
        top.add(hidden)

        # copy over some options
        #text.set_options( self.options.copy() )
        if login:
            text.set_value(display_name)
        text.set_option("read_only", "true")
        text.add_class("spt_ad_display")
        top.add(text)

        top.add("&nbsp;&nbsp;")

        groups_str = self.get_option("groups_allowed_to_search")
        if groups_str:
            stmt = 'groups_list = %s' % groups_str
            exec stmt
        else:
            groups_list = None

        allow_search = True

        if groups_list:
            allow_search = False
            login_in_group_list = Search.eval(
                "@SOBJECT(sthpw/login_in_group['login','=','%s'])" % login)
            for login_in_group in login_in_group_list:
                group = login_in_group.get_value("login_group")
                if group in groups_list:
                    allow_search = True
                    break

        if login == 'admin':
            allow_search = True

        if allow_search:
            button = IconButtonWdg('Search for User', IconWdg.USER)
            #button = ButtonWdg()
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                var top = bvr.src_el.getParent('.ad_input_top');
                var content = top.getElement('.ad_input_content');
                spt.toggle_show_hide(content);
                '''
            })
            top.add(button)

        ad_top = DivWdg()
        ad_top.add_class("ad_input_content")
        ad_top.add_style("display: none")
        ad_top.add_style("position: absolute")
        ad_top.add_style("background: #222")
        ad_top.add_style("min-width: 300px")
        ad_top.add_style("border: solid 1px #000")
        ad_top.add_style("padding: 20px")

        cbjs_action = '''
        var value = bvr.src_el.getAttribute('spt_input_value');
        var display_value = bvr.src_el.getAttribute('spt_display_value');
        var phone_number = bvr.src_el.getAttribute('spt_phone_number');
        var email = bvr.src_el.getAttribute('spt_mail');

        var top = bvr.src_el.getParent('.ad_input_top');
        var content = top.getElement('.ad_input_content');
        var input = top.getElement('.spt_ad_input');
        var display = top.getElement('.spt_ad_display');
        input.value = value;
        display.value = display_value;

        server = TacticServerStub.get()
        server.execute_cmd("tactic.active_directory.ADCacheUserCbk", {login: value})

        spt.toggle_show_hide(content);

        '''
        ad_search_wdg = ADSearchWdg(cbjs_action=cbjs_action)
        ad_top.add(ad_search_wdg)

        top.add(ad_top)

        return top
Example #7
0
    def get_display(my):
        sobject = my.get_current_sobject()

        # handle the start and end
        frame_start = sobject.get_value("tc_frame_start")
        frame_end = sobject.get_value("tc_frame_end")

        frame_start_text = TextWdg("tc_frame_start")
        frame_start_text.set_value(frame_start)
        frame_start_text.set_option("size", "2")

        frame_end_text = TextWdg("tc_frame_end")
        frame_end_text.set_value(frame_end)
        frame_end_text.set_option("size", "2")

        # handle the notes
        frame_notes = sobject.get_value("frame_note")
        frame_notes_text = TextAreaWdg("frame_note")
        frame_notes_text.set_value(frame_notes)
        frame_notes_text.set_option("rows", "2")


        # handle the in and out handles
        frame_in = sobject.get_value("frame_in")
        frame_out = sobject.get_value("frame_out")

        frame_in_text = TextWdg("frame_in")
        frame_in_text.set_value(frame_in)
        frame_in_text.set_option("size", "2")

        frame_out_text = TextWdg("frame_out")
        frame_out_text.set_value(frame_out)
        frame_out_text.set_option("size", "2")


        div = DivWdg()


        table = Table()
        div.add(table)
        table.add_row()
        td = table.add_cell("Range:")
        td.add_style("width: 100px")
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("start: ")
        td.add(frame_start_text)
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("end: ")
        td.add(frame_end_text)

        table.add_row()
        table.add_cell("Handles:")
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("in: ")
        td.add(frame_in_text)
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("out: ")
        td.add(frame_out_text)
        td.add("<br/>")

        table.add_row()
        table.add_cell("Notes:")
        td = table.add_cell(frame_notes_text)
        td.add_style("padding: 5px")
        td.add_attr("colspan", "2")

        return div
Example #8
0
    def get_display(my):
        sobject = my.get_current_sobject()

        # handle the start and end
        frame_start = sobject.get_value("tc_frame_start")
        frame_end = sobject.get_value("tc_frame_end")

        frame_start_text = TextWdg("tc_frame_start")
        frame_start_text.set_value(frame_start)
        frame_start_text.set_option("size", "2")

        frame_end_text = TextWdg("tc_frame_end")
        frame_end_text.set_value(frame_end)
        frame_end_text.set_option("size", "2")

        # handle the notes
        frame_notes = sobject.get_value("frame_note")
        frame_notes_text = TextAreaWdg("frame_note")
        frame_notes_text.set_value(frame_notes)
        frame_notes_text.set_option("rows", "1")

        # handle the in and out handles
        frame_in = sobject.get_value("frame_in")
        frame_out = sobject.get_value("frame_out")

        frame_in_text = TextWdg("frame_in")
        frame_in_text.set_value(frame_in)
        frame_in_text.set_option("size", "2")

        frame_out_text = TextWdg("frame_out")
        frame_out_text.set_value(frame_out)
        frame_out_text.set_option("size", "2")

        div = DivWdg()

        table = Table()
        div.add(table)
        table.add_row()
        td = table.add_cell("Range:")
        td.add_style("width: 100px")
        td = table.add_cell()
        td.add("start: ")
        td.add(frame_start_text)
        td.add(" - end: ")
        td.add(frame_end_text)

        table.add_row()
        table.add_cell("Handles:")
        td = table.add_cell()
        td.add("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in: ")
        td.add(frame_in_text)
        td.add(" - out: ")
        td.add(frame_out_text)
        td.add("<br/>")

        table.add_row()
        table.add_cell("Notes:")
        td = table.add_cell(frame_notes_text)
        """
        div.add("Range - start: ")
        div.add(frame_start_text)
        div.add(" - end: ")
        div.add(frame_end_text)
        div.add("<br/>")
        div.add("Handles - in: ")
        div.add(frame_in_text)
        div.add(" - out: ")
        div.add(frame_out_text)
        div.add("<br/>")
        div.add("Notes:")
        div.add(frame_notes_text)
        """

        return div
Example #9
0
    def get_display(my):   
        widget = DivWdg()
        widget.add_attr('id','whole_fb_container_%s' % my.custom_top_name)
        if 'dir' in my.kwargs.keys():
            my.dir = my.kwargs.get('dir')
        if 'old_dir' in my.kwargs.keys():
            my.old_dir = my.kwargs.get('old_dir')
        else:
            my.old_dir = my.dir
        if 'mode' in my.kwargs.keys():
            my.mode = my.kwargs.get('mode')
            if my.mode in [None,'']:
                my.mode = 'classic'
        #print "DIR = %s, OLD DIR = %s" % (my.dir, my.old_dir)
        
        err_msg = ''
        if not os.path.isdir(my.dir):
            err_msg = '%s is not a valid directory' % my.dir 
            my.dir = my.old_dir
       
        trimmed_dir = my.dir
        if trimmed_dir[len(trimmed_dir) - 1] == '/' and len(trimmed_dir) > 1:
            trimmed_dir = trimmed_dir[:-1]
        
        prev_dir_s = trimmed_dir.split('/')
        prev_dir_s = prev_dir_s[:-1]
        prev_dir = ''
        
        for ct in range(0,len(prev_dir_s)):
            if prev_dir_s[ct] not in [None,'']:
                if prev_dir == '':
                    prev_dir = '/%s' % prev_dir_s[ct]
                else:   
                    prev_dir = '%s/%s' % (prev_dir, prev_dir_s[ct])
        if prev_dir in [None,'','//']:
            prev_dir = '/'
        #print "PREV DIR = %s" % prev_dir
        
        files_list = []
        dir_list = []
        
        files_dict = {}
        dirs_dict = {}
        
        longest_name_len = 0
        
        for f in os.listdir(my.dir):
            joined = join(my.dir,f)
            if os.path.isfile(joined):
                files_list.append(joined)
                last_modified = 'N/A'
                created = 'N/A'
                size = 'N/A'
                if joined.count('/') > 3:
                    last_modified =  datetime.fromtimestamp(os.path.getmtime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                    created =  datetime.fromtimestamp(os.path.getctime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                    size = my.convertSize(os.path.getsize(joined),'file')
                file_name_s = joined.split('/')
                file_name = file_name_s[len(file_name_s) - 1]
                file_path = joined
                files_dict[joined] = {'last_modified': last_modified, 'created': created, 'size': size, 'name': file_name, 'path': joined}
                if len(file_name) > longest_name_len:
                    longest_name_len = len(file_name)
            
            elif os.path.isdir(joined):
                dir_name_s = joined.split('/')
                dir_name = dir_name_s[len(dir_name_s) - 1]
                if dir_name[0] != '.':
                    dir_list.append(joined)
                    size = 'N/A'
                    created = 'N/A'
                    last_modified = 'N/A'
                   
                    #This is to keep us from calculating the size of the huge base directories
                    #Probably want a way to turn directory sizes on and off
                    if joined.count('/') > 5:
                        last_modified =  datetime.fromtimestamp(os.path.getmtime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                        created =  datetime.fromtimestamp(os.path.getctime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                        prepresize = commands.getoutput('du -s %s' % joined).split()[0]
                        try:
                            presize = float(prepresize)
                            if not math.isnan(presize):
                                size = my.convertSize(float(presize),'dir')
                        except ValueError:
                            print "GOT AN ERROR FOR %s" % joined
                            pass
                    dir_path = joined
                    dirs_dict[joined] = {'size': size, 'created': created, 'last_modified': last_modified, 'name': dir_name, 'path' : dir_path}
                    if len(dir_name) > longest_name_len:
                        longest_name_len = len(dir_name)
        
        #print "LONGEST NAME LEN = %s" % longest_name_len
        name_len = longest_name_len * 10
        
        # Displaying the table of the folders and files 
        top_tbl = Table()
        if err_msg != '':
            top_tbl.add_row()
            top_tbl.add_cell('<b><font color="#FF0000">%s</font></b>' % err_msg)
        top_tbl.add_row()
        dir_path_txt = TextWdg('dir_path')
        dir_path_txt.add_attr('id','dir_path')
        dir_path_txt.set_value(my.dir)
        dir_path_txt.set_option('size','100')
        dir_path_txt.add_behavior(my.change_location(my.old_dir))
        top_tbl.add_cell('Location: ')
        top_tbl.add_cell(dir_path_txt)
        
        div = DivWdg()
        
        back_tbl = Table()
        back_dir = back_tbl.add_cell("<-Back...")
        back_dir.add_attr('dir',prev_dir)
        back_dir.add_style('cursor: pointer;')
        back_dir.add_style('width: %spx;' % name_len)
        back_dir.add_behavior(my.dir_click())
        back_size = back_tbl.add_cell('Size')
        back_size.add_style('width: 100px;')
        back_created = back_tbl.add_cell('Created')
        back_created.add_style('width: 150px;')
        back_modified = back_tbl.add_cell('Last Modified')
        back_modified.add_style('width: 150px;')
        div.add(back_tbl)
    
        content_counter = 0
        dir_list.sort()
        files_list.sort()
        mult_dirs = DivWdg()
        mult_dirs.add_attr('class','DragContainer')
        mult_dirs.add_attr('id','DragContainer1')

        # Getting all the directories displayed, adding drag and drop attributes to each folder 
        for dr in dir_list:
         
            tbl = Table()
            tbl.add_row()
            dir_name = dirs_dict[dr]['name']
            dir_path = dirs_dict[dr]['path']
            FOLDER_ICON = my.folder_icon.replace("TITLE",dir_name)
            lil_tbl = Table()
            lil_tbl.add_row()
            lil_tbl.add_cell(FOLDER_ICON)
            
            directory_div = lil_tbl.add_cell('<b>%s</b>' % dir_name)
            
            if my.mode not in ['select']:
                directory_div.add_behavior(my.drag_controller())
                directory_div.add_style("-khtml-user-drag: element;")
                directory_div.add_attr("draggable", "true")
                directory_div.add_attr("ondragstart", "spt.drag.ondragstart(event, this, {path_name : '%s'}) "% dir_path)
                directory_div.add_attr("ondragover", "spt.drag.allowDrop(event, this)")
                directory_div.add_attr("ondrop", "spt.drag.ondrop(event, this, {destination_location: '%s'})" % dir_path)

            lil_cell = tbl.add_cell(lil_tbl)
            lil_cell.add_attr('name','clickable')
            lil_cell.add_attr('dir',dr)
            lil_cell.add_attr('type','dir')
            lil_cell.add_attr('path_name',dr)
            lil_cell.add_attr('highlight','off')
            #lil_cell.add_attr('class','biotches')
            lil_cell.add_style('cursor: pointer;')
            lil_cell.add_style('width: %spx;' % name_len)
            lil_cell.add_behavior(my.dir_click())
            lil_cell.add_behavior(my.highlighter_ctrl());
            lil_cell.add_behavior(my.hover_highlighter());
            if my.mode in ['select']:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
            
            sc = tbl.add_cell('<i>%s</i>' % dirs_dict[dr]['size'])
            sc.add_attr('nowrap','nowrap')
            sc.add_attr('title','Size of Contents')
            sc.add_attr('name','Size of Contents')
            sc.add_style('width: 100px;')
           
            cc = tbl.add_cell(dirs_dict[dr]['created'])
            cc.add_attr('nowrap','nowrap')
            cc.add_attr('title','Created')
            cc.add_attr('name','Created')
            cc.add_style('width: 150px;')
         
            mc = tbl.add_cell(dirs_dict[dr]['last_modified'])
            mc.add_attr('nowrap','nowrap')
            mc.add_attr('title','Last Modified')
            mc.add_attr('name','Last Modified')
            mc.add_style('width: 150px;')
            div_dir = DivWdg()
            div_dir.add(tbl)
            mult_dirs.add(div_dir)
            content_counter = content_counter + 1
        div.add(mult_dirs)
        mult_files = DivWdg()
        mult_files.add_attr('class','DragContainer')
        mult_files.add_attr('id','DragContainer2')
        
        for fl in files_list:
            tbl = Table()
            tbl.add_row()

            file_name = files_dict[fl]['name']
            path_name = files_dict[fl]['path']

            text_wdg_file_name = DivWdg(file_name)
            if my.mode not in ['select']:
                text_wdg_file_name.add_behavior(my.drag_controller())
                text_wdg_file_name.add_style("-khtml-user-drag: element;")
                text_wdg_file_name.add_attr("draggable", "true")
                text_wdg_file_name.add_attr("ondragstart", "spt.drag.ondragstart(event, this, {path_name : '%s'}) "% path_name)
            
            FILE_ICON = my.file_icon.replace("TITLE",file_name)
            lil_tbl = Table()
            lil_tbl.add_row()
            lil_tbl.add_cell(FILE_ICON)
            file_div = lil_tbl.add_cell(text_wdg_file_name)
            lil_cell = tbl.add_cell(lil_tbl)
            lil_cell.add_attr('name','clickable')
            lil_cell.add_attr('file',fl)
            lil_cell.add_attr('type','file')
            lil_cell.add_attr('file_name',file_name)
            lil_cell.add_attr('path_name',path_name)
            lil_cell.add_attr('highlight','off')
            #lil_cell.add_attr('class','biotches')
            lil_cell.add_style('cursor: pointer;')
            lil_cell.add_style('width: %spx;' % name_len)
            lil_cell.add_behavior(my.highlighter_ctrl())
            lil_cell.add_behavior(my.hover_highlighter());
            if my.mode in ['select']:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
            else:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
             
            sc = tbl.add_cell('<i>%s</i>' % files_dict[fl]['size'])
            sc.add_attr('nowrap','nowrap')
            sc.add_attr('title','Size')
            sc.add_attr('name','Size')
            sc.add_style('width: 100px;')
            cc = tbl.add_cell(files_dict[fl]['created'])
            cc.add_attr('nowrap','nowrap')
            cc.add_attr('title','Created')
            cc.add_attr('name','Created')
            cc.add_style('width: 150px;')
            mc = tbl.add_cell(files_dict[fl]['last_modified'])
            mc.add_attr('nowrap','nowrap')
            mc.add_attr('title','Last Modified')
            mc.add_attr('name','Last Modified')
            mc.add_style('width: 150px;')
            div_fl = DivWdg()
            div_fl.add(tbl)
            mult_files.add(div_fl)
            content_counter = content_counter + 1
        div.add(mult_files)
        widget.add(top_tbl)
        widget.add(div)
        widget.add_behavior(my.click_anywhere())
        return widget 
Example #10
0
    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
Example #11
0
    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
Example #12
0
    def get_display(self):
        sobject = self.get_current_sobject()

        # handle the start and end
        frame_start = sobject.get_value("tc_frame_start")
        frame_end = sobject.get_value("tc_frame_end")

        frame_start_text = TextWdg("tc_frame_start")
        frame_start_text.set_value(frame_start)
        frame_start_text.set_option("size", "2")

        frame_end_text = TextWdg("tc_frame_end")
        frame_end_text.set_value(frame_end)
        frame_end_text.set_option("size", "2")

        # handle the notes
        frame_notes = sobject.get_value("frame_note")
        frame_notes_text = TextAreaWdg("frame_note")
        frame_notes_text.set_value(frame_notes)
        frame_notes_text.set_option("rows", "2")

        # handle the in and out handles
        frame_in = sobject.get_value("frame_in")
        frame_out = sobject.get_value("frame_out")

        frame_in_text = TextWdg("frame_in")
        frame_in_text.set_value(frame_in)
        frame_in_text.set_option("size", "2")

        frame_out_text = TextWdg("frame_out")
        frame_out_text.set_value(frame_out)
        frame_out_text.set_option("size", "2")

        div = DivWdg()

        table = Table()
        div.add(table)
        table.add_row()
        td = table.add_cell("Range:")
        td.add_style("width: 100px")
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("start: ")
        td.add(frame_start_text)
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("end: ")
        td.add(frame_end_text)

        table.add_row()
        table.add_cell("Handles:")
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("in: ")
        td.add(frame_in_text)
        td = table.add_cell()
        td.add_style("text-align: right")
        td.add_style("padding: 5px")
        td.add("out: ")
        td.add(frame_out_text)
        td.add("<br/>")

        table.add_row()
        table.add_cell("Notes:")
        td = table.add_cell(frame_notes_text)
        td.add_style("padding: 5px")
        td.add_attr("colspan", "2")

        return div
Example #13
0
    def get_default_display_wdg(cls, element_name, display_options, element_type, kbd_handler=False):

        from pyasm.widget import TextAreaWdg, CheckboxWdg, SelectWdg, TextWdg
        if element_type in ["integer", "smallint", "bigint", "int"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableIntegerTextEdit'
            }
            input = TextWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["float"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableFloatTextEdit'
            }
            input = TextAreaWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["string", "link", "varchar", "character", "timecode"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)


        elif element_type in ["text"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextAreaWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type == "boolean":
            input = CheckboxWdg('main')
            input.set_options(display_options)
            input.add_behavior(
             {"type" : "click_up",
                    'propagate_evt': True})

        elif element_type in  ["timestamp", "date", "time", "datetime2"]:
            from tactic.ui.widget import CalendarInputWdg, CalendarWdg, TimeInputWdg
            # FIXME: take wild guess for the time
            if element_name.endswith("_time"):
                #input = TimeInputWdg()
                behavior = {
                    'type': 'keyboard',
                    'kbd_handler_name': 'DgTableMultiLineTextEdit'
                }
                input = TextWdg('main')
                input.set_options(display_options)
                if kbd_handler:
                    input.add_behavior(behavior)

            else:
                #input = CalendarWdg()
                input = CalendarInputWdg()
                input.set_option('show_activator', False)
            #input.set_options(display_options)

        elif element_type == 'datetime':
            from tactic.ui.widget import CalendarInputWdg
            input = CalendarInputWdg()
            input.set_option('show_time', 'true')

        elif element_type == "color":
            from tactic.ui.widget import ColorInputWdg
            input = ColorInputWdg()
            input.set_options(display_options)

        elif element_type =="sqlserver_timestamp":
            # NoneType Exception is prevented in WidgetConfig already
            input = None
        else:
            # else try to instantiate it as a class
            print "WARNING: EditWdg handles type [%s] as default TextWdg" %element_type
            input = TextWdg()
            input.add("No input defined")

        return input 
Example #14
0
    def get_display(my):
        my.icon_string = my.get_value("icon")
        my.icon_label = my.get_value("label")

        top = DivWdg()
        top.add_class("spt_icon_chooser_top")

        # FIXME: this is being generated every time .... where to put is?
        icon_chooser = IconChooserWdg(is_popup=True)
        top.add(icon_chooser)

        icon_entry_text = TextWdg(my.get_input_name())
        icon_entry_text.set_option("size", "30")
        #icon_entry_text.set_attr("disabled", "disabled")
        icon_entry_text.add_class("SPT_ICON_ENTRY_TEXT")

        button = ActionButtonWdg(title='Choose', tip='Click to select an icon')

        icon_img = HtmlElement.img()
        icon_img.add_class("SPT_ICON_IMG")

        if my.icon_string:
            # icon_path = IconWdg.icons.get(my.icon_string)
            icon_path = IconWdg.get_icon_path(my.icon_string)
            if icon_path:
                # icon = IconWdg( my.icon_string, icon_path, right_margin='0px' )
                icon_img.set_attr("src", icon_path)
            else:
                icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

            icon_entry_text.set_value(my.icon_string)
        else:
            icon_entry_text.set_value("")
            icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

        named_event_name = "ICON_CHOOSER_SELECTION_MADE"
        icon_entry_text.add_behavior({
            'type':
            'listen',
            'event_name':
            named_event_name,
            'cbjs_action':
            '''
                var top = $("IconChooserPopup");
                var chooser = spt.get_element(top, ".SPT_ICON_CHOOSER_WRAPPER_DIV");
                //var chooser = spt.get_cousin( bvr.src_el,
                //    ".spt_icon_chooser_top", ".SPT_ICON_CHOOSER_WRAPPER_DIV" );

                var icon_name = chooser.getProperty("spt_icon_selected");
                var icon_path = chooser.getProperty("spt_icon_path");
                // bvr.src_el.innerHTML = icon_name;
                bvr.src_el.value = icon_name;
                if( spt.is_hidden( bvr.src_el ) ) { spt.show( bvr.src_el ); }
                var img_el = spt.get_cousin( bvr.src_el,
                    ".spt_icon_chooser_top", ".SPT_ICON_IMG" );
                if( icon_path ) {
                    img_el.setProperty("src", icon_path);
                } else {
                    img_el.setProperty("src","/context/icons/common/transparent_pixel.gif");
                }
           '''
        })

        top.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            'spt.popup.open( "IconChooserPopup", false);'
        })

        #top.add( my.icon_label )
        spacing = "<img src='%s' style='width: %spx;' />" % (
            IconWdg.get_icon_path("TRANSPARENT"), 3)

        #button.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
        #top.add( button )
        #button.add_style("float: right")
        #button.add_style("margin-top: -3px")

        top.add(icon_img)
        top.add(spacing)
        top.add(icon_entry_text)

        return top
Example #15
0
    def get_display(my):
        sobject = my.get_current_sobject()

        # handle the start and end
        frame_start = sobject.get_value("tc_frame_start")
        frame_end = sobject.get_value("tc_frame_end")

        frame_start_text = TextWdg("tc_frame_start")
        frame_start_text.set_value(frame_start)
        frame_start_text.set_option("size", "2")

        frame_end_text = TextWdg("tc_frame_end")
        frame_end_text.set_value(frame_end)
        frame_end_text.set_option("size", "2")

        # handle the notes
        frame_notes = sobject.get_value("frame_note")
        frame_notes_text = TextAreaWdg("frame_note")
        frame_notes_text.set_value(frame_notes)
        frame_notes_text.set_option("rows", "1")


        # handle the in and out handles
        frame_in = sobject.get_value("frame_in")
        frame_out = sobject.get_value("frame_out")

        frame_in_text = TextWdg("frame_in")
        frame_in_text.set_value(frame_in)
        frame_in_text.set_option("size", "2")

        frame_out_text = TextWdg("frame_out")
        frame_out_text.set_value(frame_out)
        frame_out_text.set_option("size", "2")


        div = DivWdg()


        table = Table()
        div.add(table)
        table.add_row()
        td = table.add_cell("Range:")
        td.add_style("width: 100px")
        td = table.add_cell()
        td.add("start: ")
        td.add(frame_start_text)
        td.add(" - end: ")
        td.add(frame_end_text)

        table.add_row()
        table.add_cell("Handles:")
        td = table.add_cell()
        td.add("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in: ")
        td.add(frame_in_text)
        td.add(" - out: ")
        td.add(frame_out_text)
        td.add("<br/>")

        table.add_row()
        table.add_cell("Notes:")
        td = table.add_cell(frame_notes_text)

        """
        div.add("Range - start: ")
        div.add(frame_start_text)
        div.add(" - end: ")
        div.add(frame_end_text)
        div.add("<br/>")
        div.add("Handles - in: ")
        div.add(frame_in_text)
        div.add(" - out: ")
        div.add(frame_out_text)
        div.add("<br/>")
        div.add("Notes:")
        div.add(frame_notes_text)
        """

        return div
Example #16
0
    def get_display(self):

        web = WebContainer.get_web()
        naming_util = NamingUtil()

        if not self.widget_name:
            self.widget_name = self.get_name()

        # get the sobject required by this input
        sobject = self.get_current_sobject()
        if not sobject:
            sobject = Search.get_by_id(self.search_type, self.search_id)

        if self.new_sample_name:
            self.new_sample_name.replace("//", "/")
        else:
            self.new_sample_name = sobject.get_value(self.widget_name)

        widget = DivWdg()
        widget.set_id("naming")
        widget.add_style("display: block")

        # set the sample text
        div = DivWdg()
        div.add("Sample name: <i>%s</i>" % self.new_sample_name)
        div.add(HtmlElement.br(2))

        new_sample_wdg = ProdIconButtonWdg("Set New Sample")
        new_sample_wdg.add_event("onclick", "toggle_display('generate')")
        div.add(new_sample_wdg)

        generate = DivWdg()
        generate.add(HtmlElement.br())
        generate.set_id("generate")
        generate.add_style("display: none")
        sample_text = TextWdg("new_sample_name")
        sample_text.set_option("size", "30")
        #sample_text.set_persist_on_submit()
        #if self.new_sample_name:
        #    sample_text.set_value(self.new_sample_name)
        generate.add(sample_text)

        button = IconButtonWdg("Generate", IconWdg.REFRESH, long=True)
        on_script = self.setup_ajax("naming")
        button.add_event("onclick", on_script)
        generate.add(button)
        generate.add(HtmlElement.br(2))

        div.add(generate)
        widget.add(div)

        hidden = TextWdg(self.widget_name)
        value = self.naming
        hidden.set_value(self.new_sample_name)
        widget.add(self.widget_name)
        widget.add(hidden)

        # get all of the parts

        # TODO: not sure if this should be dictated by the sample name
        # break up the name into parts
        import re
        if self.new_sample_name:
            tmp = self.new_sample_name.strip("/")
            parts = re.split('[\\/._]', tmp)
            print "parts: ", parts
        else:
            return widget

        # if there is a naming, then populate that
        if self.edit_search_type:
            options = naming_util.get_options(self.edit_search_type)
        else:
            options = naming_util.get_options(sobject.get_value("search_type"))

        table = Table()
        type_values = []
        padding_values = []
        for idx, part in enumerate(parts):
            table.add_row()
            table.add_cell(part)

            type_select = SelectWdg("type_%s" % idx)
            type_select.add_empty_option("-- Explicit --")
            type_select.set_persist_on_submit()
            type_select.set_option("values", "|".join(options))
            type_values.append(type_select.get_value())
            td = table.add_cell(type_select)

        widget.add(table)

        return widget
Example #17
0
    def get_display(self):
        top = DivWdg()
        top.add_class("ad_input_top")

        name = self.get_name()
        text = TextWdg(self.get_input_name())


        # get the login
        sobject = self.get_current_sobject()
        client = sobject.get_value("contact_name")
        print "client: ", client
        if client:
            login_sobj = Login.get_by_code(client)
        else:
            login_sobj = Environment.get_login()

        # build the display_name
        login = login_sobj.get_value("login")
        display_name = login_sobj.get_value("display_name")
        if not display_name:
            display_name = "%s %s" % (user.get('first_name'), user.get('last_name'))
        display_name = display_name.replace('"', "'")


        
        print "login: "******"spt_ad_input")
        if login:
            hidden.set_value(login)
        top.add(hidden)


        # copy over some options
        #text.set_options( self.options.copy() )
        if login:
            text.set_value(display_name)
        text.set_option("read_only", "true")
        text.add_class("spt_ad_display")
        top.add(text)



        top.add("&nbsp;&nbsp;")



        groups_str = self.get_option("groups_allowed_to_search")
        if groups_str:
            stmt = 'groups_list = %s' % groups_str
            exec stmt
        else:
            groups_list = None

        allow_search = True

        if groups_list:
            allow_search = False
            login_in_group_list = Search.eval("@SOBJECT(sthpw/login_in_group['login','=','%s'])" % login)
            for login_in_group in login_in_group_list:
                group = login_in_group.get_value("login_group")
                if group in groups_list:
                    allow_search = True
                    break

        if login == 'admin':
            allow_search = True


        if allow_search:
            button = IconButtonWdg('Search for User', IconWdg.USER)
            #button = ButtonWdg()
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var top = bvr.src_el.getParent('.ad_input_top');
                var content = top.getElement('.ad_input_content');
                spt.toggle_show_hide(content);
                '''
            } )
            top.add(button)

        ad_top = DivWdg()
        ad_top.add_class("ad_input_content")
        ad_top.add_style("display: none")
        ad_top.add_style("position: absolute")
        ad_top.add_style("background: #222")
        ad_top.add_style("min-width: 300px")
        ad_top.add_style("border: solid 1px #000")
        ad_top.add_style("padding: 20px")

        cbjs_action = '''
        var value = bvr.src_el.getAttribute('spt_input_value');
        var display_value = bvr.src_el.getAttribute('spt_display_value');
        var phone_number = bvr.src_el.getAttribute('spt_phone_number');
        var email = bvr.src_el.getAttribute('spt_mail');

        var top = bvr.src_el.getParent('.ad_input_top');
        var content = top.getElement('.ad_input_content');
        var input = top.getElement('.spt_ad_input');
        var display = top.getElement('.spt_ad_display');
        input.value = value;
        display.value = display_value;

        server = TacticServerStub.get()
        server.execute_cmd("tactic.active_directory.ADCacheUserCbk", {login: value})

        spt.toggle_show_hide(content);

        '''
        ad_search_wdg = ADSearchWdg(cbjs_action=cbjs_action)
        ad_top.add(ad_search_wdg)

        top.add(ad_top)

        return top
Example #18
0
    def get_display(my):
        my.icon_string = my.get_value("icon")
        my.icon_label = my.get_value("label")

        top = DivWdg()
        top.add_class("spt_icon_chooser_top")

        # FIXME: this is being generated every time .... where to put is?
        icon_chooser = IconChooserWdg( is_popup=True )
        top.add( icon_chooser )

        icon_entry_text = TextWdg(my.get_input_name())
        icon_entry_text.set_option("size", "30")
        #icon_entry_text.set_attr("disabled", "disabled")
        icon_entry_text.add_class( "SPT_ICON_ENTRY_TEXT" )


        button = ActionButtonWdg(title='Choose', tip='Click to select an icon')

        icon_img = HtmlElement.img()
        icon_img.add_class( "SPT_ICON_IMG" )

        if my.icon_string:
            # icon_path = IconWdg.icons.get(my.icon_string)
            icon_path = IconWdg.get_icon_path(my.icon_string)
            if icon_path:
                # icon = IconWdg( my.icon_string, icon_path, right_margin='0px' )
                icon_img.set_attr("src", icon_path)
            else:
                icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

            icon_entry_text.set_value( my.icon_string )
        else:
            icon_entry_text.set_value( "" )
            icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))


        named_event_name = "ICON_CHOOSER_SELECTION_MADE"
        icon_entry_text.add_behavior( {'type': 'listen', 'event_name': named_event_name,
           'cbjs_action': '''
                var top = $("IconChooserPopup");
                var chooser = spt.get_element(top, ".SPT_ICON_CHOOSER_WRAPPER_DIV");
                //var chooser = spt.get_cousin( bvr.src_el,
                //    ".spt_icon_chooser_top", ".SPT_ICON_CHOOSER_WRAPPER_DIV" );

                var icon_name = chooser.getProperty("spt_icon_selected");
                var icon_path = chooser.getProperty("spt_icon_path");
                // bvr.src_el.innerHTML = icon_name;
                bvr.src_el.value = icon_name;
                if( spt.is_hidden( bvr.src_el ) ) { spt.show( bvr.src_el ); }
                var img_el = spt.get_cousin( bvr.src_el,
                    ".spt_icon_chooser_top", ".SPT_ICON_IMG" );
                if( icon_path ) {
                    img_el.setProperty("src", icon_path);
                } else {
                    img_el.setProperty("src","/context/icons/common/transparent_pixel.gif");
                }
           ''' } )

        top.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )

        #top.add( my.icon_label )
        spacing = "<img src='%s' style='width: %spx;' />" % (IconWdg.get_icon_path("TRANSPARENT"), 3)

        #button.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
        #top.add( button )
        #button.add_style("float: right")
        #button.add_style("margin-top: -3px")

        top.add( icon_img )
        top.add( spacing )
        top.add( icon_entry_text )



        return top