Exemplo n.º 1
0
    def get_buttons(my):
        button_div = DivWdg()


        button_row = ButtonRowWdg()
        button_div.add(button_row)
        button_row.add_style("float: right")
        button_row.add_style("padding-top: 5px")
        button_row.add_style("padding-bottom: 3px")
        button_row.add_style("padding-right: 5px")

        button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH)
        button_row.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.app_busy.show("Refreshing");
            var top = bvr.src_el.getParent(".spt_undo_log_top");
            spt.panel.refresh(top)
            spt.app_busy.hide();
            '''
        } )


        button = ButtonNewWdg(title="Undo the last transaction", icon=IconWdg.UNDO)
        button_row.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.undo_cbk(evt, bvr);
            spt.panel.refresh('UndoLogWdg');
            '''
        } )



        button = ButtonNewWdg(title="Redo the last transaction", icon=IconWdg.REDO)
        button_row.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.redo_cbk(evt, bvr);
            spt.panel.refresh('UndoLogWdg');
            '''
        } )


        # concept of a work session, which holds transaction codes
        session = {}

        # how should this session be stored?  Timestamp based?
        now = datetime.datetime.now()
        today = now.strftime("%Y-%m-%d")
        now = now.strftime("%Y-%m-%d %H:%M:%S")


        location = Config.get_value("install", "server")
        login = Environment.get_user_name()
        project_code = Project.get_project_code()


        """
        button = ButtonNewWdg(title="Save Selected Transactions", icon=IconWdg.SAVE)
        button_row.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'login': login,
            'project_code': project_code,
            'session': session,
            'cbjs_action': '''


            var top = bvr.src_el.getParent(".spt_undo_log_top");
            var table = top.getElement(".spt_table");

            var search_keys = spt.dg_table.get_selected_search_keys(table);
            if (search_keys.length == 0) {
                spt.error("No transactions selected");
                return;
            }

            spt.app_busy.show("Saving Selected Transactions")
            bvr.session['search_keys'] = search_keys.join("|");

            var server = TacticServerStub.get();
            var kwargs = {
                login: bvr.login,
                project_code: bvr.project_code,
                session: bvr.session
            }

            var class_name = 'tactic.command.TransactionPluginCreateCmd';
            server.execute_cmd(class_name, kwargs);

            spt.panel.refresh('UndoLogWdg');

            spt.app_busy.hide();

            '''
        } )


        #button.add_arrow_behavior( {
        #    'type': 'click_up',
        #    'cbjs_action': '''alert('cow')'''
        #} )
        button.set_show_arrow_menu(True)

        from tactic.ui.container import SmartMenu, Menu, MenuItem
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Save Today\'s Transactions')
        menu.add(menu_item)

        session['start_time'] =  "%s 00:00:00" % today
        session['end_time'] =  now

        menu_item.add_behavior( {
            'type': 'click_up',
            'login': login,
            'project_code': project_code,
            'session': session,
            'cbjs_action': '''

            spt.app_busy.show("Saving Today's Transactions")

            var server = TacticServerStub.get();
            var kwargs = {
                login: bvr.login,
                project_code: bvr.project_code,
                session: bvr.session
            }

            var class_name = 'tactic.command.TransactionPluginCreateCmd';
            server.execute_cmd(class_name, kwargs);

            spt.panel.refresh('UndoLogWdg');

            spt.app_busy.hide();

            '''
        } )


        SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } )
        SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True )





        button = ButtonNewWdg(title="Upload Transaction Session", icon=IconWdg.UPLOAD)
        button_row.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''

            spt.app_busy.show("Select Transaction File");

            var applet = spt.Applet.get();
            var files = applet.open_file_browser();
            if (files.length == 0) {
                spt.alert("No files selected");
                spt.app_busy.hide();
                return;
            }

            var path = files[0];

            spt.app_busy.show("Installing Transaction File");

            var server = TacticServerStub.get();
            server.upload_file(path);

            var class_name = 'tactic.command.TransactionPluginInstallCmd';
            var kwargs = {
                path: path
            }

            try {
                var info = server.execute_cmd(class_name, kwargs);
            }
            catch(e) {
                spt.alert(e);
            }

            spt.panel.refresh('UndoLogWdg');

            spt.app_busy.hide();
            '''
        } )
        """



        return button_div
Exemplo n.º 2
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        my.process = my.kwargs.get("process")
        my.sobject = Search.get_by_search_key(my.search_key)
        my.pipeline_code = my.kwargs.get("pipeline_code")

        top = DivWdg()
        top.add_class("spt_file_selector")
        top.add_style("position: relative")

        hidden = HiddenWdg("mode")
        #hidden = TextWdg("mode")
        hidden.add_class("spt_mode")
        top.add(hidden)

        top.add_style("padding: 5px")
        top.add_style("min-width: 500px")
        top.add_style("min-height: 400px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        #top.add_border()

        logo_wdg = DivWdg()
        logo = HtmlElement.img(src="/context/icons/logo/perforce_logo.gif")
        logo_wdg.add(logo)
        top.add(logo_wdg)
        logo_wdg.add_style("opacity: 0.2")
        logo_wdg.add_style("position: absolute")
        logo_wdg.add_style("bottom: 0px")
        logo_wdg.add_style("right: 5px")

        # get some info from the config file
        """
        client_env_var = Config.get_value("perforce", "client_env_var")
        if not client_env_var:
            client_env_var = "P4Client"
        port_env_var = Config.get_value("perforce", "port_env_var")
        if not port_env_var:
            port_env_var = "P4Port"
        user_env_var = Config.get_value("perforce", "user_env_var")
        if not user_env_var:
            user_env_var = "P4User"
        password_env_var = Config.get_value("perforce", "password_env_var")
        if not password_env_var:
            password_env_var = "P4Passwd"
        """

        # {GET(sthpw/login)}_user
        host = ""
        client = ""
        user = ""
        password = ""
        port = ""

        project = my.sobject.get_project()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = ""

        top.add_behavior({
            'type': 'load',
            #'client_env_var': client_env_var,
            #'port_env_var': port_env_var,
            #'user_env_var': user_env_var,
            #'password_env_var': password_env_var,
            'client': client,
            'user': user,
            'password': password,
            'host': host,
            'port': port,
            'depot': depot,
            'cbjs_action': get_onload_js()
        })

        list_wdg = DivWdg()
        top.add(list_wdg)
        list_wdg.add_style("height: 32px")

        from tactic.ui.widget import SingleButtonWdg, ButtonNewWdg, ButtonRowWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: left")

        button = ButtonNewWdg(title="Refresh",
                              icon=IconWdg.REFRESH,
                              long=False)
        button_row.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.app_busy.show("Reading file system ...")
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        spt.app_busy.hide();
        '''
        })

        button = ButtonNewWdg(title="Check-out",
                              icon=IconWdg.CHECK_OUT,
                              long=False)
        button_row.add(button)

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

        # what are we trying to do here???
        #my.root_sandbox_dir = Environment.get_sandbox_dir()
        #project = my.sobject.get_project()
        #my.root_sandbox_dir = "%s/%s" % (my.root_sandbox_dir, project.get_code())
        #repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")
        #repo_dir = "%s/%s" % (project.get_code(), repo_dir)

        # checkout command requires either starting with //<depot>/ or just
        # the relative path to the root.  The following removes
        # the root of the sandbox folder assuming that this is mapped
        # to the base of the depot
        my.root_sandbox_dir = Environment.get_sandbox_dir()
        repo_dir = my.sandbox_dir
        repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")

        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'repo_dir':
            repo_dir,
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.app_busy.show("Reading file system ...")

        var data = spt.scm.checkout(bvr.repo_dir)
        spt.panel.refresh(top);

        spt.app_busy.hide();
        '''
        })

        button = ButtonNewWdg(title="Perforce Actions",
                              icon=IconWdg.PERFORCE,
                              show_arrow=True)
        #button.set_show_arrow_menu(True)
        button_row.add(button)

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='Perforce')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Show Workspaces')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.WorkspaceWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "workspace";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='action', label='Show Changelists')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "changelist";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='action', label='Show Branches')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "branch";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        })

        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Add New Changelist')
        menu.add(menu_item)

        menu_item.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            var activator = spt.smenu.get_activator(bvr);
            spt.scm.run("add_changelist", ["New Changelist"]);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");
            spt.panel.load(content, class_name);

            '''
        })

        menu_item = MenuItem(type='separator')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Sign Out of Perforce')
        menu.add(menu_item)

        menu_item.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''

            if (!confirm("Are you sure you wish to sign out of Perforce?")) {
                return;
            }
            spt.scm.signout_user();

            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);


            '''
        })

        #SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } )
        #SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True )

        SmartMenu.add_smart_menu_set(button.get_button_wdg(),
                                     {'BUTTON_MENU': menu})
        SmartMenu.assign_as_local_activator(button.get_button_wdg(),
                                            "BUTTON_MENU", True)

        # Perforce script editor. (nice because it should run as the user
        # in the appopriate environment
        """
        button = ButtonNewWdg(title="P4 Script Editor", icon=IconWdg.CREATE, show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")
        """

        button = ButtonNewWdg(title="Changelists Counter",
                              icon=IconWdg.CHECK_OUT_SM,
                              show_arrow=True)
        #button_row.add(button)
        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                // find any changelists that were missed
                var changelists = spt.scm.run("get_changelists", []);
                for (var i = 0; i < changelists.length; i++) {
                    var changelist = changelists[i];
                    var info = spt.scm.run("get_changelist_info",[changelist.change]);
                    console.log(info);
                }
                '''
        })

        # Hiding this for now

        button = ButtonNewWdg(title="Create",
                              icon=IconWdg.NEW,
                              show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='New ...')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Text File')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'sandbox_dir':
            my.sandbox_dir,
            'cbjs_action':
            '''
        var path = bvr.sandbox_dir + "/" + "new_text_file.txt";
        var env = spt.Environment.get();
        var url = env.get_server_url() + "/context/VERSION_API";
        var applet = spt.Applet.get();
        applet.download_file(url, path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        })

        #create_sobj = SObject.create("sthpw/virtual")
        #create_sobj.set_value("title", "Maya Project")
        #create_sobj.set_value("script_path", "create/maya_project")

        script_path = 'create/maya_project'
        menu_item = MenuItem(type='action', label='Maya Project')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'sandbox_dir':
            my.sandbox_dir,
            'process':
            my.process,
            'script_path':
            script_path,
            'cbjs_action':
            '''
        var script = spt.CustomProject.get_script_by_path(bvr.script_path);
        var options = {};
        options.script = script;

        // add some data to options
        options.sandbox_dir = bvr.sandbox_dir;
        options.process = bvr.process;
        spt.CustomProject.exec_custom_script({}, options);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        '''
        })

        template_path = '/context/template/maya_project.zip'
        menu_item = MenuItem(type='action', label='Zipped Template')
        menu.add(menu_item)
        menu_item.add_behavior({
            'type':
            'click_up',
            'sandbox_dir':
            my.sandbox_dir,
            'template_path':
            template_path,
            'cbjs_action':
            '''
        var path = bvr.sandbox_dir + "/" + "_template.zip";
        var env = spt.Environment.get();
        var url = env.get_server_url() + bvr.template_path;
        var applet = spt.Applet.get();
        applet.download_file(url, path);
        applet.unzip_file(path, bvr.sandbox_dir);
        applet.rmtree(path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        })

        SmartMenu.add_smart_menu_set(button, {'BUTTON_MENU': menu})
        SmartMenu.assign_as_local_activator(button, "BUTTON_MENU", True)

        # Browse button for browsing files and dirs directly
        """
        browse_div = DivWdg()
        list_wdg.add(browse_div)
        browse_div.add_style("float: left")

        button = ActionButtonWdg(title="Browse", tip="Select Files or Folder to Check-In")
        browse_div.add(button)

        behavior = {
        'type': 'click_up',
        'base_dir': my.sandbox_dir,
        'cbjs_action': '''
            var current_dir = bvr.base_dir;
            var is_sandbox = false;
            spt.checkin.browse_folder(current_dir, is_sandbox);
        '''
        }
        button.add_behavior( behavior )
        """

        from tactic.ui.widget import SandboxButtonWdg, CheckoutButtonWdg, ExploreButtonWdg, GearMenuButtonWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: right")

        #button = SandboxButtonWdg(base_dir=my.sandbox_dir, process=my.process)
        #button_row.add(button)

        #button = CheckoutButtonWdg(base_dir=my.sandbox_dir, sobject=my.sobject, proces=my.process)
        #button_row.add(button)

        button = ExploreButtonWdg(base_dir=my.sandbox_dir)
        button_row.add(button)

        button = GearMenuButtonWdg(base_dir=my.sandbox_dir,
                                   process=my.process,
                                   pipeline_code=my.pipeline_code)
        button_row.add(button)

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

        top.add("<hr/>")

        content_div = DivWdg()
        top.add(content_div)
        content_div.add_class("spt_checkin_content")

        content = my.get_content_wdg()
        content_div.add(content)

        return top
Exemplo n.º 3
0
    def get_action_wdg(self):
        div = DivWdg()
        div.add_gradient("background", "background", -5)
        div.add_border()
        div.add_style("padding: 3px")

        button_row = ButtonRowWdg()
        div.add(button_row)
        button_row.add_style("float: left")
        div.add("<br clear='all'/>")

        button = ButtonNewWdg(title='Save Layout', icon=IconWdg.SAVE)
        button_row.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.app_busy.show("Saving ...");
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);
        var xml = spt.freeform.export();
        var search_type = canvas.getAttribute("spt_search_type");
        var view = canvas.getAttribute("spt_view");
        if (!search_type || !view) {
            alert("Cannot find search type or view");
            return;
        }

        var server = TacticServerStub.get();
        var sobject = server.get_unique_sobject("config/widget_config", {search_type: search_type, view: view} );
        server.update(sobject, {config: xml} );
        spt.app_busy.hide();

        '''
        })

        button = ButtonNewWdg(title='Add', icon=IconWdg.ADD, show_arrow=True)
        button_row.add(button)

        from tactic.ui.container import SmartMenu
        smenu_set = SmartMenu.add_smart_menu_set(
            button.get_button_wdg(), {'BUTTON_MENU': self.get_add_menu()})
        SmartMenu.assign_as_local_activator(button.get_button_wdg(),
                                            "BUTTON_MENU", True)

        button = ButtonNewWdg(title='Remove', icon=IconWdg.DELETE)
        button_row.add(button)

        button = ButtonNewWdg(title='Clear', icon=IconWdg.KILL)
        button_row.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);

        if ( !confirm("Are you sure you wish to clear the canvas?") ) {
            return;
        }
        spt.freeform.clear_canvas();


        '''
        })

        return div
Exemplo n.º 4
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        my.process = my.kwargs.get("process")
        my.sobject = Search.get_by_search_key(my.search_key)
        my.pipeline_code = my.kwargs.get("pipeline_code")

        top = DivWdg()
        top.add_class("spt_file_selector")
        top.add_style("position: relative")


        hidden = HiddenWdg("mode")
        #hidden = TextWdg("mode")
        hidden.add_class("spt_mode")
        top.add(hidden)



        top.add_style("padding: 5px")
        top.add_style("min-width: 500px")
        top.add_style("min-height: 400px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        #top.add_border()


        logo_wdg = DivWdg()
        logo = HtmlElement.img(src="/context/icons/logo/perforce_logo.gif")
        logo_wdg.add(logo)
        top.add(logo_wdg)
        logo_wdg.add_style("opacity: 0.2")
        logo_wdg.add_style("position: absolute")
        logo_wdg.add_style("bottom: 0px")
        logo_wdg.add_style("right: 5px")



        # get some info from the config file
        """
        client_env_var = Config.get_value("perforce", "client_env_var")
        if not client_env_var:
            client_env_var = "P4Client"
        port_env_var = Config.get_value("perforce", "port_env_var")
        if not port_env_var:
            port_env_var = "P4Port"
        user_env_var = Config.get_value("perforce", "user_env_var")
        if not user_env_var:
            user_env_var = "P4User"
        password_env_var = Config.get_value("perforce", "password_env_var")
        if not password_env_var:
            password_env_var = "P4Passwd"
        """

        # {GET(sthpw/login)}_user
        host = ""
        client = ""
        user = ""
        password = ""
        port = ""

        project = my.sobject.get_project()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = ""


        top.add_behavior( {
            'type': 'load',
            #'client_env_var': client_env_var,
            #'port_env_var': port_env_var,
            #'user_env_var': user_env_var,
            #'password_env_var': password_env_var,
            'client': client,
            'user': user,
            'password': password,
            'host': host,
            'port': port,
            'depot': depot,
            'cbjs_action': get_onload_js()
        } )


        list_wdg = DivWdg()
        top.add(list_wdg)
        list_wdg.add_style("height: 32px")

        from tactic.ui.widget import SingleButtonWdg, ButtonNewWdg, ButtonRowWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: left")

        button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH, long=False)
        button_row.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.app_busy.show("Reading file system ...")
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        spt.app_busy.hide();
        '''
        } )



        button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT, long=False)
        button_row.add(button)

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



        # what are we trying to do here???
        #my.root_sandbox_dir = Environment.get_sandbox_dir()
        #project = my.sobject.get_project()
        #my.root_sandbox_dir = "%s/%s" % (my.root_sandbox_dir, project.get_code())
        #repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")
        #repo_dir = "%s/%s" % (project.get_code(), repo_dir)




        # checkout command requires either starting with //<depot>/ or just
        # the relative path to the root.  The following removes
        # the root of the sandbox folder assuming that this is mapped
        # to the base of the depot
        my.root_sandbox_dir = Environment.get_sandbox_dir()
        repo_dir = my.sandbox_dir
        repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "")



        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'repo_dir': repo_dir,
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_checkin_top");
        spt.app_busy.show("Reading file system ...")

        var data = spt.scm.checkout(bvr.repo_dir)
        spt.panel.refresh(top);

        spt.app_busy.hide();
        '''
        } )





        button = ButtonNewWdg(title="Perforce Actions", icon=IconWdg.PERFORCE, show_arrow=True)
        #button.set_show_arrow_menu(True)
        button_row.add(button)

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='Perforce')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Show Workspaces')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.WorkspaceWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "workspace";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        } )





        menu_item = MenuItem(type='action', label='Show Changelists')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "changelist";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        } )



        menu_item = MenuItem(type='action', label='Show Branches')
        menu.add(menu_item)
        menu_item.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");

            var el = top.getElement(".spt_mode");
            el.value = "branch";

            var kwargs = {};
            spt.panel.load(content, class_name, kwargs);
            '''
        } )


        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)
        menu_item = MenuItem(type='action', label='Add New Changelist')
        menu.add(menu_item)

        menu_item.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            spt.scm.run("add_changelist", ["New Changelist"]);

            var class_name = 'tactic.ui.checkin.ChangelistWdg';
            var top = activator.getParent(".spt_checkin_top");
            var content = top.getElement(".spt_checkin_content");
            spt.panel.load(content, class_name);

            '''
        } )


        menu_item = MenuItem(type='separator')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Sign Out of Perforce')
        menu.add(menu_item)

        menu_item.add_behavior( {
            'type': 'load',
            'cbjs_action': '''

            if (!confirm("Are you sure you wish to sign out of Perforce?")) {
                return;
            }
            spt.scm.host = null;
            spt.scm.user = null;
            spt.scm.password = null;

            var activator = spt.smenu.get_activator(bvr);
            var top = activator.getParent(".spt_checkin_top");
            spt.panel.refresh(top);


            '''
        } )



 
        #SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } )
        #SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True )

        SmartMenu.add_smart_menu_set( button.get_button_wdg(), { 'BUTTON_MENU': menu } )
        SmartMenu.assign_as_local_activator( button.get_button_wdg(), "BUTTON_MENU", True )




        # Perforce script editor. (nice because it should run as the user
        # in the appopriate environment
        """
        button = ButtonNewWdg(title="P4 Script Editor", icon=IconWdg.CREATE, show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")
        """



        button = ButtonNewWdg(title="Changelists Counter", icon=IconWdg.CHECK_OUT_SM, show_arrow=True)
        #button_row.add(button)
        #button.add_style("padding-right: 14px")
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                // find any changelists that were missed
                var changelists = spt.scm.run("get_changelists", []);
                for (var i = 0; i < changelists.length; i++) {
                    var changelist = changelists[i];
                    var info = spt.scm.run("get_changelist_info",[changelist.change]);
                    console.log(info);
                }
                '''
            } )



        # Hiding this for now

        button = ButtonNewWdg(title="Create", icon=IconWdg.NEW, show_arrow=True)
        #button_row.add(button)
        button.add_style("padding-right: 14px")
        button.add_style("float: left")

        menu = Menu(width=220)
        menu_item = MenuItem(type='title', label='New ...')
        menu.add(menu_item)


        menu_item = MenuItem(type='action', label='Text File')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'sandbox_dir': my.sandbox_dir,
        'cbjs_action': '''
        var path = bvr.sandbox_dir + "/" + "new_text_file.txt";
        var env = spt.Environment.get();
        var url = env.get_server_url() + "/context/VERSION_API";
        var applet = spt.Applet.get();
        applet.download_file(url, path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        } )


        #create_sobj = SObject.create("sthpw/virtual")
        #create_sobj.set_value("title", "Maya Project")
        #create_sobj.set_value("script_path", "create/maya_project")


        script_path = 'create/maya_project'
        menu_item = MenuItem(type='action', label='Maya Project')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'sandbox_dir': my.sandbox_dir,
        'process': my.process,
        'script_path': script_path,
        'cbjs_action': '''
        var script = spt.CustomProject.get_script_by_path(bvr.script_path);
        var options = {};
        options.script = script;

        // add some data to options
        options.sandbox_dir = bvr.sandbox_dir;
        options.process = bvr.process;
        spt.CustomProject.exec_custom_script({}, options);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);
        '''
        } )


        template_path = '/context/template/maya_project.zip'
        menu_item = MenuItem(type='action', label='Zipped Template')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'sandbox_dir': my.sandbox_dir,
        'template_path': template_path,
        'cbjs_action': '''
        var path = bvr.sandbox_dir + "/" + "_template.zip";
        var env = spt.Environment.get();
        var url = env.get_server_url() + bvr.template_path;
        var applet = spt.Applet.get();
        applet.download_file(url, path);
        applet.unzip_file(path, bvr.sandbox_dir);
        applet.rmtree(path);

        var activator = spt.smenu.get_activator(bvr);
        var top = activator.getParent(".spt_checkin_top");
        spt.panel.refresh(top);

        '''
        } )



        SmartMenu.add_smart_menu_set( button, { 'BUTTON_MENU': menu } )
        SmartMenu.assign_as_local_activator( button, "BUTTON_MENU", True )



        # Browse button for browsing files and dirs directly
        """
        browse_div = DivWdg()
        list_wdg.add(browse_div)
        browse_div.add_style("float: left")

        button = ActionButtonWdg(title="Browse", tip="Select Files or Folder to Check-In")
        browse_div.add(button)

        behavior = {
        'type': 'click_up',
        'base_dir': my.sandbox_dir,
        'cbjs_action': '''
            var current_dir = bvr.base_dir;
            var is_sandbox = false;
            spt.checkin.browse_folder(current_dir, is_sandbox);
        '''
        }
        button.add_behavior( behavior )
        """

        from tactic.ui.widget import SandboxButtonWdg, CheckoutButtonWdg, ExploreButtonWdg, GearMenuButtonWdg

        button_row = ButtonRowWdg()
        list_wdg.add(button_row)
        button_row.add_style("float: right")

        #button = SandboxButtonWdg(base_dir=my.sandbox_dir, process=my.process)
        #button_row.add(button)

        #button = CheckoutButtonWdg(base_dir=my.sandbox_dir, sobject=my.sobject, proces=my.process)
        #button_row.add(button)

        button = ExploreButtonWdg(base_dir=my.sandbox_dir)
        button_row.add(button)

        button = GearMenuButtonWdg(base_dir=my.sandbox_dir, process=my.process, pipeline_code=my.pipeline_code)
        button_row.add(button)



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

        top.add("<hr/>")

        content_div = DivWdg()
        top.add(content_div)
        content_div.add_class("spt_checkin_content")

        content = my.get_content_wdg()
        content_div.add(content)

        return top
Exemplo n.º 5
0
    def get_action_wdg(my):
        div = DivWdg()
        div.add_gradient("background", "background", -5)
        div.add_border()
        div.add_style("padding: 3px")

        button_row = ButtonRowWdg()
        div.add(button_row)
        button_row.add_style("float: left")
        div.add("<br clear='all'/>")

        button = ButtonNewWdg(title="Save Layout", icon=IconWdg.SAVE)
        button_row.add(button)
        button.add_behavior(
            {
                "type": "click_up",
                "cbjs_action": """
        spt.app_busy.show("Saving ...");
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);
        var xml = spt.freeform.export();
        var search_type = canvas.getAttribute("spt_search_type");
        var view = canvas.getAttribute("spt_view");
        if (!search_type || !view) {
            alert("Cannot find search type or view");
            return;
        }

        var server = TacticServerStub.get();
        var sobject = server.get_unique_sobject("config/widget_config", {search_type: search_type, view: view} );
        server.update(sobject, {config: xml} );
        spt.app_busy.hide();

        """,
            }
        )

        button = ButtonNewWdg(title="Add", icon=IconWdg.ADD, show_arrow=True)
        button_row.add(button)

        from tactic.ui.container import SmartMenu

        smenu_set = SmartMenu.add_smart_menu_set(button.get_button_wdg(), {"BUTTON_MENU": my.get_add_menu()})
        SmartMenu.assign_as_local_activator(button.get_button_wdg(), "BUTTON_MENU", True)

        button = ButtonNewWdg(title="Remove", icon=IconWdg.DELETE)
        button_row.add(button)

        button = ButtonNewWdg(title="Clear", icon=IconWdg.KILL)
        button_row.add(button)
        button.add_behavior(
            {
                "type": "click_up",
                "cbjs_action": """
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);

        if ( !confirm("Are you sure you wish to clear the canvas?") ) {
            return;
        }
        spt.freeform.clear_canvas();


        """,
            }
        )

        return div