[Zope-CVS] CVS: Packages/Moztop/moztop/content/Explorer - Explorer.js:1.3 ExplorerOverlay.xul:1.3

Paul Everitt paul@zope.com
Thu, 30 Jan 2003 14:02:02 -0500


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

Modified Files:
	Explorer.js ExplorerOverlay.xul 
Log Message:
No longer a need to copy files to profile dir.  We now create the files in 
place.  Also, if there are no sites yet defined, the explorer says so.



=== Packages/Moztop/moztop/content/Explorer/Explorer.js 1.2 => 1.3 ===
--- Packages/Moztop/moztop/content/Explorer/Explorer.js:1.2	Tue Jan 28 16:24:35 2003
+++ Packages/Moztop/moztop/content/Explorer/Explorer.js	Thu Jan 30 14:01:30 2003
@@ -179,9 +179,30 @@
   newsite.addTarget(sitepassword,site_password);
   newsite.addTarget(sitert,siteres);
 
+  // Prepare the area for psuedo-folders (Configurations, Content, etc.)
+  var urn = "urn:moztop:sites:" + site_name + ":subitems";
+  var subitems = sitesds.getNode(urn);
+  subitems.makeSeq();
+  newsite.addTarget("http://home.netscape.com/NC-rdf#subitems",subitems);
+
+  // Now add the psuedo folders
+  var pfs = new Array ('Views','Configurations','Content','Bundles','Packages');
+  for (var i = 0; i < pfs.length; i++) {
+    var rt = pfs[i];
+    var urn = "urn:moztop:sites:" + site_name + ":" + rt.toLowerCase();
+    var newpf = sitesds.getNode(urn);
+    subitems.addChild(newpf);
+    newpf.addTarget(dctitle,rt);
+  }
+
+  // Now we can hide the "no sites defined" label and turn on the tree
+  doc = getDocumentOfWindowWithId("moztop-main-window");
+
+  doc.getElementById("explorer-ishidden").setAttribute("hidden",true);
+  doc.getElementById("explorertree").setAttribute("hidden",false);
+  doc.getElementById("explorer-buttons").setAttribute("hidden",false);
   sitesds.save();  
 
-  //  alert(typesds.serializeToString());
 }
 
 
@@ -199,4 +220,102 @@
   sitesds.deleteRecursive(rdf.Value);
   sitesds.save()
   return;
+}
+
+
+/* Initialize the Explorer datasource */
+function initExplorer() {
+    // var ds = RDF.GetDataSource(RDF_BASE + '@@contents.rdf');
+    // var tree = document.getElementById('navigationtree');
+    // tree.database.AddDataSource(ds);
+    // tree.setAttribute("ref", "urn:explorer:data");
+		
+  var prefsdir = getProfileURL();
+  var sitesds = new RDFDataSource(prefsdir + "/moztop_sites.rdf");
+  var typesds = new RDFDataSource(prefsdir + "/moztop_types.rdf");
+
+  var explorer=document.getElementById("explorertree");
+  explorer.database.AddDataSource(sitesds.getRawDataSource());
+  explorer.database.AddDataSource(typesds.getRawDataSource());
+  explorer.builder.rebuild();		
+}
+
+/* Reload Explorer datasource */
+function reloadContentData() {
+    var tree = document.getElementById('navigationtree');
+    var sources = tree.database.GetDataSources();
+    sources.getNext(); // Hack, we should find this out in a better way.
+    var ds = sources.getNext();
+    ds = ds.QueryInterface(
+	      Components.interfaces.nsIRDFRemoteDataSource);
+    ds.Refresh(false);
+    /* We need this alert, so the RDF has time to load, otherwise the tree
+       will be empty. We have find a better way of doing this.
+
+       This happens because the DS is loaded asynchronically.
+    */ 
+    alert('Done reloading Content Tree.');
+    tree.builder.rebuild();
+}
+
+
+/* Initialize the Explorer datasource */
+function initExplorer() {
+
+    // var ds = RDF.GetDataSource(RDF_BASE + '@@contents.rdf');
+    // var tree = document.getElementById('navigationtree');
+    // tree.database.AddDataSource(ds);
+    // tree.setAttribute("ref", "urn:explorer:data");
+
+  var prefsdir = getProfileURL();
+  var sitesds = new RDFDataSource(prefsdir + "/moztop_sites.rdf");
+  var typesds = new RDFDataSource(prefsdir + "/moztop_types.rdf");
+
+  // Are these datasource empty?  If so, this means this is a first-startup
+  var allres = sitesds.getAllResources();
+  if (! allres.hasMoreElements()) {
+    logmanager.addMessage('First time installation', 
+			'Explorer.js, initExplorer', 
+			sitesds.serializeToString());
+
+    // First create moztop_sites.rdf in the profile dir
+    var dcref = "http://www.purl.org/dc/1.1#";
+    var siteref = "http://www.zope.org/rdf/site#";
+    var ncref ="http://home.netscape.com/NC-rdf#";
+    var rootnode = sitesds.getNode("urn:moztop:sites");
+    var subitems = sitesds.getNode("urn:moztop:sites:subitems");
+    subitems.makeSeq();
+    rootnode.addTarget("http://home.netscape.com/NC-rdf#subitems",subitems);
+    sitesds.save();
+
+    // Now create moztop_types.rdf in the profile dir
+    var sitetypenode = typesds.getNode("urn:moztop:resourcetypes:site");
+    sitetypenode.addTarget(dcref + "title","Site");
+    sitetypenode.addTarget(siteref + "styleid", "site");
+    typesds.save();
+
+  }
+
+  var explorer=document.getElementById("explorertree");
+  explorer.database.AddDataSource(sitesds.getRawDataSource());
+  explorer.database.AddDataSource(typesds.getRawDataSource());
+  explorer.builder.rebuild();		
+}
+
+/* Reload Explorer datasource */
+function reloadContentData() {
+    var tree = document.getElementById('navigationtree');
+    var sources = tree.database.GetDataSources();
+    sources.getNext(); // Hack, we should find this out in a better way.
+    var ds = sources.getNext();
+    ds = ds.QueryInterface(
+	      Components.interfaces.nsIRDFRemoteDataSource);
+    ds.Refresh(false);
+    /* We need this alert, so the RDF has time to load, otherwise the tree
+       will be empty. We have find a better way of doing this.
+
+       This happens because the DS is loaded asynchronically.
+    */ 
+    alert('Done reloading Content Tree.');
+    tree.builder.rebuild();
 }


=== Packages/Moztop/moztop/content/Explorer/ExplorerOverlay.xul 1.2 => 1.3 ===
--- Packages/Moztop/moztop/content/Explorer/ExplorerOverlay.xul:1.2	Tue Jan 28 16:24:35 2003
+++ Packages/Moztop/moztop/content/Explorer/ExplorerOverlay.xul	Thu Jan 30 14:01:30 2003
@@ -7,7 +7,9 @@
   <script src="Explorer.js"/>
 
 <vbox id="explorer">
-<tree flex="1" 
+<label flex="1" id="explorer-ishidden" 
+       value="No sites defined in this Moztop" hidden="false"/>
+<tree flex="1" hidden="true"
     id="explorertree" ref="urn:moztop:sites" 
     datasources="rdf:null" 
     containment="http://home.netscape.com/NC-rdf#subitems">
@@ -55,10 +57,8 @@
       </rule>
     </template>
 </tree>
-<button label="Delete Site" oncommand="deleteSelectedSite();" />
-
 
-<box orient="vertical">
+<box id="explorer-buttons" orient="vertical" hidden="true">
   <box orient="horizontal">
     <menulist id="field_obj_type" label="Type">
       <menupopup>
@@ -73,6 +73,7 @@
     <textbox id="field_obj_name" value="Name" flex="1" />
   </box>
   <box orient="horizontal">
+<button label="Delete Site" oncommand="deleteSelectedSite();" />
     <button command="explorer-add:command" label="Add" />
     <button command="explorer-delete:command" label="Delete" />
     <button command="explorer-rename:command" label="Rename" />