Exemple #1
0
    def init_setup(my):
       
        hidden = HiddenWdg(my.DELETE_MODE)
        my.add_ajax_input(hidden)
        hidden = HiddenWdg(my.NEW_ITEM)
        my.add_ajax_input(hidden)
        hidden = HiddenWdg(my.NEW_ITEM_LABEL)
        my.add_ajax_input(hidden)
        hidden = HiddenWdg("code_col")
        my.add_ajax_input(hidden)
        if not my.is_from_ajax():
            hidden.set_value(my.get_option('code_col'))
        my.add(hidden)

        hidden = HiddenWdg('ref_search_type')
        my.add_ajax_input(hidden)
        if not my.is_from_ajax():
            hidden.set_value(my.web.get_form_value('ref_search_type'))
        my.add(hidden)
        hidden = HiddenWdg('search_id')
        my.add_ajax_input(hidden)
       
        if my.is_from_ajax():
            col_name = my.web.get_form_value('col_name')
        else:
            col_name = my.get_name()
        my.col_name = HiddenWdg('col_name', col_name)
        my.add_ajax_input(my.col_name)

        my.select_items = HiddenWdg('%s|%s' %(col_name, my.SELECT_ITEMS))
        my.add_ajax_input(my.select_items)
Exemple #2
0
    def init_setup(self):
       
        hidden = HiddenWdg(self.DELETE_MODE)
        self.add_ajax_input(hidden)
        hidden = HiddenWdg(self.NEW_ITEM)
        self.add_ajax_input(hidden)
        hidden = HiddenWdg(self.NEW_ITEM_LABEL)
        self.add_ajax_input(hidden)
        hidden = HiddenWdg("code_col")
        self.add_ajax_input(hidden)
        if not self.is_from_ajax():
            hidden.set_value(self.get_option('code_col'))
        self.add(hidden)

        hidden = HiddenWdg('ref_search_type')
        self.add_ajax_input(hidden)
        if not self.is_from_ajax():
            hidden.set_value(self.web.get_form_value('ref_search_type'))
        self.add(hidden)
        hidden = HiddenWdg('search_id')
        self.add_ajax_input(hidden)
       
        if self.is_from_ajax():
            col_name = self.web.get_form_value('col_name')
        else:
            col_name = self.get_name()
        self.col_name = HiddenWdg('col_name', col_name)
        self.add_ajax_input(self.col_name)

        self.select_items = HiddenWdg('%s|%s' %(col_name, self.SELECT_ITEMS))
        self.add_ajax_input(self.select_items)
Exemple #3
0
    def init_setup(my):

        hidden = HiddenWdg(my.DELETE_MODE)
        my.add_ajax_input(hidden)
        hidden = HiddenWdg(my.NEW_ITEM)
        my.add_ajax_input(hidden)
        hidden = HiddenWdg(my.NEW_ITEM_LABEL)
        my.add_ajax_input(hidden)
        hidden = HiddenWdg("code_col")
        my.add_ajax_input(hidden)
        if not my.is_from_ajax():
            hidden.set_value(my.get_option('code_col'))
        my.add(hidden)

        hidden = HiddenWdg('ref_search_type')
        my.add_ajax_input(hidden)
        if not my.is_from_ajax():
            hidden.set_value(my.web.get_form_value('ref_search_type'))
        my.add(hidden)
        hidden = HiddenWdg('search_id')
        my.add_ajax_input(hidden)

        if my.is_from_ajax():
            col_name = my.web.get_form_value('col_name')
        else:
            col_name = my.get_name()
        my.col_name = HiddenWdg('col_name', col_name)
        my.add_ajax_input(my.col_name)

        my.select_items = HiddenWdg('%s|%s' % (col_name, my.SELECT_ITEMS))
        my.add_ajax_input(my.select_items)
Exemple #4
0
    def get_display(my):

        new_tab_names = my.tab_names
        
        app_css = app_style = None    
        if WebContainer.get_web().get_app_name_by_uri() != 'Browser':
            app_css = 'smaller'
            app_style = 'padding: 0px 2px 3px 2px' 
            
        div = my.div
        div.set_style("margin-top: 10px; margin-bottom: 20px")
        
        # add some spacing
        span = SpanWdg(css='tab_front')
        div.add(span)

        selected_widget = None

        # figure out which is the selected one
        selected_index = 0
        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            if tab_name == my.tab_value:
                selected_index = i
                break

        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            widget = my.get_widget(tab_name)

            tab = SpanWdg()
            if i == selected_index:
                # selected tab
                tab.set_class("%s_selected" %my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
                selected_widget = widget
            else:
                # unselected tab
                tab.set_class("%s_unselected" %my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
            tab.add( my.get_header(tab_name, selected_index, app_css))
            div.add(tab)

        # FIXME: hide this for now 
        #div.add( my.get_add_tab_wdg() )


        tab_hidden = HiddenWdg(my.tab_key)
        tab_hidden.set_persistence()
        # explicitly records this value for init-type submit
        tab_hidden._set_persistent_values([my.tab_value])

        # TODO: not sure if this is legal ... This is rather redundant,
        # but set_value is a pretty complex function.  In the end this
        # forces it to be set to a value even though widget settings is disabled
        value = tab_hidden.get_value()
        if value:
            tab_hidden.set_value(value)

        div.add(tab_hidden)
        
        
        
        # if an error occured, draw the error 
        if my.error_wdg:
            div.add(my.error_wdg)
        else:
            # display the content
            content_div = HtmlElement.div()
            if my.content_height:
                content_div.add_style("height: %spx" % my.content_height)
                content_div.add_style("padding: 10px 0 10px 0")
                content_div.add_style("overflow: auto")
                content_div.add_style("border-style: solid")
            
            content_div.set_class("%s_content" %my.get_style_prefix())
            content_div.add_style("display: block")

            try:
                content = my.get_content(selected_widget)
                if isinstance( content, Widget):
                    content = content.get_buffer_display()
            except Exception, e:
                my.handle_exception(e)

                # TODO: need some way to make this automatic in Widget.
                #if my.tab_path:
                #    last_buffer = len(my.tab_path)+1
                #    buffer = my.get_buffer_on_exception(last_buffer)
                #else:
                buffer = my.get_buffer_on_exception()

                div.add(buffer)


                content = my.error_wdg

            content_div.add( content )
            div.add(content_div)
Exemple #5
0
    def get_display(my):

        new_tab_names = my.tab_names

        app_css = app_style = None
        if WebContainer.get_web().get_app_name_by_uri() != 'Browser':
            app_css = 'smaller'
            app_style = 'padding: 0px 2px 3px 2px'

        div = my.div
        div.set_style("margin-top: 10px; margin-bottom: 20px")

        # add some spacing
        span = SpanWdg(css='tab_front')
        div.add(span)

        selected_widget = None

        # figure out which is the selected one
        selected_index = 0
        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            if tab_name == my.tab_value:
                selected_index = i
                break

        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            widget = my.get_widget(tab_name)

            tab = SpanWdg()
            if i == selected_index:
                # selected tab
                tab.set_class("%s_selected" % my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
                selected_widget = widget
            else:
                # unselected tab
                tab.set_class("%s_unselected" % my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
            tab.add(my.get_header(tab_name, selected_index, app_css))
            div.add(tab)

        # FIXME: hide this for now
        #div.add( my.get_add_tab_wdg() )

        tab_hidden = HiddenWdg(my.tab_key)
        tab_hidden.set_persistence()
        # explicitly records this value for init-type submit
        tab_hidden._set_persistent_values([my.tab_value])

        # TODO: not sure if this is legal ... This is rather redundant,
        # but set_value is a pretty complex function.  In the end this
        # forces it to be set to a value even though widget settings is disabled
        value = tab_hidden.get_value()
        if value:
            tab_hidden.set_value(value)

        div.add(tab_hidden)

        # if an error occured, draw the error
        if my.error_wdg:
            div.add(my.error_wdg)
        else:
            # display the content
            content_div = HtmlElement.div()
            if my.content_height:
                content_div.add_style("height: %spx" % my.content_height)
                content_div.add_style("padding: 10px 0 10px 0")
                content_div.add_style("overflow: auto")
                content_div.add_style("border-style: solid")

            content_div.set_class("%s_content" % my.get_style_prefix())
            content_div.add_style("display: block")

            try:
                content = my.get_content(selected_widget)
                if isinstance(content, Widget):
                    content = content.get_buffer_display()
            except Exception, e:
                my.handle_exception(e)

                # TODO: need some way to make this automatic in Widget.
                #if my.tab_path:
                #    last_buffer = len(my.tab_path)+1
                #    buffer = my.get_buffer_on_exception(last_buffer)
                #else:
                buffer = my.get_buffer_on_exception()

                div.add(buffer)

                content = my.error_wdg

            content_div.add(content)
            div.add(content_div)
    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
Exemple #7
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