コード例 #1
0
ファイル: help_wdg.py プロジェクト: 2gDigitalPost/tactic_src
            else:
                link_rel_path = "%s" % (href)
 
            target = xml.get_attribute(node, "target")
            if target:
                target = xml.set_attribute(node, "href", "/doc/%s" % link_rel_path)
                continue

            # get a unique id for the node
            unique_id = my.top.generate_unique_id(base='replace')
            xml.set_attribute(node, "id", unique_id)

            div = SpanWdg()
            elements.append(div)
            div.add_class("spt_replace_element")
            div.add_attr("spt_replace_id", unique_id)
            div.add_class("hand")
            div.add_class("spt_link")
            div.add_color("background", "background")

            text = xml.get_node_value(node)
            div.add(text)
            div.add_behavior( {
                'type': 'click_up',
                'rel_path': link_rel_path,
                'cbjs_action': '''
                spt.help.set_top();
                spt.help.load_rel_path( bvr.rel_path );
                '''
            } )
コード例 #2
0
                link_rel_path = "%s" % (href)

            target = xml.get_attribute(node, "target")
            if target:
                target = xml.set_attribute(node, "href",
                                           "/doc/%s" % link_rel_path)
                continue

            # get a unique id for the node
            unique_id = my.top.generate_unique_id(base='replace')
            xml.set_attribute(node, "id", unique_id)

            div = SpanWdg()
            elements.append(div)
            div.add_class("spt_replace_element")
            div.add_attr("spt_replace_id", unique_id)
            div.add_class("hand")
            div.add_class("spt_link")
            div.add_color("background", "background")

            text = xml.get_node_value(node)
            div.add(text)
            div.add_behavior({
                'type':
                'click_up',
                'rel_path':
                link_rel_path,
                'cbjs_action':
                '''
                spt.help.set_top();
                spt.help.load_rel_path( bvr.rel_path );
コード例 #3
0
    def get_display(self):
        top = DivWdg()

        element_name = self.kwargs.get('element_name')

        config_view = self.kwargs.get("config_view")
        display_class = config_view.get_display_handler(element_name)
        display_options = config_view.get_display_options(element_name)
        element_attr = config_view.get_element_attributes(element_name)

        name = element_attr.get('name')
        edit = element_attr.get('edit')
        title = element_attr.get('title')
        width = element_attr.get('width')

        # add the name
        from pyasm.web import Table
        table = Table()
        top.add(table)

        table.add_row()
        td = table.add_cell("Name: ")
        td.add_style("padding: 5px")
        name_text = SpanWdg(name)
        name_text.add_style('font-weight: bold')
        name_text.add_attr("size", "50")
        table.add_cell(name_text)

        table.add_row_cell("<br/>Element Attributes:<br/>")

        # add the title
        table.add_row()
        td = table.add_cell("Title: ")
        td.add_style("padding: 5px")
        title_text = TextWdg("title")
        title_text.add_attr("size", "50")
        if title:
            title_text.set_value(title)
        table.add_cell(title_text)

        # add the width
        table.add_row()
        td = table.add_cell("Width: ")
        td.add_style("padding: 5px")
        width_text = TextWdg("width")
        if width:
            width_text.set_value(width)
        width_text.add_attr("size", "50")
        table.add_cell(width_text)

        # add the editable
        table.add_row()
        td = table.add_cell("Editable: ")
        td.add_style("padding: 5px")
        editable_text = CheckboxWdg("editable")
        editable_text.add_attr("size", "50")
        table.add_cell(editable_text)

        table.add_row_cell("<br/>Display:<br/>")

        # add the widget
        table.add_row()
        td = table.add_cell("Widget: ")
        td.add_style("padding: 5px")
        widget_select = SelectWdg("widget")
        options = ['Expression']
        widget_select.set_option("values", options)
        widget_select.add_empty_option("-- Select --")
        #widget_select.set_value(display_class)
        table.add_cell(widget_select)

        table.add_row_cell("&nbsp;&nbsp;&nbsp;&nbsp;- or -")

        # add the class
        table.add_row()
        td = table.add_cell("Class Name: ")
        td.add_style("padding: 5px")
        class_text = TextWdg("class_name")
        class_text.set_value(display_class)
        class_text.add_attr("size", "50")
        table.add_cell(class_text)

        # introspect the widget
        if not display_class:
            display_class = "pyasm.widget.SimpleTableElementWdg"
        #display_class = "tactic.ui.panel.ViewPanelWdg"

        from pyasm.common import Common
        import_stmt = Common.get_import_from_class_path(display_class)
        if import_stmt:
            exec(import_stmt)
        else:
            exec("from pyasm.widget import %s" % display_class)
        try:
            options = eval("%s.get_args_options()" % display_class)
        except AttributeError:
            try:
                info = eval("%s.get_args_keys()" % display_class)
            except AttributeError:
                return top

            options = []
            for key, description in info.items():
                option = {
                    'name': key,
                    'type': 'TextWdg',
                    'description': description
                }
                options.append(option)
        '''
        options = [
        {
            'name': 'expression',
            'type': 'TextWdg',
            'size': '50'
        },
        ]
        '''

        if options:
            top.add("<br/>Widget Options:<br/>")

        table = Table()
        top.add(table)

        for option in options:
            table.add_row()

            name = option.get('name')
            title = name
            type = option.get('type')

            td = table.add_cell("%s: " % title)
            td.add_style("padding: 5px")

            value = display_options.get(name)

            if type == 'SelectWdg':
                edit_wdg = SelectWdg("%s|value" % name)
                edit_wdg.add_style("width: 250px")
                edit_wdg.add_empty_option('-- Select --')
                values = option.get('values')
                edit_wdg.set_option('values', values)
                if value:
                    edit_wdg.set_value(value)
            elif type == 'TextAreaWdg':
                edit_wdg = TextAreaWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_attr("cols", "60")
                edit_wdg.add_attr("rows", "3")
            else:
                edit_wdg = TextWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_style("width: 250px")

            table.add_cell(edit_wdg)

        return top
コード例 #4
0
    def get_display(my):
        top = DivWdg()

        element_name = my.kwargs.get('element_name')

        config_view = my.kwargs.get("config_view")
        display_class = config_view.get_display_handler(element_name)
        display_options = config_view.get_display_options(element_name)
        element_attr = config_view.get_element_attributes(element_name)

        name = element_attr.get('name')
        edit = element_attr.get('edit')
        title = element_attr.get('title')
        width = element_attr.get('width')


        # add the name
        from pyasm.web import Table
        table = Table()
        top.add(table)

        table.add_row()
        td = table.add_cell("Name: ")
        td.add_style("padding: 5px")
        name_text = SpanWdg(name)
        name_text.add_style('font-weight: bold')
        name_text.add_attr("size", "50")
        table.add_cell(name_text)


        table.add_row_cell("<br/>Element Attributes:<br/>")

        # add the title
        table.add_row()
        td = table.add_cell("Title: ")
        td.add_style("padding: 5px")
        title_text = TextWdg("title")
        title_text.add_attr("size", "50")
        if title:
            title_text.set_value(title)
        table.add_cell(title_text)



        # add the width
        table.add_row()
        td = table.add_cell("Width: ")
        td.add_style("padding: 5px")
        width_text = TextWdg("width")
        if width:
            width_text.set_value(width)
        width_text.add_attr("size", "50")
        table.add_cell(width_text)

        # add the editable
        table.add_row()
        td = table.add_cell("Editable: ")
        td.add_style("padding: 5px")
        editable_text = CheckboxWdg("editable")
        editable_text.add_attr("size", "50")
        table.add_cell(editable_text)




        table.add_row_cell("<br/>Display:<br/>")

        # add the widget
        table.add_row()
        td = table.add_cell("Widget: ")
        td.add_style("padding: 5px")
        widget_select = SelectWdg("widget")
        options = ['Expression']
        widget_select.set_option("values", options)
        widget_select.add_empty_option("-- Select --")
        #widget_select.set_value(display_class)
        table.add_cell(widget_select)

        table.add_row_cell("&nbsp;&nbsp;&nbsp;&nbsp;- or -")

        # add the class
        table.add_row()
        td = table.add_cell("Class Name: ")
        td.add_style("padding: 5px")
        class_text = TextWdg("class_name")
        class_text.set_value(display_class)
        class_text.add_attr("size", "50")
        table.add_cell(class_text)


        # introspect the widget
        if not display_class:
            display_class = "pyasm.widget.SimpleTableElementWdg"
        #display_class = "tactic.ui.panel.ViewPanelWdg"

        from pyasm.common import Common
        import_stmt = Common.get_import_from_class_path(display_class)
        if import_stmt:
            exec(import_stmt)
        else:
            exec("from pyasm.widget import %s" % display_class)
        try:
            options = eval("%s.get_args_options()" % display_class)
        except AttributeError:
            try:
                info = eval("%s.get_args_keys()" % display_class)
            except AttributeError:
                return top
                
            options = []
            for key, description in info.items():
                option = {
                    'name': key,
                    'type': 'TextWdg',
                    'description': description
                }
                options.append(option)


        '''
        options = [
        {
            'name': 'expression',
            'type': 'TextWdg',
            'size': '50'
        },
        ]
        '''

        if options:
            top.add("<br/>Widget Options:<br/>")

        table = Table()
        top.add(table)

        for option in options:
            table.add_row()

            name = option.get('name') 
            title = name
            type = option.get('type')

            td = table.add_cell( "%s: " % title )
            td.add_style("padding: 5px")

            value = display_options.get(name)

            if type == 'SelectWdg':
                edit_wdg = SelectWdg("%s|value" % name)
                edit_wdg.add_style("width: 250px")
                edit_wdg.add_empty_option('-- Select --')
                values = option.get('values')
                edit_wdg.set_option('values', values)
                if value:
                    edit_wdg.set_value(value)
            elif type == 'TextAreaWdg':
                edit_wdg = TextAreaWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_attr("cols", "60")
                edit_wdg.add_attr("rows", "3")
            else:
                edit_wdg = TextWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_style("width: 250px")

            table.add_cell(edit_wdg)

        return top