[Zope-CVS] CVS: Packages/MoZTop/moztop/content/zopetop/Inspector - Sites.js:1.1 SitesOverlay.xul:1.3
Stephan Richter
srichter@cbu.edu
Thu, 9 Jan 2003 18:42:25 -0500
Update of /cvs-repository/Packages/MoZTop/moztop/content/zopetop/Inspector
In directory cvs.zope.org:/tmp/cvs-serv12237/content/Inspector
Modified Files:
SitesOverlay.xul
Added Files:
Sites.js
Log Message:
Adding new sites works now, but the tree does not update correctly for
some reason. Also, deleting does not work.
=== Added File Packages/MoZTop/moztop/content/zopetop/Inspector/Sites.js ===
var RDFCUtils = '@mozilla.org/rdf/container-utils;1';
RDFCUtils = Components.classes[RDFCUtils].getService();
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 =
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),
true);
DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
RDF.GetResource("http://www.zope.org/rdf/site#serverport"),
RDF.GetLiteral(serverport),
true);
DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
RDF.GetResource("http://www.zope.org/rdf/site#username"),
RDF.GetLiteral(username),
true);
DS.Assert(RDF.GetResource("urn:sites:site" + siteCount),
RDF.GetResource("http://www.zope.org/rdf/site#password"),
RDF.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),
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');
}
function deleteSelectedSite() {
var tree = document.getElementById("sites-tree");
DS = tree.database.GetDataSources().getNext();
DS = DS.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));
}
}
DS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
DS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Refresh(
false);
tree.builder.rebuild()
alert('done');
}
=== Packages/MoZTop/moztop/content/zopetop/Inspector/SitesOverlay.xul 1.2 => 1.3 ===
--- Packages/MoZTop/moztop/content/zopetop/Inspector/SitesOverlay.xul:1.2 Thu Jan 9 17:08:56 2003
+++ Packages/MoZTop/moztop/content/zopetop/Inspector/SitesOverlay.xul Thu Jan 9 18:42:22 2003
@@ -3,9 +3,15 @@
<overlay id="SitesOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<script type="application/x-javascript" src="./Sites.js"/>
+
<tabpanel id="sites-panel">
-<tree id="connections-tree" flex="1"
+<button onclick="addSite('test.com', '8081', 'test', 'test');"
+ label="Add Site" />
+<button onclick="deleteSelectedSite();" label="Delete Site" />
+
+<tree id="sites-tree" flex="1"
datasources="chrome://moztop/content/Data/connections.rdf"
ref="urn:sites:data">
<treecols>