[Zope-CVS] CVS: Packages/MoZTop/moztop/content/zopetop/Inspector - Sites.js:1.2 SitesOverlay.xul:1.4

Stephan Richter srichter@cbu.edu
Thu, 9 Jan 2003 19:50:58 -0500


Update of /cvs-repository/Packages/MoZTop/moztop/content/zopetop/Inspector
In directory cvs.zope.org:/tmp/cvs-serv23099/content/Inspector

Modified Files:
	Sites.js SitesOverlay.xul 
Log Message:
Sites (with data in RDF Files - not memory) can now be added and deleted.


=== Packages/MoZTop/moztop/content/zopetop/Inspector/Sites.js 1.1 => 1.2 ===
--- Packages/MoZTop/moztop/content/zopetop/Inspector/Sites.js:1.1	Thu Jan  9 18:42:22 2003
+++ Packages/MoZTop/moztop/content/zopetop/Inspector/Sites.js	Thu Jan  9 19:50:56 2003
@@ -1,85 +1,81 @@
 var RDFCUtils = '@mozilla.org/rdf/container-utils;1';
 RDFCUtils = Components.classes[RDFCUtils].getService();
-RDFCUtils = RDFCUtils.QueryInterface(Components.interfaces.nsIRDFContainerUtils);
+RDFCUtils = RDFCUtils.QueryInterface(
+                        Components.interfaces.nsIRDFContainerUtils);
 
 var RDFC = '@mozilla.org/rdf/container;1';
 RDFC = Components.classes[RDFC].createInstance();
 RDFC = RDFC.QueryInterface(Components.interfaces.nsIRDFContainer);
 
-var RDF =
+var RDF2 =
   Components
   .classes["@mozilla.org/rdf/rdf-service;1"]
   .getService(Components.interfaces.nsIRDFService);
 
-// This will remember the index of the last child we've added
-var siteCount = 20;
-
 function addSite(servername, serverport, username, password) {
     tree = document.getElementById("sites-tree");
-    DS = tree.database.GetDataSources().getNext();
-    DS = DS.QueryInterface(Components.interfaces.nsIRDFDataSource);
-
-    DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
-              RDF.GetResource("http://www.zope.org/rdf/site#servername"),
-              RDF.GetLiteral(servername),
+    source = tree.database.GetDataSources().getNext();
+    source = source.QueryInterface(Components.interfaces.nsIRDFDataSource);
+    var root = "urn:sites:" + servername+"_"+serverport
+
+    source.Assert(RDF2.GetResource(root),
+              RDF2.GetResource("http://www.zope.org/rdf/site#servername"),
+              RDF2.GetLiteral(servername),
               true);
 
-    DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
-              RDF.GetResource("http://www.zope.org/rdf/site#serverport"),
-              RDF.GetLiteral(serverport),
+    source.Assert(RDF2.GetResource(root),
+              RDF2.GetResource("http://www.zope.org/rdf/site#serverport"),
+              RDF2.GetLiteral(serverport),
               true);
 
-    DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
-              RDF.GetResource("http://www.zope.org/rdf/site#username"),
-              RDF.GetLiteral(username),
+    source.Assert(RDF2.GetResource(root),
+              RDF2.GetResource("http://www.zope.org/rdf/site#username"),
+              RDF2.GetLiteral(username),
               true);
     
-    DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
-              RDF.GetResource("http://www.zope.org/rdf/site#password"),
-              RDF.GetLiteral(password),
+    source.Assert(RDF2.GetResource(root),
+              RDF2.GetResource("http://www.zope.org/rdf/site#password"),
+              RDF2.GetLiteral(password),
               true);
 
-    DS.Assert(RDF.GetResource("urn:sites:data"),
-              RDF.GetResource("http://www.zope.org/rdf/site#child"),
-              RDF.GetLiteral("urn:sites:site" + siteCount),
+    source.Assert(RDF2.GetResource("urn:sites:data"),
+              RDF2.GetResource("http://www.zope.org/rdf/site#child"),
+              RDF2.GetLiteral(root),
               true);
 
     // Write it all out.
-    RDFCUtils.MakeSeq(DS, RDF.GetResource("urn:sites:data"));
-    RDFC.Init(DS, RDF.GetResource("urn:sites:data"));
-    RDFC.AppendElement(RDF.GetResource("urn:sites:site" + siteCount), true);
-    DS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
-    DS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Refresh(
-                                                                      false);
-    ++siteCount;
-    tree.builder.rebuild()
-    alert('done');
+    RDFCUtils.MakeSeq(source, RDF2.GetResource("urn:sites:data"));
+    RDFC.Init(source, RDF2.GetResource("urn:sites:data"));
+    RDFC.AppendElement(RDF2.GetResource(root), true);
+    source.QueryInterface(
+             Components.interfaces.nsIRDFRemoteDataSource).Flush();
+    tree.builder.rebuild();
 }
 
 function deleteSelectedSite() {
     var tree = document.getElementById("sites-tree");
-    DS = tree.database.GetDataSources().getNext();
-    DS = DS.QueryInterface(Components.interfaces.nsIRDFDataSource);
+    source = tree.database.GetDataSources().getNext();
+    source = source.QueryInterface(Components.interfaces.nsIRDFDataSource);
     var start = new Object();
     var end = new Object();
-    var source = new Object();
     var numRanges = tree.view.selection.getRangeCount();
-    alert(tree.builder.);
+
     for (var t=0; t<numRanges; t++){
         tree.view.selection.getRangeAt(t,start,end);
         for (var v = start.value; v <= end.value; v++){
 	    var builder = tree.builder.QueryInterface(
                                   Components.interfaces.nsIXULTreeBuilder)
             rdf = builder.getResourceAtIndex(v)
-            DS.Unassert(RDF.GetResource("urn:sites:data"),
-                        RDF.GetResource("http://www.zope.org/rdf/site#child"),
-                        RDF.GetResource(rdf.Value));
+            source.Unassert(RDF2.GetResource("urn:sites:data"),
+	             RDF2.GetResource("http://www.zope.org/rdf/site#child"),
+                     RDF2.GetResource(rdf.Value));
+            RDFCUtils.MakeSeq(source, RDF2.GetResource("urn:sites:data"));
+            RDFC.Init(source, RDF2.GetResource("urn:sites:data"));
+            RDFC.RemoveElement(RDF2.GetResource(rdf.Value), true);
         }
     }
-    DS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
-    DS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Refresh(
-                                                                      false);
-    tree.builder.rebuild()
-    alert('done');
+    source.QueryInterface(
+               Components.interfaces.nsIRDFRemoteDataSource).Flush();
+    tree.builder.rebuild();
 }
 


=== Packages/MoZTop/moztop/content/zopetop/Inspector/SitesOverlay.xul 1.3 => 1.4 ===
--- Packages/MoZTop/moztop/content/zopetop/Inspector/SitesOverlay.xul:1.3	Thu Jan  9 18:42:22 2003
+++ Packages/MoZTop/moztop/content/zopetop/Inspector/SitesOverlay.xul	Thu Jan  9 19:50:56 2003
@@ -3,7 +3,8 @@
 <overlay id="SitesOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-<script type="application/x-javascript" src="./Sites.js"/>
+<script type="application/x-javascript" 
+        src="chrome://moztop/content/Inspector/Sites.js"/>
 
 <tabpanel id="sites-panel">
 
@@ -12,6 +13,7 @@
 <button onclick="deleteSelectedSite();" label="Delete Site" />
 
 <tree id="sites-tree" flex="1" 
+      flags="dont-build-content"
       datasources="chrome://moztop/content/Data/connections.rdf"
       ref="urn:sites:data">
   <treecols>