示例#1
0
    def get_display(self):

        sobject = self.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        
        button = IconButtonWdg("Dependency", IconWdg.DEPENDENCY)
        
        button.add_style("margin: 3px 5px")

        # view doesn't matter
        behavior = self.get_edit_behavior('pyasm.widget.DependencyWdg', search_type, \
            search_id)
        button.add_behavior(behavior)

        return button
示例#2
0
    def get_display(my):

        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        button = IconButtonWdg("Dependency", IconWdg.DEPENDENCY)

        button.add_style("margin: 3px 5px")

        # view doesn't matter
        behavior = my.get_edit_behavior('pyasm.widget.DependencyWdg', search_type, \
            search_id)
        button.add_behavior(behavior)

        return button
示例#3
0
    def get_display(my):

        web = WebContainer.get_web()

        widget = Widget()

        div = SpanWdg(css='med')
        div.set_attr("nowrap", "1")

        limit_wdg = my.text
        limit_wdg.add_event(
            'onchange',
            'if (this.value < 20 || !Common.validate_int(this.value)) this.value=20 '
        )
        limit_wdg.add_style("margin-top: -3px")
        limit_wdg.set_attr("size", "1")
        #limit_wdg.set_value(my.search_limit)

        offset_wdg = HiddenWdg("%s_last_search_offset" % my.label)
        offset_wdg.set_value(my.current_offset)
        #div.add(limit_wdg)
        div.add(offset_wdg)

        if my.search or my.sobjects:
            # my.count should have been set in alter_search()
            # which can be called explicitly thru this instance, my.
            if not my.count:
                my.count = my.search.get_count()

            # if my.sobjects exist thru inheriting from parent widgets
            # or explicitly set, (this is not mandatory though)
            if my.sobjects and len(my.sobjects) < my.search_limit:
                limit = len(my.sobjects)
            elif my.search and my.count < my.search_limit:
                # this is only true if the total result of the search is
                # less than the limit and so this wdg will not display
                limit = my.count
            else:
                limit = my.search_limit

            if my.current_offset == 0 and limit < my.search_limit:
                return None

            if my.refresh:
                prev = IconSubmitWdg("Prev", IconWdg.LEFT, False)
                next = IconSubmitWdg("Next",
                                     IconWdg.RIGHT,
                                     False,
                                     icon_pos="right")
            else:
                prev = IconButtonWdg("Prev", IconWdg.LEFT, False)
                hidden_name = my.prev_hidden_name
                hidden = HiddenWdg(hidden_name, "")
                prev.add(hidden)
                prev.add_event('onclick',"get_elements('%s').set_value('Prev');%s"\
                        %(hidden_name, my.refresh_script))
                next = IconButtonWdg("Next",
                                     IconWdg.RIGHT,
                                     False,
                                     icon_pos="right")
                hidden_name = my.next_hidden_name
                hidden = HiddenWdg(hidden_name, "")
                next.add(hidden)
                next.add_event('onclick',"get_elements('%s').set_value('Next');%s" \
                        %(hidden_name, my.refresh_script))

            label_span = SpanWdg("Showing:")
            label_span.add_style('color', '#c2895d')
            div.add(label_span)
            div.add(prev)

            # this min calculation is used so that if my.sobjects is not set
            # above for the calculation of the limit, which will make the last
            # set of range numbers too big

            left_bound = my.current_offset + 1
            right_bound = min(my.current_offset + limit, my.count)
            if left_bound > right_bound:
                left_bound = 1
            current_value = "%d - %d" % (left_bound, right_bound)

            if my.style == my.SIMPLE:
                div.add(current_value)
            else:
                # add a range selector using ItemsNavigatorWdg
                from input_wdg import ItemsNavigatorWdg
                selector = ItemsNavigatorWdg(my.label,
                                             my.count,
                                             my.search_limit,
                                             refresh=my.refresh)
                selector.set_style(my.style)

                selector.set_value(current_value)
                selector.set_display_label(False)
                if my.refresh_script:
                    selector.set_refresh_script(my.refresh_script)
                div.add(selector)
                div.add(" - ")
                div.add(limit_wdg)

            div.add(next)

            widget.add(div)

        return widget
示例#4
0
    def _handle_files(self, snapshot, widget, upstream, recursive=True):

        web_dir = snapshot.get_web_dir()
        xml = snapshot.get_xml_value("snapshot")

        # handle files
        files = xml.get_nodes("snapshot/file")
        for file in files:
            
            file_code = Xml.get_attribute(file, "file_code")
            file_type = Xml.get_attribute(file, "type")
            file_range = Xml.get_attribute(file, "file_range")
            #file_range = "1-4/1"

            dir = snapshot.get_client_lib_dir(file_type=file_type)
            lib_dir = snapshot.get_lib_dir(file_type=file_type)
            open_button = IconButtonWdg( "Explore: %s" % dir, IconWdg.LOAD, False)
            if dir == lib_dir:
                open_button.add_behavior({'type':'click_up', 'cbjs_action': '''var applet = spt.Applet.get();
                                       
                                            spt.alert('You are not allowed to browse directories on a web server.');
                                    '''})
            else:
                open_button.add_behavior({'type':'click_up', 
                                        'dir' : dir,
                                        'cbjs_action': '''
                                        var applet = spt.Applet.get();
                                        
                                        var dir = bvr.dir;
                                      
                                        applet.open_explorer(dir);'''})
            open_button.add_class('small')
            open_button.add_style('float: left')
            widget.add(open_button)

            if file_range:
                file_name = Xml.get_attribute(file, "name")
                widget.add("%s [code = %s, type = %s]" % (file_name, file_code, file_type))
                widget.add(HtmlElement.br(2))

                # display all of the paths
                file_names = FileGroup.expand_paths( file_name, FileRange.get(file_range) )
                for file_name in file_names:
                    #link = HtmlElement.href(file_name, "%s/%s" % (web_dir, file_name), target="_blank" )
                    link = SpanWdg(file_name)
                    link.add_color("color", "color")
                    widget.add(link)
                    widget.add(HtmlElement.br())

            else:
                thumb = DependencyThumbWdg()
                thumb.set_show_filename(True)
                thumb.set_sobject(snapshot)
                thumb.set_icon_size(15)
                thumb.set_image_link_order([file_type])
                thumb.set_option('detail', 'false')

                widget.add(SpanWdg(thumb, css='small'))
                widget.add("[code = %s, type = %s]" % ( file_code, file_type))

            widget.add(HtmlElement.br())
            

            block = DivWdg()
            block.add_style("margin-left: 30px")
            block.add_style("margin-top: 10px")
            nodes = xml.get_nodes("snapshot/file[@file_code='%s']/ref" % file_code)
            widget.add(HtmlElement.br(clear="all"))
            # handle sub refs
            for node in nodes:
                self._handle_ref_node(node, block, upstream, recursive)
                block.add(HtmlElement.br())
            if nodes:
                widget.add(block)

            widget.add(HtmlElement.br())



        files = xml.get_nodes("snapshot/unknown_ref")
        if files:
            widget.add(HtmlElement.b("Unknown ref."))
        for file in files:
            block = DivWdg()
            block.add_style("margin-left: 30px")
            block.add_style("margin-top: 10px")

            block.add( IconWdg( "Unknown", IconWdg.UNKNOWN) )

            path = Xml.get_attribute(file, "path")
            block.add(path)
            widget.add(block)