Changeset 919c17


Ignore:
Timestamp:
Jan 13, 2009, 1:04:25 AM (13 years ago)
Author:
rene <rene@…>
Branches:
lite_0.1, multiEdit, ng_0.6, ng_0.6_help, ng_0.8, ng_0.9
Children:
774108
Parents:
771a68
Message:

repaired filter

Location:
chrome/content/v_identity
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_rdfDataTree.js

    r771a68 r919c17  
    3737
    3838
    39 function rdfDataTree(sourceName) {
    40     this.treeElem = document.getElementById("rdfDataTree_" + sourceName);
     39function rdfDataTree(treeType) {
     40    this.treeType = treeType;
    4141    this.filterText = "";
     42    this.loadTable();
    4243}
    4344rdfDataTree.prototype = {
    4445    idTable : null,
    4546    idData : null,
    46     treeElem : null,
    4747    filterText : null,
     48    treeType : null,
     49
     50    get treeElem() { return document.getElementById("rdfDataTree_" + this.treeType); },
     51    get tabElem() { return document.getElementById(this.treeType + "Tab"); },
    4852   
    4953    //this function is called every time the tree is sorted, filtered, or reloaded
    50     loadTable : function(container) {
     54    loadTable : function() {
    5155        //remember scroll position. this is useful if this is an editable table
    5256        //to prevent the user from losing the row they edited
     
    5559        if (this.idData == null) {
    5660            this.idData = [];
    57             vI_rdfDatasource.readAllEntriesFromRDF(container, this);
     61            vI_rdfDatasource.readAllEntriesFromRDF(this.addNewDatum, this.treeType, this.idData);
    5862        }
    5963        if (this.filterText == "") {
     
    6266        } else {
    6367            //filter out the ones we want to display
    64             this.idTable = [];
     68            var curTable = [];
     69            var curFilterText = this.filterText;
    6570            this.idData.forEach(function(element) {
    6671                //we'll match on every property
    6772                for (var i in element) {
    68                     if (prepareForComparison(element[i]).indexOf(this.filterText) != -1) {
    69                         this.idTable.push(element);
     73                    if (prepareForComparison(element[i]).indexOf(curFilterText) != -1) {
     74                        curTable.push(element);
    7075                        break;
    7176                    }
    7277                }
    7378            });
     79            this.idTable = curTable;
    7480        }   
    7581        this.sort();
     82       
    7683        //restore scroll position
    7784        if (topVisibleRow) {
    7885            this.treeElem.treeBoxObject.scrollToRow(topVisibleRow);
    7986        }
     87
     88        // set Tab label
     89        this.tabElem.setAttribute("label", this.treeType + " (" + this.idTable.length + ")");
    8090    },
    8191
     
    133143            .getService(Components.interfaces.nsIPromptService),
    134144
     145    treeTypes : Array("email", "maillist", "newsgroup", "filter"),
     146
    135147    trees : {},
    136148    tabbox : null,
     
    139151   
    140152    onselect : function () {
    141 vI_notificationBar.dump("## onselect " + vI_rdfDataTree.tabbox.selectedPanel.id + ".\n");
    142153        var tree = vI_rdfDataTree.trees[vI_rdfDataTree.tabbox.selectedPanel.id];
    143154        var htmlBox = document.getElementById("vI_rdfDataTreeInfoBox")
     
    171182        vI_storageExtrasHelper.hideUnusedTreeCols(); // XXX what happens heree ?? :)
    172183       
    173         vI_rdfDataTree.trees["email"] = new rdfDataTree("email");
    174         vI_rdfDataTree.trees["email"].loadTable(vI_rdfDatasource.emailContainer);
    175         vI_rdfDataTree.trees["maillist"] = new rdfDataTree("maillist");
    176         vI_rdfDataTree.trees["maillist"].loadTable(vI_rdfDatasource.maillistContainer);
    177         vI_rdfDataTree.trees["newsgroup"] = new rdfDataTree("newsgroup");
    178         vI_rdfDataTree.trees["newsgroup"].loadTable(vI_rdfDatasource.newsgroupContainer);
    179         vI_rdfDataTree.trees["filter"] = new rdfDataTree("filter");
    180         vI_rdfDataTree.trees["filter"].loadTable(vI_rdfDatasource.filterContainer);
     184        for each (var treeType in vI_rdfDataTree.treeTypes) {
     185            vI_rdfDataTree.trees[treeType] = new rdfDataTree(treeType);
     186        }
    181187    },
    182188   
     
    204210        this.getCellProperties = function(row,col,props){};
    205211        this.getColumnProperties = function(colid,col,props){};
    206         this.cycleHeader = function(col, elem) { vI_rdfDataTree.sort(col) };
     212        this.cycleHeader = function(col, elem) {
     213            var tree = vI_rdfDataTree.trees[vI_rdfDataTree.tabbox.selectedPanel.id];
     214            tree.sort(col)
     215        };
    207216    },
    208217
    209218   
    210219    __setFilter : function (text) {
    211 // loop trough all trees
    212         vI_rdfDataTree.filterText = text;
    213         vI_rdfDataTree.loadTable();
     220        // loop trough all trees
     221        for each (var treeType in vI_rdfDataTree.treeTypes) {
     222            var tree = vI_rdfDataTree.trees[treeType];
     223            tree.filterText = text;
     224            tree.loadTable();
     225        }
    214226    },
    215227
    216228    inputFilter : function(event) {
    217229        //do this now rather than doing it at every comparison
    218         var value = vI_rdfDataTree.__prepareForComparison(event.target.value);
     230        var value = prepareForComparison(event.target.value);
    219231        vI_rdfDataTree.__setFilter(value);
    220232        document.getElementById("clearFilter").disabled = value.length == 0;
     
    249261
    250262    modifySelected : function() {
    251         var tree = vI_rdfDataTree.trees[vI_rdfDataTree.tabbox.selectedPanel.id];
     263        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     264        var tree = vI_rdfDataTree.trees[treeType];
    252265        if (tree.treeElem.view.selection.count == 0) return;
    253266        if (tree.treeElem.view.selection.count > 5) {
     
    271284       
    272285        tree.idData = null; tree.idTable = null;
    273         vI_rdfDataTree.loadTable(vI_rdfDataTree.tabbox.selectedPanel.id);
     286        tree.loadTable()
    274287        vI_rdfDataTree.hideInfoBox();
    275288    },
    276289   
    277290    removeSelected : function() {
    278         if (vI_rdfDataTree.__treeElem.view.selection.count == 0) return;
    279         var warning = vI_rdfDataTree.__strings.getString("vI_rdfDataTree.remove.Warning1") + " " +
    280             vI_rdfDataTree.__treeElem.view.selection.count + " " +
    281             vI_rdfDataTree.__strings.getString("vI_rdfDataTree.remove.Warning2")
     291        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     292        var tree = vI_rdfDataTree.trees[treeType];
     293        if (tree.treeElem.view.selection.count == 0) return;
     294        var warning = vI_rdfDataTree._strings.getString("vI_rdfDataTree.remove.Warning1") + " " +
     295            tree.treeElem.view.selection.count + " " +
     296            vI_rdfDataTree._strings.getString("vI_rdfDataTree.remove.Warning2")
    282297       
    283298        if (!vI_rdfDataTree.promptService.confirm(window,"Warning",warning)) return;
    284299       
    285300        var start = new Object(); var end = new Object();
    286         var numRanges = vI_rdfDataTree.__treeElem.view.selection.getRangeCount();
     301        var numRanges = tree.treeElem.view.selection.getRangeCount();
    287302
    288303        for (var t=0; t<numRanges; t++){
    289             vI_rdfDataTree.__treeElem.view.selection.getRangeAt(t,start,end);
     304            tree.treeElem.view.selection.getRangeAt(t,start,end);
    290305            for (var v=start.value; v<=end.value; v++){
    291                 vI_rdfDatasource.removeBagForResource(vI_rdfDataTree.__idTable[v]["resource"], vI_rdfDataTree.__idTable[v]["type"])
    292                 vI_rdfDatasource.removeVIdentityFromRDF(vI_rdfDataTree.__idTable[v]["resource"])
     306                vI_rdfDatasource.removeBagForResource(tree.idTable[v]["resource"], tree.idTable[v]["type"])
     307                vI_rdfDatasource.removeVIdentityFromRDF(tree.idTable[v]["resource"])
    293308            }
    294309        }
    295310       
    296         vI_rdfDataTree.__idData = null; vI_rdfDataTree.__idTable = null;
    297         vI_rdfDataTree.loadTable();
     311        tree.idData = null; tree.idTable = null;
     312        tree.loadTable();
    298313        vI_rdfDataTree.hideInfoBox();
    299314    },
     
    314329
    315330    selectAll : function() {
    316         vI_rdfDataTree.__treeElem.view.selection.selectAll();
     331        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     332        var tree = vI_rdfDataTree.trees[treeType];
     333        tree.treeElem.view.selection.selectAll();
    317334    },
    318335   
    319336    newItem : function() {
     337        alert("XXX repair this");
    320338        var newItemPreset = {
    321339                recipientCol : "",
  • chrome/content/v_identity/vI_rdfDataTree.xul

    r771a68 r919c17  
    121121<tabbox id="TreeTabbox" flex="1">
    122122<tabs>
    123 <tab label="Emails"/>
    124 <tab label="Mailing Lists"/>
    125 <tab label="Newsgroups"/>
    126 <tab label="Filter"/>
     123<tab id="emailTab" />
     124<tab id="maillistTab" />
     125<tab id="newsgroupTab" />
     126<tab id="filterTab" />
    127127</tabs>
    128128<tabpanels flex="1">
  • chrome/content/v_identity/vI_rdfDatasource.js

    r771a68 r919c17  
    5858    filterContainer : Components.classes["@mozilla.org/rdf/container;1"]
    5959            .createInstance(Components.interfaces.nsIRDFContainer),
     60
     61    getContainer : function (type) {
     62        switch (type) {
     63            case "email": return vI_rdfDatasource.emailContainer;
     64            case "maillist": return vI_rdfDatasource.maillistContainer;
     65            case "newsgroup": return vI_rdfDatasource.newsgroupContainer;
     66            case "filter": return vI_rdfDatasource.filterContainer;
     67        }
     68    },
    6069
    6170    init: function() {
     
    201210   
    202211    // this will be used from rdfDataTree to get all RDF values, callFunction is vI_rdfDataTree.__addNewDatum
    203     readAllEntriesFromRDF : function (container, rdfDataTree) {
     212    readAllEntriesFromRDF : function (addNewDatum, treeType, idData) {
    204213        vI_notificationBar.dump("## vI_rdfDatasource: readAllEntriesFromRDF.\n");
    205         var enumerator = container.GetElements();
     214        var enumerator = vI_rdfDatasource.getContainer(treeType).GetElements();
    206215        while (enumerator && enumerator.hasMoreElements()) {
    207216            var resource = enumerator.getNext();
     
    217226           
    218227            var localIdentityData = new identityData(email, fullName, id, smtp, extras)
    219             rdfDataTree.addNewDatum (resource, name, localIdentityData, rdfDataTree.idData)
     228            addNewDatum (resource, name, localIdentityData, idData)
    220229        }
    221230    },
Note: See TracChangeset for help on using the changeset viewer.