예제 #1
0
    def get_display(my):
        sobject = my.get_current_sobject()
        title = sobject.get_value("title")
        widget = Widget()
        widget.add(sobject.get_description())

        if title == 'Debug':
            pop = PopupWdg("pref_help_%s" % title)
            hint = 'If set to [true], you can view the Debug Widget at the bottom left corner of your page.'
            icon_wdg = IconWdg(hint, IconWdg.HELP)
            widget.add(SpanWdg(icon_wdg, css='small'))

            widget.add(pop)

        elif title == 'Filter':
            pop = PopupWdg("pref_help_%s" % title)
            hint = 'If set to [multi], It generally applies to filters in the filter box for Artist Tab.'
            icon_wdg = IconWdg(hint, IconWdg.HELP)
            widget.add(SpanWdg(icon_wdg, css='small'))

            widget.add(pop)

        elif title == 'Quick Text':
            pop = PopupWdg("pref_help_%s" % title)
            hint = 'A list of | separated phrases a user can pick from to enter into the note area of Note Sheet.'
            icon_wdg = IconWdg(hint, IconWdg.HELP)
            widget.add(SpanWdg(icon_wdg, css='small'))

            widget.add(pop)

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

        mode = my.get_option('mode')
        if not mode:
            mode = 'sandbox'

        widget = Widget()
        sobject_dir = ''
        sobject_lib_dir = ''
        # find the path to open explorer
        if sobject.is_insert():
            button = IconWdg("No Path Found", IconWdg.CROSS, long=False)
        else:
            try:
                if mode == 'sandbox':
                    sobject_dir = my.get_base_dir(sobject)
                elif mode in ['client_repo', 'repository']:
                    sobject_dir = my.get_client_repo_dir(sobject)
                    sobject_lib_dir = my.get_lib_dir(sobject)
                sobject_dir = sobject_dir.strip()
                sobject_dir = Common.process_unicode_string(sobject_dir)
            except TacticException, e:
                print "WARNING: ", str(e)
                button = IconWdg("No Path Found", IconWdg.CROSS, long=False)
            else:
예제 #3
0
    def get_tool_bar(my):
        widget = Widget()
        trash_div = SpanWdg()
        trash_div.set_id('trash_me')

        trash_div.add(IconWdg('Trash', IconWdg.TRASH))
        trash_div.add("TRASH!")
        trash_div.add_class("hand")
        trash_div.add_class("spt_side_bar_trash")

        trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
        bvr = { "type": "click_up",\
                'cbjs_action': "alert('Drag and drop element name here to remove it.')"}
        trash_div.add_behavior(bvr)

        widget.add(trash_div)

        save_div = SpanWdg(css='med hand spt_side_bar_trash')
        save_div.add(IconWdg('Save', IconWdg.SAVE))

        bvr = { "type": "click_up",\
                'cbjs_action': "spt.custom_project.manage_action_cbk({'value':'save'},'%s');" % my.view}
        save_div.add_behavior(bvr)
        widget.add(save_div)
        return widget
예제 #4
0
    def get_tool_bar(my):
        widget = Widget()
        trash_div = SpanWdg()
        # reset some global variables on load
        trash_div.add_behavior({
            'type':
            'load',
            'cbjs_action':
            'spt.side_bar.trashed_items=[]; spt.side_bar.changed_views={}'
        })

        trash_div.set_id('trash_me')

        trash_div.add(IconWdg('Trash', IconWdg.TRASH))
        trash_div.add("TRASH!")
        trash_div.add_class("hand")
        trash_div.add_class("spt_side_bar_trash")

        trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
        bvr = { "type": "click_up",\
                'cbjs_action': "alert('Drag and drop link or folder here to remove it.')"}
        trash_div.add_behavior(bvr)

        widget.add(trash_div)

        save_div = SpanWdg(css='med hand spt_side_bar_trash')
        save_div.add(IconWdg('Save Ordering', IconWdg.SAVE))

        # FIXME: is_personal???
        is_personal = 'false'
        bvr = { "type": "click_up",\
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({'value':'save'},'%s',%s);" % (my.view, is_personal)}
        save_div.add_behavior(bvr)
        widget.add(save_div)
        return widget
예제 #5
0
    def get_local_wdg(my):

        div = DivWdg()

        server = Config.get_value("install", "server")
        if not server:

            msg_div = DivWdg()
            msg_div.add(IconWdg("No local prefix set", IconWdg.WARNING))
            msg_div.add(
                "WARNING: No local server prefix set.  This will allow transactions to be merged properly with remote servers.  Without a local prefix, it is highly likely that transactions will conflict"
            )

            msg_div.add("<br/>" * 2)

            text = TextWdg("local_prefix")
            change_div = DivWdg()
            msg_div.add(change_div)
            change_div.add("Set Local Prefix: ")
            change_div.add(text)

        else:
            msg_div = DivWdg()
            msg_div.add(IconWdg("No local prefix set", IconWdg.CREATE))
            msg_div.add("Local server set to [%s]" % server)

        msg_div.add_style("padding: 30px")
        msg_div.add_style("width: 80%")
        msg_div.add_color("background", "background3")
        msg_div.add_border()
        msg_div.add_style("text-align: center")

        div.add(msg_div)

        return div
예제 #6
0
    def _get_swap_wdg(self, event_id=''):
        swap_wdg = SwapDisplayWdg(on_event_name='on_%s' % event_id,
                                  off_event_name='off_%s' % event_id)
        icon1 = IconWdg('open', IconWdg.INFO_CLOSED_SMALL)
        icon2 = IconWdg('close', IconWdg.INFO_OPEN_SMALL)
        swap_wdg.set_display_widgets(icon1, icon2)

        return swap_wdg
예제 #7
0
 def set_default_wdg(self):
     theme = DivWdg().get_theme()
     if theme == "default":
         self.on_wdg = IconWdg('open', IconWdg.ARROWHEAD_DARK_DOWN)
         self.off_wdg = IconWdg('closed', IconWdg.ARROWHEAD_DARK_RIGHT)
     else:
         self.on_wdg = IconWdg('open', IconWdg.INFO_OPEN_SMALL)
         self.off_wdg = IconWdg('closed', IconWdg.INFO_CLOSED_SMALL)
예제 #8
0
    def get_header_wdg(my):
        div = DivWdg()

        div.add("<hr/>")

        dots_div = DivWdg()
        dots_div.add_style("margin-top: -12px")
        div.add(dots_div)

        left = 50
        width = 60
        for i, widget in enumerate(my.widgets):
            on_dot = IconWdg("", IconWdg.DOT_GREEN)
            on_dot.add_class("spt_wizard_on_dot")
            off_dot = IconWdg("", IconWdg.DOT_GREY)
            off_dot.add_class("spt_wizard_off_dot")
            if i == 0:
                off_dot.add_style("display: none")
            else:
                on_dot.add_style("display: none")

            dot_div = DivWdg()
            dots_div.add(dot_div)
            dot_div.add(on_dot)
            dot_div.add(off_dot)
            dot_div.add_style("width: %spx" % width)
            dot_div.add_style("float: left")
            dot_div.add_style("margin-left: %spx" % left)
            dot_div.add_style("text-align: center")

            if (i + 1) < len(my.widgets):
                arrow_div = DivWdg()
                dots_div.add(arrow_div)
                arrow_div.add_style("float: left")
                arrow_div.add_style("position: absolute")
                arrow_div.add_style("margin-left: %spx" % ((width + left) *
                                                           (i + 1.2)))
                arrow_div.add_style("margin-top: -3px")
                arrow_div.add_style("text-align: center")
                icon = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT)
                arrow_div.add(icon)

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

        for widget in my.widgets:
            name_div = DivWdg()
            div.add(name_div)
            name_div.add_style("float: left")
            name_div.add_style("margin-left: %spx" % left)
            name = widget.get_name()
            name_div.add(name)
            name_div.add_style("width: %spx" % width)
            name_div.add_style("text-align: center")

        div.add("<br clear='all'/>")
        return div
예제 #9
0
    def get_display(my):
        sobject = my.get_current_sobject()
        expression = my.get_option("expression")

        parser = ExpressionParser()
        value = parser.eval(expression, sobject)

        div = DivWdg()
        div.add_style("text-align: center")
        if value == False:
            div.add(IconWdg("XXX", IconWdg.DOT_GREEN))
        else:
            div.add(IconWdg("YYY", IconWdg.DOT_RED))

        return div
예제 #10
0
    def get_license_info_wdg(my):
        div = DivWdg()

        license = Environment.get_security().get_license()
        if my.first_error:
            return div
        #if not license.is_licensed():
        #    return div

        msg = DivWdg()
        div.add(msg)
        msg.add("The following describes the details of the installed license:<br/><br/>")


        info_wdg = DivWdg()
        div.add(info_wdg)
        info_wdg.add_style("margin: 10px 30px")
        info_wdg.add_style("font-size: 12px")

        version = license.get_data("tactic_version")
        if version:
            info_wdg.add("TACTIC Version: ")
            if version == "ALL":
                version = "ALL (Open Source)"
            info_wdg.add(version)
            info_wdg.add(HtmlElement.br(2))


        company = license.get_data("company")
        info_wdg.add("Licensed To: ")
        if company.find("Southpaw EPL") != -1:
            company = SpanWdg("<a name='license'>Eclipse Public License v1.0</a> &nbsp;")
            icon = IconWdg("EPL v1.0", IconWdg.ZOOM)
            company.add(icon)
            company.add_class("hand")
            company.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                    spt.help.load_alias("license")
                '''
            } )
        info_wdg.add(company)
        info_wdg.add(HtmlElement.br(2))

        info_wdg.add("Max Users: ")
        info_wdg.add(license.get_data("max_users") )
        info_wdg.add(HtmlElement.br(2))

        info_wdg.add("Current Users: ")
        info_wdg.add(license.get_current_users() )
        info_wdg.add(HtmlElement.br(2))

        info_wdg.add("Expiry Date: ")
        expiry_date = license.get_data("expiry_date")
        if not expiry_date:
            expiry_date = "Permanent"
        info_wdg.add(expiry_date)
        info_wdg.add(HtmlElement.br(2))

        return div
예제 #11
0
    def add_resize_row(my):
        tr, td = my.table.add_row_cell()
        td.add_style("height: 3px")
        td.add_style("min-height: 3px")
        td.add_style("cursor: n-resize")

        tr.add_behavior({
            'type': 'drag',
            'cb_set_prefix': 'spt.resizable_table.row_drag'
        })

        tr.add_behavior({
            'type':
            'hover',
            'hilight':
            my.hilight,
            'cbjs_action_over':
            '''
        var color = bvr.src_el.getStyle("background-color");
        bvr.src_el.setStyle("background-color", bvr.hilight);
        bvr.src_el.setAttribute("spt_last_background", color);
        ''',
            'cbjs_action_out':
            '''
        var color = bvr.src_el.getAttribute("spt_last_background");
        bvr.src_el.setStyle("background-color", color);
        '''
        })
        icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL)
        td.add(icon)

        return tr, td
예제 #12
0
    def get_display(my):

        widget = Widget()

        project = my.get_current_sobject()

        table = Table()
        widget.add(table)
        table.add_style("width: 140px")

        table.add_row()
        table.add_cell("Exists: ")
        table.add_cell("&nbsp;")

        try:
            exists = project.database_exists()
        except:
            #print "Error checking if database exists for project [%s]" % project.get_code()
            exists = False

        if exists:
            table.add_cell(IconWdg("database", IconWdg.DOT_GREEN))
        else:
            table.add_cell(IconWdg("database", IconWdg.DOT_RED))

        table.add_row()
        table.add_cell("Version: ")
        last_version_update = project.get_value("last_version_update")
        table.add_cell(last_version_update)
        if last_version_update >= my.version:
            table.add_cell(IconWdg("database", IconWdg.DOT_GREEN))
        else:
            table.add_cell(IconWdg("database", IconWdg.DOT_RED))

        widget.add("<br/>")
        """
        widget.add("Schema: ")
        widget.add("<br/>")

        widget.add("Context: ")
        widget.add("<br/>")

        widget.add("Data: ")
        widget.add("<br/>")
        """

        return widget
예제 #13
0
    def add_cell(my, widget=None, resize=True, rowspan=1, colspan=1):
        td_content = my.table.add_cell()
        td_content.add_style("vertical-align: top")

        if rowspan > 1:
            td_content.add_attr("rowspan", rowspan + 1)
        if colspan > 1:
            td_content.add_attr("colspan", colspan + 1)

        if not resize:
            return td_content

        # add resize cell
        td = my.table.add_cell()
        td.add_style("width: 4px")
        td.add_style("min-width: 4px")
        td.add_style("cursor: e-resize")

        icon_div = DivWdg()
        icon_div.add_style("width: 4px")
        icon_div.add_style("overflow: hidden")
        icon = IconWdg("Drag to Resize", IconWdg.RESIZE_HORIZ)
        icon_div.add(icon)
        td.add(icon_div)

        td.add_style("vertical-align: middle")

        td.add_behavior({
            'type': 'drag',
            'cb_set_prefix': 'spt.resizable_table.cell_drag'
        })

        td.add_behavior({
            'type':
            'hover',
            'hilight':
            my.hilight,
            'cbjs_action_over':
            '''
        var color = bvr.src_el.getStyle("background-color");
        bvr.src_el.setStyle("background-color", bvr.hilight);
        bvr.src_el.setAttribute("spt_last_background", color);
        ''',
            'cbjs_action_out':
            '''
        var color = bvr.src_el.getAttribute("spt_last_background");
        bvr.src_el.setStyle("background-color", color);
        '''
        })

        if rowspan > 1:
            td.add_attr("rowspan", rowspan + 1)
        if colspan > 1:
            td.add_attr("colspan", colspan + 1)

        if widget:
            td_content.add(widget)

        return td_content
예제 #14
0
    def get_link_wdg(self, element_name, config, options):
        attributes = config.get_element_attributes(element_name)
        title = self._get_title(config, element_name)

        default_access = "view"
        path = options.get('path')
        security = Environment.get_security()
        if not security.check_access(
                "side_bar", element_name, "view", default=default_access):
            return

        # backwards compatibility??
        #if not security.check_access("url", path, "view"):
        #    return

        link_wdg = DivWdg(css="hand")
        link_wdg.add_style("padding-top: 4px")

        link_wdg.add_attr("spt_title", title)
        link_wdg.add_attr("spt_icon", attributes.get("icon"))
        link_wdg.add_class("spt_side_bar_link")
        link_wdg.add_attr("spt_view", config.get_view())
        link_wdg.add_attr("spt_element_name", element_name)
        link_wdg.add_attr("spt_path", options['path'])

        # add the mouseover color change
        link_wdg.add_style("color: #292929")
        link_wdg.add_class("SPT_DTS")
        hover = link_wdg.get_color("background3", -10)
        link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover)
        link_wdg.add_event("onmouseout", "this.style.background=''")
        link_wdg.add_class("spt_side_bar_element")

        link_wdg.add_looks("fnt_text")

        link_wdg.add_attr("spt_view", config.get_view())

        # add an invisible drop widget
        drop_wdg = self.get_drop_wdg()
        drop_wdg.add_style("margin-top: -3px")
        link_wdg.add(drop_wdg)

        span = SpanWdg()
        span.add_class("spt_side_bar_title")

        # add an icon
        icon = attributes.get("icon")
        if icon:
            icon = icon.upper()
            from pyasm.widget import IconWdg
            try:
                span.add(IconWdg(title, eval("IconWdg.%s" % icon)))
            except:
                pass

        span.add(title)
        link_wdg.add(span)

        return link_wdg
예제 #15
0
    def get_display(my):
        my.display_expr = my.kwargs.get('display_expr')
        my.values = []

        instance_type = my.get_option("instance_type")
        accepted_type = my.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("height: 100%")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")

        my.value_wdg = HiddenWdg(my.get_name())
        my.value_wdg.add_class("spt_drop_element_value")
        div.add(my.value_wdg)

        version = my.parent_wdg.get_layout_version()
        if version != "2":
            my.add_drop_behavior(div, accepted_type)

        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = my.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        #template_item.add_style('float: left')
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left', '3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(" - ")
        template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)

        # list out the relationships
        #sobject = my.get_current_sobject()
        #search_type = sobject.get_base_search_type()

        content_div = DivWdg()
        div.add(content_div)
        # shrink wrapping for FF
        content_div.add_style('float: left')
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = my.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)

        return div
예제 #16
0
    def get_item_div(my, sobject):
        ''' get the item div the sobject'''
        top = DivWdg()
        top.add_style("padding: 3px 2px")
        top.add_class("spt_drop_item")
        top.add_class("SPT_DROP_ITEM")

        item_div = DivWdg()
        top.add(item_div, "item_div")
        item_div.add_style("text-overflow: ellipsis")
        item_div.add_style("white-space: nowrap")
        item_div.add_style("width: 80%")
        item_div.add_attr('title', 'Click to remove')
        item_div.add_style("display", "inline-block")
        item_div.add_style("vertical-align", "top")
        item_div.add_style("overflow", "hidden")

        icon_div = DivWdg()
        top.add(icon_div)
        icon = IconWdg(icon="BS_REMOVE")
        icon_div.add(icon)
        icon_div.add_behavior({
            'type':
            'click_up',
            #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)'''
            'cbjs_action':
            '''spt.drop.sobject_drop_remove(evt,bvr)'''
        })
        icon.add_style("opacity: 0.3")
        icon_div.add_class("hand")
        icon_div.add_style("display", "inline-block")
        icon_div.add_style("vertical-align", "top")
        #icon_div.add_border()

        #my.menu.set_over(item_div, event="mousein")
        #my.menu.set_out(top, event="mouseleave")

        # set this as the place for the display value to go
        item_div.add_class("spt_drop_display_value")

        add_icon = True
        ExpressionParser.clear_cache()
        if sobject:
            if add_icon:
                my._add_icon(sobject, item_div)

            if my.display_expr:
                display_value = Search.eval(my.display_expr,
                                            sobjects=sobject,
                                            single=True)
            else:
                display_value = sobject.get_display_value()
            if isinstance(display_value, list):
                display_value = display_value[0]
            item_div.add(display_value)
            my.values.append(SearchKey.get_by_sobject(sobject))
        return top
예제 #17
0
    def get_display(self):

        widget = DivWdg()
        widget.add_style("text-align: center")

        search_type = self.get_current_sobject()

        project_code = search_type.get_value("database")
        if project_code == "{project}":
            # HACK: assumes database == project_code.  Can't seem to get
            # around the {project} variable ... need to look at this
            # sometime
            project = Project.get()
        else:
            project = Project.get_by_code(project_code)

        if not project:
            widget.add(IconWdg("Exists", IconWdg.ERROR))
            widget.add("Project does not exist")
            return widget

        table = search_type.get_table()

        if not table:
            return ""

        try:
            db_resource = project.get_project_db_resource()
            sql = DbContainer.get(db_resource)
            tables = sql.get_tables()
            has_table = table in tables
        except DatabaseException:
            has_table = False

        if has_table:
            widget.add(IconWdg("Exists", IconWdg.DOT_GREEN))
        else:
            widget.add(IconWdg("Does not Exist", IconWdg.DOT_RED))

        return widget
예제 #18
0
    def get_display(self):
        self.display_expr = self.kwargs.get('display_expr')
        self.values = []

        instance_type = self.get_option("instance_type")
        accepted_type = self.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("min-height: 70px")
        div.add_style("height: auto")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")
        div.add_style("overflow-x: hidden")

        self.value_wdg = HiddenWdg(self.get_name())
        self.value_wdg.add_class("spt_drop_element_value")
        div.add(self.value_wdg)

        version = self.parent_wdg.get_layout_version()
        #if version != "2":
        self.add_drop_behavior(div, accepted_type)

        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = self.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        #item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left', '3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)

        content_div = DivWdg()
        div.add(content_div)
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = self.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)

        return div
예제 #19
0
    def handle_unknown_instance(my, table, instance):
        '''handle unassigned or non-tactic nodes'''

        table.add_row()
        table.add_blank_cell()
        icon = IconWdg("unknown", icon=IconWdg.UNKNOWN)
        table.add_cell(icon)

        info_wdg = Widget()
        info_wdg.add("<b>%s</b>" % instance)
        table.add_cell(info_wdg)
        table.add_blank_cell()
        table.add_blank_cell()
예제 #20
0
    def get_display(self):
        snapshot = self.get_current_sobject()
        key = self.get_key(snapshot)
        is_locked = self.is_locked_dict.get(key)

        div = DivWdg()
        div.add_style("padding: 3px")

        if is_locked:
            icon = IconWdg("Locked by ''", IconWdg.LOCK)
            div.add(icon)
            div.add_style("text-align: center")
        else:
            div.add("&nbsp;")

        return div
예제 #21
0
    def get_display(self):

        sobject = self.get_current_sobject()

        value = sobject.get_value(self.get_name())
        if value.startswith("{") and value.endswith("}"):
            value = Search.eval(value)

        if value.startswith("/"):
            new_window = 'false'
        else:
            new_window = 'true'

        top = DivWdg()
        top.add_class("hand")
        top.add_style("width: 0%")

        if value:
            top.add_behavior({
                'type':
                'click_up',
                'link':
                value,
                'new_window':
                new_window,
                'cbjs_action':
                '''
            if (bvr.new_window == 'false') {
                document.location = bvr.link;
            }
            else{
                var new_window = window.open(bvr.link, '_blank');
                new_window.focus();
            }
            '''
            })

            icon = self.get_option("icon")
            if not icon:
                icon = 'jump'

            from pyasm.widget import IconWdg
            icon = icon.upper()
            icon = IconWdg(value, eval("IconWdg.%s" % icon))
            top.add(icon)

        return top
예제 #22
0
    def get_display(my):
        alias = my.kwargs.get("alias")

        div = DivWdg()
        div.add_style("padding: 15px")
        div.add_style("margin: 10px")
        div.add_border()
        div.add_color("background", "background", -5)
        div.add_style("text-align: center")
        div.add_style("font-weight: bold")

        icon = IconWdg("WARNING", IconWdg.HELP_MISSING)
        div.add(icon)
        div.add("Add custom documentation page by clicking the Create button")

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title="Create",
                                 tip="Create docs for this view")
        div.add(button)
        button.add_style("margin-right: auto")
        button.add_style("margin-left: auto")
        button.add_style("margin-top: 15px")
        button.add_style("margin-bottom: 15px")
        # FIXME: copied code from above
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.app.HelpEditWdg';

        var element_name = spt.help.get_view();
        if (!element_name) {
          element_name = "default";
        }
        var kwargs = {
          view: element_name
        }

        spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
            
        '''
        })
        return div
예제 #23
0
    def add_row(my, resize=True):

        # add resize row
        if not my.is_first_row and resize == True:
            tr, td = my.table.add_row_cell()
            td.add_style("height: 3px")
            td.add_style("min-height: 3px")
            td.add_style("cursor: n-resize")

            tr.add_behavior({
                'type': 'drag',
                'cb_set_prefix': 'spt.resizable_table.row_drag'
            })

            tr.add_behavior({
                'type':
                'hover',
                'hilight':
                my.hilight,
                'cbjs_action_over':
                '''
            var color = bvr.src_el.getStyle("background-color");
            bvr.src_el.setStyle("background-color", bvr.hilight);
            bvr.src_el.setAttribute("spt_last_background", color);
            ''',
                'cbjs_action_out':
                '''
            var color = bvr.src_el.getAttribute("spt_last_background");
            bvr.src_el.setStyle("background-color", color);
            '''
            })

            icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL)
            td.add(icon)
            td.add_style("text-align: center")

        content_tr = my.table.add_row()

        my.is_first_row = False

        return content_tr
예제 #24
0
    def get_display(self):

        msg = self.kwargs.get("message")

        arrow_div = DivWdg()
        icon = IconWdg(msg, IconWdg.ARROW_UP_LEFT_32)
        icon.add_style("margin-top: -20")
        icon.add_style("margin-left: -15")
        icon.add_style("position: absolute")
        arrow_div.add(icon)
        arrow_div.add("&nbsp;" * 5)
        arrow_div.add("<b>%s</b>" % msg)
        arrow_div.add_style("position: relative")
        arrow_div.add_style("margin-top: 5px")
        arrow_div.add_style("margin-left: 20px")
        arrow_div.add_style("float: left")
        arrow_div.add_style("padding: 25px")
        arrow_div.set_box_shadow("1px 1px 2px 2px")
        arrow_div.set_round_corners(30)
        arrow_div.add_color("background", "background")
        return arrow_div
예제 #25
0
    def get_display(self):

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add(HtmlElement.br(7))

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

        div.add(table)

        error_div = DivWdg()
        error_div.add_class("maq_search_bar")
        error_div.add_style("font-size: 1.5em")
        error_div.add_style("padding: 5px")
        error_div.add_style("margin: 0 5px 0 5px")
        error_div.add_style("text-align: center")
        icon = IconWdg("Database Error", IconWdg.ERROR)
        error_div.add(icon)
        error_div.add("Databsae Error")
        table.add_cell(error_div)

        error = self.get_error()
        table.add_row()
        td = table.add_cell("<b>%s</b>" % error)
        td.add_style("padding: 5px 20px 5px 20px")
        table.add_row()
        td = table.add_cell(
            "<b>Please contact your Admistrator. In the meantime, you can login with 'admin'</b>"
        )
        td.add_style("padding: 5px 20px 5px 20px")
        table.add_row()
        table.add_row()
        OK = ProdIconSubmitWdg('Return to Login')

        return div
예제 #26
0
    def get_display(self):

        menu_div = DivWdg()
        menu_div.set_attr("id", self.menu_id)
        menu_div.add_class("SPT_CTX_MENU")
        menu_div.add_class(
            "SPT_PUW"
        )  # make it a Page Utility Widget (now processed client side)

        menu_div.set_z_start(300)
        menu_div.add_looks("menu border curs_default")

        m_width = self.width - 2
        menu_div.add_style(("width: %spx" % m_width))

        menu_table = Table()
        menu_table.add_styles(
            "text-align: left; text-indent: 3px; border-collapse: collapse;")

        options = self.opt_spec_list
        for opt in options:

            tbody = menu_table.add_tbody()
            tbody.add_style("display", "table-row-group")

            tr = menu_table.add_row()
            tr.add_looks("menu")
            tr.add_class("SPT_CTX_MENU_%s" % opt['type'].upper())
            disabled = False

            if opt.has_key('disabled') and opt['disabled']:
                disabled = True

            if not disabled:
                if opt['type'] in ['action', 'toggle']:
                    tr.add_behavior({
                        'type': 'hover',
                        'cbfn_over': 'spt.ctx_menu.entry_over',
                        'cbfn_out': 'spt.ctx_menu.entry_out',
                        'hover_class': 'look_menu_hover'
                    })

                if opt['type'] == 'action':
                    if opt.has_key('bvr_cb') and type(opt['bvr_cb']) == dict:
                        bvr = opt['bvr_cb']
                        bvr['cbjs_preaction'] = 'spt.ctx_menu.clear();'
                        # bvr['cbfn_preaction'] = 'spt.ctx_menu.clear'
                        bvr.update({'type': 'click', 'mouse_btn': 'LMB'})
                        tr.add_behavior(bvr)

                if opt['type'] == 'submenu':
                    bvr = {
                        'type': 'hover',
                        'cbfn_over': 'spt.ctx_menu.submenu_entry_over',
                        'cbfn_out': 'spt.ctx_menu.submenu_entry_out',
                        'hover_class': 'look_menu_hover',
                        'options': {
                            'menu_id': opt['submenu_id']
                        }
                    }
                    tr.add_behavior(bvr)
                    # now trap click on submenu, so that it doesn't make the current menu disappear ...
                    tr.add_behavior({
                        'type': 'click',
                        'cbjs_action': ';',
                        'activator_type': 'ctx_menu'
                    })

            tr.add_looks("curs_default")

            icon_width = 16
            icon_col_width = 0

            # Left icon cell ...
            if self.allow_icons:
                td = menu_table.add_cell()
                icon_col_width = icon_width + 2
                td.add_styles(
                    "text-align: center; vertical-align: middle; width: %spx;"
                    % icon_col_width)
                td.add_looks("menu_icon_column")

                if opt.has_key('icon'):
                    icon_wdg = IconWdg("", opt['icon'])
                    td.add(icon_wdg)
                    if disabled:
                        icon_wdg.add_style("opacity: .4")
                        icon_wdg.add_style("filter: alpha(opacity=40)")

            # Menu option label cell ...
            td = menu_table.add_cell()
            w = m_width - icon_col_width - icon_width
            td.add_style("width", ("%spx" % w))
            td.add_style("height", ("%spx" % icon_col_width))
            td.add_style("padding-left: 4px")
            td.add_style("padding-top: 2px")
            td.add_style("cursor: default")

            label_str = ''
            if opt.has_key('label'):
                label_str = opt.get('label')
            elif opt.get('type') == 'separator':
                label_str = '<HR>'

            td.add_looks("fnt_text")
            if opt.get('type') == 'title':
                td.add_looks("fnt_bold")

            td.add(label_str)

            if disabled:
                td.add_style("opacity: .2")
                td.add_style("filter: alpha(opacity=20)")

            # Submenu arrow icon cell ...
            td = menu_table.add_cell()
            td.add_style("width", ("%spx" % icon_width))

            if opt['type'] == 'submenu':
                icon_wdg = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT)
                td.add(icon_wdg)

            if disabled:
                td.add_style("opacity: .4")
                td.add_style("filter: alpha(opacity=40)")

        menu_div.add(menu_table)
        menu_div.add_style("display: none")
        menu_div.add_style("position: absolute")
        return menu_div
예제 #27
0
    def get_title_wdg(my):

        title = my.kwargs.get("title")
        if not title:
            widget = my.get_widget("title")
            if not widget and my.widgets:
                widget = my.widgets[0]
                title = widget.get_name().title()
        if not title:
            title = "No Title"

        icon = my.kwargs.get("icon")
        if not icon:
            icon = "G_FOLDER"

        title_div = DivWdg()
        title_div.add_class("spt_content_box_title")

        # icon on the left
        icon_div = DivWdg()
        title_div.add(icon_div)
        icon = IconWdg(icon=icon, width=16)
        icon_div.add(icon)
        icon_div.add_styles(
            '''float: left; height: 25px; margin-top: 0px; padding: 0px 8px 0px 5px;'''
        )

        # icon on the right
        show_gear = my.kwargs.get("show_gear")
        if show_gear in [True, 'true']:
            icon_div = DivWdg()
            title_div.add(icon_div)
            icon = IconWdg(icon="G_SETTINGS", width=16)
            icon_div.add(icon)
            icon_div.add_styles(
                '''float: right; height: 25px; margin-top: 0px; padding: 0px 8px 0px 5px;'''
            )

        icon_div = DivWdg()
        title_div.add(icon_div)
        icon = IconButtonWdg(icon="G_UP", width=16)
        icon_div.add(icon)
        icon_div.add_styles(
            '''float: right; height: 25px; margin-top: 0px; padding: 0px 8px;'''
        )
        icon_div.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_content_box");
            var content = top.getElement(".spt_content_box_content");
            var inner = top.getElement(".spt_content_box_inner");
            var state = inner.getAttribute("spt_state");
            if ( state != "closed" ) {
                var size = inner.getSize();
                dst = -size.y-5;
                inner.setAttribute("spt_state", "open");
            }
            else {
                dst = 0;
                inner.setAttribute("spt_state", "closed");
            }
            new Fx.Tween(content, {duration: 500}).start("margin-top", dst);


            '''
        })

        icon_div = DivWdg()
        title_div.add(icon_div)
        icon = IconButtonWdg(icon="G_MAXIMIZE", width=16)
        icon_div.add(icon)
        icon_div.add_styles(
            '''float: right; height: 25px; margin-top: 0px; padding: 0px 0px;'''
        )

        icon_div.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_content_box");
            if (top.hasClass("spt_content_box_max")) {
                top.removeClass("spt_content_box_max");
                top.addClass("spt_content_box_inline");
                top.size = top.getSize();
                var window_size = window.getSize();
                top.setStyle("height", window_size.y)


            }
            else {
                top.addClass("spt_content_box_max");
                top.removeClass("spt_content_box_inline");
                var size = top.size;
                top.setStyle("height", size.y)
            }
            '''
        })

        #title_div.add('''<div style="float: right; width: 20px; height: 20px; margin-top: -9px; margin-right: -8px; padding: 8px; border: solid 0px #000;">X</div>''')

        title_div.add(title)

        return title_div
예제 #28
0
    def get_display(my):
        value = my.get_value()
        name = my.get_name()

        type = my.get_option("type")
        if not type:
            type = my.get_type()

        # FIXME: this needs to be handled outside of this class to centralize
        # the type of an element!!!
        if type in ["timestamp"]:
            # make a guess here
            if name.endswith('time'):
                type = 'time'
            elif name.endswith('date'):
                type = 'date'

        if type == "text":
            wiki = WikiUtil()
            display = wiki.convert(value)

        elif type in ["time"]:
            if value:
                display = Date(value).get_display_time()
            else:
                display = ''

        elif type in ["datetime"]:
            if value:
                display = Date(value).get_display_datetime()
            else:
                display = ''

        elif type in ["timestamp", 'date']:
            if value == '{now}':
                display = Date()
            elif value:
                display = Date(value).get_display_date()
            else:
                display = ''
        elif type == "timecode":
            display = "00:00:00:00"
        elif type == "currency":
            display = "$%s" % value

        elif type == "color":
            display = DivWdg()

            color = DivWdg("&nbsp")
            color.add_style("height: 15px")
            color.add_style("width: 15px")
            color.add_style("float: left")
            color.add_style("margin: 0 5px 0 5px")
            color.add_style("background: %s" % value)
            display.add(color)

            display.add(value)

            display.add_style("width: 100%")
            display.add_style("height: 100%")

        elif type == "boolean":
            display = DivWdg()
            display.add_style("text-align: center")
            display.add_style("width: 100%")
            display.add_style("height: 100%")
            if value == True:
                from pyasm.widget import IconWdg
                icon = IconWdg("True", IconWdg.CHECK)
                display.add(icon)
            elif value == False:
                from pyasm.widget import IconWdg
                icon = IconWdg("False", IconWdg.INVALID)
                display.add(icon)
            else:
                display.add("&nbsp;")
        else:
            if not isinstance(value, basestring):
                display = DivWdg()
                display.add_style("float: right")
                display.add_style("padding-right: 3px")
                display.add(str(value))
            else:
                display = value

        return display
예제 #29
0
파일: main_wdg.py 프로젝트: zieglerm/TACTIC
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.named_events.fire_event("side_bar|hide_now", {} );
            '''
        })

        project = Project.get()
        title = DivWdg()
        title.add("Project Startup and Configuration")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin",
                                              "view_side_bar",
                                              "allow",
                                              default='allow')
        if view_side_bar:
            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            shelf.add_attr("title", "Toggle Side Bar (or press '1')")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        search_wdg = Table()
        top.add(search_wdg)
        search_wdg.add_row()

        search_wdg.add_class("spt_main_top")
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 20px auto")
        search_wdg.add_style("width: 430px")

        td = search_wdg.add_cell("Search: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 8px")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'result_list',
                    'keywords': keywords,
                    'simple_search_view': 'simple_filter',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search",
                                     custom_cbk=custom_cbk,
                                     width='280',
                                     height='42px')
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")

        search_wdg.add_cell(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        icon_div = DivWdg()
        td = search_wdg.add_cell(icon_div)
        td.add_style("vertical-align: top")
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 7px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'result_list',
                'keywords': keywords,
                'simple_search_view': 'simple_filter',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        #security = Environment.get_security()
        #if not security.check_access("builtin", "view_site_admin", "allow"):

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Configuration"
        #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.'''
        description = '''Configure a Project from start to finish.'''
        image = "<img src='/context/icons/64x64/configuration_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.ProjectConfigWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs);
            '''
        }
        config_wdg = self.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(config_wdg)

        # Manage Users
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Users and Security"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        image = DivWdg()
        image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>"
        image.add(image_link)

        image1 = IconWdg("Manage Users", IconWdg.USER_32)
        image2 = IconWdg("Manage Users", IconWdg.USER_32)
        image3 = IconWdg("Manage Users", IconWdg.USER_32)
        image4 = IconWdg("Manage Users", IconWdg.USER_32)
        image.add(image1)
        image.add(image2)
        image.add("<br/>")
        image.add(image3)
        image.add(image4)
        description = '''Manage users that can access the system'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.UserConfigWdg';
        var kwargs = {
            help_alias: 'project-startup-manage-users'
            };
        spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs);
        '''
        }
        manage_users_wdg = self.get_main_section_wdg(title, description, image,
                                                     behavior)
        td.add(manage_users_wdg)

        # custom layout editor
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Custom Layouts"
        description = '''Create interfaces using the Custom Layout Editor.'''
        image = "<img src='/context/icons/64x64/layout_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.tools.CustomLayoutEditWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs);
            '''
        }
        config_wdg = self.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(config_wdg)

        tr = table.add_row()

        # Plugins
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Plugins"
        image = IconWdg("Manage Plugins", IconWdg.PLUGIN_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Upload, install, remove and create TACTIC plugins.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.app.PluginWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs);
        '''
        }
        plugin_wdg = self.get_small_section_wdg(title, description, image,
                                                behavior)
        td.add(plugin_wdg)

        # Examples
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Tools"
        image = IconWdg("Tools", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A collection of example views.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.ToolsWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("tools", "Tools", class_name, kwargs);
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image,
                                               behavior)
        td.add(share_wdg)

        # Share
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Shares"
        image = IconWdg("Shares", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Share project with other TACTIC installs.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ShareWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("shares", "Shares", class_name, kwargs);
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)
        """

        # Advanced
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Advanced Setup"
        image = IconWdg("Advanced", IconWdg.ADVANCED_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A set of advanced configuration tools.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.app.ProjectStartWdg';
        spt.tab.set_main_body_tab()
        spt.tab.add_new("project_setup", "Project Setup", class_name)
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image,
                                               behavior)
        td.add(share_wdg)
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")

        from misc_wdg import QuickLinksWdg
        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        #td = table.add_cell()
        #totals_wdg = self.get_totals_wdg()
        #td.add(totals_wdg)

        return top
예제 #30
0
    def get_display(my):

        div = DivWdg()

        if not Container.get_dict("JSLibraries", "spt_popup"):
            div.add_style("position: fixed")
            div.add_style("top: 0px")
            div.add_style("left: 0px")
            div.add_style("opacity: 0.4")
            div.add_style("background", "#000")
            div.add_style("padding: 100px")
            div.add_style("height: 100%")
            div.add_style("width: 100%")
            div.add_class("spt_popup_background")
            div.add_style("display: none")
            div.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.hide(bvr.src_el);
                '''
            })

        Container.put("PopupWdg:background", True)

        # This is the absolute outside of a popup, including the drop shadow
        widget = DivWdg()
        div.add(widget)
        widget.add_class("spt_popup")

        if not Container.get_dict("JSLibraries", "spt_popup"):
            widget.add_behavior({
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            })

        width = my.kwargs.get("width")
        if not width:
            width = 10

        #widget.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': 'bvr.src_el.makeResizable({handle:bvr.src_el.getElement(".spt_popup_resize")})'
        #} )

        web = WebContainer.get_web()

        widget.set_id(my.name)
        if my.kwargs.get("display") == "true":
            pass
        else:
            widget.add_style("display: none")

        widget.add_style("position: absolute")
        widget.add_style("left: 400px")
        widget.add_style("top: 100px")

        widget.add_border()
        widget.add_color("background", "background")

        #widget.set_box_shadow(color="#000")
        widget.set_box_shadow()

        table = Table()
        table.add_behavior({
            'type':
            'load',
            'width':
            width,
            'cbjs_action':
            '''
        bvr.src_el.setStyle("width", bvr.width)

        var popup = bvr.src_el.getParent(".spt_popup");
        var window_size = $(window).getSize();
        var size = bvr.src_el.getSize();
        var left = window_size.x/2 - size.x/2;
        var top = window_size.y/2 - size.y/2;
        popup.setStyle("left", left);
        //popup.setStyle("top", top);

        '''
        })

        table.add_row()
        """
        # Qt doesn't support shadows very well
        if web.get_browser() == 'Qtx':
            # dynamically add css files

            table.add_class("css_shadow_table")
            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top_left SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top_right SPT_POPUP_SHADOW")


            # Middle (Content) Row of Shadow table ...
            table.add_row()

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_left SPT_POPUP_SHADOW")
        """

        content_td = table.add_cell()
        content_td.add_class("css_shadow_td")
        """
        if web.get_browser() == 'Qtx':
            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_right SPT_POPUP_SHADOW")


            # Bottom Row of Shadow table ...
            table.add_row()

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom_left SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom_right SPT_POPUP_SHADOW")
        """

        drag_div = DivWdg()

        #from tactic.ui.container import ArrowWdg
        #arrow = ArrowWdg()
        #drag_div.add(arrow)

        # FIXME: for some reason, this causes popups to stop functioning after
        # close a couple of times
        my.add_header_context_menu(drag_div)

        # create the 'close' button ...
        if my.allow_close:
            close_wdg = SpanWdg()
            #close_wdg.add( IconWdg("Close", IconWdg.POPUP_WIN_CLOSE) )
            close_wdg.add(IconWdg("Close", "BS_REMOVE"))
            close_wdg.add_style("margin: 5px 1px 3px 1px")
            close_wdg.add_style("float: right")
            close_wdg.add_class("hand")

            close_wdg.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.get_cancel_script()
            })

            drag_div.add(close_wdg)

            # create the 'minimize' button ...
            minimize_wdg = SpanWdg()
            minimize_wdg.add_style("margin: 5px 1px 3px 1px")
            #minimize_wdg.add( IconWdg("Minimize", IconWdg.POPUP_WIN_MINIMIZE) )
            minimize_wdg.add(IconWdg("Minimize", "BS_MINUS"))
            minimize_wdg.add_style("float: right")
            minimize_wdg.add_class("hand")
            behavior = {
                'type': 'click_up',
                'cbjs_action': "spt.popup.toggle_minimize( bvr.src_el );"
            }
            minimize_wdg.add_behavior(behavior)
            drag_div.add(minimize_wdg)

        #-- TO ADD SOON -- create the 'refresh' button ...
        #   refresh_wdg = SpanWdg()
        #   refresh_wdg.add( IconWdg("Refresh Popup", IconWdg.POPUP_WIN_REFRESH) )
        #   refresh_wdg.add_style("float: right")
        #   refresh_wdg.add_class("hand")
        #   behavior = {
        #       'type': 'click_up',
        #       'cbjs_action': "spt.popup.toggle_minimize( bvr.src_el );"
        #   }
        #   refresh_wdg.add_behavior( behavior );
        #   drag_div.add(refresh_wdg)

        width = my.kwargs.get("width")

        # style
        drag_div.add_style("font-size: 1.1em")

        drag_div.add_style("text-align: left")
        drag_div.add_class("spt_popup_width")

        drag_handle_div = DivWdg(id='%s_title' % my.name)
        drag_handle_div.add_style("padding: 12px;")
        #drag_handle_div.add_gradient("background", "background", +10)
        drag_handle_div.add_color("background", "background", -5)
        drag_handle_div.add_color("color", "color")
        drag_handle_div.add_style("font-weight", "bold")
        drag_handle_div.add_style("font-size", "12px")

        # add the drag capability.
        # NOTE: need to use getParent because spt.popup has not yet been
        # initialized when this is processed
        shadow_color = drag_div.get_color("shadow")
        drag_div.add_behavior({
            'type': 'smart_drag',
            'shadow_color': shadow_color,
            'drag_el': "@.getParent('.spt_popup')",
            'bvr_match_class': 'spt_popup_title',
            'options': {
                'z_sort': 'bring_forward'
            },
            'ignore_default_motion': 'true',
            "cbjs_setup": '''
              if (spt.popup.is_background_visible) {
                  spt.popup.offset_x = document.body.scrollLeft;
                  spt.popup.offset_y = document.body.scrollTop;
                  spt.popup.hide_background();
                  var parent = bvr.src_el.getParent(".spt_popup");
                  parent.setStyle("box-shadow","0px 0px 20px " + bvr.shadow_color);
              }
              else {
                  spt.popup.offset_x = 0;
                  spt.popup.offset_y = 0;
              }
            ''',
            "cbjs_motion": '''
              mouse_411.curr_x += spt.popup.offset_x;
              mouse_411.curr_y += spt.popup.offset_y;
              spt.mouse.default_drag_motion(evt, bvr, mouse_411);
            ''',
            "cbjs_action": ''
        })

        title_wdg = my.title_wdg
        if not title_wdg:
            title_wdg = "No Title"
        #else:
        #    title_wdg = title_wdg

        drag_handle_div.add_behavior({
            'type': 'double_click',
            'cbjs_action': my.get_cancel_script()
        })

        drag_handle_div.add(title_wdg)
        drag_handle_div.add_class("spt_popup_title")

        # add a context menu
        from tactic.ui.container.smart_menu_wdg import SmartMenu
        SmartMenu.assign_as_local_activator(drag_handle_div, 'HEADER_CTX')
        drag_handle_div.add_attr("spt_element_name", "Test Dock")

        # add the content
        content_div = DivWdg()
        content_div.add_color("color", "color2")
        #content_div.add_color("background", "background2")
        from pyasm.web.palette import Palette
        palette = Palette.get()
        content_div.add_color("color", "color2")
        content_div.add_color("background", "background2")

        content_div.add_style("margin", "0px, -1px -0px -1px")

        content_div.set_id("%s_content" % my.name)
        content_div.add_class("spt_popup_content")
        content_div.add_style("overflow: hidden")
        content_div.add_style("display: block")
        #content_div.add_style("padding: 10px")
        if not my.content_wdg:
            my.content_wdg = "No Content"

        content_div.add(my.content_wdg)

        drag_div.add(drag_handle_div)
        my.position_aux_div(drag_div, content_div)
        content_td.add(drag_div)
        widget.add(table)

        # ALWAYS make the Popup a Page Utility Widget (now processed client side)
        widget.add_class("SPT_PUW")

        if my.z_start:
            widget.set_z_start(my.z_start)
            widget.add_style("z-index: %s" % my.z_start)
        else:
            widget.add_style("z-index: 102")

        # add the resize icon
        icon = IconWdg("Resize", IconWdg.RESIZE_CORNER)
        icon.add_style("cursor: nw-resize")
        icon.add_style("z-index: 1000")
        icon.add_class("spt_popup_resize")
        icon.add_style("float: right")
        icon.add_style("margin-top: -15px")
        icon.add_behavior({
            'type': 'drag',
            "drag_el": '@',
            "cb_set_prefix": 'spt.popup.resize_drag'
        })
        content_td.add(icon)

        #return widget
        return div