[Commits] (john) - Rewrote sidebar navigation to make it more complete and much simpler

commits at osafoundation.org commits at osafoundation.org
Mon Feb 2 08:36:27 PST 2004


Commit by: john
Modified files:
osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml 1.6 1.7
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Node.py None 1.1
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py 1.6 1.7
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml 1.40 1.41
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py 1.52 1.53
osaf/chandler/Chandler/parcels/OSAF/views/locations/parcel.xml None 1.1

Log message:
- Rewrote sidebar navigation to make it more complete and much simpler
- Made a partial pass simplifying and generalizing navigation bar. more work remains
- Added persistent URL mechanism
- Fixed a minor bug in broadcast
- Persist selection in sidebar
- Use events to connect Sidebar and navigation bar blocks instead of hardcoding communication between blocks


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Node.py?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml.diff?r1=text&tr1=1.40&r2=text&tr2=1.41
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py.diff?r1=text&tr1=1.52&r2=text&tr2=1.53
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/views/locations/parcel.xml?rev=1.1&content-type=text/vnd.viewcvs-markup

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py:1.6 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py:1.7
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py:1.6	Fri Jan 30 14:29:01 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Views.py	Mon Feb  2 08:35:55 2004
@@ -27,9 +27,9 @@
               Call method named methodName on every block and it's children
             who implements it
             """
-            if block:
-                callMethod (block, methodName, notification)
-                for child in block.childrenBlocks:
+            callMethod (block, methodName, notification)
+            for child in block.childrenBlocks:
+                if child and not child.eventBoundary:
                     broadcast (child, methodName, notification)
 
         event = notification.event

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml:1.40 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml:1.41
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml:1.40	Fri Jan 30 15:56:48 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml	Mon Feb  2 08:35:55 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.40 $ -->
-<!-- $Date: 2004/01/30 23:56:48 $ -->
+<!-- $Revision: 1.41 $ -->
+<!-- $Date: 2004/02/02 16:35:55 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -320,11 +320,18 @@
       <defaultValue type="Boolean">False</defaultValue>
     </Attribute>
 
+
+    <Attribute itemName="eventBoundary">
+      <type itemref="Boolean"/>
+      <defaultValue type="Boolean">False</defaultValue>
+    </Attribute>
+
     <attributes itemref="docSchema:Block/contentSpec"/>
     <attributes itemref="docSchema:Block/childrenBlocks"/>
     <attributes itemref="docSchema:Block/parentBlock"/>
     <attributes itemref="docSchema:Block/styles"/>
     <attributes itemref="docSchema:Block/open"/>
+    <attributes itemref="docSchema:Block/eventBoundary"/>
   </Kind>
   
   <!--
@@ -343,13 +350,6 @@
   <Kind itemName="ContainerChild">
     <classes key="python">OSAF.framework.blocks.ContainerBlocks.ContainerChild</classes>
     <superKinds itemref="docSchema:Block"/>
-
-    <Attribute itemName="eventBoundary">
-      <type itemref="Boolean"/>
-      <defaultValue type="Boolean">False</defaultValue>
-    </Attribute>
-
-    <attributes itemref="docSchema:ContainerChild/eventBoundary"/>
   </Kind>
 
   <!--
@@ -872,6 +872,10 @@
       <defaultValue type="String"></defaultValue>
     </Attribute>
 
+    <Attribute itemName="rootPath">
+      <type itemref="Item"/>
+    </Attribute>
+
     <attributes itemref="docSchema:TreeList/hideRoot"/>
     <attributes itemref="docSchema:TreeList/noLines"/>
     <attributes itemref="docSchema:TreeList/useButtons"/>    
@@ -879,6 +883,7 @@
     <attributes itemref="docSchema:TreeList/columnWidths"/>
     <attributes itemref="docSchema:TreeList/openedContainers"/>
     <attributes itemref="docSchema:TreeList/selection"/>
+    <attributes itemref="docSchema:TreeList/rootPath"/>
   </Kind>  
 
   <!--
@@ -914,5 +919,33 @@
     <attributes itemref="docSchema:ItemView/selection"/>
   </Kind>  
 
+  <!--
+    Node
+  -->
+  <Kind itemName="Node">
+    <classes key="python">OSAF.framework.blocks.Node.Node</classes>
+
+    <Attribute itemName="parent">
+      <type itemref="docSchema:Node"/>
+      <cardinality>single</cardinality>
+      <inverseAttribute itemref="docSchema:Node/children"/>
+    </Attribute>
+  
+    <Attribute itemName="children">
+      <type itemref="docSchema:Node"/>
+      <cardinality>list</cardinality>
+      <inverseAttribute itemref="docSchema:Node/parent"/>
+    </Attribute>
+
+    <Attribute itemName="item">
+      <type itemref="docSchema:Block"/>
+      <cardinality>single</cardinality>
+    </Attribute>
+
+    <attributes itemref="docSchema:Node/children"/>
+    <attributes itemref="docSchema:Node/parent"/>
+    <attributes itemref="docSchema:Node/item"/>
+  </Kind>
+  
 </Parcel>
 

Index: osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml:1.6 osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml:1.7
--- osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml:1.6	Fri Jan 30 15:56:47 2004
+++ osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml	Mon Feb  2 08:35:54 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.6 $ -->
-<!-- $Date: 2004/01/30 23:56:47 $ -->
+<!-- $Revision: 1.7 $ -->
+<!-- $Date: 2004/02/02 16:35:54 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -10,7 +10,10 @@
              xmlns:core="//Schema/Core"
              xmlns="//parcels/OSAF/framework/blocks"
              xmlns:doc="//parcels/OSAF/views/main"
-             xmlns:events="//parcels/OSAF/framework/blocks/Events">
+             xmlns:events="//parcels/OSAF/framework/blocks/Events"
+             xmlns:repository="//parcels/OSAF/views/repositoryviewer"
+             xmlns:demo="//parcels/OSAF/views/demo"
+             xmlns:zaobao="//parcels/OSAF/views/zaobao">
 
   <core:version>0.3</core:version>
 
@@ -264,6 +267,31 @@
   </StatusBar>
 
   <!--
+    Sidebar locations
+  -->
+  <Node itemName="URLRoot">
+    <displayName></displayName>
+    <children itemref="doc:Repository"/>
+    <children itemref="doc:Demo"/>
+    <children itemref="doc:ZaoBao"/>
+  </Node>
+
+  <Node itemName="Repository">
+    <displayName>Repository</displayName>
+    <item itemref="repository:RepositoryBox"/>
+  </Node>
+
+  <Node itemName="Demo">
+    <displayName>Demo</displayName>
+    <item itemref="demo:TabBox"/>
+  </Node>
+
+  <Node itemName="ZaoBao">
+    <displayName>ZaoBao</displayName>
+    <item itemref="zaobao:ZaoBaoTab"/>
+  </Node>
+
+  <!--
     Layout blocks
   -->
   <EmbeddedContainer itemName="ParcelViewer">
@@ -284,6 +312,8 @@
     <useButtons>False</useButtons>
     <columnHeadings>View</columnHeadings>    
     <columnWidths>200</columnWidths>
+    <rootPath  itemref="doc:URLRoot"/>
+    <selection>/Repository</selection>
 
     <open>True</open>
     <size>200,600</size>

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.52 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.53
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.52	Fri Jan 30 15:56:48 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py	Mon Feb  2 08:35:55 2004
@@ -1,5 +1,6 @@
 import application.Globals as Globals
 from Block import Block
+from Node import Node
 from wxPython.wx import *
 from wxPython.gizmos import *
 from wxPython.html import *
@@ -183,29 +184,35 @@
         child.Destroy ()
         parent.Layout ()
     
-    def switchEmbeddedContents(self, newPath):
-        oldChild = Globals.repository.find (self.contentSpec.data)
-        wxOldChild = Globals.association [oldChild.getUUID()]
-        embeddedPanel = Globals.association [self.getUUID()]
-        embeddedSizer = embeddedPanel.GetSizer ()
-        embeddedSizer.Remove(wxOldChild)
-        wxOldChild.Destroy()
-        embeddedSizer.Layout()
-        oldChild.parentBlock = None
-        
-        self.contentSpec.data = newPath     
-        newChild = Globals.repository.find (self.contentSpec.data)
-        if newChild:
-            newChild.parentBlock = self
-            newChild.render (embeddedSizer, embeddedPanel)
-        embeddedSizer.Layout()
+    def OnSelectionChangedEvent(self, notification):
+        node = notification.data['item']
+        if node and isinstance(node, Node):
+            newChild = node.item
+            if isinstance(newChild, Block):
+                try:
+                    embeddedPanel = Globals.association [self.getUUID()]
+                except KeyError:
+                    return  # embedded container hasn't been rendered yet
+                embeddedSizer = embeddedPanel.GetSizer ()
+
+                oldChild = Globals.repository.find (self.contentSpec.data)
+                wxOldChild = Globals.association [oldChild.getUUID()]
+                self.removeFromContainer (embeddedSizer, wxOldChild)
+                oldChild.parentBlock = None
+            
+                newChild = node.item
+                self.contentSpec.data = str (newChild.getItemPath())
+                newChild.parentBlock = self
+                newChild.render (embeddedSizer, embeddedPanel)
+                embeddedSizer.Layout()
         
             
 class Button(RectangularChild):
     def renderOneBlock(self, parent, parentWindow):
-        id = 0
-        if self.hasAttributeValue ("clicked"):  # Repository bug/feature -- DJA
+        try:
             id = self.clicked.getwxID()
+        except AttributeError:
+            id = 0
 
         if self.buttonKind == "Text":
             button = wxButton(parentWindow, id, self.title,
@@ -535,9 +542,9 @@
             pass
         elif self.toolbarItemKind == 'Text':
             tool = wxTextCtrl (wxToolbar, -1, "", 
-                                  wxDefaultPosition, 
-                                  wxSize(300,-1), 
-                                  wxTE_PROCESS_ENTER)
+                               wxDefaultPosition, 
+                               wxSize(300,-1), 
+                               wxTE_PROCESS_ENTER)
             tool.SetName(self.title)
             wxToolbar.AddControl (tool)
             EVT_TEXT_ENTER(tool, tool.GetId(), toolbar.toolEnterPressed)
@@ -690,7 +697,7 @@
     def GoToPath(self, path):
         treeNode = self.GetRootItem()
         counterpart = Globals.repository.find (self.counterpartUUID)
-        child = None
+        child = treeNode
         for name in path.split ('/'):
             if name:
                 assert (self.ItemHasChildren (treeNode))
@@ -711,9 +718,8 @@
                       path doesn't exist
                     """
                     return
-        if child:
-            self.SelectItem (child)
-            self.ScrollTo (child)
+        self.SelectItem (child)
+        self.ScrollTo (child)
 
 
 class TreeList(RectangularChild):
@@ -725,6 +731,7 @@
     def __init__(self, *arguments, **keywords):
         super (TreeList, self).__init__ (*arguments, **keywords)
         self.openedContainers = {}
+        self.rootPath = None
 
     def renderOneBlock(self, parent, parentWindow, nativeWindow=None):
         if nativeWindow:
@@ -778,35 +785,33 @@
 
     def OnSelectionChangedEvent (self, notification):
         wxTreeListWindow = Globals.association[self.getUUID()]
-        wxTreeListWindow.GoToPath (str (notification.GetData()['item'].getItemPath()))
+        path = str (notification.GetData()['item'].getItemPath())
+        wxTreeListWindow.GoToPath (path)
 
 
 class Sidebar(TreeList):
     def GetTreeData (self, node):
         item = node.GetData()
         if item:
-            for child in item:
-                node.AddChildNode (child[1], [child[0]], false)
+            for child in item.children:
+                node.AddChildNode (child,
+                                   [self.GetTreeDataName (child)],
+                                   len(child.children) != 0)
         else:
-            node.AddRootNode ([('Repository Viewer','parcels/OSAF/views/repositoryviewer/RepositoryBox'),
-                               ('Demo', 'parcels/OSAF/views/demo/TabBox'), 
-                               ('Zaobao', 'parcels/OSAF/views/zaobao/ZaoBaoTab')], 
-                              ['Views'], true)
+            node.AddRootNode (self.rootPath, [""], len(self.rootPath.children) != 0)
             
     def GetTreeDataName (self, item):
         return item.getItemDisplayName()
 
     def OnSelectionChangedEvent (self, notification):
-        path = notification.data['item']
-        parcelViewer = Globals.repository.find('//parcels/OSAF/views/main/ParcelViewer')
-        parcelViewer.switchEmbeddedContents(path)
-
-    def SelectItem(self, itemId):
-        treeList = Globals.association[self.getUUID()]
-        treeList.ignoreSelect = true
-        treeList.SelectItem(itemId)
-        treeList.ignoreSelect = false
-        
+        try:
+            path = notification.GetData()['item'].GetPath()
+        except AttributeError:
+            return
+        wxTreeListWindow = Globals.association[self.getUUID()]
+        wxTreeListWindow.GoToPath (path)
+
+
 class NavigationBar(Toolbar):
     def renderOneBlock(self, parent, parentWindow):
         self.history = []
@@ -825,37 +830,33 @@
     def tooEnterPressed(self, event):
         tool = Block.wxIDToObject(event.GetId())
         
+    def SendSelectionChanged(self, item):
+        chandlerEvent = Globals.repository.find('//parcels/OSAF/framework/blocks/Events/SelectionChanged')
+        notification = Notification(chandlerEvent, None, None)
+        notification.SetData ({'item':item, 'type':'Normal'})
+        Globals.notificationManager.PostNotification (notification)
+
     def GoBack(self):
         if len(self.history) > 1:
             currentLocation = self.history.pop()
             self.future.append(currentLocation)
-            newName, newPath, id = self.history[-1]
-            urlBox = Globals.repository.find('//parcels/OSAF/views/main/URLBox')
-            wxURLBox = Globals.association[urlBox.getUUID()]
-            wxURLBox.SetValue(newName)
-            parcelViewer = Globals.repository.find('//parcels/OSAF/views/main/ParcelViewer')
-            parcelViewer.switchEmbeddedContents(newPath)
-            sidebar = Globals.repository.find('//parcels/OSAF/views/main/Sidebar')
-            sidebar.SelectItem(id)
+            self.SendSelectionChanged (self.history[-1])
     
     def GoForward(self):
         if len(self.future) > 0:
             newLocation = self.future.pop()
             self.history.append(newLocation)
-            urlBox = Globals.repository.find('//parcels/OSAF/views/main/URLBox')
-            wxURLBox = Globals.association[urlBox.getUUID()]
-            wxURLBox.SetValue(newLocation[0])
-            parcelViewer = Globals.repository.find('//parcels/OSAF/views/main/ParcelViewer')
-            parcelViewer.switchEmbeddedContents(newLocation[1])
-            sidebar = Globals.repository.find('//parcels/OSAF/views/main/Sidebar')
-            sidebar.SelectItem(newLocation[2])
+            self.SendSelectionChanged (newLocation)
 
     def OnSelectionChangedEvent (self, notification):
-        name = notification.data['name']
-        path = notification.data['item']
-        id = notification.data['id']
-        self.history.append((name,path,id))
-        self.future = []
-        urlBox = Globals.repository.find('//parcels/OSAF/views/main/URLBox')
+        item = notification.data['item']
+        try:
+            path = item.GetPath()
+        except AttributeError:
+            return
+
+        if len(self.history) == 0 or self.history[-1] != item:
+            self.history.append(item)
+        urlBox = Globals.repository.find ('//parcels/OSAF/views/main/URLBox')
         wxURLBox = Globals.association[urlBox.getUUID()]
-        wxURLBox.SetValue(name)
+        wxURLBox.SetValue(path)



More information about the Commits mailing list