예제 #1
0
    def get_display(my):
        widget = Widget()
        
        thumb = super(ThumbPublishWdg, my).get_display()

        widget.add(thumb)
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        publish_link = PublishLinkWdg(search_type,search_id) 
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build an iframe to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')


        return widget
예제 #2
0
    def get_display(my):

        sobject = my.get_current_sobject()

        widget_class = my.get_option("class")
        
        if widget_class == '':
            raise WidgetException("No widget class defined")

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", widget_class)
        url.set_option("search_key", sobject.get_search_key())

        ref = url.get_url()

        iframe = Container.get("iframe")
        iframe.set_width(90)
        action = iframe.get_on_script(ref)

        info_type = my.get_option("info_type")
        
        button = IconButtonWdg("%s info" % info_type, IconWdg.INFO)
        button.add_event("onclick", "%s" % (action) )
        button.add_style("margin: 3px 5px")

        return button
예제 #3
0
    def get_display(my):

        sobject = my.get_current_sobject()

        widget_class = my.get_option("class")

        if widget_class == '':
            raise WidgetException("No widget class defined")

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", widget_class)
        url.set_option("search_key", sobject.get_search_key())

        ref = url.get_url()

        iframe = Container.get("iframe")
        iframe.set_width(90)
        action = iframe.get_on_script(ref)

        info_type = my.get_option("info_type")

        button = IconButtonWdg("%s info" % info_type, IconWdg.INFO)
        button.add_event("onclick", "%s" % (action))
        button.add_style("margin: 3px 5px")

        return button
예제 #4
0
    def get_display(my):
        widget = Widget()

        thumb = super(ThumbPublishWdg, my).get_display()

        widget.add(thumb)
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        publish_link = PublishLinkWdg(search_type, search_id)
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build an iframe to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')

        return widget
예제 #5
0
    def init(self):

        self.layer = LayerWdg(self.xpos, self.ypos, self.display)
        if not self.width:
            self.shadowbox = ShadowBoxWdg(self.shad_name)
        else:
            self.shadowbox = ShadowBoxWdg(self.shad_name, self.width)

        # do not enable it for the Login page
        web = WebContainer.get_web()
        if self.shad_name and not web.is_IE():
            BaseAppServer.add_onload_script("Move.drag('%s','%s')" \
                    %(self.shadowbox.get_name(), self.iframe_name))

        div = DivWdg()

        from pyasm.widget import IconButtonWdg

        move_button = IconWdg(name='move me', icon=IconWdg.NAV)
        move_button.set_id("%s_handle" % (self.shad_name))
        move_button.add_class('move')

        move_button.add_style('float: left')
        move_button.add_style('padding: 2px 0 0 6px')
        if not web.is_IE():
            div.add(move_button)

        mbutton = IconButtonWdg(name='close window', icon=IconWdg.KILL)
        mbutton.set_class("moduleKillBtn")
        mbutton.add_event("onclick", self.layer.get_off_script())

        div.add(mbutton)

        if self.nav_links:
            back_link = HtmlElement.href("<<",
                                         "javascript:history.back()")
            back_link.add_style("font-size", "1.4em")

            for_link = HtmlElement.href(">>",
                                        "javascript:history.forward()")
            for_link.add_style("font-size", "1.4em")

            div.add(SpanWdg(back_link, css='med'))
            div.add(SpanWdg(for_link, css='med'))

        self.shadowbox.set_header(div)

        # add button and title_wdg to shadow box
        if self.title_wdg:
            title_wdg = DivWdg()
            title_wdg.set_class("moduleTitle")
            title_wdg.add(self.title_wdg)
            self.shadowbox.set_title_wdg(title_wdg)

        self.layer.add(self.shadowbox)
        self._add_widget(self.layer)
예제 #6
0
    def get_display(my):
        web = WebContainer.get_web()
        if not my.view:
            view = web.get_form_value("filter|view")

        # create popup
        create_popup = PopupWdg("create_action")
        create_popup.set_auto_hide(False)
        create_popup.add("Enter name of view: ")
        create_popup.add(TextWdg("create_view_name"))
        # create_popup.add( HtmlElement.br(2) )
        # create_popup.add( "Copy from template: " )
        # template_select = SelectWdg("copy_from_template")
        # template_select.add_empty_option("-- None --")
        # template_select.set_option("values", "list|summary|task")
        # create_popup.add( template_select )

        create_popup.add(HtmlElement.br(2, clear="all"))

        from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg

        create_icon = ProdIconButtonWdg("Create")

        ajax = AjaxCmd()
        ajax.register_cmd("pyasm.widget.CustomCreateViewCbk")
        ajax.add_element_name("create_view_name")
        ajax.add_element_name("auto_create_edit")
        ajax.set_option("search_type", my.search_type)
        ajax.set_option("project", Project.get_project_code())
        if my.view:
            ajax.set_option("template_view", my.view)
        create_icon.add_event(
            "onclick",
            "%s;%s"
            % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)"),
        )

        cancel_icon = ProdIconButtonWdg("Cancel")
        cancel_icon.add_event("onclick", "toggle_display('create_action')")

        span = SpanWdg()
        span.add(create_icon)
        span.add(cancel_icon)
        create_popup.add(span)
        create_popup.add(HtmlElement.br())

        # add the create button
        create = IconButtonWdg("Create View", IconWdg.SAVE, True)
        create.add_event("onclick", "%s" % create_popup.get_on_script())

        # lay it all out
        widget = Widget()
        widget.add(create_popup)
        # Browser does not have create
        # widget.add(create)
        return widget
예제 #7
0
    def init(my):
        
        my.layer = LayerWdg(my.xpos, my.ypos, my.display)
        if not my.width:
            my.shadowbox = ShadowBoxWdg(my.shad_name)
        else:
            my.shadowbox = ShadowBoxWdg(my.shad_name, my.width)

        # do not enable it for the Login page
        web = WebContainer.get_web()
        if my.shad_name and not web.is_IE():
            BaseAppServer.add_onload_script("Move.drag('%s','%s')" \
                    %(my.shadowbox.get_name(), my.iframe_name))

        div = DivWdg()
        
        from pyasm.widget import IconButtonWdg
        
        move_button = IconWdg(name='move me', icon=IconWdg.NAV)
        move_button.set_id("%s_handle" % (my.shad_name))
        move_button.add_class('move')

        move_button.add_style('float: left')
        move_button.add_style('padding: 2px 0 0 6px')
        if not web.is_IE():
            div.add(move_button)

        mbutton = IconButtonWdg(name='close window', icon=IconWdg.KILL)
        mbutton.set_class("moduleKillBtn")
        mbutton.add_event("onclick", my.layer.get_off_script() )
        
        div.add(mbutton)
        
        if my.nav_links:
            back_link = HtmlElement.href("<<", "javascript:history.back()")
            back_link.add_style("font-size", "1.4em")
            
            for_link = HtmlElement.href(">>", "javascript:history.forward()")
            for_link.add_style("font-size", "1.4em")
           
            div.add(SpanWdg(back_link, css='med'))
            div.add(SpanWdg(for_link, css='med'))
        
        my.shadowbox.set_header(div)
        
        # add button and title_wdg to shadow box
        if my.title_wdg:
            title_wdg = DivWdg()
            title_wdg.set_class("moduleTitle")
            title_wdg.add(my.title_wdg)
            my.shadowbox.set_title_wdg(title_wdg)
        
       
        my.layer.add(my.shadowbox)
        my._add_widget(my.layer)
예제 #8
0
    def get_display(my):
        web = WebContainer.get_web()
        if not my.view:
            view = web.get_form_value("filter|view")

        # create popup
        create_popup = PopupWdg("create_action")
        create_popup.set_auto_hide(False)
        create_popup.add("Enter name of view: ")
        create_popup.add(TextWdg("create_view_name"))
        #create_popup.add( HtmlElement.br(2) )
        #create_popup.add( "Copy from template: " )
        #template_select = SelectWdg("copy_from_template")
        #template_select.add_empty_option("-- None --")
        #template_select.set_option("values", "list|summary|task")
        #create_popup.add( template_select )

        create_popup.add(HtmlElement.br(2, clear="all"))

        from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg
        create_icon = ProdIconButtonWdg('Create')

        ajax = AjaxCmd()
        ajax.register_cmd("pyasm.widget.CustomCreateViewCbk")
        ajax.add_element_name("create_view_name")
        ajax.add_element_name("auto_create_edit")
        ajax.set_option("search_type", my.search_type)
        ajax.set_option("project", Project.get_project_code())
        if my.view:
            ajax.set_option("template_view", my.view)
        create_icon.add_event(
            "onclick", "%s;%s" %
            (ajax.get_on_script(),
             "toggle_display('create_action');setTimeout('document.form.submit()',1000)"
             ))

        cancel_icon = ProdIconButtonWdg('Cancel')
        cancel_icon.add_event("onclick", "toggle_display('create_action')")

        span = SpanWdg()
        span.add(create_icon)
        span.add(cancel_icon)
        create_popup.add(span)
        create_popup.add(HtmlElement.br())

        # add the create button
        create = IconButtonWdg("Create View", IconWdg.SAVE, True)
        create.add_event("onclick", "%s" % create_popup.get_on_script())

        # lay it all out
        widget = Widget()
        widget.add(create_popup)
        # Browser does not have create
        #widget.add(create)
        return widget
예제 #9
0
    def get_create_view_wdg(my, search_type):

        # create popup
        create_popup = PopupWdg("create_action")
        create_popup.set_auto_hide(False)
        create_popup.add("Enter name of view: ")
        create_popup.add(TextWdg("create_view_name"))
        #create_popup.add( HtmlElement.br(2) )
        #create_popup.add( "Copy from template: " )
        #template_select = SelectWdg("copy_from_template")
        #template_select.add_empty_option("-- None --")
        #template_select.set_option("values", "list|summary|task")
        #create_popup.add( template_select )
        create_popup.add(HtmlElement.br(2))
        create_popup.add(
            CheckboxWdg('auto_create_edit', label='Auto Create Edit View'))
        create_popup.add(HtmlElement.br(2, clear="all"))

        from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg
        create_icon = ProdIconButtonWdg('Create')

        ajax = AjaxCmd()
        ajax.register_cmd("pyasm.widget.CustomCreateViewCbk")
        ajax.add_element_name("create_view_name")
        ajax.add_element_name("auto_create_edit")
        ajax.set_option("search_type", search_type)
        ajax.set_option("project", Project.get_project_code())
        div = ajax.generate_div()
        div.set_post_ajax_script('document.form.submit()')
        create_icon.add_event(
            "onclick", "%s;%s" %
            (ajax.get_on_script(), "toggle_display('create_action')"))

        cancel_icon = ProdIconButtonWdg('Cancel')
        cancel_icon.add_event("onclick", "toggle_display('create_action')")

        span = SpanWdg()
        span.add(create_icon)
        span.add(cancel_icon)
        create_popup.add(span)
        create_popup.add(HtmlElement.br())

        # add the create button
        create = IconButtonWdg("Create View", IconWdg.SAVE, True)
        create.add_event("onclick", "%s" % create_popup.get_on_script())

        # lay it all out
        widget = Widget()
        widget.add(create_popup)
        widget.add(create)
        widget.add(div)
        return widget
예제 #10
0
    def get_create_view_wdg(my, search_type):

        # create popup
        create_popup = PopupWdg("create_action")
        create_popup.set_auto_hide(False)
        create_popup.add("Enter name of view: ")
        create_popup.add(TextWdg("create_view_name"))
        # create_popup.add( HtmlElement.br(2) )
        # create_popup.add( "Copy from template: " )
        # template_select = SelectWdg("copy_from_template")
        # template_select.add_empty_option("-- None --")
        # template_select.set_option("values", "list|summary|task")
        # create_popup.add( template_select )
        create_popup.add(HtmlElement.br(2))
        create_popup.add(CheckboxWdg("auto_create_edit", label="Auto Create Edit View"))
        create_popup.add(HtmlElement.br(2, clear="all"))

        from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg

        create_icon = ProdIconButtonWdg("Create")

        ajax = AjaxCmd()
        ajax.register_cmd("pyasm.widget.CustomCreateViewCbk")
        ajax.add_element_name("create_view_name")
        ajax.add_element_name("auto_create_edit")
        ajax.set_option("search_type", search_type)
        ajax.set_option("project", Project.get_project_code())
        div = ajax.generate_div()
        div.set_post_ajax_script("document.form.submit()")
        create_icon.add_event("onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')"))

        cancel_icon = ProdIconButtonWdg("Cancel")
        cancel_icon.add_event("onclick", "toggle_display('create_action')")

        span = SpanWdg()
        span.add(create_icon)
        span.add(cancel_icon)
        create_popup.add(span)
        create_popup.add(HtmlElement.br())

        # add the create button
        create = IconButtonWdg("Create View", IconWdg.SAVE, True)
        create.add_event("onclick", "%s" % create_popup.get_on_script())

        # lay it all out
        widget = Widget()
        widget.add(create_popup)
        widget.add(create)
        widget.add(div)
        return widget
예제 #11
0
    def get_display(self):
        sobject = self.get_current_sobject()

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", self.get_annotate_wdg_class())
        url.set_option("search_type", sobject.get_search_type())
        url.set_option("search_id", sobject.get_id())

        button = IconButtonWdg("Annotate", IconWdg.DETAILS, False)
        button.add_event("onclick", \
            "document.location='%s'" % url.to_string() )

        widget = Widget()
        widget.add(button)

        return widget
예제 #12
0
    def get_display(my):
        sobject = my.get_current_sobject()

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", my.get_annotate_wdg_class() )
        url.set_option("search_type", sobject.get_search_type() )
        url.set_option("search_id", sobject.get_id() )

        button = IconButtonWdg("Annotate", IconWdg.DETAILS, False)
        button.add_event("onclick", \
            "document.location='%s'" % url.to_string() )

        widget = Widget()
        widget.add(button)

        return widget
예제 #13
0
    def get_display(my):
        # add the add property button
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        add = IconButtonWdg("Add Property", IconWdg.INSERT, True)

        add.add_event("oncontextmenu", "%s;return false" % action )
        add.add_event("onclick", "%s" % action )

        widget = Widget()
        widget.add(add)
        return widget
예제 #14
0
    def get_display(my):
        # add the add property button
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        add = IconButtonWdg("Add Property", IconWdg.INSERT, True)

        add.add_event("oncontextmenu", "%s;return false" % action )
        add.add_event("onclick", "%s" % action )

        widget = Widget()
        widget.add(add)
        return widget
예제 #15
0
    def get_open_wdg(sobject, file_type=None):
        ''' given a snapshot. open the sandbox in explorer '''

        span = SpanWdg()

        # explore button
        dir = sobject.get_client_lib_dir(file_type=file_type)
        open_button = IconButtonWdg("Explore: %s" % dir, IconWdg.LOAD, False)
        open_button.add_event("onclick", "Applet.open_explorer('%s')" % dir)
        open_button.add_class('small')
        span.add(open_button)

        #dir = sobject.get_sandbox_dir()
        #copy_button = IconButtonWdg( "Copy to sandbox: %s" % dir, IconWdg.DOWNLOAD, False)
        #span.add(copy_button)

        return span
예제 #16
0
    def get_open_wdg( sobject, file_type=None):
        ''' given a snapshot. open the sandbox in explorer '''

        span = SpanWdg()

        # explore button
        dir = sobject.get_client_lib_dir(file_type=file_type)
        open_button = IconButtonWdg( "Explore: %s" % dir, IconWdg.LOAD, False)
        open_button.add_event("onclick", "Applet.open_explorer('%s')" % dir)
        open_button.add_class('small')
        span.add(open_button)

        #dir = sobject.get_sandbox_dir()
        #copy_button = IconButtonWdg( "Copy to sandbox: %s" % dir, IconWdg.DOWNLOAD, False)
        #span.add(copy_button)

        return span
예제 #17
0
    def init(my):
        my.name = "iframe%s" % (my.generate_unique_id())
        my.img_span_name = '%s_loading' %my.name
        my.iframe = HtmlElement.iframe()
        my.iframe.set_id(my.name)
        my.iframe.set_attr('name',my.name)
        # To adjust the real-time size of the overlay box, do it in get_on_script
        
        my.overlay = OverlayWdg(name='%s_shadowbox'%my.name, \
            width=my.width * 1.0, display=False, iframe_name=my.name )

        
        my.overlay.add(my.iframe)
        
        my.shadowbox = my.overlay.get_shadow_box()

        


        tall_control = IconButtonWdg(name='taller', icon='/context/icons/common/dn_button.png')
        tall_control.add_style("float: right")
        
       
        tall_control.add_event("onclick", my.get_taller_script(my.name, my.shadowbox.name) )
       
        short_control = IconButtonWdg(name='shorter', icon='/context/icons/common/up_button.png')
        short_control.add_style("float: right")
        short_control.add_style("padding-bottom: 4px")
        
        short_control.add_event("onclick", my.get_shorter_script(my.name, my.shadowbox.name) )
        
        control = DivWdg()
        control.add_style('margin-top: -30px')
        control.add(short_control)
        control.add(tall_control)
        
        if not WebContainer.get_web().is_IE():
            my.shadowbox.set_control(control)
        my.overlay.add(my._get_loading_span()) 
        my.add(my.overlay)
예제 #18
0
    def init(self):
        self.name = "iframe%s" % (self.generate_unique_id())
        self.img_span_name = '%s_loading' % self.name
        self.iframe = HtmlElement.iframe()
        self.iframe.set_id(self.name)
        self.iframe.set_attr('name', self.name)
        # To adjust the real-time size of the overlay box, do it in get_on_script

        self.overlay = OverlayWdg(name='%s_shadowbox'%self.name, \
            width=self.width * 1.0, display=False, iframe_name=self.name )

        self.overlay.add(self.iframe)

        self.shadowbox = self.overlay.get_shadow_box()

        tall_control = IconButtonWdg(
            name='taller', icon='/context/icons/common/dn_button.png')
        tall_control.add_style("float: right")

        tall_control.add_event(
            "onclick", self.get_taller_script(self.name, self.shadowbox.name))

        short_control = IconButtonWdg(
            name='shorter', icon='/context/icons/common/up_button.png')
        short_control.add_style("float: right")
        short_control.add_style("padding-bottom: 4px")

        short_control.add_event(
            "onclick", self.get_shorter_script(self.name, self.shadowbox.name))

        control = DivWdg()
        control.add_style('margin-top: -30px')
        control.add(short_control)
        control.add(tall_control)

        if not WebContainer.get_web().is_IE():
            self.shadowbox.set_control(control)
        self.overlay.add(self._get_loading_span())
        self.add(self.overlay)
예제 #19
0
    def _add_publish_link(self, main_div):
        publish_link = PublishLinkWdg(self.sobject.get_search_type(), self.sobject.get_id())
        div = DivWdg(publish_link)
        div.add_style('padding-top','5px')
        main_div.add(div)


        # build an iframe to show publish browsing
        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        from pyasm.widget import IconButtonWdg, IconWdg
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')
예제 #20
0
    def _add_publish_link(self, main_div):
        publish_link = PublishLinkWdg(self.sobject.get_search_type(),
                                      self.sobject.get_id())
        div = DivWdg(publish_link)
        div.add_style('padding-top', '5px')
        main_div.add(div)

        # build an iframe to show publish browsing
        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        from pyasm.widget import IconButtonWdg, IconWdg
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')
예제 #21
0
    def init(my):

        WebContainer.register_cmd("pyasm.widget.AnnotateCbk")

        sobject = my.get_current_sobject()

        if not sobject:
            if not my.__dict__.has_key("search_type"):
                web = WebContainer.get_web()
                my.search_type = web.get_form_value("search_type")
                my.search_id = web.get_form_value("search_id")

            if not my.search_type:
                my.add("No search type")
                return


            search = Search(my.search_type)
            search.add_id_filter(my.search_id)
            sobject = search.get_sobject()


        snapshot = Snapshot.get_latest_by_sobject(sobject)

        # TODO:
        # this is a bit klunky
        snapshot_xml = snapshot.get_xml_value("snapshot")
        file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
        file = File.get_by_code(file_code)
        web_dir = snapshot.get_web_dir()
        path = "%s/%s" % (web_dir, file.get_full_file_name() )


        # add the annotate js object
        script = HtmlElement.script("annotate = new Annotate()")
        my.add(script)


        # add the image

        my.add("<h3>Image Annotations</h3>")

        width = 600
        img = HtmlElement.img(path)
        img.add_style("position: absolute")
        img.set_id("annotate_image")
        img.add_style("left: 0px")
        img.add_style("top: 0px")
        img.add_style("opacity: 1.0")
        img.add_style("z-index: 1")
        img.add_style("width", width)
        img.add_event("onmouseup", "annotate.add_new(event)")
        my.add(img)



        # test 
        version = snapshot.get_value("version")
        if version != 1:
            last_version = version - 1
            snapshot = Snapshot.get_by_version( \
                my.search_type, my.search_id, version=last_version )

            snapshot_xml = snapshot.get_xml_value("snapshot")
            file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
            file = File.get_by_code(file_code)
            web_dir = snapshot.get_web_dir()
            path = "%s/%s" % (web_dir, file.get_full_file_name() )

            img = HtmlElement.img(path)
            img.set_id("annotate_image_alt")
            img.add_style("position: absolute")
            img.add_style("left: 0px")
            img.add_style("top: 0px")
            img.add_style("opacity: 1.0")
            img.add_style("z-index: 0")
            img.add_style("width", width)
            img.add_event("onmouseup", "annotate.add_new(event)")
            my.add(img)


            #script = HtmlElement.script("align_element('%s','%s')" % \
            #    ("annotate_image", "annotate_image_alt") )
            #my.add(script)

            div = DivWdg()
            div.add_style("position: absolute")
            div.add_style("left: 620")
            div.add_style("top: 300")
            my.add(div)

            button = IconButtonWdg("Switch", IconWdg.REFRESH, True)
            button.add_event("onclick", "annotate.switch_alt()")
            div.add(button)

            button = IconButtonWdg("Opacity", IconWdg.LOAD, True)
            button.add_event("onclick", "annotate.set_opacity()")
            div.add(button)







        # add the new annotation div
        new_annotation_div = DivWdg()
        new_annotation_div.set_id("annotate_msg")
        new_annotation_div.set_class("annotate_new")
        new_annotation_div.add_style("top: 0")
        new_annotation_div.add_style("left: 0")

        title = DivWdg("Enter Annotation:")
        title.add_style("background-color: #000000")
        title.add_style("color: #ffffff")
        new_annotation_div.add(title)

        text = TextAreaWdg("annotate_msg")
        text.set_attr("cols", "30")
        text.set_attr("rows", "3")
        new_annotation_div.add(text)
        new_annotation_div.add("<br/>")
        cancel = ButtonWdg("Cancel")
        cancel.add_style("float: right")
        cancel.add_event("onclick", "toggle_display('annotate_msg')")
        new_annotation_div.add( cancel )
        submit = SubmitWdg("Add Annotation")
        submit.add_style("float: right")

        new_annotation_div.add( submit )

        new_annotation_div.add_style("display: none")
        new_annotation_div.add_style("position: absolute")
        my.add(new_annotation_div)

        # get all of the stored annotations for this image
        search = Search("sthpw/annotation")
        search.add_order_by("login")
        search.add_filter("file_code", file_code)
        annotations = search.get_sobjects()


        # sort by user
        sorted_annotations = {}
        for annotation in annotations:
            user = annotation.get_value("login")

            if not sorted_annotations.has_key(user):
                sorted_annotations[user] = []

            sorted_annotations[user].append(annotation)


        buttons = []
        for user, annotations in sorted_annotations.items():

            button = IconButtonWdg(user, IconWdg.INSERT, True)
            button.add_event("onclick", "annotate.show_marks('%s','%s')" % (user, len(annotations)-1) )
            buttons.append(button)

            count = 0
            for annotation in annotations:
                my.add( my.get_annotate_wdg(annotation,count) )
                count += 1



        # add the user buttons
        table = Table()
        table.set_class("table")
        table.add_style("width: 0px")
        table.add_style("position: absolute")
        table.add_style("left: 620")
        table.add_style("top: 0")
        table.add_row()

        table.add_header("Annotations")
        for button in buttons:
            table.add_row()
            legend_wdg = DivWdg()
            legend_wdg.set_class("annotate_mark")
            legend_wdg.add_style("position: relative")
            legend_wdg.add("&nbsp;")

            table.add_cell(legend_wdg)

            table.add_cell(button)

        my.add(table)


        # add form elements
        hidden = HiddenWdg("mouse_xpos")
        my.add(hidden)
        hidden = HiddenWdg("mouse_ypos")
        my.add(hidden)
        hidden = HiddenWdg("file_code", file_code)
        my.add(hidden)

        # move the rest below
        my.add("<div style='height:300'>&nbsp</div>")
예제 #22
0
    def get_preview_wdg(self):

        widget = Widget()

        web = WebContainer.get_web()

        csv_parser = CsvParser(self.file_path)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        ajax = AjaxCmd()
        ajax.set_option("search_type", self.search_type)
        ajax.set_option("file_path", self.file_path)
        ajax.add_element_name("has_title")

        event = WebContainer.get_event_container()
        caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
        div = ajax.generate_div()
        div.set_post_ajax_script(caller)
        widget.add(div)

        columns = []
        num_columns = len(csv_titles)
        ajax.set_option("num_columns", num_columns)
        for i in range(0, num_columns):
            column = web.get_form_value("column_%s" % i)
            if column:
                column = csv_titles[i]
            else:
                column = web.get_form_value("column_new_%s" % i)

            columns.append(column)

            ajax.add_element_name("column_%s" % i)
            ajax.add_element_name("new_column_%s" % i)

        ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
        import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
        import_button.add_event("onclick",
                                ajax.get_on_script(show_progress=False))
        import_button.add_style("float: right")
        widget.add(import_button)

        preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
        preview_submit.add_style("float: right")
        widget.add(preview_submit)

        sobject_title = self.search_type_obj.get_title()
        widget.add("<p>4. Import</p>")
        widget.add(HtmlElement.br())
        widget.add(
            "<p>The following table will be imported into %s (Showing Max: 100)</p>"
            % sobject_title)

        table = Table(css="table")
        table.add_style("width: 100%")

        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            table.add_header(title)

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            table.add_row()
            for j, cell in enumerate(row):
                table.add_cell(cell)

        widget.add(table)

        return widget
예제 #23
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
예제 #24
0
    def get_display(my):

        web = WebContainer.get_web()

        widget = DivWdg()
        widget.add_class("spt_search_limit_top")
        #widget.add_style("border", "solid 1px blue")
        widget.add_color("background", "background")
        widget.add_color("color", "color")
        widget.add_style("padding: 5px")

        hidden = HiddenWdg("prefix", my.prefix)
        widget.add(hidden)

   
        if not my.search and not my.sobjects:
            widget.add("No search or sobjects found")
            return widget

        # 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(no_exception=True)
        
        # 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 not limit:
            limit = 50
            my.search_limit = limit

    
        if my.refresh: 
            prev = SpanWdg( IconButtonWdg("Prev", IconWdg.LEFT, False ) )
            prev.add_style("margin-left: 8px")
            prev.add_style("margin-right: 6px")
            prev.add_style("margin-top: -2px")
            next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
            next.add_style("margin-left: 6px")

            prev.add_behavior( {
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            } )
            next.add_behavior( {
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            } )
        else: # the old code pre 2.5
            prev = IconButtonWdg("Prev", IconWdg.LEFT, False )
            hidden_name = my.prev_hidden_name
            hidden = HiddenWdg(hidden_name,"")
            prev.add(hidden)
            prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').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',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \
                    %(hidden_name, my.refresh_script))


        showing_wdg = DivWdg()
        widget.add(showing_wdg)
        showing_wdg.add_style("padding: 10px")
        showing_wdg.add_style("margin: 10px")
        showing_wdg.add_color("background", "background", -5)
        showing_wdg.add_border()

        label_span = SpanWdg("Showing: ")
        showing_wdg.add(label_span)
        showing_wdg.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
        if not limit:
            # prevent error in ItemsNavigatorWdg if a search encounters query error
            limit = 50
            my.search_limit = limit

        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:
            showing_wdg.add( current_value )
        else:
            # add a range selector using ItemsNavigatorWdg
            from pyasm.widget import ItemsNavigatorWdg
            selector = ItemsNavigatorWdg(my.label, my.count, my.search_limit)
            selector.select.add_behavior( {
                'type': 'change',
                'cbjs_action': my.refresh_script
            } )

            selector.set_style(my.style)

            selector.set_value(current_value)
            selector.set_display_label(False)

            showing_wdg.add( selector) 

        showing_wdg.add( next )

        #showing_wdg.add( " x ")
        showing_wdg.add(my.text)
        my.text.add_style("margin-top: -3px")
        my.text.set_attr("size", "1")
        my.text.add_attr("title", "Set number of items per page")

        widget.add("<hr/>")


        # set the limit
        set_limit_wdg = my.get_set_limit_wdg()
        widget.add(set_limit_wdg)


        from tactic.ui.widget.button_new_wdg import ActionButtonWdg
        button = ActionButtonWdg(title='Search')
        widget.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: 8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_search_limit_top");
            var select = top.getElement(".spt_search_limit_select");
            var value = select.value;
            if (value == 'Custom') {
                custom = top.getElement(".spt_search_limit_custom_text");
                value = custom.value;
            }
            if (value == '') {
                value = 20;
            }
            var text = top.getElement(".spt_search_limit_text");
            text.value = value;

            spt.dg_table.search_cbk({}, bvr) 
            '''
        } )


        offset_wdg = HiddenWdg("%s_last_search_offset" %my.label)
        offset_wdg.set_value(my.current_offset)
        widget.add(offset_wdg)

        widget.add("<br clear='all'/>")
 
        return widget
예제 #25
0
    def get_display(my):

        web = WebContainer.get_web()

        widget = DivWdg()
        widget.add_class("spt_search_limit_top")
        #widget.add_style("border", "solid 1px blue")
        widget.add_color("background", "background")
        widget.add_color("color", "color")
        widget.add_style("padding: 5px")

        hidden = HiddenWdg("prefix", my.prefix)
        widget.add(hidden)

        if not my.search and not my.sobjects:
            widget.add("No search or sobjects found")
            return widget

        # 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(no_exception=True)

        # 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 not limit:
            limit = 50
            my.search_limit = limit

        if my.refresh:
            prev = SpanWdg(IconButtonWdg("Prev", IconWdg.LEFT, False))
            prev.add_style("margin-left: 8px")
            prev.add_style("margin-right: 6px")
            prev.add_style("margin-top: -2px")
            next = IconButtonWdg("Next",
                                 IconWdg.RIGHT,
                                 False,
                                 icon_pos="right")
            next.add_style("margin-left: 6px")

            prev.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            })
            next.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            })
        else:  # the old code pre 2.5
            prev = IconButtonWdg("Prev", IconWdg.LEFT, False)
            hidden_name = my.prev_hidden_name
            hidden = HiddenWdg(hidden_name, "")
            prev.add(hidden)
            prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').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',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \
                    %(hidden_name, my.refresh_script))

        showing_wdg = DivWdg()
        widget.add(showing_wdg)
        showing_wdg.add_style("padding: 10px")
        showing_wdg.add_style("margin: 10px")
        showing_wdg.add_color("background", "background", -5)
        showing_wdg.add_border()

        label_span = SpanWdg("Showing: ")
        showing_wdg.add(label_span)
        showing_wdg.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
        if not limit:
            # prevent error in ItemsNavigatorWdg if a search encounters query error
            limit = 50
            my.search_limit = limit

        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:
            showing_wdg.add(current_value)
        else:
            # add a range selector using ItemsNavigatorWdg
            from pyasm.widget import ItemsNavigatorWdg
            selector = ItemsNavigatorWdg(my.label, my.count, my.search_limit)
            selector.select.add_behavior({
                'type': 'change',
                'cbjs_action': my.refresh_script
            })

            selector.set_style(my.style)

            selector.set_value(current_value)
            selector.set_display_label(False)

            showing_wdg.add(selector)

        showing_wdg.add(next)

        #showing_wdg.add( " x ")
        showing_wdg.add(my.text)
        my.text.add_style("margin-top: -3px")
        my.text.set_attr("size", "1")
        my.text.add_attr("title", "Set number of items per page")

        widget.add("<hr/>")

        # set the limit
        set_limit_wdg = my.get_set_limit_wdg()
        widget.add(set_limit_wdg)

        from tactic.ui.widget.button_new_wdg import ActionButtonWdg
        button = ActionButtonWdg(title='Search')
        widget.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: 8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_search_limit_top");
            var select = top.getElement(".spt_search_limit_select");
            var value = select.value;
            if (value == 'Custom') {
                custom = top.getElement(".spt_search_limit_custom_text");
                value = custom.value;
            }
            if (value == '') {
                value = 20;
            }
            var text = top.getElement(".spt_search_limit_text");
            text.value = value;

            spt.dg_table.search_cbk({}, bvr) 
            '''
        })

        offset_wdg = HiddenWdg("%s_last_search_offset" % my.label)
        offset_wdg.set_value(my.current_offset)
        widget.add(offset_wdg)

        widget.add("<br clear='all'/>")

        return widget
예제 #26
0
    def init(self):

        WebContainer.register_cmd("pyasm.widget.AnnotateCbk")

        sobject = self.get_current_sobject()

        if not sobject:
            if not self.__dict__.has_key("search_type"):
                web = WebContainer.get_web()
                self.search_type = web.get_form_value("search_type")
                self.search_id = web.get_form_value("search_id")

            if not self.search_type:
                self.add("No search type")
                return

            search = Search(self.search_type)
            search.add_id_filter(self.search_id)
            sobject = search.get_sobject()

        snapshot = Snapshot.get_latest_by_sobject(sobject)

        # TODO:
        # this is a bit klunky
        snapshot_xml = snapshot.get_xml_value("snapshot")
        file_code = snapshot_xml.get_value(
            "snapshot/file[@type='web']/@file_code")
        file = File.get_by_code(file_code)
        web_dir = snapshot.get_web_dir()
        path = "%s/%s" % (web_dir, file.get_full_file_name())

        # add the annotate js object
        script = HtmlElement.script("annotate = new Annotate()")
        self.add(script)

        # add the image

        self.add("<h3>Image Annotations</h3>")

        width = 600
        img = HtmlElement.img(path)
        img.add_style("position: absolute")
        img.set_id("annotate_image")
        img.add_style("left: 0px")
        img.add_style("top: 0px")
        img.add_style("opacity: 1.0")
        img.add_style("z-index: 1")
        img.add_style("width", width)
        img.add_event("onmouseup", "annotate.add_new(event)")
        self.add(img)

        # test
        version = snapshot.get_value("version")
        if version != 1:
            last_version = version - 1
            snapshot = Snapshot.get_by_version( \
                self.search_type, self.search_id, version=last_version )

            snapshot_xml = snapshot.get_xml_value("snapshot")
            file_code = snapshot_xml.get_value(
                "snapshot/file[@type='web']/@file_code")
            file = File.get_by_code(file_code)
            web_dir = snapshot.get_web_dir()
            path = "%s/%s" % (web_dir, file.get_full_file_name())

            img = HtmlElement.img(path)
            img.set_id("annotate_image_alt")
            img.add_style("position: absolute")
            img.add_style("left: 0px")
            img.add_style("top: 0px")
            img.add_style("opacity: 1.0")
            img.add_style("z-index: 0")
            img.add_style("width", width)
            img.add_event("onmouseup", "annotate.add_new(event)")
            self.add(img)

            #script = HtmlElement.script("align_element('%s','%s')" % \
            #    ("annotate_image", "annotate_image_alt") )
            #self.add(script)

            div = DivWdg()
            div.add_style("position: absolute")
            div.add_style("left: 620")
            div.add_style("top: 300")
            self.add(div)

            button = IconButtonWdg("Switch", IconWdg.REFRESH, True)
            button.add_event("onclick", "annotate.switch_alt()")
            div.add(button)

            button = IconButtonWdg("Opacity", IconWdg.LOAD, True)
            button.add_event("onclick", "annotate.set_opacity()")
            div.add(button)

        # add the new annotation div
        new_annotation_div = DivWdg()
        new_annotation_div.set_id("annotate_msg")
        new_annotation_div.set_class("annotate_new")
        new_annotation_div.add_style("top: 0")
        new_annotation_div.add_style("left: 0")

        title = DivWdg("Enter Annotation:")
        title.add_style("background-color: #000000")
        title.add_style("color: #ffffff")
        new_annotation_div.add(title)

        text = TextAreaWdg("annotate_msg")
        text.set_attr("cols", "30")
        text.set_attr("rows", "3")
        new_annotation_div.add(text)
        new_annotation_div.add("<br/>")
        cancel = ButtonWdg("Cancel")
        cancel.add_style("float: right")
        cancel.add_event("onclick", "toggle_display('annotate_msg')")
        new_annotation_div.add(cancel)
        submit = SubmitWdg("Add Annotation")
        submit.add_style("float: right")

        new_annotation_div.add(submit)

        new_annotation_div.add_style("display: none")
        new_annotation_div.add_style("position: absolute")
        self.add(new_annotation_div)

        # get all of the stored annotations for this image
        search = Search("sthpw/annotation")
        search.add_order_by("login")
        search.add_filter("file_code", file_code)
        annotations = search.get_sobjects()

        # sort by user
        sorted_annotations = {}
        for annotation in annotations:
            user = annotation.get_value("login")

            if not sorted_annotations.has_key(user):
                sorted_annotations[user] = []

            sorted_annotations[user].append(annotation)

        buttons = []
        for user, annotations in sorted_annotations.items():

            button = IconButtonWdg(user, IconWdg.INSERT, True)
            button.add_event(
                "onclick", "annotate.show_marks('%s','%s')" %
                (user, len(annotations) - 1))
            buttons.append(button)

            count = 0
            for annotation in annotations:
                self.add(self.get_annotate_wdg(annotation, count))
                count += 1

        # add the user buttons
        table = Table()
        table.set_class("table")
        table.add_style("width: 0px")
        table.add_style("position: absolute")
        table.add_style("left: 620")
        table.add_style("top: 0")
        table.add_row()

        table.add_header("Annotations")
        for button in buttons:
            table.add_row()
            legend_wdg = DivWdg()
            legend_wdg.set_class("annotate_mark")
            legend_wdg.add_style("position: relative")
            legend_wdg.add("&nbsp;")

            table.add_cell(legend_wdg)

            table.add_cell(button)

        self.add(table)

        # add form elements
        hidden = HiddenWdg("mouse_xpos")
        self.add(hidden)
        hidden = HiddenWdg("mouse_ypos")
        self.add(hidden)
        hidden = HiddenWdg("file_code", file_code)
        self.add(hidden)

        # move the rest below
        self.add("<div style='height:300'>&nbsp</div>")
예제 #27
0
    def get_display(my):
        if not my.search_type:
            return "No search type found"

        web = WebContainer.get_web()
        my.view = web.get_form_value("view")
        if not my.view:
            my.view = web.get_form_value("filter|view")
        if not my.view:
            my.view = get_template_view()

        widget = Widget()

        widget.add( HiddenWdg("search_type", my.search_type) )

        element_names = []

        # see if there is an override
        search_type_obj = SearchType.get(my.search_type)  
        config = WidgetConfig.get_by_search_type(my.search_type,"browser_list")
        if config:
            element_names = config.get_element_names()


        search = Search("sthpw/widget_config")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", my.view)
        widget_config = search.get_sobject()
        if widget_config:
            edit_link_wdg = EditLinkWdg("sthpw/widget_config", widget_config.get_id(), text="Edit XML", long=True)
            edit_link_wdg.set_iframe_width(95)
            widget.add(edit_link_wdg)


        custom_config = WidgetConfigView.get_by_search_type(my.search_type,my.view)
        custom_element_names = custom_config.get_element_names()


        # get the custom properties
        search = Search("prod/custom_property")
        search.add_filter("search_type", my.search_type)
        custom_properties = search.get_sobjects()


        # action popup
        action_popup = PopupMenuWdg("table_action", multi=True, width='12em')
        action_popup.set_auto_hide(False)
        action_popup.set_submit(False)

        
        action_popup.add( HtmlElement.href("Add ...", "javascript:document.form.submit()") )


        for custom_property in custom_properties:
            element_name = custom_property.get_name()
            if element_name not in custom_element_names:
                action_popup.add( " %s" % element_name, "add|%s" % element_name )

        # if there is an override
        if element_names:
            for element_name in element_names:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )


        # get all of the columns
        else:
            search_type_obj = SearchType.get(my.search_type)
            element_names = search_type_obj.get_columns()

            for element_name in element_names:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )

            # add some standard properties
            if my.view in ["edit", "insert"]:
                for element_name in PREDEFINED_EDIT_ELEMENTS:
                    if element_name not in custom_element_names:
                        action_popup.add( " %s" % element_name, "add|%s" % element_name )
            else:
                for element_name in PREDEFINED_ELEMENTS:
                    if element_name not in custom_element_names:
                        action_popup.add( " %s" % element_name, "add|%s" % element_name )

        action_popup.add_separator()
        action_popup.add( HtmlElement.href("Remove ...", "javascript:document.form.submit()") )
        for element_name in custom_element_names:
            action_popup.add( " %s" % element_name, "remove|%s" % element_name )
        action_popup.add_separator()

        span = SpanWdg("New Custom ...", css="hand")
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        span.add_event("onclick", action)
        action_popup.add( span )


        # add the edit button
        edit = IconButtonWdg("Edit View", IconWdg.EDIT, True)

        edit.add_event("oncontextmenu", "%s;return false" % action_popup.get_on_script() )
        edit.add_event("onclick", "%s" % action_popup.get_on_script() )



        # lay it all out
        widget.add(SpanWdg(action_popup))
        widget.add(edit)

        # add the edit button
        #save = IconButtonWdg("Save", IconWdg.SAVE, True)
        #widget.add(save)

        # add the add property button
        if my.mode == "admin":
            add = CustomAddPropertyLinkWdg(my.search_type, my.view)
            widget.add(add)
            #add_element = CustomAddElementLinkWdg(my.search_type, my.view)
            #widget.add(add_element)


        # add the clear button
        if my.mode == "admin" or my.view.startswith("custom_"):
            clear = IconSubmitWdg("Clear", IconWdg.DELETE, True)
            widget.add(clear)

        
        widget.add(SpanWdg(css="small"))


        WebContainer.register_cmd("pyasm.widget.CustomViewAction")

        return widget
예제 #28
0
    def get_display(my):
        if not my.search_type:
            return "No search type found"

        web = WebContainer.get_web()
        my.view = web.get_form_value("view")
        if not my.view:
            my.view = web.get_form_value("filter|view")
        if not my.view:
            my.view = get_template_view()

        widget = Widget()

        widget.add( HiddenWdg("search_type", my.search_type) )

        element_names = []

        # see if there is an override
        search_type_obj = SearchType.get(my.search_type)  
        config = WidgetConfigView.get_by_search_type(my.search_type,"browser_list")
        if config:
            element_names = config.get_element_names()


        search = Search("sthpw/widget_config")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", my.view)
        widget_config = search.get_sobject()
        if widget_config:
            edit_link_wdg = EditLinkWdg("sthpw/widget_config", widget_config.get_id(), text="Edit XML", long=True)
            edit_link_wdg.set_iframe_width(95)
            widget.add(edit_link_wdg)


        custom_config = WidgetConfigView.get_by_search_type(my.search_type,my.view)
        custom_element_names = custom_config.get_element_names()


        # get the custom properties
        search = Search("prod/custom_property")
        search.add_filter("search_type", my.search_type)
        custom_properties = search.get_sobjects()


        # action popup
        action_popup = PopupMenuWdg("table_action", multi=True, width='12em')
        action_popup.set_auto_hide(False)
        action_popup.set_submit(False)

        
        action_popup.add( HtmlElement.href("Add ...", "javascript:document.form.submit()") )


        for custom_property in custom_properties:
            element_name = custom_property.get_name()
            if element_name not in custom_element_names:
                action_popup.add( " %s" % element_name, "add|%s" % element_name )

        # if there is an override
        if element_names:
            for element_name in element_names:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )


        # get all of the columns
        else:
            search_type_obj = SearchType.get(my.search_type)
            element_names = search_type_obj.get_columns()

            for element_name in element_names:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )

            # add some standard properties
            if my.view in ["edit", "insert"]:
                for element_name in PREDEFINED_EDIT_ELEMENTS:
                    if element_name not in custom_element_names:
                        action_popup.add( " %s" % element_name, "add|%s" % element_name )
            else:
                for element_name in PREDEFINED_ELEMENTS:
                    if element_name not in custom_element_names:
                        action_popup.add( " %s" % element_name, "add|%s" % element_name )

        action_popup.add_separator()
        action_popup.add( HtmlElement.href("Remove ...", "javascript:document.form.submit()") )
        for element_name in custom_element_names:
            action_popup.add( " %s" % element_name, "remove|%s" % element_name )
        action_popup.add_separator()

        span = SpanWdg("New Custom ...", css="hand")
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        span.add_event("onclick", action)
        action_popup.add( span )


        # add the edit button
        edit = IconButtonWdg("Edit View", IconWdg.EDIT, True)

        edit.add_event("oncontextmenu", "%s;return false" % action_popup.get_on_script() )
        edit.add_event("onclick", "%s" % action_popup.get_on_script() )



        # lay it all out
        widget.add(SpanWdg(action_popup))
        widget.add(edit)

        # add the edit button
        #save = IconButtonWdg("Save", IconWdg.SAVE, True)
        #widget.add(save)

        # add the add property button
        if my.mode == "admin":
            add = CustomAddPropertyLinkWdg(my.search_type, my.view)
            widget.add(add)
            #add_element = CustomAddElementLinkWdg(my.search_type, my.view)
            #widget.add(add_element)


        # add the clear button
        if my.mode == "admin" or my.view.startswith("custom_"):
            clear = IconSubmitWdg("Clear", IconWdg.DELETE, True)
            widget.add(clear)

        
        widget.add(SpanWdg(css="small"))


        WebContainer.register_cmd("pyasm.widget.CustomViewAction")

        return widget
예제 #29
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
예제 #30
0
    def get_preview_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()

        csv_parser = CsvParser(my.file_path)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()



        ajax = AjaxCmd()
        ajax.set_option("search_type", my.search_type)
        ajax.set_option("file_path", my.file_path)
        ajax.add_element_name("has_title")

        event = WebContainer.get_event_container()
        caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
        div = ajax.generate_div()
        div.set_post_ajax_script(caller)
        widget.add(div)

        columns = []
        num_columns = len(csv_titles)
        ajax.set_option("num_columns", num_columns)
        for i in range(0, num_columns):
            column = web.get_form_value("column_%s" % i)
            if column:
                column = csv_titles[i]
            else:
                column = web.get_form_value("column_new_%s" % i)

            columns.append(column)

            ajax.add_element_name("column_%s" % i)
            ajax.add_element_name("new_column_%s" % i)


        ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
        import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
        import_button.add_event("onclick", ajax.get_on_script(show_progress=False))
        import_button.add_style("float: right")
        widget.add( import_button )


        preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
        preview_submit.add_style("float: right")
        widget.add(preview_submit)

        sobject_title = my.search_type_obj.get_title()
        widget.add("<p>4. Import</p>")
        widget.add(HtmlElement.br())
        widget.add("<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title)


        table = Table(css="table")
        table.add_style("width: 100%")

        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            table.add_header(title)

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            table.add_row()
            for j, cell in enumerate(row):
                table.add_cell(cell)

        widget.add(table)

        return widget