def get_display(my): top = my.top top.add_class("spt_changelist_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() # HARD CODED project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot changelist = my.kwargs.get("changelist") if not changelist: changelist = WidgetSettings.get_value_by_key("current_changelist") else: WidgetSettings.set_value_by_key("current_changelist", changelist) if not changelist: changelist = 'default' changelists = my.kwargs.get("changelists") if not changelists: changelists = [] elif isinstance(changelists, basestring): changelists = changelists.replace("'", '"') changelists = jsonloads(changelists) top.add_behavior( { 'type': 'load', 'sync_dir': sync_dir, 'depot': depot, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_color("background", "background", -3) table.add_row() th = table.add_header("") th = table.add_header("Changelist") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("Status") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Delete") th.add_style("text-align: left") #table.set_unique_id() #table.add_smart_styles("spt_changelist_item", { # 'text-align: right' # } )) bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_changelist_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_changelist_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_changelist_radio", 'cbjs_action': ''' var changelist = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", changelist); spt.app_busy.show("Loading Changelists Information"); spt.changelist.load(bvr.src_el, changelist); spt.app_busy.hide(); ''' } ) for c in changelists: num_items = len(c.get("info")) name = c.get("change") tr = table.add_row() tr.add_class("spt_changelist_item") radio = RadioWdg("changelist") radio.add_class("spt_changelist_radio") table.add_cell(radio) radio.set_option("value", name) if name == changelist: radio.set_checked() table.add_cell(name) table.add_cell(c.get("desc")) table.add_cell(num_items) table.add_cell(c.get("status")) if num_items: icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM) icon.add_behavior( { 'type': 'click_up', 'changelist': c.get("change"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", bvr.changelist); spt.app_busy.show("Loading Changelist"); spt.changelist.load(bvr.src_el, bvr.changelist); spt.app_busy.hide(); ''' } ) else: icon = '' table.add_cell(icon) if not num_items and name != 'default': icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE) else: icon = "" table.add_cell(icon) inner.add("<hr/>") files = my.kwargs.get("files") if isinstance(files, basestring): files = files.replace("'", '"') files = jsonloads(files) if files == None: inner.add_behavior( { 'type': 'load', 'location': location, 'changelist': changelist, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.changelist = {} spt.changelist.load = function(el, changelist) { var applet = spt.Applet.get(); var changelists = spt.scm.run("get_changelists_by_user",[]); var dflt = { 'change': 'default', 'status': 'pending' } changelists.push(dflt); changelists = changelists.reverse(); for (var i = 0; i < changelists.length; i++) { var info = spt.scm.run("get_changelist_files",[changelists[i].change]); changelists[i]['info'] = info; } // get the current chnage list var files = spt.scm.run("get_changelist_files",[changelist]); var path_info = {}; var sizes = []; for ( var i = 0; i < files.length; i++) { // FIXME: perforce specific var path = files[i].depotFile; path = path.replace(bvr.location, bvr.sync_dir); files[i].path = path; var size; if (applet.exists(path)) { var info = applet.get_path_info(path); size = info.size; } else { size = 0; } sizes.push(size); path_info[path] = 'editable'; } //var ret_val = spt.scm.status(bvr.sync_dir); //console.log(ret_val); var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg'; var kwargs = { files: files, sizes: sizes, changelist: changelist, changelists: changelists, path_info: path_info, } var top = el.getParent(".spt_changelist_content"); spt.panel.load(top, class_name, kwargs); } spt.changelist.load(bvr.src_el, bvr.changelist); ''' } ) content = DivWdg() inner.add(content) content.add_class("spt_changelist_content") if files == None: loading_wdg = DivWdg() content.add(loading_wdg) loading_wdg.add("<b>Loading ...</b>") loading_wdg.add_style("padding: 30px") elif files: title_wdg = DivWdg() title_wdg.add_style("height: 15px") title_wdg.add("Changelist: [%s]" % changelist) content.add(title_wdg) title_wdg.add_gradient("background", "background", -5) title_wdg.add_style("padding: 5px") title_wdg.add_border() #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD) #content.add(button) content.add("<br/>") paths = [x.get("path") for x in files] sizes = my.kwargs.get("sizes") path_info = my.kwargs.get("path_info") from scm_dir_list_wdg import ScmDirListWdg # dummy search_key search_key = "sthpw/virtual?code=xx001" dir_list_wdg = ScmDirListWdg( base_dir=sync_dir, paths=paths, sizes=sizes, path_info=path_info, all_open=True, #search_key=search_key ) content.add(dir_list_wdg) else: content.add("Changelist: [%s]" % changelist) content.add("<br/>"*2) no_files_wdg = DivWdg() content.add(no_files_wdg) no_files_wdg.add_style("padding: 20px") no_files_wdg.add_border() no_files_wdg.add("No files in changelist") no_files_wdg.add_color("color", "color3") no_files_wdg.add_color("background", "background3") no_files_wdg.add_style("font-weight: bold") no_files_wdg.add_style("text-align: center") return top
def get_display(my): top = my.top top.add_class("spt_branch_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot branch = my.kwargs.get("branch") if not branch: branch = WidgetSettings.get_value_by_key("current_branch") else: WidgetSettings.set_value_by_key("current_branch", branch) if not branch: branch = 'main' branches = my.kwargs.get("branches") if not branches: branches = [] elif isinstance(branches, basestring): branches = branches.replace("'", '"') branches = jsonloads(branches) top.add_behavior( { 'type': 'load', 'depot': depot, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_row() th = table.add_header("") th = table.add_header("Branches") th.add_style("text-align: left") th = table.add_header("Options") th.add_style("text-align: left") th = table.add_header("Owner") th.add_style("text-align: left") th = table.add_header("Check-out") th.add_style("text-align: left") bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_branch_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_branch_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_branch_radio", 'cbjs_action': ''' var value = bvr.src_el.value; spt.app_busy.show("Setting current branch to " + value); var server = TacticServerStub.get(); server.set_widget_setting("current_branch", value); var top = bvr.src_el.getParent(".spt_checkin_top"); top.removeAttribute("spt_sandbox_dir"); spt.panel.refresh(top); spt.app_busy.hide(); ''' } ) for c in branches: name = c.get("branch") tr = table.add_row() tr.add_class("spt_branch_item") radio = RadioWdg("branch") radio.add_class("spt_branch_radio") table.add_cell(radio) radio.set_option("value", name) if name == branch: radio.set_checked() table.add_cell(name) table.add_cell(c.get("Options")) table.add_cell(c.get("Owner")) icon = IconButtonWdg(title="Check-out", icon=IconWdg.CHECK_OUT_SM) table.add_cell(icon) icon.add_behavior( { 'type': 'click_up', 'branch': c.get("branch"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_branch_content"); top.setAttribute("spt_brange", bvr.branch); spt.app_busy.show("Checking out branch ["+bvr.branch+"]"); spt.scm.checkout("new_project/"+bvr.branch); spt.app_busy.hide(); ''' } ) inner.add("<hr/>") if my.kwargs.get("branches") == None: inner.add_behavior( { 'type': 'load', 'location': location, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.branch = {} spt.branch.load = function(el) { var branches = spt.scm.run("get_branches",[]); var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg'; var kwargs = { branches: branches, } var top = el.getParent(".spt_branch_content"); spt.panel.load(top, class_name, kwargs); } spt.branch.load(bvr.src_el); ''' } ) return top
def get_display(my): top = my.top top.add_class("spt_changelist_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior({'type': 'load', 'cbjs_action': scm_get_onload_js()}) sync_dir = Environment.get_sandbox_dir() # HARD CODED project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot changelist = my.kwargs.get("changelist") if not changelist: changelist = WidgetSettings.get_value_by_key("current_changelist") else: WidgetSettings.set_value_by_key("current_changelist", changelist) if not changelist: changelist = 'default' changelists = my.kwargs.get("changelists") if not changelists: changelists = [] elif isinstance(changelists, basestring): changelists = changelists.replace("'", '"') changelists = jsonloads(changelists) top.add_behavior({ 'type': 'load', 'sync_dir': sync_dir, 'depot': depot, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' }) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_color("background", "background", -3) table.add_row() th = table.add_header("") th = table.add_header("Changelist") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("Status") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Delete") th.add_style("text-align: left") #table.set_unique_id() #table.add_smart_styles("spt_changelist_item", { # 'text-align: right' # } )) bgcolor = table.get_color("background", -8) table.add_relay_behavior({ 'type': 'mouseover', 'bvr_match_class': 'spt_changelist_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' }) table.add_relay_behavior({ 'type': 'mouseout', 'bvr_match_class': 'spt_changelist_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' }) table.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': "spt_changelist_radio", 'cbjs_action': ''' var changelist = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", changelist); spt.app_busy.show("Loading Changelists Information"); spt.changelist.load(bvr.src_el, changelist); spt.app_busy.hide(); ''' }) for c in changelists: num_items = len(c.get("info")) name = c.get("change") tr = table.add_row() tr.add_class("spt_changelist_item") radio = RadioWdg("changelist") radio.add_class("spt_changelist_radio") table.add_cell(radio) radio.set_option("value", name) if name == changelist: radio.set_checked() table.add_cell(name) table.add_cell(c.get("desc")) table.add_cell(num_items) table.add_cell(c.get("status")) if num_items: icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM) icon.add_behavior({ 'type': 'click_up', 'changelist': c.get("change"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", bvr.changelist); spt.app_busy.show("Loading Changelist"); spt.changelist.load(bvr.src_el, bvr.changelist); spt.app_busy.hide(); ''' }) else: icon = '' table.add_cell(icon) if not num_items and name != 'default': icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE) else: icon = "" table.add_cell(icon) inner.add("<hr/>") files = my.kwargs.get("files") if isinstance(files, basestring): files = files.replace("'", '"') files = jsonloads(files) if files == None: inner.add_behavior({ 'type': 'load', 'location': location, 'changelist': changelist, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.changelist = {} spt.changelist.load = function(el, changelist) { var applet = spt.Applet.get(); var changelists = spt.scm.run("get_changelists_by_user",[]); var dflt = { 'change': 'default', 'status': 'pending' } changelists.push(dflt); changelists = changelists.reverse(); for (var i = 0; i < changelists.length; i++) { var info = spt.scm.run("get_changelist_files",[changelists[i].change]); changelists[i]['info'] = info; } // get the current chnage list var files = spt.scm.run("get_changelist_files",[changelist]); var path_info = {}; var sizes = []; for ( var i = 0; i < files.length; i++) { // FIXME: perforce specific var path = files[i].depotFile; path = path.replace(bvr.location, bvr.sync_dir); files[i].path = path; var size; if (applet.exists(path)) { var info = applet.get_path_info(path); size = info.size; } else { size = 0; } sizes.push(size); path_info[path] = 'editable'; } //var ret_val = spt.scm.status(bvr.sync_dir); //console.log(ret_val); var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg'; var kwargs = { files: files, sizes: sizes, changelist: changelist, changelists: changelists, path_info: path_info, } var top = el.getParent(".spt_changelist_content"); spt.panel.load(top, class_name, kwargs); } spt.changelist.load(bvr.src_el, bvr.changelist); ''' }) content = DivWdg() inner.add(content) content.add_class("spt_changelist_content") if files == None: loading_wdg = DivWdg() content.add(loading_wdg) loading_wdg.add("<b>Loading ...</b>") loading_wdg.add_style("padding: 30px") elif files: title_wdg = DivWdg() title_wdg.add_style("height: 15px") title_wdg.add("Changelist: [%s]" % changelist) content.add(title_wdg) title_wdg.add_gradient("background", "background", -5) title_wdg.add_style("padding: 5px") title_wdg.add_border() #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD) #content.add(button) content.add("<br/>") paths = [x.get("path") for x in files] sizes = my.kwargs.get("sizes") path_info = my.kwargs.get("path_info") from scm_dir_list_wdg import ScmDirListWdg # dummy search_key search_key = "sthpw/virtual?code=xx001" dir_list_wdg = ScmDirListWdg( base_dir=sync_dir, paths=paths, sizes=sizes, path_info=path_info, all_open=True, #search_key=search_key ) content.add(dir_list_wdg) else: content.add("Changelist: [%s]" % changelist) content.add("<br/>" * 2) no_files_wdg = DivWdg() content.add(no_files_wdg) no_files_wdg.add_style("padding: 20px") no_files_wdg.add_border() no_files_wdg.add("No files in changelist") no_files_wdg.add_color("color", "color3") no_files_wdg.add_color("background", "background3") no_files_wdg.add_style("font-weight: bold") no_files_wdg.add_style("text-align: center") return top
def get_display(my): top = my.top top.add_class("spt_workspace_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") top.add_style("min-width: 600px") top.add_style("min-height: 400px") # NOTE: is there ever a time when this is not loaded already? top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot workspace = my.kwargs.get("workspace") if not workspace: workspace = WidgetSettings.get_value_by_key("current_workspace") else: WidgetSettings.set_value_by_key("current_workspace", workspace) if not workspace: workspace = 'main' workspaces = my.kwargs.get("workspaces") if not workspaces: workspaces = [] elif isinstance(workspaces, basestring): workspaces = workspaces.replace("'", '"') workspaces = jsonloads(workspaces) top.add_behavior( { 'type': 'load', 'depot': depot, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_row() th = table.add_header("") th = table.add_header("Workspaces") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("Owner") th.add_style("text-align: left") th = table.add_header("Root") th.add_style("text-align: left") bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_workspace_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_workspace_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_workspace_radio", 'cbjs_action': ''' var value = bvr.src_el.value; spt.app_busy.show("Setting current workspace to " + value); var server = TacticServerStub.get(); server.set_widget_setting("current_workspace", value); var top = bvr.src_el.getParent(".spt_checkin_top"); top.removeAttribute("spt_sandbox_dir"); spt.panel.refresh(top); spt.app_busy.hide(); ''' } ) for c in workspaces: name = c.get("client") tr = table.add_row() tr.add_class("spt_workspace_item") radio = RadioWdg("workspace") radio.add_class("spt_workspace_radio") table.add_cell(radio) radio.set_option("value", name) if name == workspace: radio.set_checked() table.add_cell(name) table.add_cell(c.get("Description")) table.add_cell(c.get("Owner")) table.add_cell(c.get("Root")) if not workspaces: ws_div = DivWdg() table.add_row() table.add_cell(ws_div) ws_div.add_style("height: 60px") ws_div.add_style("width: 300px") ws_div.add("<b>No workspaces defined</b>") ws_div.add_color("color", "color3") ws_div.add_color("background", "background3") ws_div.add_border() ws_div.add_style("margin-top: 30px") ws_div.add_style("margin-bottom: 30px") ws_div.add_style("margin-left: auto") ws_div.add_style("margin-right: auto") ws_div.add_style("padding-top: 30px") ws_div.add_style("text-align: center") inner.add("<hr/>") if my.kwargs.get("workspaces") == None: inner.add_behavior( { 'type': 'load', 'location': location, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.workspace = {} spt.workspace.load = function(el) { var workspaces = spt.scm.run("get_workspaces",[]); console.log(workspaces); var class_name = 'tactic.ui.checkin.workspace_wdg.WorkspaceWdg'; var kwargs = { workspaces: workspaces, } var top = el.getParent(".spt_workspace_content"); spt.panel.load(top, class_name, kwargs); } spt.workspace.load(bvr.src_el); ''' } ) return top