コード例 #1
0
    def get_display(my):

        my.sobject = my.kwargs.get("sobject")
        search_key = my.sobject.get_search_key()

        top = DivWdg()
        top.add_class("spt_checkin_publish")
        top.add_style("padding: 10px")

        margin_top = '60px'
        top.add_style("margin-top", margin_top)
        top.add_style("position: relative")

        current_changelist = WidgetSettings.get_value_by_key(
            "current_changelist")
        current_branch = WidgetSettings.get_value_by_key("current_branch")
        current_workspace = WidgetSettings.get_value_by_key(
            "current_workspace")

        top.add("Branch: %s<br/>" % current_branch)
        top.add("Changelist: %s<br/>" % current_changelist)
        top.add("Workspace: %s<br/>" % current_workspace)
        top.add("<br/>")

        checked_out_div = DivWdg()
        checkbox = CheckboxWdg("editable")
        top.add(checked_out_div)
        checkbox.add_class("spt_checkin_editable")
        checked_out_div.add(checkbox)
        checked_out_div.add("Leave files editable")

        top.add("<br/>")

        top.add("Publish Description<br/>")
        text = TextAreaWdg("description")
        # this needs to be set or it will stick out to the right
        text.add_style("width: 220px")
        text.add_class("spt_checkin_description")
        top.add(text)

        # add as a note
        note_div = DivWdg()
        top.add(note_div)
        note_div.add_class("spt_add_note")
        checkbox = CheckboxWdg("add_note")

        web = WebContainer.get_web()
        browser = web.get_browser()
        if browser in ['Qt']:
            checkbox.add_style("margin-top: -4px")
            checkbox.add_style("margin-right: 3px")
            note_div.add_style("margin-top: 3px")

        checkbox.add_class("spt_checkin_add_note")
        note_div.add(checkbox)
        note_div.add("Also add as note")

        top.add("<br/><br/>")

        button = ActionButtonWdg(title="Check-in",
                                 icon=IconWdg.PUBLISH,
                                 size='medium')
        top.add(button)

        my.repo_type = 'perforce'
        if my.repo_type == 'perforce':

            # the depot is set per project (unless overridden)
            project = my.sobject.get_project()
            depot = project.get_value("location", no_exception=True)
            if not depot:
                depot = project.get_code()

            asset_dir = Environment.get_asset_dir()
            sandbox_dir = Environment.get_sandbox_dir()

            changelist = WidgetSettings.get_value_by_key("current_changelist")
            button.add_behavior({
                'type':
                'click_up',
                'depot':
                depot,
                'changelist':
                changelist,
                'sandbox_dir':
                sandbox_dir,
                'search_key':
                search_key,
                'cbjs_action':
                '''

            var paths = spt.checkin.get_selected_paths();
            spt.app_busy.show("Checking in "+paths.length+" file/s into Perforce");
            var top = bvr.src_el.getParent(".spt_checkin_top");
            var description = top.getElement(".spt_checkin_description").value;
            var add_note = top.getElement(".spt_checkin_add_note").value;
            var editable = top.getElement(".spt_checkin_editable").value;

            if (editable == 'on') {
                editable = true;
            }
            else {
                editable = false;
            }

            var process = top.getElement(".spt_checkin_process").value;

            // check into TACTIC
            var server = TacticServerStub.get();

            var revisions = [];
            server.start({description: "File Check-in"});

            try {

            var top = bvr.src_el.getParent(".spt_checkin_top");
            var el = top.getElement(".spt_mode");
            var mode = el.value;

            // check-in the changelist
            var changelist = 'default';
            if (mode == 'changelist') {
                var scm_info = spt.scm.run("commit_changelist", [changelist, description]);

                for ( var i = 1; i < scm_info.length-1; i++) {
                    // the first item is the changelist number
                    //console.log(scm_info[i]);

                    var action = scm_info[i];
                    revision = action.rev;
                    revisions.push(revision);

                    // Do an inplace check-in into TACTIC
                    var path = action.depotFile;

                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    var context = process + "/" + filename;

                    var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
                }

            }
            else {

                // check in all of the files
                for ( var i = 0; i < paths.length; i++) {
                    var path = paths[i];
                    var scm_info = spt.scm.run("commit_file", [path, description, editable]);
                    // the first item is the changelist number
                    var action = scm_info[1];
                    revision = action.rev;
                    revisions.push(revision);

                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    var context = process + "/" + filename;

                    //path = path.replace(bvr.sandbox_dir, "//"+bvr.depot);
                    // NOTE: this assumes project == depot
                    path = path.replace(bvr.sandbox_dir, "//");

                    // Do an inplace check-in into TACTIC
                    var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
                }
            }


            if (add_note == 'on') {
                var note = [];
                note.push('CHECK-IN');
                for (var i = 0; i < paths.length; i++) { 
                    var parts = paths[i].split("/");
                    var filename = parts[parts.length-1];
                    note.push(filename+' (v'+revisions[i]+')');
                }
                note.push(': ');
                note.push(description);

                note = note.join(" ");
                server.create_note(bvr.search_key, note, {process: process});
            }
            server.finish({description: "File Check-in ["+paths.length+" file/s]"});
            spt.panel.refresh(top);

            }
            catch(e) {
              spt.error("Error detected: " + e.msg)
              //console.log(e);
              server.abort();
            }

            spt.app_busy.hide();
            '''
            })
        else:
            button.add_behavior(behavior)

        button.add_style("margin-right: auto")
        button.add_style("margin-left: auto")
        button.add_style("margin-top: 20px")
        button.add_style("margin-bottom: 20px")

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

        hidden = HiddenWdg("checkin_type")
        top.add(hidden)
        hidden.add_class("spt_checkin_type")

        grey_out_div = DivWdg()
        top.add(grey_out_div)
        grey_out_div.add_class("spt_publish_disable")
        grey_out_div.add_style("position: absolute")
        grey_out_div.add_style("left: 0px")
        grey_out_div.add_style("top: 10px")
        grey_out_div.add_style("opacity: 0.6")
        grey_out_div.add_color("background", "background")
        grey_out_div.add_style("height: 100%")
        grey_out_div.add_style("width: 100%")
        #grey_out_div.add_border()

        return top
コード例 #2
0
    def handle_dir_or_item(my, item_div, dirname, basename):
        spath = "%s/%s" % (dirname, basename)
        fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename))

        md5 = my.md5s.get(fspath)
        changed = False
        context = None
        error_msg = None
        snapshot = None
        file_obj = my.checked_in_paths.get(fspath)
        if not file_obj:
            if fspath.startswith(my.base_dir):
                rel = fspath.replace("%s/" % my.base_dir, "")
                file_obj = my.checked_in_paths.get(rel)


        if file_obj != None:

            snapshot_code = file_obj.get_value("snapshot_code")
            snapshot = my.snapshots_dict.get(snapshot_code)
            if not snapshot:
                # last resort
                snapshot = file_obj.get_parent()

            if snapshot:
                context = snapshot.get_value("context")
                item_div.add_attr("spt_snapshot_code", snapshot.get_code())

                snapshot_md5 = file_obj.get_value("md5")
                item_div.add_attr("spt_md5", snapshot_md5)
                item_div.add_attr("title", "Checked-in as: %s" % file_obj.get_value("file_name"))

                if md5 and md5 != snapshot_md5:
                    item_div.add_class("spt_changed")
                    changed = True
            else:
                error_msg = 'snapshot not found'

            


        status = None
        if file_obj != None:
            if changed:
                check = IconWdg( "Checked-In", IconWdg.ERROR, width=12 )
                status = "changed"
            else:
                check = IconWdg( "Checked-In", IconWdg.CHECK, width=12 )
                status = "same"
            item_div.add_color("color", "color", [0, 0, 50])

        else:
            check = None
            item_div.add_style("opacity: 0.8")
            status = "unversioned"



        if check:
            item_div.add(check)
            check.add_style("float: left")
            check.add_style("margin-left: -16px")
            check.add_style("margin-top: 4px")


        # add the file name
        filename_div = DivWdg()
        item_div.add(filename_div)
        filename_div.add(basename)
        file_info_div = None
        if snapshot and status != 'unversioned':
            file_info_div = SpanWdg()
            filename_div.add(file_info_div)

        if error_msg:
            filename_div.add(' (%s)'%error_msg)
        filename_div.add_style("float: left")
        filename_div.add_style("overflow: hidden")
        filename_div.add_style("width: 65%")


        # DEPRECATED
        from pyasm.widget import CheckboxWdg, TextWdg, SelectWdg, HiddenWdg
        checkbox = CheckboxWdg("check")
      

        checkbox.add_style("display: none")
        checkbox.add_class("spt_select")
        checkbox.add_style("float: right")
        checkbox.add_style("margin-top: 1px")
        item_div.add(checkbox)

        subcontext_val = ''
        cat_input = None
        is_select = True
        if my.context_options:
            context_sel = SelectWdg("context")
            context_sel.add_attr('title', 'context')
            context_sel.set_option("show_missing", False)
            context_sel.set_option("values", my.context_options)
            item_div.add_attr("spt_context", my.context_options[0]) 
            cat_input = context_sel
            input_cls = 'spt_context'

    
        else:
            if my.subcontext_options in [['(main)'], ['(auto)'] , []]:
                is_select = False
                #subcontext = TextWdg("subcontext")
                subcontext = HiddenWdg("subcontext")
                subcontext.add_class("spt_subcontext")

            elif my.subcontext_options == ['(text)']:
                is_select = False
                subcontext = TextWdg("subcontext")
                subcontext.add_class("spt_subcontext")

            else:
                is_select = True


                subcontext = SelectWdg("subcontext")
                subcontext.set_option("show_missing", False)
                subcontext.set_option("values", my.subcontext_options)
                #subcontext.add_empty_option("----")


            cat_input = subcontext
            input_cls = 'spt_subcontext'
            
          


            if my.subcontext_options == ['(main)'] or my.subcontext_options == ['(auto)']:
                subcontext_val = my.subcontext_options[0]
                subcontext.set_value(subcontext_val)
                item_div.add_attr("spt_subcontext", subcontext_val)
            elif context:
                parts = context.split("/")
                if len(parts) > 1:

                    # get the actual subcontext value
                    subcontext_val = "/".join(parts[1:])

                    # identify a previous "auto" check-in and preselect the item in the select
                    if is_select and subcontext_val not in my.subcontext_options:
                        subcontext_val = '(auto)'

                    elif isinstance(cat_input,  HiddenWdg):
                        subcontext_val =  ''
                    # the Text field will adopt the subcontext value of the last check-in
                    subcontext.set_value(subcontext_val)
                    item_div.add_attr("spt_subcontext", subcontext_val)

            else:
                if is_select:
                    if my.subcontext_options:
                        subcontext_val = my.subcontext_options[0]
                    #subcontext_val = '(auto)'
                    cat_input.set_value(subcontext_val)
                else:
                    subcontext_val = ''
                item_div.add_attr("spt_subcontext", subcontext_val)
        item_div.add(cat_input)


        cat_input.add_behavior( {
                'type': 'click_up',
                'propagate_evt': False,
                'cbjs_action': '''
                bvr.src_el.focus();
                '''
            } )

        cat_input.add_style("display: none") 
        cat_input.add_class("spt_subcontext")
        cat_input.add_style("float: right")
        cat_input.add_style("width: 50px")
        cat_input.add_style("margin-top: -1px")
        cat_input.add_style("font-size: 10px")
        cat_input.add_style("height: 16px")


        # we depend on the attribute cuz sometimes we go by the initialized value 
        # since they are not drawn
        cat_input.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
            var el = bvr.src_el.getParent('.spt_dir_list_item');
            el.setAttribute("%s", bvr.src_el.value);
            ''' %input_cls
        } )


       


        if file_info_div:
            if subcontext_val in ['(auto)','(main)', '']:
                file_info_div.add(" <i style='font-size: 9px; opacity: 0.6'>(v%s)</i>" % snapshot.get_value("version") )
            else:
                file_info_div.add(" <i style='font-size: 9px; opacity: 0.6'>(v%s - %s)</i>" % (snapshot.get_value("version"), subcontext_val) )
コード例 #3
0
ファイル: scm_dir_list_wdg.py プロジェクト: blezek/TACTIC
    def get_display(my):

        my.sobject = my.kwargs.get("sobject")
        search_key = my.sobject.get_search_key()

        top = DivWdg()
        top.add_class("spt_checkin_publish")
        top.add_style("padding: 10px")

        margin_top = '60px'
        top.add_style("margin-top", margin_top)
        top.add_style("position: relative")


        current_changelist = WidgetSettings.get_value_by_key("current_changelist")
        current_branch = WidgetSettings.get_value_by_key("current_branch")
        current_workspace = WidgetSettings.get_value_by_key("current_workspace")

        top.add("Branch: %s<br/>" % current_branch)
        top.add("Changelist: %s<br/>" % current_changelist)
        top.add("Workspace: %s<br/>" % current_workspace)
        top.add("<br/>")


        checked_out_div = DivWdg()
        checkbox = CheckboxWdg("editable")
        top.add(checked_out_div)
        checkbox.add_class("spt_checkin_editable")
        checked_out_div.add(checkbox)
        checked_out_div.add("Leave files editable")

        top.add("<br/>")

        top.add("Publish Description<br/>")
        text = TextAreaWdg("description")
        # this needs to be set or it will stick out to the right
        text.add_style("width: 220px")
        text.add_class("spt_checkin_description")
        top.add(text)


        # add as a note
        note_div = DivWdg()
        top.add(note_div)
        note_div.add_class("spt_add_note")
        checkbox = CheckboxWdg("add_note")

        web = WebContainer.get_web()
        browser = web.get_browser()
        if browser in ['Qt']:
            checkbox.add_style("margin-top: -4px")
            checkbox.add_style("margin-right: 3px")
            note_div.add_style("margin-top: 3px")



        checkbox.add_class("spt_checkin_add_note")
        note_div.add(checkbox)
        note_div.add("Also add as note")

        top.add("<br/><br/>")


        button = ActionButtonWdg(title="Check-in", icon=IconWdg.PUBLISH, size='medium')
        top.add(button)

        my.repo_type = 'perforce'
        if my.repo_type == 'perforce':

            # the depot is set per project (unless overridden)
            project = my.sobject.get_project()
            depot = project.get_value("location", no_exception=True)
            if not depot:
                depot = project.get_code()

            asset_dir = Environment.get_asset_dir()
            sandbox_dir = Environment.get_sandbox_dir()
           
            changelist = WidgetSettings.get_value_by_key("current_changelist")
            button.add_behavior( {
            'type': 'click_up',
            'depot': depot,
            'changelist': changelist,
            'sandbox_dir': sandbox_dir,
            'search_key': search_key,
            'cbjs_action': '''

            var paths = spt.checkin.get_selected_paths();
            spt.app_busy.show("Checking in "+paths.length+" file/s into Perforce");
            var top = bvr.src_el.getParent(".spt_checkin_top");
            var description = top.getElement(".spt_checkin_description").value;
            var add_note = top.getElement(".spt_checkin_add_note").value;
            var editable = top.getElement(".spt_checkin_editable").value;

            if (editable == 'on') {
                editable = true;
            }
            else {
                editable = false;
            }

            var process = top.getElement(".spt_checkin_process").value;

            // check into TACTIC
            var server = TacticServerStub.get();

            var revisions = [];
            server.start({description: "File Check-in"});

            try {

            var top = bvr.src_el.getParent(".spt_checkin_top");
            var el = top.getElement(".spt_mode");
            var mode = el.value;

            // check-in the changelist
            var changelist = 'default';
            if (mode == 'changelist') {
                var scm_info = spt.scm.run("commit_changelist", [changelist, description]);

                for ( var i = 1; i < scm_info.length-1; i++) {
                    // the first item is the changelist number
                    //console.log(scm_info[i]);

                    var action = scm_info[i];
                    revision = action.rev;
                    revisions.push(revision);

                    // Do an inplace check-in into TACTIC
                    var path = action.depotFile;

                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    var context = process + "/" + filename;

                    var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
                }

            }
            else {

                // check in all of the files
                for ( var i = 0; i < paths.length; i++) {
                    var path = paths[i];
                    var scm_info = spt.scm.run("commit_file", [path, description, editable]);
                    // the first item is the changelist number
                    var action = scm_info[1];
                    revision = action.rev;
                    revisions.push(revision);

                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    var context = process + "/" + filename;

                    //path = path.replace(bvr.sandbox_dir, "//"+bvr.depot);
                    // NOTE: this assumes project == depot
                    path = path.replace(bvr.sandbox_dir, "//");

                    // Do an inplace check-in into TACTIC
                    var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
                }
            }


            if (add_note == 'on') {
                var note = [];
                note.push('CHECK-IN');
                for (var i = 0; i < paths.length; i++) { 
                    var parts = paths[i].split("/");
                    var filename = parts[parts.length-1];
                    note.push(filename+' (v'+revisions[i]+')');
                }
                note.push(': ');
                note.push(description);

                note = note.join(" ");
                server.create_note(bvr.search_key, note, {process: process});
            }
            server.finish({description: "File Check-in ["+paths.length+" file/s]"});
            spt.panel.refresh(top);

            }
            catch(e) {
              spt.error("Error detected: " + e.msg)
              //console.log(e);
              server.abort();
            }

            spt.app_busy.hide();
            '''
            } )
        else:
            button.add_behavior(behavior)





        button.add_style("margin-right: auto")
        button.add_style("margin-left: auto")
        button.add_style("margin-top: 20px")
        button.add_style("margin-bottom: 20px")



        top.add("<br clear='all'/>")
        top.add("<hr/>")
 
        hidden = HiddenWdg("checkin_type")
        top.add(hidden)
        hidden.add_class("spt_checkin_type")


        grey_out_div = DivWdg()
        top.add(grey_out_div)
        grey_out_div.add_class("spt_publish_disable")
        grey_out_div.add_style("position: absolute")
        grey_out_div.add_style("left: 0px")
        grey_out_div.add_style("top: 10px")
        grey_out_div.add_style("opacity: 0.6")
        grey_out_div.add_color("background", "background")
        grey_out_div.add_style("height: 100%")
        grey_out_div.add_style("width: 100%")
        #grey_out_div.add_border()



        return top
コード例 #4
0
ファイル: collection_wdg.py プロジェクト: asmboom/TACTIC
    def get_display(my):
        search_type = my.kwargs.get("search_type")

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return my.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        top = my.top
        top.add_class("spt_dialog")
        button = IconButtonWdg(title='Add to Collection', icon="BS_TH_LARGE", show_arrow=True)
        top.add(button)

        detail_wdg = DivWdg()
        top.add(detail_wdg)

        dialog = DialogWdg()
        top.add(dialog)
        
        dialog.set_as_activator(button, offset={'x':-25,'y': 0})
        dialog.add_title("Collections")

        dialog.add("<div style='margin: 10px'><b>Add selected items to a collection</b></div>")

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")


        insert_view = "edit_collection"

        add_div.add_behavior( {
            'type': 'click_up',
            'insert_view': insert_view,
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Add New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        } )

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");
            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''
        filters = []
        filters.append(("_is_collection",True))
        filters.append(("status","Verified"))
        text = LookAheadTextInputWdg(
            search_type = "workflow/asset",
            column="name",
            icon="BS_SEARCH",
            icon_pos="right",
            width="100%",
            hint_text="'Enter' to search for Colllection...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True
        )
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()


            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")

            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )


            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key() )

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")


        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior( {
            'type': 'click',
            'cbjs_action': '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No assets selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;

            var dialog_top = bvr.src_el.getParent(".spt_dialog_top");

            for (i = 0; i < checkboxes.length; i++) {
                var checked_collection_attr = checkboxes[i].attributes;
                var collection_key = checked_collection_attr[3].value;
                // Preventing a collection being added to itself, check if search_keys contain collection_key.
                if (search_keys.indexOf(collection_key) != -1) {
                    spt.notify.show_message("Collection cannot be added to itself.");
                    return;
                }

                if (checkboxes[i].checked == true) {
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    var search_keys = spt.table.get_selected_search_keys(false);
                    var kwargs = {
                        collection_key: collection_key,
                        search_keys: search_keys
                    }
                    server.execute_cmd(cmd, kwargs);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
                return;
            }
            else {
                spt.notify.show_message("Assets added to Collection.");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        } )
        

        return top
コード例 #5
0
ファイル: tile_layout_wdg.py プロジェクト: blezek/TACTIC
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 16px")


        detail_div = DivWdg()
        div.add(detail_div)
        detail_div.add_class("spt_tile_detail")
        detail_div.add_style("float: right")
        detail_div.add_style("margin-top: -2px")

        detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
        detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        header_div.add_class("hand")
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")

        title = sobject.get_name()
        if not title:
            title = sobject.get_code()
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div
コード例 #6
0
    def get_display(my):

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

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return my.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        dialog = DivWdg()
        my.set_as_panel(dialog)
        dialog.add_class('spt_col_dialog_top')

        title_div = DivWdg()
        title_div.add_style('margin: 10px')
        title_div.add(HtmlElement.b("Add selected items to collection(s)"))
        dialog.add(title_div)

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")

        insert_view = "edit_collection"

        add_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'refresh_col_dialog',
            'cbjs_action':
            '''
                var dialog_content = bvr.src_el.getParent('.spt_col_dialog_top');
                spt.panel.refresh(dialog_content);
            '''
        })

        add_div.add_behavior({
            'type':
            'click_up',
            'insert_view':
            insert_view,
            'event_name':
            'refresh_col_dialog',
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Create New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        })

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");
            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''
        filters = []
        filters.append(("_is_collection", True))
        filters.append(("status", "Verified"))
        text = LookAheadTextInputWdg(
            search_type="workflow/asset",
            column="name",
            icon="BS_SEARCH",
            icon_pos="right",
            width="100%",
            height="30px",
            hint_text="'Enter' to search for Colllection...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True)
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()

            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")

            #TODO: add some interaction with this arrow
            # icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            # go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )

            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            #collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key())

            check.add_attr("collection_name", collection.get_name())

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")

        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior({
            'type':
            'click',
            'cbjs_action':
            '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No items selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;
            var added = [];
            var collection_keys = [];
            
            var dialog_top = bvr.src_el.getParent(".spt_col_dialog_top");
            
            for (i = 0; i < checkboxes.length; i++) {

                if (checkboxes[i].checked == true) {
                    var collection_key = checkboxes[i].getAttribute('collection_key');
                    var collection_name = checkboxes[i].getAttribute('collection_name');
                    
                    
                    // Preventing a collection being added to itself, check if search_keys contain collection_key.
                    if (search_keys.indexOf(collection_key) != -1) {
                        spt.notify.show_message("Collection [" + collection_name + " ] cannot be added to itself.");
                        return;
                    }
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    // If the collection is not being added to itself, append to the list of collection keys
                    collection_keys.push(collection_key);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
            }
            else {
                var kwargs = {
                    collection_keys: collection_keys,
                    search_keys: search_keys
                }
                var rtn = server.execute_cmd(cmd, kwargs);
                var rtn_message = rtn.info.message;

                if (rtn_message['circular'] == 'True') {
                    var parent_collection_names = rtn_message['parent_collection_names'].join(", ");
                    spt.notify.show_message("Collection [" + collection_name + " ] is a child of the source [" + parent_collection_names + "]");
                    
                    return;
                }
                for (var collection_name in rtn_message) {
                    if (rtn_message[collection_name] != 'No insert')
                        added.push(collection_name);
                }

                if (added.length == 0)
                    spt.notify.show_message("Items already added to Collection.");
                else 
                    spt.notify.show_message("Items added to Collection [ " + added.join(', ') + " ].");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        })

        return dialog
コード例 #7
0
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 20px")


        if sobject.get_base_search_type() not in ["sthpw/snapshot"]:
            detail_div = DivWdg()
            div.add(detail_div)
            detail_div.add_class("spt_tile_detail")
            detail_div.add_style("float: right")
            detail_div.add_style("margin-top: -2px")

            #detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
            detail = IconButtonWdg(title="Detail", icon="BS_SEARCH")
            detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        #header_div.add_attr("title",'[ draggable ]')
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")
        header_div.add_style("overflow-y: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")
        # to prevent clicking on the checkbox directly and not turning on the yellow border
        #checkbox.add_attr("disabled","disabled")

        title_expr = my.kwargs.get("title_expr")
        if title_expr:
            title = Search.eval(title_expr, sobject, single=True)
        elif sobject.get_base_search_type() == "sthpw/snapshot":
            title = sobject.get_value("context")
        else:
            title = sobject.get_value("name", no_exception=True)
        if not title:
            title = sobject.get_value("code", no_exception=True)
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")
        title_div.add_class("hand")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div
コード例 #8
0
ファイル: loader_element_wdg.py プロジェクト: 0-T-0/TACTIC
    def get_display(my):
        my.init_kwargs()
        sobject = my.get_current_sobject()

        table = Table(css='minimal')
        table.add_color("color", "color")
        table.add_style("font-size: 0.9em")

       
        
        snapshots = my.get_snapshot(my.mode)
        for snapshot in snapshots:
            table.add_row()

            value = my.get_input_value(sobject, snapshot)

            current_version = snapshot.get_value("version")
            current_context = snapshot.get_value("context")
            current_revision = snapshot.get_value("revision", no_exception=True)
            current_snapshot_type = snapshot.get_value("snapshot_type")

            # hack hard coded type translation
            if current_snapshot_type == "anim_export":
                current_snapshot_type = "anim"

            # ignore icon context completely
            if current_context == "icon":
                table.add_blank_cell()
                table.add_cell("(---)")
                return table

            checkbox = CheckboxWdg('%s_%s' %(my.search_type, my.CB_NAME))
            
            # this is added back in for now to work with 3.7 Fast table
            checkbox.add_behavior({'type': 'click_up',
            'propagate_evt': True})

            checkbox.add_class('spt_latest_%s' %my.mode)
            checkbox.set_option("value", value )
            table.add_cell( checkbox )

            load_all = False
            if load_all:
                checkbox.set_checked()


            # add the file type icon
            xml = snapshot.get_snapshot_xml()
            file_name = xml.get_value("snapshot/file/@name")
            icon_link = ThumbWdg.find_icon_link(file_name)
            image = HtmlElement.img(icon_link)
            image.add_style("width: 15px")
            table.add_cell(image)

            namespace = my.get_namespace(sobject, snapshot) 
            asset_code = my.get_asset_code()
          
            # force asset mode = True   
            my.session.set_asset_mode(asset_mode=my.get_session_asset_mode())
            node_name = my.get_node_name(snapshot, asset_code, namespace)
            # get session info
            session_context = session_version = session_revision = None
            if my.session:
                
                session_context = my.session.get_context(node_name, asset_code, current_snapshot_type)
                session_version = my.session.get_version(node_name, asset_code, current_snapshot_type)
                session_revision = my.session.get_revision(node_name, asset_code,current_snapshot_type)


                # Maya Specific: try with namespace in front of it for referencing
                referenced_name = '%s:%s' %(namespace, node_name)
                if not session_context or not session_version:
                    session_context = my.session.get_context(referenced_name, asset_code, current_snapshot_type)
                    session_version = my.session.get_version(referenced_name, asset_code, current_snapshot_type)
                    session_revision = my.session.get_revision(referenced_name, asset_code, current_snapshot_type)

            from version_wdg import CurrentVersionContextWdg, SubRefWdg

            version_wdg = CurrentVersionContextWdg()
            data = {'session_version': session_version, \
                'session_context': session_context,  \
                'session_revision': session_revision,  \
                'current_context': current_context, \
                'current_version': current_version, \
                'current_revision': current_revision }
            version_wdg.set_options(data)
            
            table.add_cell(version_wdg, "no_wrap")
            td = table.add_cell(HtmlElement.b("(%s)" %current_context))
            td.add_tip("Snapshot code: %s" % snapshot.get_code())
            #table.add_cell(snapshot.get_code() )

            #if snapshot.is_current():
            #    current = IconWdg("current", IconWdg.CURRENT)
            #    table.add_cell(current)
            #else:
            #    table.add_blank_cell()


            # handle subreferences
            has_subreferences = True
            xml = snapshot.get_xml_value("snapshot")
            refs = xml.get_nodes("snapshot/file/ref")
            if my.mode == "output" and refs:
                table.add_row()
                td = table.add_cell()
                swap = SwapDisplayWdg.get_triangle_wdg()
                td.add(swap)
                td.add("[ %s reference(s)" % len(refs))
                #td.add_style("text-align: right")

                sub_ref_wdg = SubRefWdg()
                sub_ref_wdg.set_info(snapshot, my.session, namespace)
                swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id() )

                status = sub_ref_wdg.get_overall_status()
                td.add(SpanWdg(VersionWdg.get(status), css='small_left'))
                td.add(']')
             
                td.add( sub_ref_wdg )
                td.add_style('padding-left: 10px')



        #else:
        if not snapshots:
            table.add_row()
            table.add_blank_cell()
            table.add_cell("(---)")

        return table
コード例 #9
0
ファイル: loader_element_wdg.py プロジェクト: 0-T-0/TACTIC
    def get_bottom_wdg(my):
        if my.get_option('mode') =='input':
            return 
        web = WebContainer.get_web()
        if web.get_selected_app() not in ['XSI','Maya']:
            return
        div = DivWdg(css='spt_outdated_ref')
       

        refs = my.session.get_data().get_nodes("session/node/ref")
        snap_codes = []
        snap_contexts = []
        sobjects = []
        session_data_dict = {}
        asset_codes = []
        current_snapshots = []
        node_names = []
        session_versions = []
        for ref in refs:
            snap_code = Xml.get_attribute(ref, "asset_snapshot_code")
            node_name = Xml.get_attribute(ref, "name")
            version = Xml.get_attribute(ref, "asset_snapshot_version")
            asset_code = Xml.get_attribute(ref, "asset_code")
            if snap_code in snap_codes:
                continue
            snap_codes.append(snap_code)
            snap_contexts.append(Xml.get_attribute(ref, "asset_snapshot_context"))
            asset_codes.append(asset_code)
            session_data_dict[snap_code] = version, node_name  
        
        
        # must search one by one
        warnings=[]
        for idx, snap_code in enumerate(snap_codes):
            snapshot = Snapshot.get_by_code(snap_code)
            if not snapshot:
                continue
            search_type = snapshot.get_value('search_type')
            search_id = snapshot.get_value('search_id')
            sk = SearchKey.build_search_key(search_type, search_id, column='id')
            current_snapshot = Snapshot.get_snapshot(search_type, search_id, context=snap_contexts[idx], version=0)
            if not current_snapshot:
                warnings.append("Current version for [%s] context [%s] not found" %(sk, snap_contexts[idx]))
                continue
            session_version, node_name  = session_data_dict.get(snap_code)
            if session_version and int(current_snapshot.get_version()) > int(session_version):
                current_snapshots.append(current_snapshot)
                sobjects.append(current_snapshot.get_sobject())
                node_names.append(node_name)
                session_versions.append(int(session_version))
        

        title = DivWdg('Outdated References')
        title.add_style('text-decoration','underline')
        div.add(title)

        # draw the nodes to be udpated
        for idx, current_snap in enumerate(current_snapshots):
            
            cb = CheckboxWdg(my.REF_CB_NAME)
            cb.add_class('spt_ref')
            cb.add_style('display: none')
            sobj = sobjects[idx]
            node_name = node_names[idx]
            session_version = session_versions[idx]
            snapshot = current_snap
            cb_value = my.get_input_value(sobj, snapshot)
            items = cb_value.split('|')
            items[-1] = node_name
            cb_value = '|'.join(items)
            cb.set_option('value', cb_value)
            div.add(cb)
            div.add('%0.1d. %s v%0.3d -> v%0.3d\n' \
                %(idx+1, node_name, session_version, snapshot.get_version()))
            div.add(HtmlElement.br())

        for warning in warnings:
            div.add(SpanWdg(warning, css='warning'))
        div.add(HtmlElement.br())

        if current_snapshots:
            # add the button
            prefix = my.search_type
            #input_name = '%s_%s' %(my.search_type, my.CB_NAME)
            update_button = ProdIconButtonWdg("Update all references")
            update_button.add_behavior({'type': "click_up",\
            'cbjs_action': '''var cousins = bvr.src_el.getParent('.spt_outdated_ref').getElements('.spt_ref');
                             cousins.each( function(x) {x.checked=true;}); py_replace_reference(bvr, '%s','%s')'''
                    % (prefix, my.REF_CB_NAME)})
            div.add( SpanWdg(update_button, css='small'))
       
        div.add(HtmlElement.br(2))
        return div
コード例 #10
0
    def get_bottom_wdg(my):
        if my.get_option('mode') == 'input':
            return
        web = WebContainer.get_web()
        if web.get_selected_app() not in ['XSI', 'Maya']:
            return
        div = DivWdg(css='spt_outdated_ref')

        refs = my.session.get_data().get_nodes("session/node/ref")
        snap_codes = []
        snap_contexts = []
        sobjects = []
        session_data_dict = {}
        asset_codes = []
        current_snapshots = []
        node_names = []
        session_versions = []
        for ref in refs:
            snap_code = Xml.get_attribute(ref, "asset_snapshot_code")
            node_name = Xml.get_attribute(ref, "name")
            version = Xml.get_attribute(ref, "asset_snapshot_version")
            asset_code = Xml.get_attribute(ref, "asset_code")
            if snap_code in snap_codes:
                continue
            snap_codes.append(snap_code)
            snap_contexts.append(
                Xml.get_attribute(ref, "asset_snapshot_context"))
            asset_codes.append(asset_code)
            session_data_dict[snap_code] = version, node_name

        # must search one by one
        warnings = []
        for idx, snap_code in enumerate(snap_codes):
            snapshot = Snapshot.get_by_code(snap_code)
            if not snapshot:
                continue
            search_type = snapshot.get_value('search_type')
            search_id = snapshot.get_value('search_id')
            sk = SearchKey.build_search_key(search_type,
                                            search_id,
                                            column='id')
            current_snapshot = Snapshot.get_snapshot(
                search_type, search_id, context=snap_contexts[idx], version=0)
            if not current_snapshot:
                warnings.append(
                    "Current version for [%s] context [%s] not found" %
                    (sk, snap_contexts[idx]))
                continue
            session_version, node_name = session_data_dict.get(snap_code)
            if session_version and int(
                    current_snapshot.get_version()) > int(session_version):
                current_snapshots.append(current_snapshot)
                sobjects.append(current_snapshot.get_sobject())
                node_names.append(node_name)
                session_versions.append(int(session_version))

        title = DivWdg('Outdated References')
        title.add_style('text-decoration', 'underline')
        div.add(title)

        # draw the nodes to be udpated
        for idx, current_snap in enumerate(current_snapshots):

            cb = CheckboxWdg(my.REF_CB_NAME)
            cb.add_class('spt_ref')
            cb.add_style('display: none')
            sobj = sobjects[idx]
            node_name = node_names[idx]
            session_version = session_versions[idx]
            snapshot = current_snap
            cb_value = my.get_input_value(sobj, snapshot)
            items = cb_value.split('|')
            items[-1] = node_name
            cb_value = '|'.join(items)
            cb.set_option('value', cb_value)
            div.add(cb)
            div.add('%0.1d. %s v%0.3d -> v%0.3d\n' \
                %(idx+1, node_name, session_version, snapshot.get_version()))
            div.add(HtmlElement.br())

        for warning in warnings:
            div.add(SpanWdg(warning, css='warning'))
        div.add(HtmlElement.br())

        if current_snapshots:
            # add the button
            prefix = my.search_type
            #input_name = '%s_%s' %(my.search_type, my.CB_NAME)
            update_button = ProdIconButtonWdg("Update all references")
            update_button.add_behavior({'type': "click_up",\
            'cbjs_action': '''var cousins = bvr.src_el.getParent('.spt_outdated_ref').getElements('.spt_ref');
                             cousins.each( function(x) {x.checked=true;}); py_replace_reference(bvr, '%s','%s')'''
                    % (prefix, my.REF_CB_NAME)})
            div.add(SpanWdg(update_button, css='small'))

        div.add(HtmlElement.br(2))
        return div
コード例 #11
0
    def get_display(my):
        my.init_kwargs()
        sobject = my.get_current_sobject()

        table = Table(css='minimal')
        table.add_color("color", "color")
        table.add_style("font-size: 0.9em")

        snapshots = my.get_snapshot(my.mode)
        for snapshot in snapshots:
            table.add_row()

            value = my.get_input_value(sobject, snapshot)

            current_version = snapshot.get_value("version")
            current_context = snapshot.get_value("context")
            current_revision = snapshot.get_value("revision",
                                                  no_exception=True)
            current_snapshot_type = snapshot.get_value("snapshot_type")

            # hack hard coded type translation
            if current_snapshot_type == "anim_export":
                current_snapshot_type = "anim"

            # ignore icon context completely
            if current_context == "icon":
                table.add_blank_cell()
                table.add_cell("(---)")
                return table

            checkbox = CheckboxWdg('%s_%s' % (my.search_type, my.CB_NAME))

            # this is added back in for now to work with 3.7 Fast table
            checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True})

            checkbox.add_class('spt_latest_%s' % my.mode)
            checkbox.set_option("value", value)
            table.add_cell(checkbox)

            load_all = False
            if load_all:
                checkbox.set_checked()

            # add the file type icon
            xml = snapshot.get_snapshot_xml()
            file_name = xml.get_value("snapshot/file/@name")
            icon_link = ThumbWdg.find_icon_link(file_name)
            image = HtmlElement.img(icon_link)
            image.add_style("width: 15px")
            table.add_cell(image)

            namespace = my.get_namespace(sobject, snapshot)
            asset_code = my.get_asset_code()

            # force asset mode = True
            my.session.set_asset_mode(asset_mode=my.get_session_asset_mode())
            node_name = my.get_node_name(snapshot, asset_code, namespace)
            # get session info
            session_context = session_version = session_revision = None
            if my.session:

                session_context = my.session.get_context(
                    node_name, asset_code, current_snapshot_type)
                session_version = my.session.get_version(
                    node_name, asset_code, current_snapshot_type)
                session_revision = my.session.get_revision(
                    node_name, asset_code, current_snapshot_type)

                # Maya Specific: try with namespace in front of it for referencing
                referenced_name = '%s:%s' % (namespace, node_name)
                if not session_context or not session_version:
                    session_context = my.session.get_context(
                        referenced_name, asset_code, current_snapshot_type)
                    session_version = my.session.get_version(
                        referenced_name, asset_code, current_snapshot_type)
                    session_revision = my.session.get_revision(
                        referenced_name, asset_code, current_snapshot_type)

            from version_wdg import CurrentVersionContextWdg, SubRefWdg

            version_wdg = CurrentVersionContextWdg()
            data = {'session_version': session_version, \
                'session_context': session_context,  \
                'session_revision': session_revision,  \
                'current_context': current_context, \
                'current_version': current_version, \
                'current_revision': current_revision }
            version_wdg.set_options(data)

            table.add_cell(version_wdg, "no_wrap")
            td = table.add_cell(HtmlElement.b("(%s)" % current_context))
            td.add_tip("Snapshot code: %s" % snapshot.get_code())
            #table.add_cell(snapshot.get_code() )

            #if snapshot.is_current():
            #    current = IconWdg("current", IconWdg.CURRENT)
            #    table.add_cell(current)
            #else:
            #    table.add_blank_cell()

            # handle subreferences
            has_subreferences = True
            xml = snapshot.get_xml_value("snapshot")
            refs = xml.get_nodes("snapshot/file/ref")
            if my.mode == "output" and refs:
                table.add_row()
                td = table.add_cell()
                swap = SwapDisplayWdg.get_triangle_wdg()
                td.add(swap)
                td.add("[ %s reference(s)" % len(refs))
                #td.add_style("text-align: right")

                sub_ref_wdg = SubRefWdg()
                sub_ref_wdg.set_info(snapshot, my.session, namespace)
                swap.add_action_script(
                    sub_ref_wdg.get_on_script(),
                    "toggle_display('%s')" % sub_ref_wdg.get_top_id())

                status = sub_ref_wdg.get_overall_status()
                td.add(SpanWdg(VersionWdg.get(status), css='small_left'))
                td.add(']')

                td.add(sub_ref_wdg)
                td.add_style('padding-left: 10px')

        #else:
        if not snapshots:
            table.add_row()
            table.add_blank_cell()
            table.add_cell("(---)")

        return table
コード例 #12
0
ファイル: collection_wdg.py プロジェクト: mincau/TACTIC
    def get_display(self):
       
        search_type = self.kwargs.get("search_type")

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return self.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        
        dialog = DivWdg()
        self.set_as_panel(dialog)
        dialog.add_class('spt_col_dialog_top')

        title_div = DivWdg()
        title_div.add_style('margin: 10px')
        title_div.add(HtmlElement.b("Add selected items to collection(s)"))
        dialog.add(title_div)

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")


        insert_view = "edit_collection"

        add_div.add_behavior( {
            'type': 'listen',
            'event_name': 'refresh_col_dialog',
            'cbjs_action': '''
                var dialog_content = bvr.src_el.getParent('.spt_col_dialog_top');
                spt.panel.refresh(dialog_content);
            '''})

        add_div.add_behavior( {
            'type': 'click_up',
            'insert_view': insert_view,
            'event_name': 'refresh_col_dialog',
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Create New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        } )

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            var no_results_el = top.getElement(".spt_no_results");

            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].getElement(".spt_collection_checkbox").getAttribute("collection_name").toLowerCase();
                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, show "no_results_el"
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "none";
                }
                no_results_el.style.display = "block";
            }
            else {
                no_results_el.style.display = "none";
            }

        '''
        filters = []
        filters.append(("_is_collection",True))
        filters.append(("status","Verified"))
        text = LookAheadTextInputWdg(
            search_type = "workflow/asset",
            column="name",
            icon_pos="right",
            width="100%",
            height="30px",
            hint_text="Filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True,
            validate='false'
        )
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        no_results_div = DivWdg()
        content_div.add(no_results_div)

        no_results_div.add_color("color", "color", 50)
        no_results_div.add_style("font: normal bold 1.1em arial,serif")
        no_results_div.add("No collections found.")
        no_results_div.add_style("display: none")
        no_results_div.add_style("margin: 10px 0px 0px 10px")
        no_results_div.add_class("spt_no_results")

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()


            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")
        
            #TODO: add some interaction with this arrow
            # icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            # go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )


            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            #collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key() )
            
            check.add_attr("collection_name", collection.get_name() )

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")


        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior( {
            'type': 'click',
            'cbjs_action': '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No items selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;
            var added = [];
            var collection_keys = [];
            
            var dialog_top = bvr.src_el.getParent(".spt_col_dialog_top");
            
            for (i = 0; i < checkboxes.length; i++) {

                if (checkboxes[i].checked == true) {
                    var collection_key = checkboxes[i].getAttribute('collection_key');
                    var collection_name = checkboxes[i].getAttribute('collection_name');
                    
                    
                    // Preventing a collection being added to itself, check if search_keys contain collection_key.
                    if (search_keys.indexOf(collection_key) != -1) {
                        spt.notify.show_message("Collection [" + collection_name + " ] cannot be added to itself.");
                        return;
                    }
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    // If the collection is not being added to itself, append to the list of collection keys
                    collection_keys.push(collection_key);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
            }
            else {
                var kwargs = {
                    collection_keys: collection_keys,
                    search_keys: search_keys
                }
                var rtn = server.execute_cmd(cmd, kwargs);
                var rtn_message = rtn.info.message;

                if (rtn_message['circular'] == 'True') {
                    var parent_collection_names = rtn_message['parent_collection_names'].join(", ");
                    spt.notify.show_message("Collection [" + collection_name + " ] is a child of the source [" + parent_collection_names + "]");
                    
                    return;
                }
                for (var collection_name in rtn_message) {
                    if (rtn_message[collection_name] != 'No insert')
                        added.push(collection_name);
                }

                if (added.length == 0)
                    spt.notify.show_message("Items already added to Collection.");
                else 
                    spt.notify.show_message("Items added to Collection [ " + added.join(', ') + " ].");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        } )
        

        return dialog
コード例 #13
0
ファイル: tile_layout_wdg.py プロジェクト: mwx1993/TACTIC
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 20px")


        if sobject.get_base_search_type() not in ["sthpw/snapshot"]:
            detail_div = DivWdg()
            div.add(detail_div)
            detail_div.add_class("spt_tile_detail")
            detail_div.add_style("float: right")
            detail_div.add_style("margin-top: -2px")

            #detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
            detail = IconButtonWdg(title="Detail", icon="BS_SEARCH")
            detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        #header_div.add_attr("title",'[ draggable ]')
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")
        header_div.add_style("overflow-y: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")
        # to prevent clicking on the checkbox directly and not turning on the yellow border
        #checkbox.add_attr("disabled","disabled")

        title_expr = my.kwargs.get("title_expr")
        if title_expr:
            title = Search.eval(title_expr, sobject, single=True)
        elif sobject.get_base_search_type() == "sthpw/snapshot":
            title = sobject.get_value("context")
        else:
            title = sobject.get_value("name", no_exception=True)
        if not title:
            title = sobject.get_value("code", no_exception=True)
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")
        title_div.add_class("hand")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div
コード例 #14
0
ファイル: tile_layout_wdg.py プロジェクト: hellios78/TACTIC
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 16px")


        detail_div = DivWdg()
        div.add(detail_div)
        detail_div.add_class("spt_tile_detail")
        detail_div.add_style("float: right")
        detail_div.add_style("margin-top: -2px")

        detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
        detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        header_div.add_class("hand")
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")

        title = sobject.get_name()
        if not title:
            title = sobject.get_code()
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div