[Zope3-checkins] CVS: Zope3/src/zope/app/browser/skins/rotterdam - xmltree.js:1.5 xmlobject.py:1.2 zope3.css:1.2 configure.zcml:1.2

Godefroid Chapelle gotcha@swing.be
Mon, 30 Dec 2002 06:40:40 -0500


Update of /cvs-repository/Zope3/src/zope/app/browser/skins/rotterdam
In directory cvs.zope.org:/tmp/cvs-serv4477

Modified Files:
	xmltree.js xmlobject.py zope3.css configure.zcml 
Log Message:
navigation tree is working on contained items also

styled action list to show multiline items


=== Zope3/src/zope/app/browser/skins/rotterdam/xmltree.js 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/skins/rotterdam/xmltree.js:1.4	Sat Dec 28 17:28:32 2002
+++ Zope3/src/zope/app/browser/skins/rotterdam/xmltree.js	Mon Dec 30 06:40:39 2002
@@ -21,7 +21,7 @@
 var baseurl;
 var navigationTree;
 
-var loglevel = LG_NOLOG;
+var loglevel = LG_INFO;
 
 
 
@@ -31,7 +31,7 @@
         this.isEmpty = 1;
         this.isCollapsed = 1;
         this.domNode = domNode;
-        this.name = '';
+        this.path = '';
         this.parentNode = null;
 }
 
@@ -41,13 +41,9 @@
         node.parentNode = this;
 }
 
-navigationTreeNode.prototype.getName = function() {
-        return this.name;
-}
-
-navigationTreeNode.prototype.setName = function(name) {
-        this.name = name;
-        this.domNode.setAttribute("name", name);
+navigationTreeNode.prototype.setPath = function(path) {
+        this.path = path;
+        this.domNode.setAttribute("path", path);
 }
 
 navigationTreeNode.prototype.collapse = function() {
@@ -65,14 +61,14 @@
         expand.style.backgroundImage = 'url("' + baseurl + '@@/' + icon + '")';
         }
 
-navigationTreeNode.prototype.getNodeByName = function(name) {
+navigationTreeNode.prototype.getNodeByPath = function(path) {
         var numchildren = this.childNodes.length;
-        if (name == this.name) {
+        if (path == this.path) {
                 return this;
                 }
         else {
                 for (var i=0; i< numchildren; i++) {
-                        foundChild = this.childNodes[i].getNodeByName(name);
+                        foundChild = this.childNodes[i].getNodeByPath(path);
                         if (foundChild) {
                                 return foundChild;
                                 }
@@ -88,7 +84,7 @@
         // todo xxx optimize for the case where collection has null length
         var elem = domNode;
         if (isEmpty) {
-                var url = baseurl + name + XML_CHILDREN_VIEW;
+                var url = baseurl + path + XML_CHILDREN_VIEW;
                 var data = loadtreexml(url);
                 addNavigationTreeNodes(data, this, 0);
                 isEmpty = 0;
@@ -244,7 +240,7 @@
         if (isExpand(elem)) {
                 //get collection node
                 elem = elem.parentNode;
-                var navTreeNode = navigationTree.getNodeByName(elem.getAttribute('name'));
+                var navTreeNode = navigationTree.getNodeByPath(elem.getAttribute('path'));
                 navTreeNode.toggleExpansion();
                 }
         }
@@ -253,7 +249,7 @@
 
 function getTargetURL(elem) {
         var location_href = baseurl;
-	location_href = location_href + elem.getAttribute('name');
+	location_href = location_href + elem.getAttribute('path');
 	location_href = location_href + CONTENT_VIEW;
         return location_href;
         }
@@ -342,14 +338,14 @@
         // create tree nodes from XML children nodes of sourceNode         
         // and add them to targetNode
         // if deep, create all descendants of sourceNode
-        var basename = "";
+        var basePath = "";
         if (targetNavTreeNode) {
-                basename = targetNavTreeNode.name;
+                basePath = targetNavTreeNode.path;
                 }
         var items = getCollectionChildNodes(sourceNode);
         var numitems = items.length;
         for (var i=0; i< numitems; i++) {
-                var navTreeChild = createNavigationTreeNode(items[i], basename, deep);
+                var navTreeChild = createNavigationTreeNode(items[i], basePath, deep);
                 if (targetNavTreeNode) {
                         targetNavTreeNode.appendChild(navTreeChild);
                         }
@@ -377,24 +373,24 @@
         return expandElem;
         }
 
-function createNavigationTreeNode(source, basename, deep) {
+function createNavigationTreeNode(source, basePath, deep) {
         var newelem = document.createElement(source.tagName);
 
         var navTreeNode = new navigationTreeNode(newelem);
-        var elemName;
+        var elemPath;
         var elemTitle;
-        //XXX should not hardcode root folder name string
+        //XXX should not hardcode root folder title string
         if (source.getAttribute('isroot') != null) {
                 elemTitle = '[top]';
-                elemName = basename;
+                elemPath = basePath;
                 newelem.style.marginLeft = '0px';
                 navigationTree = navTreeNode;
                 }
         else {
                 elemTitle = source.getAttribute('name');
-                elemName = basename + elemTitle + '/';
+                elemPath = basePath + elemTitle + '/';
                 }
-        navTreeNode.setName(elemName);
+        navTreeNode.setPath(elemPath);
         
         //could show number of child items
         var length = source.getAttribute('length');
@@ -411,7 +407,7 @@
                 var children = getCollectionChildNodes(source);
                 var numchildren = children.length;
                 for (var i=0; i< numchildren; i++) {
-                        var navTreeNodeChild =  createNavigationTreeNode(children[i], navTreeNode.name, deep); 
+                        var navTreeNodeChild =  createNavigationTreeNode(children[i], navTreeNode.path, deep); 
                         var newchild = navTreeNodeChild.domNode;
                         newelem.appendChild(newchild);
                         navTreeNode.appendChild(navTreeNodeChild);


=== Zope3/src/zope/app/browser/skins/rotterdam/xmlobject.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/skins/rotterdam/xmlobject.py:1.1	Thu Dec 26 15:20:48 2002
+++ Zope3/src/zope/app/browser/skins/rotterdam/xmlobject.py	Mon Dec 30 06:40:39 2002
@@ -1,28 +1,37 @@
 from zope.publisher.browser import BrowserView
 from zope.app.interfaces.container import IReadContainer
-from zope.app.traversing import objectName, getParents
+from zope.app.traversing import objectName, getParents, getParent
 from zope.component import queryView
+from zope.interface import Interface
 
-class XmlObjectView(BrowserView):
+
+class ReadContainerXmlObjectView(BrowserView):
     """Provide a xml interface for dynamic navigation tree in UI"""
 
     __used_for__ = IReadContainer
 
+    def getIconUrl(self, item):
+        result = ''
+        icon = queryView(item, 'zmi_icon', self.request) 
+        if icon:
+            result = icon.url()
+        return result
+
     def children_utility(self):
         """Return an XML document that contains the children of an object."""
         result = []
         container = self.context
         for name in container.keys():
             item = container[name]
-            icon = queryView(item, 'zmi_icon', self.request)
+            iconUrl = self.getIconUrl(item)
             if IReadContainer.isImplementedBy(item):
                 result.append(
                     '<collection name="%s" length="%s" icon_url="%s"/>'
-                    % (name, len(item), icon.url()))
+                    % (name, len(item), iconUrl))
             else:
                 result.append(
                     '<item name="%s" icon_url="%s"/>'
-                    % (name, icon.url()))
+                    % (name, iconUrl))
         return ' '.join(result)
 
         
@@ -45,24 +54,24 @@
         oldItem = self.context
         for item in getParents(self.context):
             # skip skin if present
-            if item == oldItem:
+            if item == oldItem:                
                     continue
             subItems = []
             for name in item.keys():
                 subItem = item[name]
-                icon = queryView(subItem, 'zmi_icon', self.request)
+                iconUrl = self.getIconUrl(subItem)
                 if IReadContainer.isImplementedBy(subItem):
                     if oldItem and subItem == oldItem:
                         subItems.append(
                             '<collection name="%s" length="%s" '
                             'icon_url="%s">%s</collection>'
-                            % (name, len(subItem), icon.url(), result)
+                            % (name, len(subItem), iconUrl, result)
                             )
                     else:
                         subItems.append(
                             '<collection name="%s" length="%s" '
                             'icon_url="%s"/>'
-                            % (name, len(subItem), icon.url())
+                            % (name, len(subItem), iconUrl)
                             )
                 else:
                     subItems.append('<item name="%s" />' % name)
@@ -71,11 +80,28 @@
             oldItem = item
 
         # do not forget root folder
-        icon = queryView(oldItem, 'zmi_icon', self.request)
+        iconUrl = self.getIconUrl(oldItem)
         result = ('<collection name="%s" length="%s" icon_url="%s" '
                   'isroot="">%s</collection>'
-                  % ('', len(oldItem), icon.url(), result)
+                  % ('', len(oldItem), iconUrl, result)
                   )
         
         self.request.response.setHeader('Content-Type', 'text/xml')
         return u'<?xml version="1.0" ?><children> %s </children>' % result
+ 
+class XmlObjectView(BrowserView):
+    """Provide a xml interface for dynamic navigation tree in UI"""
+
+    __used_for__ = Interface
+
+
+    def singleBranchTree(self, root=''):
+        parent = getParent(self.context)
+        while parent:
+                if IReadContainer.isImplementedBy(parent):
+                        container = parent
+                        view = queryView(container, 'singleBranchTree.xml', self.request)
+                        return view()
+                else:
+                    parent = getParent(parent)
+


=== Zope3/src/zope/app/browser/skins/rotterdam/zope3.css 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/skins/rotterdam/zope3.css:1.1	Thu Dec 26 15:20:48 2002
+++ Zope3/src/zope/app/browser/skins/rotterdam/zope3.css	Mon Dec 30 06:40:39 2002
@@ -284,20 +284,16 @@
     width: 64%;
 }
 
+#context_information {
+    float: left;
+    width: 18%;
+}
 #helpers {
-    /*float: left;
-    width: 18%;*/
 }
 
 #inspectors {
-    /*float: left;
-    width: 18%;*/
 }
 
-#context_information {
-    float: left;
-    width: 18%;
-}
 
 #footer {
     border-bottom: 1px solid black;
@@ -322,7 +318,7 @@
     font-weight: normal;
 
     padding: 0.1em 1em 0.3em 0.5em;
-    height: 1em;
+/*    height: 1em; */
 }
 
 div.box h4 {
@@ -345,6 +341,11 @@
     border: 1px solid #8CACBB;
     margin: 0;
     padding: 0.1em 1em 0.3em 0.5em;
+}
+
+div.box div.body a div{
+    display: list-item;
+    list-style-position: inside;
 }
 
 


=== Zope3/src/zope/app/browser/skins/rotterdam/configure.zcml 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/skins/rotterdam/configure.zcml:1.1	Thu Dec 26 15:20:48 2002
+++ Zope3/src/zope/app/browser/skins/rotterdam/configure.zcml	Mon Dec 30 06:40:39 2002
@@ -33,8 +33,15 @@
 <browser:view
     for="zope.app.interfaces.container.IReadContainer"
     permission="zope.View"
-    factory=".xmlobject.XmlObjectView">
+    factory=".xmlobject.ReadContainerXmlObjectView">
   <browser:page name="children.xml" attribute="children" />
+  <browser:page name="singleBranchTree.xml" attribute="singleBranchTree" />
+</browser:view>
+
+<browser:view
+    for="zope.interface.interface.Interface"
+    permission="zope.View"
+    factory=".xmlobject.XmlObjectView">
   <browser:page name="singleBranchTree.xml" attribute="singleBranchTree" />
 </browser:view>