[Zope-CVS] CVS: Packages/Moztop/moztop/content/ContentObjects/Folder - Content.js:1.1 Content.xul:1.2

Stephan Richter srichter@cbu.edu
Thu, 16 Jan 2003 01:21:01 -0500


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

Modified Files:
	Content.xul 
Added Files:
	Content.js 
Log Message:
- Content Tab is working for Folders.

- Updated CHANGES.txt to reflect my work.


=== Added File Packages/Moztop/moztop/content/ContentObjects/Folder/Content.js ===
/*****************************************************************************
*
* 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.
*
******************************************************************************
Contents Tab specific Javascript functions. 

$Id: Content.js,v 1.1 2003/01/16 06:20:58 srichter Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* Init contents tree */
function initContentsTree() {
    path = getActiveContentObjectPath();

    var ds = RDF.GetDataSource(RDF_BASE + path + '/@@contents.rdf');
    var tree = document.getElementById('navigationtree');
    tree.database.AddDataSource(ds);
    tree.setAttribute("ref", "urn:explorer:data");
    tree.builder.rebuild();
}

/* Load contents tree */
function loadContentsTree() {
    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/ContentObjects/Folder/Content.xul 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/ContentObjects/Folder/Content.xul:1.1	Wed Jan 15 08:53:04 2003
+++ Packages/Moztop/moztop/content/ContentObjects/Folder/Content.xul	Thu Jan 16 01:20:58 2003
@@ -4,9 +4,63 @@
 <?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>
 
 <window
+   onload = "initContentsTree();"
    xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-    <label value="Content" />
-    <image src="chrome://moztop/content/moztop.png" />
+  <script type="application/x-javascript" 
+          src="chrome://moztop/content/setup.js"/>
+  <script type="application/x-javascript" 
+          src="chrome://moztop/content/global.js"/>
+  <script type="application/x-javascript" src="Content.js"/>
+
+<tree flex="1" style="width:20em;" 
+    id="navigationtree"
+    datasources="rdf:null" 
+    containment="http://home.netscape.com/NC-rdf#subitems">
+  <treecols>
+    <treecol id="ResourceNameColumn" label="Name" primary="true" flex="1"/>
+    <splitter class="tree-splitter"/>
+    <treecol id="TypeColumn" label="Type" flex="1"/>
+  </treecols>
+
+   <template>
+      <rule>
+        <conditions>
+          <content uri="?uri" />
+          <triple subject="?uri"
+                  predicate="http://home.netscape.com/NC-rdf#subitems"
+                  object="?subitems" />
+          <member container="?subitems" child="?subitem" />
+          <triple subject="?subitem"
+                  predicate="http://home.netscape.com/NC-rdf#resourcetype"
+                  object="?resourcetype" />
+        </conditions>
+
+        <bindings>
+            <binding subject="?subitem"
+                    predicate="http://www.purl.org/dc/1.1#title"
+                    object="?name" />
+            <binding subject="?resourcetype"
+                    predicate="http://www.purl.org/dc/1.1#title"
+                    object="?resourcetypetitle"/>
+        </bindings>
+
+        <action>
+            <treechildren flex="1">
+                <treeitem uri="?subitem">
+                    <treerow>
+                        <treecell label="?name"/>
+                        <treecell label="?resourcetypetitle"/>
+                    </treerow>
+                </treeitem>
+            </treechildren>
+        </action>
+      </rule>
+    </template>
+</tree>
+   <box orient="horizontal">
+     <button onclick="loadContentsTree();" label="Refresh" />
+     <spring flex="100%" />
+   </box>
 
 </window>