[Zope-CVS] CVS: Packages/Moztop/moztop/content/Menu - ToolBar.js:1.14

Stephan Richter srichter@cbu.edu
Thu, 16 Jan 2003 04:55:43 -0500


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

Modified Files:
	ToolBar.js 
Log Message:
- We now have the sense of a first static TypeRegistry. Much more work is 
  needed in this area.

- If you have an image, you can now save its meta data and see the Upload
  screen. Trying to open the File Picker somehow crashes my Mozilla.

- All types that Zope supports are now listed and can be handled in the 
  contents.rdf file.


=== Packages/Moztop/moztop/content/Menu/ToolBar.js 1.13 => 1.14 ===
--- Packages/Moztop/moztop/content/Menu/ToolBar.js:1.13	Thu Jan 16 00:03:09 2003
+++ Packages/Moztop/moztop/content/Menu/ToolBar.js	Thu Jan 16 04:55:40 2003
@@ -34,6 +34,19 @@
     var tabpanels = document.getElementById("active-contents-tabpanels");
     index = tree.view.selection.currentIndex;
     rdf = tree.view.getItemAtIndex(index).resource;
+
+
+    var ds = new RDFDataSource();
+    var sources = tree.database.GetDataSources();
+    sources.getNext()
+    ds.Init(sources.getNext().QueryInterface(
+		Components.interfaces.nsIRDFDataSource));
+    
+    node = ds.getNode(rdf.Value);
+    node = node.getTarget("http://home.netscape.com/NC-rdf#resourcetype");
+    var type = node.getValue();
+    type = type.split('#')[1];
+
     var parent = rdf.Value.replace('urn:explorer:data', '');
     while (parent.indexOf(":") > -1)
 	parent = parent.replace(":", "/");
@@ -58,19 +71,20 @@
     newtabpanel.setAttribute('id', parent+'-tabpanel');
     tabpanels.appendChild(newtabpanel);
 
-    createViewTabs('Folder', parent, newtabpanel);
+    createViewTabs(type, parent, newtabpanel);
     _removeWelcome();
     tabpanels.selectedPanel = newtabpanel;
 }
 
+
 /* Create all view tabs for a content object of the specified type */
 function createViewTabs(type, name, parent_tabpanel) {
 
-    var sub_tab_ids = new Array(4);
-    sub_tab_ids[0] = 'Content'
-    sub_tab_ids[1] = 'Preview'
-    sub_tab_ids[2] = 'MetaData'
-    sub_tab_ids[3] = 'Security'
+    TypeRegistry = {"Folder": 
+		    ["Content", "Preview", "MetaData", "Security"],
+		    "Image":
+		    ["Upload", "Preview", "MetaData", "Security"]
+    }
 
     var tabbox = document.createElement("tabbox");
     tabbox.setAttribute('id', name+'-tabbox');
@@ -88,7 +102,7 @@
      
     for (var index = 0; index < 4; index++) {
 	var tab = document.createElement("tab");
-	tab.setAttribute("label", sub_tab_ids[index]);
+	tab.setAttribute("label", TypeRegistry[type][index]);
 	tabs.appendChild(tab);
 
 	var tabpanel = document.createElement("tabpanel");
@@ -97,7 +111,7 @@
 	var iframe = document.createElement("iframe");
 	iframe.setAttribute('src', 
 	   'chrome://moztop/content/ContentObjects/' + type + '/' +
-           sub_tab_ids[index] + '.xul');
+           TypeRegistry[type][index] + '.xul');
 	iframe.setAttribute('flex', '1');
 	tabpanel.appendChild(iframe);
     }