예제 #1
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
예제 #2
0
    def get_group_wdg(self):

        div = DivWdg()

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("font-size: 14px")
        title_wdg.add_gradient("background", "background")
        title_wdg.add("Users")
        title_wdg.add_style("min-width: 200px")

        filtered_groups = self.kwargs.get("groups")
        if isinstance(filtered_groups, basestring):
            filtered_groups = filtered_groups.split("|")

        search = Search("sthpw/login_group")
        if filtered_groups:
            search.add_filters("login_group", filtered_groups)

        security = Environment.get_security()
        if not security.check_access("builtin", "view_site_admin", "allow"):
            search.add_filter("login_group", "admin", op="!=")
        search.add_project_filter()

        groups = search.get_sobjects()

        groups_div = DivWdg()
        div.add(groups_div)
        for group in groups:

            group_div = DivWdg()
            groups_div.add(group_div)

            title_div = DivWdg()
            group_div.add(title_div)
            title_div.add_color("background", "background3")
            title_div.add_color("color", "color3")
            title_div.add_style("margin-top: 5px")
            title_div.add_style("padding: 2px")

            swap = SwapDisplayWdg()
            title_div.add(swap)
            swap.add_style("float: left")

            title = DivWdg(group.get_value("login_group"))
            title_div.add(title)
            #title.add_style("float: left")
            title.add_style("font-weight: bold")
            title.add_style("padding-top: 2px")

            content_div = DivWdg()
            group_div.add(content_div)

            SwapDisplayWdg.create_swap_title(title,
                                             swap,
                                             div=content_div,
                                             is_open=True,
                                             action_script=None)

            logins = group.get_logins()
            logins_div = self.get_logins_wdg(logins)
            content_div.add(logins_div)
            content_div.add_style("padding-left: 15px")

        return div
예제 #3
0
    def get_viewer(my):
        top = DivWdg(css='spt_note_viewer_top')

        # draw checkbox options
        swap = SwapDisplayWdg()
        title = SpanWdg('main context')

        split_div = FloatDivWdg(css='spt_split_cb')
        div = DivWdg(css='spt_main_context_cb')
        content_div = DivWdg()
        content_div.add_color('color', 'color')
        content_div.add_style('padding: 10px')
        SwapDisplayWdg.create_swap_title(title,
                                         swap,
                                         content_div,
                                         is_open=False)
        div.add(swap)

        div.add(title)

        checkbox_name = 'split_screen'
        split_cb = CheckboxWdg(checkbox_name, label='Split View')
        split_cb.persistence = True
        split_cb.persistence_obj = split_cb
        key = split_cb.get_key()

        #cb.add_style('float: left')
        split_cb.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            True,
            'cbjs_action':
            '''
                    var top = bvr.src_el.getParent(".spt_note_viewer_top");
                    var table_top = top.getElement(".spt_note_viewer_table");

                    var cbs = top.getElement('.spt_main_context_cb');
                    var values = spt.api.Utility.get_input_values(cbs);

                    var processes = values.note_context_cb;
                    var kwargs = { process_names: processes};
                    if (bvr.src_el.checked) {
		        kwargs.split_view = 'true';
			kwargs.show_context = 'true';
                        kwargs.left_process_names = processes;
                        kwargs.right_process_names = processes;
                   
                    }

                    spt.input.save_selected(bvr, '%s','%s');
                    spt.app_busy.show("Note Viewer", 'Loading') ;
                    setTimeout(function(){
                        spt.panel.refresh(table_top, kwargs, false);
                        if (bvr.src_el.checked) 
                            spt.hide(cbs);
                        else 
                            spt.show(cbs);
                        spt.app_busy.hide();
                        }, 50 );
                    
                ''' % (checkbox_name, key)
        })
        split_div.add(split_cb)

        top.add(split_div)
        top.add(div)
        div.add(content_div)
        top.add(HtmlElement.br())

        checkbox_name = 'note_main_context_cb'
        cb = CheckboxWdg(checkbox_name)
        cb.persistence = True
        cb.persistence_obj = cb

        my.checked_process_names = cb.get_values()

        for value in my.process_names:
            #my.checked_process_names = web.get_form_values('process_names')
            cb = CheckboxWdg(checkbox_name, label=value)

            if value in my.checked_process_names:
                my.checked_processes.append(value)
            # FIXME: this is very tenous.  Accessing private members to
            # override behavior

            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)

            cb.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''
                    var top = bvr.src_el.getParent(".spt_note_viewer_top")
                    var table_top = top.getElement('.spt_note_viewer_table');
                    var cbs = top.getElement('.spt_main_context_cb');
                    var values = spt.api.Utility.get_input_values(cbs);
                   
                    var processes = values.note_main_context_cb;
                    var kwargs = { process_names: processes};
                    spt.input.save_selected(bvr, '%s','%s');
                    spt.panel.refresh(table_top, kwargs, false);
                ''' % (checkbox_name, key)
            })
            content_div.add(cb)

        table_top = DivWdg(css='spt_note_viewer_table')
        expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join(
            my.checked_processes)

        if split_cb.is_checked():
            table = my.get_split_viewer()
        else:
            table_id = 'main_table1'

            table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\
                 show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression )

        my.set_as_panel(table_top)
        table_top.add_style('float: left')

        top.add(table_top)
        table_top.add(table)

        return top
예제 #4
0
    def get_viewer(my):
        top = DivWdg(css='spt_single_note_viewer_top')

        # draw checkbox options
        swap = SwapDisplayWdg()
        title = SpanWdg('context')
        title.add_color('color', 'color')
        div = DivWdg(css='spt_context_cb')
        div.add_color('color', 'color')
        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        checkbox_name = 'split_screen'
        checked_process_names = []
        if my.show_context:
            top.add(swap)
            top.add(title)
            top.add(div)

            #checkbox_name = 'note_context_cb'
            checkbox_name = my.checkbox_name
            cb = CheckboxWdg(checkbox_name)
            cb.persistence = True
            cb.persistence_obj = cb

            checked_process_names = cb.get_values()
            for value in my.process_names:
                #my.checked_process_names = web.get_form_values('process_names')
                cb = CheckboxWdg(checkbox_name, label=value)

                if value in checked_process_names:
                    my.checked_processes.append(value)
                # FIXME: this is very tenous.  Accessing private members to
                # override behavior

                cb.persistence = True
                cb.persistence_obj = cb
                key = cb.get_key()
                cb.set_option('value', value)

                cb.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    'cbjs_action':
                    '''
                        var top = bvr.src_el.getParent(".spt_single_note_viewer_top")
                        var table_top = top.getElement('.spt_note_viewer_table');
                        var cbs = top.getElement('.spt_context_cb');
                        var values = spt.api.Utility.get_input_values(cbs);
                        var processes = values.%s;
                        var kwargs = { process_names: processes};
                        spt.input.save_selected(bvr, '%s','%s');
                        spt.panel.refresh(table_top, kwargs, false);
                    ''' % (checkbox_name, checkbox_name, key)
                })
                div.add(cb)
        else:
            web = WebContainer.get_web()
            checked_process_names = web.get_form_values('process_names')
        table_top = DivWdg(css='spt_note_viewer_table')
        expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join(
            checked_process_names)
        table_id = 'main_table1'

        table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\
             show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression )
        if my.resize:
            from tactic.ui.container import ResizeScrollWdg
            inner_wdg = ResizeScrollWdg(width='500px',
                                        height='500px',
                                        scroll_bar_size_str='thick',
                                        scroll_expansion='inside')
            inner_wdg.add(table)
            table_top.add(inner_wdg)
        else:
            table_top.add(table)

        my.set_as_panel(table_top)
        top.add(table_top)

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

        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box

        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")

        div.add_style("font-style: bold")

        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add(my.get_process_wdg(my.search_type))
        process_div.add(my.get_context_filter_wdg())
        process_div.add(HtmlElement.br(clear="all"))

        div.add(HtmlElement.br())
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title,
                                         swap,
                                         checkin_options,
                                         is_open=False)
        div.add(swap)
        div.add(title)

        checkin_options.add(my.get_file_type_wdg())
        checkin_options.add(my.get_snapshot_type_wdg())
        checkin_options.add(HtmlElement.br(1))
        checkin_options.add(my.get_export_method_wdg())
        checkin_options.add(my.get_checkin_as_wdg())

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add(my.get_currency_wdg())

        checkin_options.add(my.get_reference_option())
        checkin_options.add(my.get_auto_version_wdg())
        checkin_options.add(my.get_texture_option(app=app_name))
        checkin_options.add(my.get_handoff_wdg())

        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)

        top.add(my.get_introspect_wdg())
        top.add(HtmlElement.br(2))

        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background', 'background2')
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header(" ")
        table.add_header(" ")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background', 'background2', -15)

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir())
        else:
            my.add("Current Project: Please press 'Introspect'")

        count = 0
        for i in range(0, len(node_names)):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()

            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue

            # list items if it is a set
            if asset.get_value('asset_type',
                               no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set(table, instance_name, asset, instance_names)
                count += 1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name,
                                                snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)

            count += 1
예제 #6
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css='spt_ui_options')
        div.set_unique_id()
        table = Table()
        div.add(table)
        table.add_style("margin: 5px 15px")
        table.add_color('color', 'color')

        swap = SwapDisplayWdg()
        #swap.set_off()
        app = WebContainer.get_web().get_selected_app()
        outer_span = SpanWdg()
        outer_span.add_style('float: right')
        span = SpanWdg(app, css='small')
        icon = IconWdg(icon=eval("IconWdg.%s" % app.upper()), width='13px')
        outer_span.add(span)
        outer_span.add(icon)

        title = SpanWdg("Loading Options")
        title.add(outer_span)

        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        widget.add(swap)
        widget.add(title)
        widget.add(div)

        if not my.hide_instantiation:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Instantiation: "))
            table.add_cell(div)
            div = my.get_instantiation_wdg()
            table.add_cell(div)

        setting = my.get_default_setting()
        default_instantiation = setting.get('instantiation')
        default_connection = setting.get('connection')
        default_dependency = setting.get('texture_dependency')

        if not my.hide_connection:
            table.add_row()
            table.add_blank_cell()
            con_div = DivWdg(HtmlElement.b("Connection: "))
            table.add_cell(con_div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['http', 'file system']:
                name = my.get_element_name("connection")
                checkbox = CheckboxWdg(name)
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                if value == default_connection:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                span = SpanWdg(checkbox, css='small')
                span.add(value)

                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        if not my.hide_dependencies:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Texture Dependencies: "))
            table.add_cell(div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['as checked in', 'latest', 'current']:
                name = my.get_element_name("dependency")
                checkbox = CheckboxWdg(name)

                checkbox.set_option("value", value)
                checkbox.set_persistence()
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                if value == default_dependency:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False

                span = SpanWdg(checkbox, css='small')
                span.add(value)
                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        from connection_select_wdg import ConnectionSelectWdg
        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Type: "))
        table.add_cell(div)
        table.add_cell(ConnectionSelectWdg())

        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Port: "))
        table.add_cell(div)
        port_div = DivWdg()
        port_text = TextWdg("port")
        port_text.set_option('size', '6')
        port_div.add(port_text)
        port_div.add_style("padding-left: 7px")
        port_div.add_style("width: 40px")
        table.add_cell(port_div)

        from pyasm.prod.web import WidgetSettings
        value = WidgetSettings.get_value_by_key("CGApp:connection_port")
        if value:
            port_text.set_value(value)
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            port_text.set_value("13000")
        else:
            port_text.set_value("4444")

        port_text.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
                var value = bvr.src_el.value;
                value = parseInt(value);
                var kwargs = {
                    'data': value,
                    'key': 'CGApp:connection_port'
                }
                var cmd = "pyasm.web.WidgetSettingSaveCbk"
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, kwargs);

                // FIXME: this is dangerous use of a global var
                app.port = value;
            '''
        })

        return widget
예제 #7
0
    def get_info_wdg(my):

        widget = Widget()

        table = Table()
        table.set_class("minimal")
        table.add_style("font-size: 0.8em")

        context_option = my.kwargs.get('context')
        context_expr_option = my.kwargs.get('context_expr')

        pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True']
        setting_option = my.kwargs.get('setting')
        context_name = "%s|context" % my.get_input_name()
        text = None
        span1 = SpanWdg("Context", id='context_mode')
        span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode')
        span2.add_style('display', 'none')
        table.add_cell(span1)
        table.add_data(span2)
        if context_expr_option or context_option or setting_option:
            # add swap display for subcontext only if there is setting or context option
            swap = SwapDisplayWdg()
            table.add_data(SpanWdg(swap, css='small'))
            swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]'))
            subcontext_name = "%s|subcontext" % my.get_input_name()
            subcontext = SpanWdg('/ ', css='small')
            subcontext.add(TextWdg(subcontext_name))
            subcontext.add_style('display', 'none')
            subcontext.set_id(subcontext_name)
            on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')" % subcontext_name
            off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\
                "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name)
            swap.add_action_script(on_script, off_script)
            text = SelectWdg(context_name)
            if my.sobjects:
                text.set_sobject(my.sobjects[0])
            if context_expr_option:
                text.set_option('values_expr', context_expr_option)
            elif context_option:
                text.set_option('values', context_option)
            elif setting_option:
                text.set_option('setting', setting_option)

            td = table.add_cell(text)

            table.add_data(subcontext)

        elif pipeline_option:
            from pyasm.biz import Pipeline
            sobject = my.sobjects[0]
            pipeline = Pipeline.get_by_sobject(sobject)
            context_names = []
            process_names = pipeline.get_process_names(recurse=True)
            for process in process_names:
                context_names.append(pipeline.get_output_contexts(process))
            text = SelectWdg(context_name)
            text.set_option('values', process_names)
            table.add_cell(text)

        else:
            text = TextWdg(context_name)
            table.add_cell(text)
            hint = HintWdg('If not specified, the default is [publish]')
            table.add_data(hint)

        revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\
            label='is revision', css='med')
        table.add_data(revision_cb)
        table.add_row()
        table.add_cell("Comment")
        textarea = TextAreaWdg("%s|description" % my.get_input_name())
        table.add_cell(textarea)
        widget.add(table)

        return widget
예제 #8
0
    def get_display(self):
        top = DivWdg()

        search_type = self.kwargs.get("search_type")
        view = self.kwargs.get("view")
        element_name = self.kwargs.get("element_name")

        config_view = WidgetConfigView.get_by_search_type(search_type, view)

        #inner_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        inner_div = RoundedCornerDivWdg(hex_color_code="272727",
                                        corner_size="10")
        inner_div.set_dimensions(width_str='400px', content_height_str='600px')
        top.add(inner_div)

        # add the save button
        buttons_list = []
        buttons_list.append({
            'label': 'Save as View',
            'tip': 'Save as View',
            'bvr': {
                'cbjs_action': "alert('Not Implemented')"
            }
        })
        buttons_list.append({
            'label': 'Save as Def',
            'tip': 'Save as Definition',
            'bvr': {
                'cbjs_action': "alert('Not Implemented')"
            }
        })

        buttons = TextBtnSetWdg(float="right",
                                buttons=buttons_list,
                                spacing=6,
                                size='small',
                                side_padding=4)

        inner_div.add(buttons)

        title_div = DivWdg()
        title_div.add_style("margin-bottom: 10px")
        title_div.add_class("maq_search_bar")
        title_div.add("Element Definition")
        inner_div.add(title_div)

        test = SimpleElementDefinitionWdg(config_view=config_view,
                                          element_name=element_name)
        inner_div.add(test)

        config_title_wdg = DivWdg()
        inner_div.add(config_title_wdg)
        config_title_wdg.add("<b>Definitions in config</b>")
        config_title_wdg.add_style("margin: 15px 0px 5px 0px")

        for config in config_view.get_configs():
            view = config.get_view()
            xml = config.get_element_xml(element_name)

            config_div = DivWdg()
            inner_div.add(config_div)

            # add the title
            from pyasm.widget import SwapDisplayWdg, IconWdg

            view_div = DivWdg()
            view_div.add_class("spt_view")
            config_div.add(view_div)

            if not xml:
                icon_wdg = IconWdg("Nothing defined", IconWdg.DOT_RED)
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)
            else:
                icon_wdg = IconWdg("Is defined", IconWdg.DOT_GREEN)
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)

            swap = SwapDisplayWdg()
            view_div.add(swap)
            swap.add_action_script('''
                var info_wdg = bvr.src_el.getParent('.spt_view').getElement('.spt_info');
                spt.toggle_show_hide(info_wdg);
            ''')

            mode = "predefined"
            file_path = config.get_file_path()
            if not file_path:
                mode = "database"
            elif file_path == 'generated':
                mode = 'generated'

            # display the title
            view_div.add("%s" % view)
            view_div.add(" - [%s]" % mode)

            info_div = DivWdg()
            info_div.add_class("spt_info")
            info_div.add_style("margin-left: 20px")
            info_div.add_style("display: none")
            #if not xml:
            #    info_div.add_style("display: none")
            #else:
            #    swap.set_off()
            view_div.add(info_div)

            path_div = DivWdg()
            if not file_path:
                file_path = mode
            path_div.add("Defined in: %s" % file_path)
            info_div.add(path_div)

            text_wdg = TextAreaWdg()
            text_wdg.set_option("rows", 15)
            text_wdg.set_option("cols", 80)
            text_wdg.set_value(xml)
            info_div.add(text_wdg)

            #view_div.add("<hr/>")

        return top