Changeset 774108


Ignore:
Timestamp:
Jan 16, 2009, 3:37:41 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:
c09d7b
Parents:
919c17
Message:

completed implementation of containers

Location:
chrome
Files:
6 edited

Legend:

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

    r919c17 r774108  
    2525var vI_rdfDataEditor = {
    2626    __rdfDatasource : null,
     27    __type : null,
    2728   
    2829    storageExtras : null,
    2930
    3031    init : function() {
    31         vI_rdfDataEditor.__rdfDatasource = window.arguments[1]
    32    
     32        vI_rdfDataEditor.__type = window.arguments[1];
     33        vI_rdfDataEditor.__rdfDatasource = window.arguments[2];
     34
    3335        document.getElementById("recipient").value = window.arguments[0]["recipientCol"];
    3436       
    3537        var typeMenuPopup = document.getElementById("type_menu_popup")
    36         for each (typeField in Array("email", "maillist", "newsgroup")) {
     38
     39        for each (typeField in Array("email", "maillist", "newsgroup", "filter")) {
    3740            var menuitem = document.createElement("menuitem");
    3841            var label = document.getElementById("vI_rdfDataTreeBundle").getString("vI_rdfDataTree.dataType." + typeField)
     
    4043            menuitem.setAttribute("key", typeField)
    4144            typeMenuPopup.appendChild(menuitem);
    42             if (label == window.arguments[0]["typeCol"]) document.getElementById("type_menu").selectedItem = menuitem
     45            if (typeField == vI_rdfDataEditor.__type) document.getElementById("type_menu").selectedItem = menuitem
    4346        }
    4447
     
    9194            vI_rdfDataEditor.storageExtras)
    9295
    93         vI_rdfDataEditor.__rdfDatasource.updateRDF(
    94                 document.getElementById("recipient").value,
     96        // if current Type and previous Type are different, remove previous resource
     97        vI_rdfDataEditor.__rdfDatasource.removeRDF(document.getElementById("recipient").value,
     98                vI_rdfDataEditor.__type);
     99
     100        vI_rdfDataEditor.__rdfDatasource.updateRDF(document.getElementById("recipient").value,
    95101                document.getElementById("type_menu").selectedItem.getAttribute("key"),
    96                 localIdentityData, true)
     102                localIdentityData, true);
     103
     104        return document.getElementById("type_menu").selectedItem.getAttribute("key");
    97105    }
    98106}
  • chrome/content/v_identity/vI_rdfDataTree.js

    r919c17 r774108  
    9292    addNewDatum : function(resource, name, localIdentityData, idData) {
    9393        var pref = {    recipientCol : name,
    94                 typeCol : "type",
    9594                senderCol : localIdentityData.combinedName,
    9695                smtpCol : localIdentityData.smtp.value,
     
    279278                window.openDialog("chrome://v_identity/content/vI_rdfDataEditor.xul",0,
    280279                    "chrome, dialog, modal, alwaysRaised, resizable=yes",
    281                     tree.idTable[v],
     280                    tree.idTable[v], treeType,
    282281                    vI_rdfDatasource).focus();
    283282        }
    284283       
    285         tree.idData = null; tree.idTable = null;
    286         tree.loadTable()
     284        // reload all trees (types might have changed)
     285        for each (var treeType in vI_rdfDataTree.treeTypes) {
     286            vI_rdfDataTree.trees[treeType].idData = null;
     287            vI_rdfDataTree.trees[treeType].idTable = null;
     288            vI_rdfDataTree.trees[treeType].loadTable()
     289        }
    287290        vI_rdfDataTree.hideInfoBox();
    288291    },
     
    304307            tree.treeElem.view.selection.getRangeAt(t,start,end);
    305308            for (var v=start.value; v<=end.value; v++){
    306                 vI_rdfDatasource.removeBagForResource(tree.idTable[v]["resource"], tree.idTable[v]["type"])
    307                 vI_rdfDatasource.removeVIdentityFromRDF(tree.idTable[v]["resource"])
     309                vI_rdfDatasource.removeVIdentityFromRDF(tree.idTable[v]["resource"], treeType)
    308310            }
    309311        }
     
    326328        vI_rdfDataTree.infoBoxHidden = true;
    327329        document.getElementById("vI_rdfDataTreeInfoBox").setAttribute("style", "height:0px");
     330        for each (var treeType in vI_rdfDataTree.treeTypes) {
     331            vI_rdfDataTree.trees[treeType].treeElem.view.selection.selectNone();
     332        }
    328333    },
    329334
     
    338343        var newItemPreset = {
    339344                recipientCol : "",
    340                 typeCol : document.getElementById("vI_rdfDataTreeBundle").getString("vI_rdfDataTree.dataType.email"),
    341345                senderCol : "",
    342346                smtpKey : "",
     
    345349        window.openDialog("chrome://v_identity/content/vI_rdfDataEditor.xul",0,
    346350            "chrome, dialog, modal, alwaysRaised, resizable=yes",
    347             newItemPreset,
     351            newItemPreset, "email",
    348352            vI_rdfDatasource).focus();
    349353        vI_rdfDataTree.__idData = null; vI_rdfDataTree.__idTable = null;
  • chrome/content/v_identity/vI_rdfDataTree.xul

    r919c17 r774108  
    120120</hbox>
    121121<tabbox id="TreeTabbox" flex="1">
    122 <tabs>
     122<tabs onselect="vI_rdfDataTree.hideInfoBox();" >
    123123<tab id="emailTab" />
    124124<tab id="maillistTab" />
  • chrome/content/v_identity/vI_rdfDatasource.js

    r919c17 r774108  
    166166            case "newsgroup" : rdfNSRecType = vI_rdfDatasource.rdfNSNewsgroup; break;
    167167            case "maillist" : rdfNSRecType = vI_rdfDatasource.rdfNSMaillist; break;
     168            case "filter" : rdfNSRecType = vI_rdfDatasource.rdfNSFilter; break;
    168169        }
    169170        return vI_rdfDatasource.rdfService.GetResource(vI_rdfDatasource.rdfNS + rdfNSRecType + "/" + recDescription);
    170171    },
    171172   
    172     removeBagForResource: function (resource, recType) {
    173         var rdfContainerUtils = Components.classes["@mozilla.org/rdf/container-utils;1"].
    174             getService(Components.interfaces.nsIRDFContainerUtils);
    175         var rdfNSRecType = null;
    176         switch (recType) {
    177             case "email": rdfNSRecType = vI_rdfDatasource.rdfNSEmail; break;
    178             case "newsgroup" : rdfNSRecType = vI_rdfDatasource.rdfNSNewsgroup; break;
    179             case "maillist" : rdfNSRecType = vI_rdfDatasource.rdfNSMaillist; break;
    180             case "filter" : rdfNSRecType = vI_rdfDatasource.rdfNSFilter; break;
    181         }
    182         var storageRes = vI_rdfDatasource.rdfService
    183             .GetResource(vI_rdfDatasource.rdfNS + rdfNSRecType);
    184         var container = Components.classes["@mozilla.org/rdf/container;1"]
    185             .createInstance(Components.interfaces.nsIRDFContainer);
    186         container.Init(vI_rdfDatasource.rdfDataSource, storageRes);
    187 
    188         if (container.IndexOf(emailRes) != -1) container.RemoveElement(resource);
    189     },
    190    
    191     removeVIdentityFromRDF : function (resource) {
     173    removeVIdentityFromRDF : function (resource, recType) {
    192174        vI_notificationBar.dump("## vI_rdfDatasource: removeVIdentityFromRDF " + resource.ValueUTF8 + ".\n");
    193175        vI_rdfDatasource.__unsetRDFValue(resource, "email", vI_rdfDatasource.__getRDFValue(resource, "email"))
     
    199181        var extras = new vI_storageExtras(vI_rdfDatasource.__getRDFValue, resource);
    200182        extras.loopForRDF(vI_rdfDatasource.__unsetRDFValue, resource);
     183vI_notificationBar.dump("## vI_rdfDatasource: removeVIdentityFromRDF recType" + recType + " 2.\n");
     184        vI_rdfDatasource.getContainer(recType).RemoveElement(resource, true);
     185vI_notificationBar.dump("## vI_rdfDatasource: removeVIdentityFromRDF " + resource.ValueUTF8 + " 3.\n");
     186//      var container = vI_rdfDatasource.getContainer(recType);
     187//      if (container.IndexOf(emailRes) != -1) container.RemoveElement(resource);
    201188    },
    202189   
     
    230217    },
    231218   
     219    // only used for upgrade to 0.0.3 - loop through all ressources.
    232220    readAllResourcesFromRDF : function (addNewDatum) {
    233221        vI_notificationBar.dump("## vI_rdfDatasource: readAllResourcesFromRDF.\n");
     
    268256
    269257        var email = vI_rdfDatasource.rdfService.GetResource(vI_rdfDatasource.rdfNS + "rdf#email");
     258        // if no data available try available filters
    270259        if (!vI_rdfDatasource.rdfDataSource.hasArcOut(resource, email))
    271260            resource = vI_rdfDatasource.__findMatchingFilter(recDescription);
     261        // if still no data available give up.
    272262        if (!vI_rdfDatasource.rdfDataSource.hasArcOut(resource, email)) {
    273263            vI_notificationBar.dump("## vI_rdfDatasource: readVIdentityFromRDF no data found.\n");
     
    305295    },
    306296   
    307     updateRDF : function (recDescription, recType, localIdentityData, storeBaseID) {
     297    removeRDF : function (recDescription, recType) {
     298        var resource = vI_rdfDatasource.__getRDFResourceForVIdentity(recDescription, recType);
     299        if (!resource) return null;
     300        vI_rdfDatasource.removeVIdentityFromRDF(resource, recType);
     301        return resource;
     302    },
     303
     304    updateRDF : function (recDescription, recType, localIdentityData, storeBaseID, previousRecType) {
    308305        if (!localIdentityData.email) {
    309306            vI_notificationBar.dump("## vI_rdfDatasource: updateRDF: no Sender-email for Recipient, aborting.\n");
    310307            return;
    311308        }
    312         var resource = vI_rdfDatasource.__getRDFResourceForVIdentity(recDescription, recType);
     309        var resource = vI_rdfDatasource.removeRDF(recDescription, recType); // just to have a clean base
    313310        if (!resource) return;
    314         else vI_rdfDatasource.removeVIdentityFromRDF(resource); // just to have a clean base
    315311
    316312        vI_notificationBar.dump("## vI_rdfDatasource: updateRDF " + resource.ValueUTF8 + ".\n");
    317         vI_rdfDatasource.__setRDFValue(resource, "email", localIdentityData.email)
    318         vI_rdfDatasource.__setRDFValue(resource, "fullName", localIdentityData.fullName)
    319         if (storeBaseID) vI_rdfDatasource.__setRDFValue(resource, "id", localIdentityData.id.key)
    320         vI_rdfDatasource.__setRDFValue(resource, "smtp", localIdentityData.smtp.key)
    321        
     313        vI_rdfDatasource.__setRDFValue(resource, "email", localIdentityData.email);
     314        vI_rdfDatasource.__setRDFValue(resource, "fullName", localIdentityData.fullName);
     315        if (storeBaseID) vI_rdfDatasource.__setRDFValue(resource, "id", localIdentityData.id.key);
     316        vI_rdfDatasource.__setRDFValue(resource, "smtp", localIdentityData.smtp.key);
     317        vI_rdfDatasource.__setRDFValue(resource, "name", recDescription);
     318
    322319        localIdentityData.extras.loopForRDF(vI_rdfDatasource.__setRDFValue, resource);
     320
     321        vI_rdfDatasource.getContainer(recType).AppendElement(resource);
    323322    },
    324323
  • chrome/content/v_identity/vI_upgrade.js

    r919c17 r774108  
    104104   
    105105    __createContainersUpgradeElems: function(resource, type, name) {
    106         var container;
    107        
    108         switch (type) {
    109             case "email": container = vI_rdfDatasource.emailContainer; break;
    110             case "newsgroup" : container = vI_rdfDatasource.newsgroupContainer; break;
    111             case "maillist" : container = vI_rdfDatasource.maillistContainer; break;
    112         }
     106        var container = vI_rdfDatasource.getContainer(type);
    113107        vI_rdfDatasource.__setRDFValue(resource, "name", name);
    114108        if (container.IndexOf(resource) == -1) container.AppendElement(resource);
  • chrome/locale/en-US/v_identity/vI_rdfDataEditor.properties

    r919c17 r774108  
    66vI_rdfDataTree.dataType.maillist=mailing list
    77vI_rdfDataTree.dataType.newsgroup=newsgroup
     8vI_rdfDataTree.dataType.filter=filter
Note: See TracChangeset for help on using the changeset viewer.