[Zope-CVS] CVS: Packages/Moztop/moztop/content - moztop.js:1.21

Stephan Richter srichter@cbu.edu
Sat, 15 Mar 2003 19:08:43 -0500


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

Modified Files:
	moztop.js 
Log Message:
Yeah, fixed the "Open Selected Resource" function. The getSelectedResource
method only checked the this.ds datasource and not the this.sitedatasources
for the node, so it would not find any of the content objects. 

Now that this is fixed, you can open both sites and folders. 

I also added some documentation where I touch the code. Added SitesManager
API methods list to Explorer doc string.

To do: 

- Move SitesManager out of Explorer.js into SitesManager.js

- Implement retrieval of resource types (RDF) from server.

- Implement other content object views.

- Implement add and delete resource.


=== Packages/Moztop/moztop/content/moztop.js 1.20 => 1.21 ===
--- Packages/Moztop/moztop/content/moztop.js:1.20	Sat Mar 15 17:24:45 2003
+++ Packages/Moztop/moztop/content/moztop.js	Sat Mar 15 19:08:13 2003
@@ -1,198 +1,192 @@
-/*****************************************************************************
-*
-* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
-* All Rights Reserved.
-*
-* This software is subject to the provisions of the Zope Public License,
-* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-* FOR A PARTICULAR PURPOSE.
-*
-******************************************************************************
-Here we define variables and functions that are relevant to the main Moztop
-window, which means this *is* the right place to define global RDF 
-datasources. 
-
-$Id$
-
-******************************************************************************/
-
-/* Setup the global RDFDataSources objects and initialize later */
-var sitesmanager = null;
-var logmanager = null;
-var taskmanager = null;
-
-/* Function that is executed when Moztop is started. */
-function startProgram() {
-    initLogManager();
-    /* We now have logmanger, let's use it */
-    logmanager.addMessage("Initializing Explorer","moztop.js, startProgram");
-    initTaskManager();
-    initExplorer();
-}
-
-/* Function that is executed when Moztop is started. */
-function closeProgram() {
-    window.close()
-}
-
-/* Function to generate the 'About Moztop' Dialog. */
-function showAbout() {
-    info = window.openDialog("chrome://moztop/content/About/dialog.xul",
-           "showmore", "chrome,modal,centerscreen,width=450,height=350");
-}
-
-/* Function to generate the 'About Moztop' Dialog. */
-function showZope3() {
-    info = alert('Zope 3\n\n' +
-	  'Zope 3 is a professional award-winning Application Server. ' +
-          'For more information see http://www.zope.org/')
-}
-
-
-/* Debug function, dumps known datasouces to stdout using dump() */
-function dumpDataSourceManagers () {
-    var s = logmanager.ds.serializeToString();
-    dump("Dumping log messages..........\n" + s);
-
-    var s = sitesmanager.ds.serializeToString();
-    dump("Dumping sites..........\n" + s);
-
-    var s = sitesmanager.commontypesds.serializeToString();
-    dump("\nDumping common types..........\n" + s + "\n");
-
-    var s = sitesmanager.sitedatasources[
-	"http://localhost:8080/Plone/"].serializeToString();
-    dump("Dumping localhostplone..........\n" + s);
-
-
-}
-
-function DataSourceManager () {
-    /* A superclass for the various datasources */
-    
-    this.dcns = "http://www.purl.org/dc/1.1#";
-    this.zoperdfns = "http://www.zope.org/rdf#";
-    this.ncns ="http://home.netscape.com/NC-rdf#";
-    
-    this.titleprop = this.dcns + "title";
-    this.descriptionprop = this.dcns + "description";
-    this.resourcetypeprop = this.zoperdfns + "resourcetype";
-    this.urlprop = this.zoperdfns + "url";
-    this.usernameprop = this.zoperdfns + "username";
-    this.passwordprop = this.zoperdfns + "password";
-    this.styleidprop = this.zoperdfns + "styleid";
-    this.subitemsprop = this.ncns + "subitems";
-    
-    this.profileurl = this.getProfileDirURL();
-    this.elementid = null;
-}
-
-DataSourceManager.prototype.getProfileDirURL=
-  function ()
-{
-
-  // First get the directory service and query interface it to
-  // nsIProperties
-  var dirService = Components.
-      classes['@mozilla.org/file/directory_service;1'].
-      getService(Components.interfaces.nsIProperties);
-
-  // Next get the "ProfD" property of type nsIFile from the directory
-  // service, FYI this constant is defined in
-  // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
-
-  const NS_APP_USER_PROFILE_50_DIR = "ProfD";
-  profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
-	Components.interfaces.nsIFile);
-
-  // Now that we have it we can show it's path. See nsIFile for the
-  // other things you that can be done with profileDir
-
-	var io_service =
-	Components.classes["@mozilla.org/network/io-service;1"].
-	getService(Components.interfaces.nsIIOService);
-   
-  var url = io_service.newFileURI(profileDir)
-     .QueryInterface(Components.interfaces.nsIFileURL);
-   
-  return url.spec;
-}
-
-
-DataSourceManager.prototype.getSelectedResource=
-  function ()
-{
-    /* For all trees, this returns a selected resource */
-    var tree = document.getElementById(this.elementid);
-    var index = tree.view.selection.currentIndex;
-
-    if (index == -1) return false;
-    var rdf = tree.view.getItemAtIndex(index).resource;
-
-    /* Now grab this ds and return a RDFNode */
-    
-    return this.ds.getNode(rdf.Value);
-}
-
-
-DataSourceManager.prototype.sendServerMessage=
-  function ()
-{
-  return;
-}
-
-
-DataSourceManager.prototype.reloadElementDataSources=
-  function ()
-{
-  return;
-}
-
-
-DataSourceManager.prototype.dumpDataSources=
-  function ()
-{
-  return;
-}
-
-
-DataSourceManager.prototype.viewDataSources=
-  function ()
-{
-  return;
-}
-
-const commontypes_data = '<?xml version="1.0"?>' +
-    '<RDF:RDF xmlns:dc="http://www.purl.org/dc/1.1#"' +
-    '         xmlns:site="http://www.zope.org/rdf#"' +
-    '         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
-    '<RDF:Description about="urn:moztop:resourcetypes:site">' +
-    '<dc:title>Site</dc:title>' +
-    '<site:styleid>site</site:styleid>' +
-    '</RDF:Description>' +
-    '' +
-    '<RDF:Description about="urn:moztop:resourcetypes:configurations">' +
-    '<dc:title>Configurations</dc:title>' +
-    '<site:styleid>configurations</site:styleid>' +
-    '</RDF:Description>' +
-    '' +
-    '<RDF:Description about="urn:moztop:resourcetypes:content">' +
-    '<dc:title>Content</dc:title>' +
-    '<site:styleid>Content</site:styleid>' +
-    '</RDF:Description>' +
-    '' +
-    '<RDF:Description about="urn:moztop:resourcetypes:packages">' +
-    '<dc:title>Packages</dc:title>' +
-    '<site:styleid>packages</site:styleid>' +
-    '</RDF:Description>' +
-    '' +
-    '<RDF:Description about="urn:moztop:resourcetypes:package">' +
-    '<dc:title>Package</dc:title>' +
-    '<site:styleid>package</site:styleid>' +
-    '</RDF:Description>' +
-    '' +
-    '</RDF:RDF>';
-
+/*****************************************************************************
+*
+* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
+* All Rights Reserved.
+*
+* This software is subject to the provisions of the Zope Public License,
+* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+* FOR A PARTICULAR PURPOSE.
+*
+******************************************************************************
+Here we define variables and functions that are relevant to the main Moztop
+window, which means this *is* the right place to define global RDF 
+datasources. 
+
+$Id$
+
+******************************************************************************/
+
+/* Setup the global RDFDataSources objects and initialize later */
+var sitesmanager = null;
+var logmanager = null;
+var taskmanager = null;
+
+/* Function that is executed when Moztop is started. */
+function startProgram() {
+    initLogManager();
+    /* We now have logmanger, let's use it */
+    logmanager.addMessage("Initializing Explorer","moztop.js, startProgram");
+    initTaskManager();
+    initExplorer();
+}
+
+/* Function that is executed when Moztop is started. */
+function closeProgram() {
+    window.close()
+}
+
+/* Function to generate the 'About Moztop' Dialog. */
+function showAbout() {
+    info = window.openDialog("chrome://moztop/content/About/dialog.xul",
+           "showmore", "chrome,modal,centerscreen,width=450,height=350");
+}
+
+/* Function to generate the 'About Moztop' Dialog. */
+function showZope3() {
+    info = alert('Zope 3\n\n' +
+	  'Zope 3 is a professional award-winning Application Server. ' +
+          'For more information see http://www.zope.org/')
+}
+
+
+/* Debug function, dumps known datasouces to stdout using dump() */
+function dumpDataSourceManagers () {
+    var s = logmanager.ds.serializeToString();
+    dump("Dumping log messages..........\n" + s);
+
+    var s = sitesmanager.ds.serializeToString();
+    dump("Dumping sites..........\n" + s);
+
+    var s = sitesmanager.commontypesds.serializeToString();
+    dump("Dumping common types..........\n" + s + "\n");
+
+    var s = sitesmanager.sitedatasources[
+	"http://localhost:8080/Plone/"].serializeToString();
+    dump("Dumping localhostplone..........\n" + s);
+
+
+}
+
+function DataSourceManager () {
+    /* A superclass for the various datasources */
+    
+    this.dcns = "http://www.purl.org/dc/1.1#";
+    this.zoperdfns = "http://www.zope.org/rdf#";
+    this.ncns ="http://home.netscape.com/NC-rdf#";
+    
+    // XXX: HACK ALARM! There is no way all these attributes are needed for
+    // all datasource managers!
+    this.titleprop = this.dcns + "title";
+    this.descriptionprop = this.dcns + "description";
+    this.resourcetypeprop = this.zoperdfns + "resourcetype";
+    this.urlprop = this.zoperdfns + "url";
+    this.usernameprop = this.zoperdfns + "username";
+    this.passwordprop = this.zoperdfns + "password";
+    this.styleidprop = this.zoperdfns + "styleid";
+    this.subitemsprop = this.ncns + "subitems";
+    
+    this.profileurl = this.getProfileDirURL();
+    this.elementid = null;
+}
+
+DataSourceManager.prototype.getProfileDirURL = function() {
+  // First get the directory service and query interface it to
+  // nsIProperties
+  var dirService = Components.
+      classes['@mozilla.org/file/directory_service;1'].
+      getService(Components.interfaces.nsIProperties);
+
+  // Next get the "ProfD" property of type nsIFile from the directory
+  // service, FYI this constant is defined in
+  // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
+
+  const NS_APP_USER_PROFILE_50_DIR = "ProfD";
+  profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
+	Components.interfaces.nsIFile);
+
+  // Now that we have it we can show it's path. See nsIFile for the
+  // other things you that can be done with profileDir
+
+	var io_service =
+	Components.classes["@mozilla.org/network/io-service;1"].
+	getService(Components.interfaces.nsIIOService);
+   
+  var url = io_service.newFileURI(profileDir)
+     .QueryInterface(Components.interfaces.nsIFileURL);
+   
+  return url.spec;
+}
+
+
+DataSourceManager.prototype.getSelectedResource = function() {
+    /* For all trees, this returns a selected resource */
+    var tree = document.getElementById(this.elementid);
+    var index = tree.view.selection.currentIndex;
+
+    if (index == -1) return false;
+    var rdf = tree.view.getItemAtIndex(index).resource;
+
+    /* Now grab this ds and return a RDFNode */
+    
+    return this.ds.getNode(rdf.Value);
+}
+
+
+DataSourceManager.prototype.sendServerMessage = function() {
+  return;
+}
+
+
+DataSourceManager.prototype.reloadElementDataSources = function() {
+  return;
+}
+
+
+DataSourceManager.prototype.dumpDataSources = function() {
+  return;
+}
+
+
+DataSourceManager.prototype.viewDataSources = function() {
+  return;
+}
+
+const commontypes_data = '<?xml version="1.0"?>' +
+    '<RDF:RDF xmlns:dc="http://www.purl.org/dc/1.1#"' +
+    '         xmlns:site="http://www.zope.org/rdf#"' +
+    '         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
+    '<RDF:Description about="urn:moztop:resourcetypes:site">' +
+    '<dc:title>Site</dc:title>' +
+    '<site:styleid>site</site:styleid>' +
+    '</RDF:Description>' +
+    '' +
+    '<RDF:Description about="urn:moztop:resourcetypes:folder">' +
+    '<dc:title>Folder</dc:title>' +
+    '<site:styleid>folder</site:styleid>' +
+    '</RDF:Description>' +
+    '' +
+    '<RDF:Description about="urn:moztop:resourcetypes:configurations">' +
+    '<dc:title>Configurations</dc:title>' +
+    '<site:styleid>configurations</site:styleid>' +
+    '</RDF:Description>' +
+    '' +
+    '<RDF:Description about="urn:moztop:resourcetypes:content">' +
+    '<dc:title>Content</dc:title>' +
+    '<site:styleid>Content</site:styleid>' +
+    '</RDF:Description>' +
+    '' +
+    '<RDF:Description about="urn:moztop:resourcetypes:packages">' +
+    '<dc:title>Packages</dc:title>' +
+    '<site:styleid>packages</site:styleid>' +
+    '</RDF:Description>' +
+    '' +
+    '<RDF:Description about="urn:moztop:resourcetypes:package">' +
+    '<dc:title>Package</dc:title>' +
+    '<site:styleid>package</site:styleid>' +
+    '</RDF:Description>' +
+    '' +
+    '</RDF:RDF>';
+