[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - datasourcemanager.js:1.15 sitesmanager.js:1.17

Paul Everitt paul@zope.com
Thu, 3 Apr 2003 04:02:36 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv25398/lib

Modified Files:
	datasourcemanager.js sitesmanager.js 
Log Message:
Fixed reload and also displaying log messages.  Both moved to 
use dont-build-content on the tree, which changes the way 
you access content in the tree.

Note that many operations don't collapse and the tree like they 
used to.  Also, restarting mozilla puts the tree in the correct 
state that it was previously, because of the move to 
dont-build-content.

refresh works much better.  It calls the .refresh method, instead 
of adding more (duplicate) datasources to the tree and doing a 
rebuild.

Still need to figure out the fix for delete.  I'll probably 
punt for now and reload the RDF, rather than making local 
assertions.


=== Packages/Moztop/moztop/content/lib/datasourcemanager.js 1.14 => 1.15 ===
--- Packages/Moztop/moztop/content/lib/datasourcemanager.js:1.14	Wed Apr  2 16:33:58 2003
+++ Packages/Moztop/moztop/content/lib/datasourcemanager.js	Thu Apr  3 04:02:05 2003
@@ -125,6 +125,7 @@
     sources = tree.database.GetDataSources();
     // the first source is always Mozilla internal
     source = sources.getNext();
+
     while (sources.hasMoreElements()) {
 	source = sources.getNext();
 	if (source.URI == rdfurl) {
@@ -133,6 +134,7 @@
 	    return ds;
 	}
     }
+    dump("\nNo datasource found for rdfurl = " + rdfurl);
     return null;
 }
 
@@ -193,16 +195,41 @@
     /* For all trees, this returns a selected resource as an RDFNode */
     var tree = document.getElementById(this.treeId);
     var index = tree.view.selection.currentIndex;
-
-    var compositeds = this.getCompositeDS();
     if (index == -1) return false;
 
     /* Switching to flags="dont-build-content" solved a lot of the  */
     /* tree flashing and rebuilding problems, but made grabbing the */
     /* current selected resource a bit harder.                      */
+
     currindex = tree.view.selection.currentIndex;
-    builder = tree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
-    r = builder.getResourceAtIndex(currindex);
+    builder = tree.builder
+                .QueryInterface(Components.interfaces.nsIXULTreeBuilder);
+    res = builder.getResourceAtIndex(currindex);
+
+    // XXX: All of the following code should be eventually replaced by the
+    //      getNode() method.
+    sources = tree.database.GetDataSources();
+    // the first source is always Mozilla internal
+    sources.getNext();
+    // we need to create the RDFDataSource object only once
+    var ds = new RDFDataSource();
+    // Go through all registered datasources
+    while (sources.hasMoreElements()) {
+	// Create a rdfds RDFNode and see whether it exists in the datasource
+	source = sources.getNext();
+	ds.Init(source);
+ 	node = ds.getNode(res.Value);
+ 	if (node.propertyExists(this.titleprop)) {
+	    dump("\nFound node in " + source.URI + " datasource");
+ 	    return node;
+	}
+	else {
+	    dump("\nNo node found in " + source.URI);
+	}
+    }
+    return false;
+
+
     return compositeds.getNode(r.Value);
 }
 


=== Packages/Moztop/moztop/content/lib/sitesmanager.js 1.16 => 1.17 ===
--- Packages/Moztop/moztop/content/lib/sitesmanager.js:1.16	Wed Apr  2 16:33:58 2003
+++ Packages/Moztop/moztop/content/lib/sitesmanager.js	Thu Apr  3 04:02:05 2003
@@ -166,6 +166,7 @@
     // Trying to get a discovery response from the server
     var request = new XMLHttpRequest();
     request.onload = loadThisSite;
+    dump("\nopen called with rsdurl = " + rsdurl);
     request.open("GET", rsdurl, false);
     request.send(null);
 }
@@ -173,8 +174,20 @@
 
 SitesManager.prototype.reloadSelectedSite = function() {
     /* Reload the latest changes from the server */
-    node = this.getSelectedResource();
-    this.loadSite(node.getValue());
+    resource = this.getSelectedResource();
+    type = resource.getTarget(this.resourcetypeprop).getValue();
+
+    if (type != 'urn:moztop:resourcetypes:site') {
+	alert("You must select a site to reload");
+	return false;
+    } 
+
+    rdfurl = resource.getTarget(this.contentsurlprop).getValue();
+    ds = this.getDataSource(rdfurl);
+
+    // Careful, the rdfds method for refresh eats exceptions!
+    ds.refresh(false)
+    return;
 }