Changeset 69321c


Ignore:
Timestamp:
Jan 20, 2009, 3:57:45 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:
201149
Parents:
3159a7
Message:

support for rdf 0.0.3

Location:
chrome/content/v_identity
Files:
5 edited

Legend:

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

    r3159a7 r69321c  
    106106    },
    107107    sort : function(columnName) {
    108         vI_notificationBar.dump("## sort: " + columnName + ".\n");
     108//      vI_notificationBar.dump("## sort: " + columnName + ".\n");
    109109        var order = this.treeElem.getAttribute("sortDirection") == "ascending" ? 1 : -1;
    110110        //if the column is passed and it's already sorted by that column, reverse sort
     
    151151   
    152152    onselect : function () {
     153        vI_rdfDataTree.moveConstraints();
     154
    153155        var tree = vI_rdfDataTree.trees[vI_rdfDataTree.tabbox.selectedPanel.id];
    154156        var htmlBox = document.getElementById("vI_rdfDataTreeInfoBox")
     
    275277        var numRanges = tree.treeElem.view.selection.getRangeCount();
    276278
     279        var retVar = { treeType: null };
    277280        for (var t=0; t<numRanges; t++){
    278281            tree.treeElem.view.selection.getRangeAt(t,start,end);
     
    281284                    "chrome, dialog, modal, alwaysRaised, resizable=yes",
    282285                    tree.idTable[v], treeType,
    283                     vI_rdfDatasource).focus();
    284         }
    285        
    286         // reload all trees (types might have changed)
     286                    vI_rdfDatasource, retVar).focus();
     287        }
     288       
     289        // reload all trees (multiple types might have changed)
    287290        for each (var treeType in vI_rdfDataTree.treeTypes) {
    288291            vI_rdfDataTree.trees[treeType].idData = null;
     
    290293            vI_rdfDataTree.trees[treeType].loadTable()
    291294        }
     295        vI_rdfDataTree.tabbox.selectedTab = document.getElementById(retVar.treeType + "Tab");
    292296        vI_rdfDataTree.hideInfoBox();
    293297    },
     
    318322    },
    319323   
     324    moveConstraints : function() {
     325        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     326        if (treeType != "filter") return;
     327        var tree = vI_rdfDataTree.trees[treeType];
     328        if (tree.treeElem.view.selection.count == 0) {
     329            document.getElementById("reorderUpButton_filter").setAttribute("disabled","true");
     330            document.getElementById("reorderDownButton_filter").setAttribute("disabled","true");
     331            return;
     332        };
     333        var start = new Object(); var end = new Object();
     334        var numRanges = tree.treeElem.view.selection.getRangeCount();
     335        if (numRanges > 1) {
     336            document.getElementById("reorderUpButton_filter").setAttribute("disabled","true");
     337            document.getElementById("reorderDownButton_filter").setAttribute("disabled","true");
     338            return;
     339        }
     340        tree.treeElem.view.selection.getRangeAt(0,start,end);
     341        if (start.value > 0)
     342            document.getElementById("reorderUpButton_filter").removeAttribute("disabled");
     343        else    document.getElementById("reorderUpButton_filter").setAttribute("disabled","true");
     344        if (end.value < tree.idTable.length - 1)
     345            document.getElementById("reorderDownButton_filter").removeAttribute("disabled");
     346        else    document.getElementById("reorderDownButton_filter").setAttribute("disabled","true");
     347    },
     348
     349    moveUpSelected : function() {
     350        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     351        if (treeType != "filter") return; // just to be safe, button should be disabled
     352        var tree = vI_rdfDataTree.trees[treeType];
     353        if (tree.treeElem.view.selection.count == 0) return; // just to be safe, button should be disabled
     354
     355        var start = new Object(); var end = new Object();
     356        var numRanges = tree.treeElem.view.selection.getRangeCount();
     357        if (numRanges > 1) return;  // just to be safe, button should be disabled
     358       
     359        tree.treeElem.view.selection.getRangeAt(0,start,end);
     360        for (var v=start.value; v<=end.value; v++){
     361            var resource = vI_rdfDatasource.filterContainer.RemoveElementAt(v+1, true);
     362            vI_rdfDatasource.filterContainer.InsertElementAt(resource,v,true);
     363        }
     364        tree.idData = null; tree.idTable = null;
     365        tree.loadTable();
     366        tree.treeElem.view.selection.rangedSelect(start.value-1,end.value-1,false);
     367    },
     368
     369    moveDownSelected : function() {
     370        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     371        if (treeType != "filter") return; // just to be safe, button should be disabled
     372        var tree = vI_rdfDataTree.trees[treeType];
     373        if (tree.treeElem.view.selection.count == 0) return; // just to be safe, button should be disabled
     374
     375        var start = new Object(); var end = new Object();
     376        var numRanges = tree.treeElem.view.selection.getRangeCount();
     377        if (numRanges > 1) return;  // just to be safe, button should be disabled
     378       
     379        tree.treeElem.view.selection.getRangeAt(0,start,end);
     380        for (var v=end.value; v>=start.value; v--){
     381            var resource = vI_rdfDatasource.filterContainer.RemoveElementAt(v+1, true);
     382            vI_rdfDatasource.filterContainer.InsertElementAt(resource,v+2,true);
     383        }
     384        tree.idData = null; tree.idTable = null;
     385        tree.loadTable();
     386        tree.treeElem.view.selection.rangedSelect(start.value+1,end.value+1,false);
     387    },
    320388
    321389    infoBoxHidden : true,
     
    324392        var htmlBox = document.getElementById("vI_rdfDataTreeInfoBox")
    325393        htmlBox.setAttribute("style", "height:" + htmlBox.contentDocument.lastChild.scrollHeight +"px");
    326 
    327394    },
    328395
     
    331398        document.getElementById("vI_rdfDataTreeInfoBox").setAttribute("style", "height:0px");
    332399        for each (var treeType in vI_rdfDataTree.treeTypes) {
    333             vI_rdfDataTree.trees[treeType].treeElem.view.selection.selectNone();
     400            try { vI_rdfDataTree.trees[treeType].treeElem.view.selection.selectNone() } catch (e) { }
    334401        }
    335402    },
     
    342409   
    343410    newItem : function() {
    344         alert("XXX repair this");
     411        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
    345412        var newItemPreset = {
    346413                recipientCol : "",
     
    349416                idKey : gAccountManager.defaultAccount.defaultIdentity.key,
    350417                resource : null }
     418        var retVar = { treeType: null };
    351419        window.openDialog("chrome://v_identity/content/vI_rdfDataEditor.xul",0,
    352420            "chrome, dialog, modal, alwaysRaised, resizable=yes",
    353             newItemPreset, "email",
    354             vI_rdfDatasource).focus();
    355         vI_rdfDataTree.__idData = null; vI_rdfDataTree.__idTable = null;
    356         vI_rdfDataTree.loadTable();
     421            newItemPreset, treeType,
     422            vI_rdfDatasource, retVar).focus();
     423        // reload all trees (multiple types might have changed)
     424        for each (var treeType in vI_rdfDataTree.treeTypes) {
     425            vI_rdfDataTree.trees[treeType].idData = null;
     426            vI_rdfDataTree.trees[treeType].idTable = null;
     427            vI_rdfDataTree.trees[treeType].loadTable()
     428        }
     429        vI_rdfDataTree.tabbox.selectedTab = document.getElementById(retVar.treeType + "Tab");
    357430        vI_rdfDataTree.hideInfoBox();
    358431    }
  • chrome/content/v_identity/vI_rdfDataTree.xul

    r3159a7 r69321c  
    278278          <button id="reorderUpButton_filter" label="&reorderUpButton.label;" accesskey="&reorderUpButton.accesskey;"
    279279                  class="up"
    280                   oncommand="vI_rdfDataTree.moveUp();"/>
     280                  oncommand="vI_rdfDataTree.moveUpSelected();"/>
    281281          <button id="reorderDownButton_filter" label="&reorderDownButton.label;" accesskey="&reorderDownButton.accesskey;"
    282282                  class="down"
    283                   oncommand="vI_rdfDataTree.moveDown();"/>
     283                  oncommand="vI_rdfDataTree.moveDownSelected();"/>
    284284          <spacer flex="1"/>
    285285</vbox>
  • chrome/content/v_identity/vI_rdfDatasource.js

    r3159a7 r69321c  
    181181        var extras = new vI_storageExtras(vI_rdfDatasource.__getRDFValue, resource);
    182182        extras.loopForRDF(vI_rdfDatasource.__unsetRDFValue, resource);
    183 vI_notificationBar.dump("## vI_rdfDatasource: removeVIdentityFromRDF recType" + recType + " 2.\n");
    184183        vI_rdfDatasource.getContainer(recType).RemoveElement(resource, true);
    185 vI_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);
    188184    },
    189185   
     
    198194    // this will be used from rdfDataTree to get all RDF values, callFunction is vI_rdfDataTree.__addNewDatum
    199195    readAllEntriesFromRDF : function (addNewDatum, treeType, idData) {
    200         vI_notificationBar.dump("## vI_rdfDatasource: readAllEntriesFromRDF.\n");
     196//      vI_notificationBar.dump("## vI_rdfDatasource: readAllEntriesFromRDF.\n");
    201197        var enumerator = vI_rdfDatasource.getContainer(treeType).GetElements();
    202198        while (enumerator && enumerator.hasMoreElements()) {
     
    244240            var resource = enumerator.getNext();
    245241            resource.QueryInterface(Components.interfaces.nsIRDFResource);
    246             var filter = vI_rdfDatasource.__getRDFValue(resource, "filter");
     242            var filter = vI_rdfDatasource.__getRDFValue(resource, "name");
    247243            vI_notificationBar.dump("## vI_rdfDatasource: __findMatchingFilter trying '" + filter + "'.\n");
    248244            if (filter && recDescription.match(new RegExp(filter,"i"))) return resource;
     
    292288        vI_rdfDatasource.updateRDF(recDescription, recType,
    293289            document.getElementById("msgIdentity_clone").identityData,
    294             (vI_statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true"));
     290            (vI_statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true"),
     291            null, null);
    295292    },
    296293   
     
    302299    },
    303300
    304     updateRDF : function (recDescription, recType, localIdentityData, storeBaseID, previousRecType) {
    305         if (!localIdentityData.email) {
    306             vI_notificationBar.dump("## vI_rdfDatasource: updateRDF: no Sender-email for Recipient, aborting.\n");
    307             return;
    308         }
    309         var resource = vI_rdfDatasource.removeRDF(recDescription, recType); // just to have a clean base
     301    updateRDF : function (recDescription, recType, localIdentityData, storeBaseID, prevRecDescription, prevRecType) {
     302//      if (!localIdentityData.email) {
     303//          vI_notificationBar.dump("## vI_rdfDatasource: updateRDF: no Sender-email for Recipient, aborting.\n");
     304//          return;
     305//      }
     306        if (recDescription.length == 0) return;
     307
     308        if (!prevRecDescription) prevRecDescription = recDescription;
     309        if (!prevRecType) prevRecType = recType;
     310
     311        var resource = vI_rdfDatasource.__getRDFResourceForVIdentity(prevRecDescription, prevRecType);
    310312        if (!resource) return;
    311 
    312313        vI_notificationBar.dump("## vI_rdfDatasource: updateRDF " + resource.ValueUTF8 + ".\n");
     314       
     315        var position = vI_rdfDatasource.getContainer(recType).IndexOf(resource); // check for index in new recType
     316        vI_rdfDatasource.removeVIdentityFromRDF(resource, prevRecType);
     317       
     318        resource = vI_rdfDatasource.__getRDFResourceForVIdentity(recDescription, recType);
     319
    313320        vI_rdfDatasource.__setRDFValue(resource, "email", localIdentityData.email);
    314321        vI_rdfDatasource.__setRDFValue(resource, "fullName", localIdentityData.fullName);
     
    318325
    319326        localIdentityData.extras.loopForRDF(vI_rdfDatasource.__setRDFValue, resource);
    320 
    321         vI_rdfDatasource.getContainer(recType).AppendElement(resource);
     327       
     328        vI_notificationBar.dump("## vI_rdfDatasource: updateRDF " + resource.ValueUTF8  + " added.\n");
     329        if (position != -1) vI_rdfDatasource.getContainer(recType).InsertElementAt(resource, position, true);
     330        else vI_rdfDatasource.getContainer(recType).AppendElement(resource);
    322331    },
    323332
  • chrome/content/v_identity/vI_smartIdentity.js

    r3159a7 r69321c  
    253253        vI_notificationBar.dump("## vI_smartIdentity: Reply()\n");
    254254       
    255         if (hdr && !hdr.getStringProperty("vI_received")) { // mail was not received
     255        if (hdr && !gMsgCompose.compFields.newsgroups && !hdr.getStringProperty("vI_received")) { // mail was not received
    256256                vI_notificationBar.dump("## vI_smartIdentity: reply on non-received (sent?) mail. Using SmartDraft. \n");
    257257                vI_smartIdentity.ReplyOnSent(hdr);
  • chrome/content/v_identity/vI_upgrade.js

    r3159a7 r69321c  
    253253       
    254254        vI_rdfDatasource.updateRDF(vI_helper.combineNames(Card.displayName, Card.primaryEmail),
    255                         "email", localIdentityData, true)
     255                        "email", localIdentityData, true, null, null)
    256256        if (Card.secondEmail.replace(/^\s+|\s+$/g,""))
    257257            vI_rdfDatasource.updateRDF(vI_helper.combineNames(Card.displayName, Card.secondEmail),
    258                     "email", localIdentityData, true)
     258                    "email", localIdentityData, true, null, null)
    259259       
    260260        Card[returnVar.prop] = "";
Note: See TracChangeset for help on using the changeset viewer.