Beispiel #1
0
    def get_display(my):

        #content.add_event("oncontextmenu", "spt.side_bar.manage_context_menu_action_cbk(); return false")
        context_menu = DivWdg()
        context_menu.add_class('spt_menu_top')
        context_menu.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            spt.finger_menu = {};
            spt.finger_menu.timeout_id = -1;
            '''
        } )
        context_menu.add_behavior( {
            'type': 'mouseover',
            'cbjs_action': '''
            if (spt.finger_menu.timeout_id != -1) {
                clearTimeout(spt.finger_menu.timeout_id);
                spt.finger_menu.timeout_id = -1;
            }
            '''
        } )

 


        #context_menu.set_box_shadow(color='#fff')
        # this may not be needed as it is set in JS
        context_menu.add_style("z-index: 200")

        # set up what happens when the mouse leaves the actual menu
        my._set_menu_out(context_menu)


        width = my.kwargs.get('width')
        height = my.kwargs.get('height')
        if not height:
            height = 20
        if not width:
            width = 35
        font_size = my.kwargs.get('font_size')
        if not font_size:
            font_size = 'smaller'


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

        if my.mode == 'horizontal':
            div = DivWdg(css='spt_finger_menu')
            if force:
                div.add_attr("spt_finger_force", force)

            div.add_style("border-color: #aaa")
            div.add_style("border-style: solid")

            if force == "left":
                div.add_style("border-width: 1px 0px 1px 1px")
                div.add_style("border-radius: 12px 0px 0px 12px")
            else:
                div.add_style("border-width: 1px 1px 1px 0px")
                div.add_style("border-radius: 0px 12px 12px 0px")


            div.set_box_shadow(value="0px 0px 2px 1px")
            #div.add_style("z-index: 1000")

            total_width = width * len(my.items) + 15
            div.add_style('width', total_width)
            div.add_styles('height: %spx; padding: 2px;' %height)
            context_menu.add(div)

            div.add_color('background','background', -10)
            palette = div.get_palette()

            sb_title_bg = palette.color('side_bar_title')
            bg_color = div.get_color('background', -10)
            color = div.get_color('color')
            
            for item in my.items:
                mouse_enter_bvr = {'type':'mouseenter', 'cbjs_action': '''
                    bvr.src_el.setStyles({'background': '%s', 'color': 'white'})''' %sb_title_bg}
                mouse_leave_bvr = {'type':'mouseleave', 'cbjs_action': '''
                    bvr.src_el.setStyles({'background': '%s', 'color': '%s'})''' %(bg_color, color)}

                menu_item = FloatDivWdg(css='unselectable hand')
                menu_item.add_color('background','background', -10)
                menu_item.add(item.get_option('label'))

                menu_item.add_behavior( mouse_enter_bvr )
                menu_item.add_behavior( mouse_leave_bvr )

                # add the passed-in bvr
                bvr = item.get_option('bvr_cb')
                menu_item.add_behavior(bvr )


                menu_item.add_styles('margin: 0px 0 0 0; padding: 2px 0 2px 0; text-align: center; font-size: %s; width: %s; height: %spx'%(font_size, width, height-4))
                menu_item.add_behavior({'type': 'click_up',
                    'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''})
                div.add(menu_item)
        
        else:
            # this width only matters in vertical mode
            context_menu.add_style("width: %s" %width)
            menu_table = Table()
            menu_table.add_styles( "text-align: left; text-indent: 4px; border-collapse: collapse; cell-padding: 8px; border-radius: 32px;" )
            context_menu.add(menu_table)
            my._add_spacer_row(menu_table, 3, width)
            for widget in my.widgets:
                tbody = menu_table.add_tbody()
                tbody.add_style("display","table-row-group")

               
                tr = menu_table.add_row()
                tr.add_looks( "smenu" )
                #tr.add_class( "SPT_SMENU_ENTRY" )
                hover_bvr = {'type':'hover', 'add_looks': 'smenu_hilite'}
                                 #'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );',
                                 #'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' }
                tr.add_behavior( hover_bvr )


                menu_item = menu_table.add_cell()
                font_size = '4px'
                menu_item.add_styles('padding: 0px 0 0 6px; font-size: %s; width: %s; height: 16px'%(font_size, width))
                menu_item.add_behavior({'type': 'click_up',
                    'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''})
                menu_item.add(widget)

               

            my._add_spacer_row(menu_table, 3, width)

        return context_menu
Beispiel #2
0
    def get_display(my):

        #content.add_event("oncontextmenu", "spt.side_bar.manage_context_menu_action_cbk(); return false")
        context_menu = DivWdg()
        context_menu.add_class('spt_menu_top')
        context_menu.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.finger_menu = {};
            spt.finger_menu.timeout_id = -1;
            '''
        })
        context_menu.add_behavior({
            'type':
            'mouseover',
            'cbjs_action':
            '''
            if (spt.finger_menu.timeout_id != -1) {
                clearTimeout(spt.finger_menu.timeout_id);
                spt.finger_menu.timeout_id = -1;
            }
            '''
        })

        #context_menu.set_box_shadow(color='#fff')
        # this may not be needed as it is set in JS
        context_menu.add_style("z-index: 200")

        # set up what happens when the mouse leaves the actual menu
        my._set_menu_out(context_menu)

        width = my.kwargs.get('width')
        height = my.kwargs.get('height')
        if not height:
            height = 20
        if not width:
            width = 35
        font_size = my.kwargs.get('font_size')
        if not font_size:
            font_size = 'smaller'

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

        if my.mode == 'horizontal':
            div = DivWdg(css='spt_finger_menu')
            if force:
                div.add_attr("spt_finger_force", force)

            div.add_style("border-color: #aaa")
            div.add_style("border-style: solid")

            if force == "left":
                div.add_style("border-width: 1px 0px 1px 1px")
                div.add_style("border-radius: 12px 0px 0px 12px")
            else:
                div.add_style("border-width: 1px 1px 1px 0px")
                div.add_style("border-radius: 0px 12px 12px 0px")

            div.set_box_shadow(value="0px 0px 2px 1px")
            #div.add_style("z-index: 1000")

            total_width = width * len(my.items) + 15
            div.add_style('width', total_width)
            div.add_styles('height: %spx; padding: 2px;' % height)
            context_menu.add(div)

            div.add_color('background', 'background', -10)
            palette = div.get_palette()

            sb_title_bg = palette.color('side_bar_title')
            bg_color = div.get_color('background', -10)
            color = div.get_color('color')

            for item in my.items:
                mouse_enter_bvr = {
                    'type':
                    'mouseenter',
                    'cbjs_action':
                    '''
                    bvr.src_el.setStyles({'background': '%s', 'color': 'white'})'''
                    % sb_title_bg
                }
                mouse_leave_bvr = {
                    'type':
                    'mouseleave',
                    'cbjs_action':
                    '''
                    bvr.src_el.setStyles({'background': '%s', 'color': '%s'})'''
                    % (bg_color, color)
                }

                menu_item = FloatDivWdg(css='unselectable hand')
                menu_item.add_color('background', 'background', -10)
                menu_item.add(item.get_option('label'))

                menu_item.add_behavior(mouse_enter_bvr)
                menu_item.add_behavior(mouse_leave_bvr)

                # add the passed-in bvr
                bvr = item.get_option('bvr_cb')
                menu_item.add_behavior(bvr)

                menu_item.add_styles(
                    'margin: 0px 0 0 0; padding: 2px 0 2px 0; text-align: center; font-size: %s; width: %s; height: %spx'
                    % (font_size, width, height - 4))
                menu_item.add_behavior({
                    'type':
                    'click_up',
                    'cbjs_action':
                    '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''
                })
                div.add(menu_item)

        else:
            # this width only matters in vertical mode
            context_menu.add_style("width: %s" % width)
            menu_table = Table()
            menu_table.add_styles(
                "text-align: left; text-indent: 4px; border-collapse: collapse; cell-padding: 8px; border-radius: 32px;"
            )
            context_menu.add(menu_table)
            my._add_spacer_row(menu_table, 3, width)
            for widget in my.widgets:
                tbody = menu_table.add_tbody()
                tbody.add_style("display", "table-row-group")

                tr = menu_table.add_row()
                tr.add_looks("smenu")
                #tr.add_class( "SPT_SMENU_ENTRY" )
                hover_bvr = {'type': 'hover', 'add_looks': 'smenu_hilite'}
                #'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );',
                #'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' }
                tr.add_behavior(hover_bvr)

                menu_item = menu_table.add_cell()
                font_size = '4px'
                menu_item.add_styles(
                    'padding: 0px 0 0 6px; font-size: %s; width: %s; height: 16px'
                    % (font_size, width))
                menu_item.add_behavior({
                    'type':
                    'click_up',
                    'cbjs_action':
                    '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''
                })
                menu_item.add(widget)

            my._add_spacer_row(menu_table, 3, width)

        return context_menu
Beispiel #3
0
    def get_display(my):

        search_key = my.kwargs.get("search_key")
        msg = None
        base_search_type = SearchKey.extract_search_type(search_key)
        sobject = SearchKey.get_by_search_key(search_key)
        process_div = DivWdg()
        process_div.add_style('padding-top: 10px')

        if base_search_type  in ['sthpw/task', 'sthpw/note']:
            my.process = sobject.get_value('process')
            my.context = sobject.get_value('context')
            if not my.process:
                my.process = ''

            parent = sobject.get_parent()
            if parent:
                search_key = SearchKey.get_by_sobject(parent)
            else:
                msg = "Parent for [%s] not found"%search_key
            
        else:
            my.process = my.kwargs.get('process')

        
        top = my.top
        top.add_class('spt_simple_checkin')
        top.add_color("background", "background")
        top.add_styles("position: relative")

        content = DivWdg(msg)
        top.add(content)
        #content.add_border()
        #content.add_color("background", "background3")
        #content.add_color("color", "background3")
        content.add_style("width: 600px")
        content.add_styles("margin-left: auto; margin-right: auto;")
        content.add_style("height: 200px")

        from tactic.ui.widget import CheckinWdg
        content.add_behavior( {
            'type': 'load',
            'cbjs_action': CheckinWdg.get_onload_js()
        } )


        button_div = DivWdg()
        
        content.add(process_div)

        content.add(button_div)
        button = IconWdg(title="Check-In", icon=IconWdg.CHECK_IN_3D_LG)

        title = Common.get_display_title(my.checkin_action)
        button.add_attr('title', title)


        button_div.add(button)
        button_div.set_box_shadow("1px 1px 1px 1px")
        button_div.add_style("width: 60px")
        button_div.add_style("height: 60px")
        button_div.add_style("float: left")
        button_div.add_style("background: white")
        button_div.add_class("hand")

        button_div.add_style("padding: 2px 3px 0 0")
        button_div.add_style("margin: 20px 60px 20px 200px")
        button_div.add_style("text-align: center")

        button_div.add("Check-in")

        # to be consistent with Check-in New File
        if my.process:
            checkin_process = my.process
        else:
            # Dont' specify, the user can choose later in check-in widget
            checkin_process = ''
        button.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'process': checkin_process,
            'context': my.context,
            'cbjs_action': '''
            var class_name = 'tactic.ui.widget.CheckinWdg';
            var applet = spt.Applet.get();


            spt.app_busy.show("Choose file(s) to check in")


            var current_dir = null;
            var is_sandbox = false;
            var refresh = false
            var values = spt.checkin.browse_folder(current_dir, is_sandbox, refresh);
            if (!values) {
                spt.app_busy.hide();
                return;
            }

            var file_paths = values.file_paths;
            if (file_paths.length == 0) {
                spt.alert("You need to select files(s) to check in.");
                spt.app_busy.hide();
                return;
            }

            spt.app_busy.hide();

            var args = {
                'search_key': bvr.search_key,
                'show_links': false,
                'show_history': false,
                'close_on_publish': true
            }
            if (bvr.process) args.process = bvr.process;
            if (bvr.context) args.context = bvr.context;

            var kwargs = {};
            kwargs.values = values;
            spt.panel.load_popup("Check-in", class_name, args, kwargs);

            /*
            var options=  {
                title: "Check-in Widget",
                class_name: 'tactic.ui.widget.CheckinWdg',
                popup_id: 'checkin_widget'
            };
            var bvr2 = {};
            bvr2.options = options;
            bvr2.values = values;
            bvr2.args = args;
            spt.popup.get_widget({}, bvr2)

            */

            '''
        } )


        button_div = DivWdg()
        content.add(button_div)
        button = IconWdg(title="Check-Out", icon=IconWdg.CHECK_OUT_3D_LG)
        button_div.add(button)
        button_div.set_box_shadow("1px 1px 1px 1px")
        button_div.add_style("width: 60px")
        button_div.add_style("height: 60px")
        button_div.add_style("float: left")
        button_div.add_style("margin: 20px")
        button_div.add_style("padding: 2px 3px 0 0")
        button_div.add_style("background: white")
        button_div.add_class("hand")

        button_div.add_style("text-align: center")
        button_div.add("Check-out")

       
        sobject = SearchKey.get_by_search_key(search_key)

        # snapshot is retrieved for getting the process informatoin, they are not being used
        # for loading as real_time snapshot query option is used. 
        search = Search("sthpw/snapshot")
        search.add_sobject_filter(sobject)
        if my.process:
            search.add_filter("process", my.process)
        search.add_filter("is_latest", True)
        snapshot = search.get_sobject()

        if not my.process and snapshot:
            my.process = snapshot.get_value('process')
            # for old process-less snapshots
            if not my.process:
                my.process = snapshot.get_value('context')

        process_wdg = DivWdg(HtmlElement.b(checkin_process))
        if checkin_process:
            width = len(checkin_process)*10
        else:
            width = 10
        process_wdg.add_styles('margin-left: auto; margin-right: auto; text-align: center; width: %s'%width)
        process_div.add(process_wdg)
        # DO NOT pass in snapshot_code, get it in real time

        snapshot_codes = []
   
        show_status = True
        if my.checkout_action == 'latest':
            cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status)
            bvr = {'snapshot_codes': snapshot_codes,
                    'real_time': True,
                    'file_types': ['main'],
                    'filename_mode': 'repo',
                    'cbjs_action': cbjs_action}

        elif my.checkout_action == 'latest (version_omitted)':
            cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status)
            bvr = {'snapshot_codes':snapshot_codes,
                    'real_time': True,
                    'file_types': ['main'],
                    'filename_mode': 'versionless',
                    'cbjs_action': cbjs_action}

        elif my.checkout_action == 'latest versionless':
            cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status)
            bvr = {'snapshot_codes':snapshot_codes,
                    'real_time': True,
                    'versionless': True,
                    'file_types': ['main'],
                    'filename_mode': 'versionless',
                    'cbjs_action': cbjs_action}
       
        elif my.checkout_action == 'open file browser':
            bvr =  {
           
            'cbjs_action': '''
            var class_name = 'tactic.ui.checkin.SObjectDirListWdg';
            var kwargs = {
                search_keys: [bvr.search_key],
                process: '%s' 
            };
            spt.panel.load_popup("Check-out", class_name, kwargs);
            '''%my.process
            }
        bvr.update({ 'type': 'click_up', 'search_key': search_key})
        button.add_behavior(bvr)
        title = Common.get_display_title(my.checkout_action)
        button.add_attr('title', title)


        
        #TODO: remove these margin-top which is used to compensate all the ButtonNewWdg top extra white space
        
        content.add("<br clear='all'/>")
        status_div = DivWdg()
        status_div.add_style('margin: 20px 0 0 10px')
        status_div.add_style('width: 100%')
        text_info = FloatDivWdg()
        text_info.add_styles('padding: 4px; width: 500px')
        text_info.add_style('margin-top: 8px')
        text_info.add_attr('title','Displays the last checked out file path')

        text_info.add_border()
        text_info.set_round_corners()

        text_content = DivWdg()
        text_content.add('&nbsp;')
        text_content.add_class('spt_status_area')

        text_info.add(text_content)
        label = FloatDivWdg('path:')
        label.add_style('margin: 12px 6px 0 6px')

        # button
        button = ButtonNewWdg(title="Explore", icon=IconWdg.FOLDER_GO)
        button.add_style('padding-bottom: 15px')
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
            var applet = spt.Applet.get();
            var status_div = bvr.src_el.getParent('.spt_simple_checkin').getElement('.spt_status_area');
            var value = status_div.get('text');

            var dir_name = spt.path.get_dirname(value);
            if (dir_name)
                applet.open_explorer(dir_name);
        '''
        } )

        status_div.add(label)
        status_div.add(text_info)
        content.add(status_div)
        content.add(button)
    

        content.add_behavior({'type':'load',
            'cbjs_action': ''' 
            
            if (!spt.Applet.applet) {
                spt.api.app_busy_show('Initializing Java', 'Please wait...');
                var exec = function() {var applet = spt.Applet.get()};
                spt.api.app_busy_hide(exec);
            }'''})
        
        return top