[Commits] (john) * Removed SelectionContainer. ContentItemDetail is now a BoxContainer.

commits at osafoundation.org commits at osafoundation.org
Fri Jan 28 15:44:47 PST 2005


Commit by: john
Modified files:
chandler/parcels/osaf/framework/blocks/ContainerBlocks.py 1.147 1.148
chandler/parcels/osaf/framework/blocks/ControlBlocks.py 1.162 1.163
chandler/parcels/osaf/framework/blocks/Trunk.py 1.3 1.4
chandler/parcels/osaf/framework/blocks/parcel.xml 1.143 1.144
chandler/parcels/osaf/framework/blocks/detail/Detail.py 1.77 1.78
chandler/parcels/osaf/framework/blocks/detail/parcel.xml 1.57 1.58
chandler/parcels/osaf/views/content/parcel.xml 1.88 1.89
chandler/parcels/osaf/views/main/parcel.xml 1.161 1.162

Log message:
* Removed SelectionContainer. ContentItemDetail is now a BoxContainer.
   * Removed my versions of TrunkParentBlock and TrunkDelegates and modified TrunkParentBlock and TrunkDelegates to work in the rest of Chandler
   * Moved the detailRoot into the detail view's event boundary so it does't collide with events in the Summary View
   * TrunkParentBlock now uses detailItem as the item to display in the tree of blocks.
   * TrunkParentBlock now handles SelectItem events
   * The default TrunkDelegate uses keys that are Blocks which get copied to the soup and plugged into the TrunkParentBlock.
   * TrunkParentBlock and TrunkDelegates now uses bidirectional references
   * Fixed a bunch of bugs resulting from these changes
   * To me it seems like the detail view still has a bunch of synchronize code that is very complicated, doesn't work when you add a new blocks to the tree and seems totally unnecessary. It should be removed/refactored when the attribute editors are in place.

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/ContainerBlocks.py.diff?r1=text&tr1=1.147&r2=text&tr2=1.148
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/ControlBlocks.py.diff?r1=text&tr1=1.162&r2=text&tr2=1.163
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Trunk.py.diff?r1=text&tr1=1.3&r2=text&tr2=1.4
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/parcel.xml.diff?r1=text&tr1=1.143&r2=text&tr2=1.144
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/detail/Detail.py.diff?r1=text&tr1=1.77&r2=text&tr2=1.78
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/detail/parcel.xml.diff?r1=text&tr1=1.57&r2=text&tr2=1.58
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/content/parcel.xml.diff?r1=text&tr1=1.88&r2=text&tr2=1.89
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/parcel.xml.diff?r1=text&tr1=1.161&r2=text&tr2=1.162

Index: chandler/parcels/osaf/framework/blocks/ControlBlocks.py
diff -u chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.162 chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.163
--- chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.162	Thu Jan 27 13:50:29 2005
+++ chandler/parcels/osaf/framework/blocks/ControlBlocks.py	Fri Jan 28 15:44:44 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.162 $"
-__date__ = "$Date: 2005/01/27 21:50:29 $"
+__version__ = "$Revision: 1.163 $"
+__date__ = "$Date: 2005/01/28 23:44:44 $"
 __copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -1220,7 +1220,7 @@
         self.synchronizeWidget ()
 
     
-class ContentItemDetail(SelectionContainer):
+class ContentItemDetail(BoxContainer):
     """
     ContentItemDetail
     Any container block in the Content Item's Detail View hierarchy.
@@ -1239,11 +1239,6 @@
         if self.hasAttributeValue("colorStyle"):
             self.colorStyle.synchronizeColor(self)
            
-    def detailRoot(self):
-        # return the root of the Detail View
-        # delegate to our parent, until we get to the Detail View Root
-        return self.parentBlock.detailRoot()
-
 class wxPyTimer(wx.PyTimer):
     """ 
     A wx.PyTimer that has an IsShown() method, like all the other widgets

Index: chandler/parcels/osaf/framework/blocks/detail/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.57 chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.58
--- chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.57	Mon Jan 24 11:50:06 2005
+++ chandler/parcels/osaf/framework/blocks/detail/parcel.xml	Fri Jan 28 15:44:44 2005
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.57 $ -->
-<!-- $Date: 2005/01/24 19:50:06 $ -->
+<!-- $Revision: 1.58 $ -->
+<!-- $Date: 2005/01/28 23:44:44 $ -->
 <!-- Copyright (c) 2003-2005 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -89,24 +89,23 @@
     Layout blocks
   -->
   
-  <!-- Root -->
-  <!-- Each summary view copies one of these - when an Item is selected in it, 
+  <!-- DetailTrunkParentBlock -->
+  <!-- Each summary view has a copy of one these - when an Item is selected in it, 
        it asks the DetailTrunkCache to build an appropriate DetailTrunk for that item. -->
-  <TrunkParentBlock itsName="DetailRootTemplate"
-                     itemClass="osaf.framework.blocks.detail.Detail.DetailRoot">
-    <blockName value="DetailRootTemplate"/>
+  <TrunkParentBlock itsName="DetailTrunkParentBlock">
+    <blockName value="DetailTrunkParentBlock"/>
     <trunkDelegate itemref="doc:DetailTrunkDelegate"/>
   </TrunkParentBlock>
 
   <!-- We have one of this - it knows how to build a DetailTrunk for a given Item's Kind,
        out of the trees of blocks below, and persists it. -->
-  <TrunkDelegate itsName="DetailTrunkDelegate"
-                 itemClass="osaf.framework.blocks.detail.Detail.DetailTrunkDelegate">
+  <DetailTrunkDelegate itsName="DetailTrunkDelegate">
     <trunkStub itemref="doc:DetailTrunkStub"/>
-  </TrunkDelegate>
+  </DetailTrunkDelegate>
 
   <!-- The DetailTrunkCache starts each specific DetailTrunk by cloning this stub. -->
-  <ContentItemDetail itsName="DetailTrunkStub">
+  <ContentItemDetail itsName="DetailTrunkStub"
+                     itemClass="osaf.framework.blocks.detail.Detail.DetailRoot">
     <blockName value="DetailTrunkStub"/>
     <!-- Attributes -->
     <orientationEnum>Vertical</orientationEnum>

Index: chandler/parcels/osaf/views/content/parcel.xml
diff -u chandler/parcels/osaf/views/content/parcel.xml:1.88 chandler/parcels/osaf/views/content/parcel.xml:1.89
--- chandler/parcels/osaf/views/content/parcel.xml:1.88	Thu Jan 27 22:03:45 2005
+++ chandler/parcels/osaf/views/content/parcel.xml	Fri Jan 28 15:44:45 2005
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.88 $ -->
-<!-- $Date: 2005/01/28 06:03:45 $ -->
+<!-- $Revision: 1.89 $ -->
+<!-- $Date: 2005/01/28 23:44:45 $ -->
 <!-- Copyright (c) 2004-2005 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -190,7 +190,7 @@
     <contents itemref="view:calendarItemCollection"/>
 
     <childrenBlocks itemref="view:CalendarSummary"/>
-    <childrenBlocks itemref="detail:DetailRootTemplate" copy="DetailRoot"/>
+    <childrenBlocks itemref="detail:DetailTrunkParentBlock" copy="CalendarDetailTrunkParentBlock"/>
 
     <eventBoundary>True</eventBoundary>
     <orientationEnum>Vertical</orientationEnum>

Index: chandler/parcels/osaf/framework/blocks/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/parcel.xml:1.143 chandler/parcels/osaf/framework/blocks/parcel.xml:1.144
--- chandler/parcels/osaf/framework/blocks/parcel.xml:1.143	Tue Jan 25 16:50:49 2005
+++ chandler/parcels/osaf/framework/blocks/parcel.xml	Fri Jan 28 15:44:44 2005
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.143 $ -->
-<!-- $Date: 2005/01/26 00:50:49 $ -->
+<!-- $Revision: 1.144 $ -->
+<!-- $Date: 2005/01/28 23:44:44 $ -->
 <!-- Copyright (c) 2003-2005 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -347,7 +347,7 @@
     <Attribute itsName="detailItemOwner">
       <type itemref="docSchema:Block/"/>
       <cardinality>list</cardinality>
-      <inverseAttribute itemref="docSchema:DetailBlock/detailItem"/>
+      <inverseAttribute itemref="docSchema:TrunkParentBlock/detailItem"/>
     </Attribute>
 
     <Attribute itsName="viewContainer">
@@ -1187,97 +1187,9 @@
     <clouds alias="default" itemref="docSchema:ToolbarItem/DefaultCloud"/>
   </Kind>
 
-  <!-- Detail Block contains detail views of various summary views  -->
-
-  <Kind itsName="DetailBlock">
-    <classes key="python">osaf.framework.blocks.ContainerBlocks.DetailBlock</classes>
-    <superKinds itemref="docSchema:BoxContainer"/>
-    
-    <Attribute itsName="viewCache">
-      <type itemref="docSchema:ViewCache"/>
-      <inverseAttribute itemref="docSchema:ViewCache/detailBlock"/>
-      <required>True</required>
-    </Attribute>
-  
-    <Attribute itsName="detailItem">
-      <type itemref="Item"/>
-      <inverseAttribute itemref="docSchema:Block/detailItemOwner"/>
-    </Attribute>
-
-    <Cloud itsName="DefaultCloud">
-        <Endpoint itsName="viewCache">
-            <attribute value="viewCache"/>
-            <includePolicy value="byCloud"/>
-            <cloudAlias value="default"/>
-        </Endpoint>
-        <endpoints itemref="docSchema:DetailBlock/DefaultCloud/viewCache"/>
-        <Endpoint itsName="detailItem">
-            <attribute value="detailItem"/>
-            <includePolicy value="byRef"/>
-            <cloudAlias value="default"/>
-        </Endpoint>
-        <endpoints itemref="docSchema:DetailBlock/DefaultCloud/detailItem"/>
-    </Cloud>
-    <clouds alias="default" itemref="docSchema:DetailBlock/DefaultCloud"/>
-  </Kind>
-
-  <!-- Detail view cache caches views for a detail view  -->
-
-  <Kind itsName="ViewCache">
-    <superKinds itemref="Item"/>
-
-    <Attribute itsName="detailBlock">
-      <type itemref="docSchema:DetailBlock"/>
-      <inverseAttribute itemref="docSchema:DetailBlock/viewCache"/>
-      <required>True</required>
-    </Attribute>
-  
-    <Cloud itsName="DefaultCloud">
-        <Endpoint itsName="detailBlock">
-            <attribute value="detailBlock"/>
-            <includePolicy value="byCloud"/>
-            <cloudAlias value="default"/>
-        </Endpoint>
-        <endpoints itemref="docSchema:ViewCache/DefaultCloud/detailBlock"/>
-    </Cloud>
-    <clouds alias="default" itemref="docSchema:ViewCache/DefaultCloud"/>
-  </Kind>
-
-  <Kind itsName="DetailViewCache">
-    <classes key="python">osaf.framework.blocks.ContainerBlocks.DetailViewCache</classes>
-    <superKinds itemref="docSchema:ViewCache"/>
-
-    <!-- 
-       We'd like to have a dictionary of references to views in the soup accesed
-     with keys that are kinds of items. However, the repository has a very limited
-     set of data types, and doesn't support dictionaries of strings.
-       This will ultimately have to be fixed, otherwise we won't be able to find
-     references that are implemented as UUIDs and clean up unreferenced views.
-     -->
-    <Attribute itsName="kindUUIDToViewUUID">
-      <type itemref="UUID"/>
-      <cardinality>dict</cardinality>
-      <initialValue/>
-    </Attribute>
-
-  </Kind>
-
-  <Kind itsName="SidebarDetailViewCache">
-    <classes key="python">osaf.framework.blocks.ContainerBlocks.SidebarDetailViewCache</classes>
-    <superKinds itemref="docSchema:ViewCache"/>
-
-    <!-- 
-       We'd like to have a dictionary of references to views in the soup accesed
-     with keys that are kinds of items. However, the repository has a very limited
-     set of data types, and doesn't support dictionaries of strings.
-       This will ultimately have to be fixed, otherwise we won't be able to find
-     references that are implemented as UUIDs and clean up unreferenced views.
-     -->
-    <Attribute itsName="itemCollectionUUIDToViewUUID">
-      <type itemref="UUID"/>
-      <cardinality>dict</cardinality>
-      <initialValue/>
-    </Attribute>
+  <Kind itsName="SidebarTrunkDelegate">
+    <classes key="python">osaf.framework.blocks.Trunk.SidebarTrunkDelegate</classes>
+    <superKinds itemref="docSchema:TrunkDelegate"/>
 
     <Attribute itsName="treeTemplatePath">
       <type itemref="String"/>
@@ -1293,15 +1205,6 @@
     <attributes itemref="docSchema:selection"/>
   </Kind>
 
-  <!-- SelectionContainer -->
- 
-  <Kind itsName="SelectionContainer">
-    <classes key="python">osaf.framework.blocks.ContainerBlocks.SelectionContainer</classes>
-    <superKinds itemref="docSchema:BoxContainer"/>
-
-    <attributes itemref="docSchema:selection"/>
-  </Kind>    
-
   <!--
   TrunkDelegate and TrunkParentBlock
   -->
@@ -1310,6 +1213,12 @@
     <classes key="python">osaf.framework.blocks.Trunk.TrunkDelegate</classes>
     <superKinds itemref="Item"/>
 
+    <Attribute itsName="trunkParentBlock">
+      <type itemref="docSchema:TrunkParentBlock"/>
+      <inverseAttribute itemref="docSchema:TrunkParentBlock/trunkDelegate"/>
+      <required>True</required>
+    </Attribute>
+  
     <issues value="We'd like to use itemrefs as keys, so reference tracking &amp; cleanup would work"/>
     <Attribute itsName="keyUUIDToTrunkUUID">
       <type itemref="UUID"/>
@@ -1317,34 +1226,73 @@
       <initialValue/>
     </Attribute>
 
-    <!-- A stub block to copy as the root of each tree-of-blocks we build. -->
-    <Attribute itsName="trunkStub">
-      <type itemref="docSchema:Block"/>
-    </Attribute>
+    <Cloud itsName="DefaultCloud">
+        <Endpoint itsName="trunkParentBlock">
+            <attribute value="trunkParentBlock"/>
+            <includePolicy value="byCloud"/>
+            <cloudAlias value="default"/>
+        </Endpoint>
+        <endpoints itemref="docSchema:TrunkDelegate/DefaultCloud/trunkParentBlock"/>
+    </Cloud>
+    <clouds alias="default" itemref="docSchema:TrunkDelegate/DefaultCloud"/>
   </Kind>
   
   <!-- A TrunkParentBlock knows which delegate to use to substitute-in 
        an appropriate Trunk. -->
   <Kind itsName="TrunkParentBlock">
     <classes key="python">osaf.framework.blocks.Trunk.TrunkParentBlock</classes>
-    <superKinds itemref="docSchema:SelectionContainer"/>
+    <superKinds itemref="docSchema:BoxContainer"/>
 
     <Attribute itsName="trunkDelegate">
       <type itemref="docSchema:TrunkDelegate"/>
+      <inverseAttribute itemref="docSchema:TrunkDelegate/trunkParentBlock"/>
+      <required>True</required>
     </Attribute>
     
+    <Attribute itsName="detailItem">
+      <type itemref="Item"/>
+      <inverseAttribute itemref="docSchema:Block/detailItemOwner"/>
+    </Attribute>
+
     <!-- Share the same trunkDelegate amongst all copies of the parent block -->
     <Cloud itsName="DefaultCloud">
         <Endpoint itsName="trunkDelegate">
             <attribute value="trunkDelegate"/>
-            <includePolicy value="byRef"/>
+            <includePolicy value="byCloud"/>
+            <cloudAlias value="default"/>
         </Endpoint>
         <endpoints itemref="docSchema:TrunkParentBlock/DefaultCloud/trunkDelegate"/>
+        <Endpoint itsName="detailItem">
+            <attribute value="detailItem"/>
+            <includePolicy value="byRef"/>
+            <cloudAlias value="default"/>
+        </Endpoint>
+        <endpoints itemref="docSchema:TrunkParentBlock/DefaultCloud/detailItem"/>
     </Cloud>
     <clouds alias="default" itemref="docSchema:TrunkParentBlock/DefaultCloud"/>
   </Kind>
   
-  <!-- A mapping between an Item and the "root blocks" that should appear when an 
+  <Kind itsName="DetailTrunkDelegate">
+    <classes key="python">osaf.framework.blocks.detail.Detail.DetailTrunkDelegate</classes>
+    <superKinds itemref="docSchema:TrunkDelegate"/>
+
+    <!-- A stub block to copy as the root of each tree-of-blocks we build. -->
+    <Attribute itsName="trunkStub">
+      <type itemref="docSchema:Block"/>
+    </Attribute>
+
+    <Cloud itsName="DefaultCloud">
+        <Endpoint itsName="trunkStub">
+            <attribute value="trunkStub"/>
+            <includePolicy value="byRef"/>
+            <cloudAlias value="default"/>
+        </Endpoint>
+        <endpoints itemref="docSchema:DetailTrunkDelegate/DefaultCloud/trunkStub"/>
+    </Cloud>
+    <clouds alias="default" itemref="docSchema:DetailTrunkDelegate/DefaultCloud"/>
+  </Kind>
+  
+ <!-- A mapping between an Item and the "root blocks" that should appear when an 
        Item inheriting from that Kind is displayed. (A "root block" should have a 
        "position" attribute to enable it to be sorted with other root blocks.) 
        (This is really only used by the detail view right now, but if I move its
@@ -1369,7 +1317,7 @@
   
   <Kind itsName="ContentItemDetail">
     <classes key="python">osaf.framework.blocks.ControlBlocks.ContentItemDetail</classes>
-    <superKinds itemref="docSchema:SelectionContainer"/>
+    <superKinds itemref="docSchema:BoxContainer"/>
     
     <Attribute itsName="selectedItemsAttribute">
       <description>Specifies which attribute of the selected Item should be associated with this block.</description>
@@ -1380,6 +1328,13 @@
     <attributes itemref="docSchema:colorStyle"/>    
   </Kind>    
 
+  <Kind itsName="DetailRoot">
+    <classes key="python">osaf.framework.blocks.detail.Detail.DetailRoot</classes>
+    <superKinds itemref="docSchema:ContentItemDetail"/>
+    
+    <attributes itemref="docSchema:selection"/>
+  </Kind>    
+
   <!-- Timer Block  -->
 
   <Kind itsName="Timer">

Index: chandler/parcels/osaf/framework/blocks/ContainerBlocks.py
diff -u chandler/parcels/osaf/framework/blocks/ContainerBlocks.py:1.147 chandler/parcels/osaf/framework/blocks/ContainerBlocks.py:1.148
--- chandler/parcels/osaf/framework/blocks/ContainerBlocks.py:1.147	Thu Jan 27 15:39:08 2005
+++ chandler/parcels/osaf/framework/blocks/ContainerBlocks.py	Fri Jan 28 15:44:44 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.147 $"
-__date__ = "$Date: 2005/01/27 23:39:08 $"
+__version__ = "$Revision: 1.148 $"
+__date__ = "$Date: 2005/01/28 23:44:44 $"
 __copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -147,27 +147,6 @@
         return wxScrolledContainer (self.parentBlock.widget, Block.getWidgetID(self))    
 
 
-class SelectionContainer(BoxContainer):
-    """
-    SelectionContainer
-    Keeps track of the current selected item
-    """
-    def __init__(self, *arguments, **keywords):
-        super (SelectionContainer, self).__init__ (*arguments, **keywords)
-        self.selection = None
-
-    def onSelectItemEvent (self, event):
-        """
-          just remember the new selected ContentItem.
-        """
-        item = event.arguments['item']
-        self.selection = item
-
-    def selectedItem(self):
-        # return the item being viewed
-        return self.selection    
-
-        
 class wxSplitterWindow(wx.SplitterWindow):
 
     def __init__(self, *arguments, **keywords):
@@ -569,93 +548,3 @@
         return uniqueName
 
         
-class wxDetailPanel (wxBoxContainer):
-    def wxSynchronizeWidget(self, *arguments, **keywords):
-        if self.blockItem.isShown:
-            self.blockItem.InstallTreeOfBlocks()
-        super (wxDetailPanel, self).wxSynchronizeWidget (*arguments, **keywords)
-
-class DetailBlock(BoxContainer):
-    def instantiateWidget (self):
-        return wxDetailPanel (self.parentBlock.widget)
-
-    def onSelectItemEvent (self, event):
-        self.detailItem = event.arguments['item']
-        self.widget.wxSynchronizeWidget()
-
-    def InstallTreeOfBlocks (self):
-        # $$$ Repository bug doesn't let us have an initial value for detailItem
-        # fix later. DJA
-        try:
-            detailItem = self.detailItem
-        except AttributeError:
-            newView = None
-        else:
-            newView = self.viewCache.GetViewForItem (detailItem)
-
-        oldView = self.childrenBlocks.first()
-
-        if not newView is oldView:
-            if not oldView is None:
-                oldView.unRender()
-
-            self.childrenBlocks = []
-
-            if not newView is None:
-                self.childrenBlocks.append (newView)
-                """
-                  Seems like we should always mark new views with an event boundary
-                """
-                assert newView.eventBoundary
-                newView.postEventByName("SetContents", {'item':detailItem})
-
-                newView.render()
-
-# @@@BJS: "reload parcels" needs to blow away this cache!
-
-class DetailViewCache (Item):
-    def GetViewForItem (self, item):
-        view = None
-        if not item is None:
-            kindUUID = item.itsUUID
-            try:
-                viewUUID = self.kindUUIDToViewUUID [kindUUID]
-            except KeyError:
-                kindString = str (item.itsKind.itsName)
-                try:
-                    name = {"MailMessage":"EmailRootTemplate",
-                            "CalendarEvent":"CalendarRootTemplate"} [kindString]
-                except KeyError:
-                    pass
-                else:
-                    # @@@BJS: work in progress...
-                    # NOT: For now, just use the old detail view
-                    # was: template = self.findPath ("//parcels/osaf/framework/blocks/detail/DetailRootTemplate")
-                    template = self.findPath ("//parcels/osaf/framework/blocks/detail/" + name)
-                    view = template.copy (parent = self.findPath ("//userdata"),
-                                          cloudAlias="default")
-                    self.kindUUIDToViewUUID [kindUUID] = view.itsUUID
-            else:
-                view = self.findUUID (viewUUID)
-        return view
-
-
-class SidebarDetailViewCache (Item):
-    def GetViewForItem (self, item):
-        view = None
-        try:
-            viewUUID = self.itemCollectionUUIDToViewUUID [item.itsUUID]
-        except KeyError:
-            if isinstance (item, ItemCollection):
-                template = self.findPath (self.treeTemplatePath)
-                view = template.copy (parent = self.findPath ("//userdata"),
-                                      cloudAlias="default")
-                self.itemCollectionUUIDToViewUUID [item.itsUUID] = view.itsUUID
-            elif isinstance (item, Block):
-                """
-                  We don't copy the view because it's already copied to the soup
-                """
-                view = item
-        else:
-            view = self.find (viewUUID)
-        return view

Index: chandler/parcels/osaf/framework/blocks/Trunk.py
diff -u chandler/parcels/osaf/framework/blocks/Trunk.py:1.3 chandler/parcels/osaf/framework/blocks/Trunk.py:1.4
--- chandler/parcels/osaf/framework/blocks/Trunk.py:1.3	Tue Jan 25 16:23:41 2005
+++ chandler/parcels/osaf/framework/blocks/Trunk.py	Fri Jan 28 15:44:44 2005
@@ -1,11 +1,12 @@
-__version__ = "$Revision: 1.3 $"
-__date__ = "$Date: 2005/01/26 00:23:41 $"
+__version__ = "$Revision: 1.4 $"
+__date__ = "$Date: 2005/01/28 23:44:44 $"
 __copyright__ = "Copyright (c) 2005 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
 import sys
 import osaf.framework.blocks.Block as Block
 import osaf.framework.blocks.ContainerBlocks as ContainerBlocks
+import osaf.contentmodel.ItemCollection as ItemCollection
 from repository.item.Item import Item
 
 """
@@ -28,8 +29,7 @@
             self.blockItem.installTreeOfBlocks()
         super(wxTrunkParentBlock, self).wxSynchronizeWidget(*arguments, **keywords)
     
-class TrunkParentBlock(ContainerBlocks.SelectionContainer):
-    # @@@ Will be a BoxContainer once SelectionContainer is obsolete.
+class TrunkParentBlock(ContainerBlocks.BoxContainer):
     """
     A block that can swap in different sets of child blocks ("trunks") based
     on its detailContents. It uses a TrunkDelegate to do the heavy lifting.
@@ -37,14 +37,15 @@
     def instantiateWidget(self):
        return wxTrunkParentBlock(self.parentBlock.widget)
     
+    def onSelectItemEvent (self, event):
+        self.detailItem = event.arguments['item']
+        self.widget.wxSynchronizeWidget()
+
     def installTreeOfBlocks(self):
         """ Maybe replace our children with a trunk of blocks appropriate for our content """
         newView = None
         try:
-            # @@@ Should be this:
-            # detailItem = self.detailItem
-            # -- but until SelectionContainer goes away, we do this:
-            detailItem = self.selectedItem()
+            detailItem = self.detailItem
         except AttributeError:
             detailItem = None
         else:
@@ -60,10 +61,16 @@
 
             if newView is not None:
                 self.childrenBlocks.append(newView)
+                """
+                  Seems like we should always mark new views with an event boundary
+                """
+                assert newView.eventBoundary
                 newView.postEventByName("SetContents", {'item':detailItem})
                 newView.render()
 
 
+# @@@BJS: "reload parcels" needs to blow away this cache!
+
 class TrunkDelegate(Item):
     """
     A mechanism to map an item to a view: call its getTrunkForItem(item)
@@ -100,9 +107,14 @@
     def _mapItemToCacheKey(self, item):
         """ 
         Given an item, determine the item to be used as the cache key.
-        Can be overridden; defaults to using the item itself
+        Can be overridden; defaults to using the item itself is it's
+        a Block. The block is copied to the soup if it's not already
+        there.
         """
-        return item
+        if isinstance (item, Block.Block):
+            return self._copyItem(item, onlyIfReadOnly=True)
+        else:
+            return None
 
     def _makeTrunkForCacheKey(self, keyItem):
         """ 
@@ -126,7 +138,7 @@
             userData = self.findPath('//userdata')
             self.userData = userData
 
-        if onlyIfReadOnly and item.parent == userData:
+        if onlyIfReadOnly and item.itsParent == userData:
             result = item
         else:
             # @@@ BJS Morgen has opined that "default" is a bad name for a cloud; use "copy" instead?
@@ -134,15 +146,13 @@
             
         return result
 
-
-# @@@BJS: For John, a sample delegate that uses an itemcollection view
-# if the item is an ItemCollection (the delegate block needs an itemCollectionView 
-# attribute added), or uses the item itself if it's a block (making a copy if
-# it's not in the soup).
-class SampleSidebarTrunkDelegate(TrunkDelegate):
+class SidebarTrunkDelegate(TrunkDelegate):
+    """
+      Returns the treeTemplatePath if the item in the sidebar is an ItemCollection
+      otherwise returns the default key
+    """
     def _mapItemToCacheKey(self, item):
-        if isinstance(item, ItemCollection):
-            result = self.itemCollectionView
+        if isinstance(item, ItemCollection.ItemCollection):
+            return self.findPath (self.treeTemplatePath)
         else:
-            assert isinstance(item, Block)
-            result = self._copyItem(item, onlyIfReadOnly=True)
+            return super(SidebarTrunkDelegate, self)._mapItemToCacheKey (item)

Index: chandler/parcels/osaf/framework/blocks/detail/Detail.py
diff -u chandler/parcels/osaf/framework/blocks/detail/Detail.py:1.77 chandler/parcels/osaf/framework/blocks/detail/Detail.py:1.78
--- chandler/parcels/osaf/framework/blocks/detail/Detail.py:1.77	Thu Jan 27 13:01:55 2005
+++ chandler/parcels/osaf/framework/blocks/detail/Detail.py	Fri Jan 28 15:44:44 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.77 $"
-__date__ = "$Date: 2005/01/27 21:01:55 $"
+__version__ = "$Revision: 1.78 $"
+__date__ = "$Date: 2005/01/28 23:44:44 $"
 __copyright__ = "Copyright (c) 2004-2005 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -30,13 +30,16 @@
 Classes for the ContentItem Detail View
 """
 
-class DetailRoot (Trunk.TrunkParentBlock):
+class DetailRoot (ControlBlocks.ContentItemDetail):
     """
       Root of the Detail View.
     """
-    ## Currently lives in the SummaryView which causes problems -- DJA
-    #def onSetContentsEvent (self, event):
-        #self.onSelectItemEvent (event)
+    def __init__(self, *arguments, **keywords):
+        super (DetailRoot, self).__init__ (*arguments, **keywords)
+        self.selection = None
+
+    def onSetContentsEvent (self, event):
+        self.selection = event.arguments['item']
 
     def onSelectItemEvent (self, event):
         """
@@ -45,8 +48,10 @@
         """
         # Finish changes to previous selected item 
         self.finishSelectionChanges () 
-           
-        super(DetailRoot, self).onSelectItemEvent(event)
+        """
+          Remember the new selected ContentItem.
+        """
+        self.selection = event.arguments['item']
 
         # Synchronize to this item; this'll swap in an appropriate detail trunk.
         self.synchronizeWidget()
@@ -55,6 +60,14 @@
             if dumpSelectItem:
                 self.dumpShownHierarchy ('onSelectItemEvent')
 
+    def selectedItem(self):
+        # return the item being viewed
+        return self.selection    
+
+    def detailRoot (self):
+        # we are the detail root object
+        return self
+
     def synchronizeDetailView(self, item):
         """
           We have an event boundary inside us, which keeps all
@@ -227,7 +240,12 @@
         ## @@@DLD - devise a block-dependency-event scheme.        
         #item= self.selectedItem()
         #self.synchronizeDetailView(item)
-        self.synchronizeWidget()
+        #
+        # After moving DetailRoot into the event boundary in the
+        # trees of blocks, we need to call synchronizeWidget on
+        # the TrunkParentBlock since stamping may change the tree
+        # of blocks displayed in the detail view event boundary -- DJA
+        self.parentBlock.synchronizeWidget()
 
     def finishSelectionChanges (self):
         """ 
@@ -242,10 +260,6 @@
         except AttributeError:
             pass
 
-    def detailRoot (self):
-        # return the detail root object
-        return self
-
 
 class DetailTrunkDelegate (Trunk.TrunkDelegate):
     """ 
@@ -318,7 +332,7 @@
     synchronizeItemDetail.
     """
     def detailRoot (self):
-        # delegate to our parent until we get outside our event boundary
+        # Cruise up the parents looking for someone who can return the detailRoot
         block = self
         while True:
             try:

Index: chandler/parcels/osaf/views/main/parcel.xml
diff -u chandler/parcels/osaf/views/main/parcel.xml:1.161 chandler/parcels/osaf/views/main/parcel.xml:1.162
--- chandler/parcels/osaf/views/main/parcel.xml:1.161	Thu Jan 27 22:03:46 2005
+++ chandler/parcels/osaf/views/main/parcel.xml	Fri Jan 28 15:44:45 2005
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.161 $ -->
-<!-- $Date: 2005/01/28 06:03:46 $ -->
+<!-- $Revision: 1.162 $ -->
+<!-- $Date: 2005/01/28 23:44:45 $ -->
 <!-- Copyright (c) 2003-2004 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -1443,15 +1443,15 @@
     <childrenBlocks itemref="doc:SidebarDetailView"/>
   </TabbedContainer>  
 
-  <DetailBlock itsName="SidebarDetailView">
+  <TrunkParentBlock itsName="SidebarDetailView">
     <blockName>SidebarDetailView</blockName>
     <detailItem itemref="content:allItemCollection"/>
-    <viewCache itemref="doc:SidebarDetailViewCache"/>
-  </DetailBlock>
+    <trunkDelegate itemref="doc:SidebarTrunkDelegate"/>
+  </TrunkParentBlock>
 
-  <SidebarDetailViewCache itsName="SidebarDetailViewCache">
+  <SidebarTrunkDelegate itsName="SidebarTrunkDelegate">
     <treeTemplatePath>//parcels/osaf/views/main/SidebarDetailViewTemplate</treeTemplatePath>
-  </SidebarDetailViewCache>
+  </SidebarTrunkDelegate>
 
   <calendar:MiniCalendar itsName="MiniCalendar">
     <stretchFactor>0</stretchFactor>
@@ -1522,7 +1522,7 @@
   
   <SplitterWindow itsName="SidebarDetailViewTemplate">
     <childrenBlocks itemref="doc:SummaryView"/>
-    <childrenBlocks itemref="detail:DetailRootTemplate" copy="DetailRoot"/>
+    <childrenBlocks itemref="detail:DetailTrunkParentBlock" copy="SidebarDetailTrunkParentBlock"/>
 
     <eventBoundary>True</eventBoundary>
     <orientationEnum>Vertical</orientationEnum>
@@ -1633,15 +1633,6 @@
     <daysPerView>1</daysPerView>
   </calendar:CanvasWeek>
 
-  <DetailBlock itsName="DetailView">
-    <blockName>DetailView</blockName>
-    <detailItem itemref="content:allItemCollection"/>
-    <viewCache itemref="doc:DetailViewCache"/>
-  </DetailBlock>
-
-  <DetailViewCache itsName="DetailViewCache">
-  </DetailViewCache>
-
   <BlockEvent itsName="ReminderTime">
     <blockName>ReminderTime</blockName>
     <destinationBlockReference itemref="doc:ReminderTimer"/>
@@ -1730,19 +1721,19 @@
     <childrenBlocks itemref="doc:CPIATestSidebarDetailView"/>
   </TabbedContainer>  
 
-  <DetailBlock itsName="CPIATestSidebarDetailView">
+  <TrunkParentBlock itsName="CPIATestSidebarDetailView">
     <blockName>SidebarDetailView</blockName>
     <detailItem itemref="content:allItemCollection"/>
-    <viewCache itemref="doc:CPIATestSidebarDetailViewCache"/>
-  </DetailBlock>
+    <trunkDelegate itemref="doc:CPIATestSidebarTrunkDelegate"/>
+  </TrunkParentBlock>
 
-  <SidebarDetailViewCache itsName="CPIATestSidebarDetailViewCache">
+  <SidebarTrunkDelegate itsName="CPIATestSidebarTrunkDelegate">
     <treeTemplatePath>//parcels/osaf/views/main/CPIATestSidebarDetailViewTemplate</treeTemplatePath>
-  </SidebarDetailViewCache>
+  </SidebarTrunkDelegate>
 
   <SplitterWindow itsName="CPIATestSidebarDetailViewTemplate">
     <childrenBlocks itemref="doc:SummaryView" copy="CPIATestSummaryView"/>
-    <childrenBlocks itemref="detail:DetailRootTemplate" copy="DetailRoot"/>
+    <childrenBlocks itemref="detail:DetailTrunkParentBlock" copy="SidebarDetailTrunkParentBlock"/>
 
     <eventBoundary>True</eventBoundary>
     <orientationEnum>Horizontal</orientationEnum>
@@ -1756,15 +1747,15 @@
     <childrenBlocks itemref="doc:MainDetailView"/>
   </ViewContainer>
 
-  <DetailBlock itsName="MainDetailView">
+  <TrunkParentBlock itsName="MainDetailView">
     <blockName>MainDetailView</blockName>
     <detailItem itemref="doc:ChandlerMainView"/>
     <childrenBlocks itemref="doc:ChandlerMainView"/>
-    <viewCache itemref="doc:MainDetailViewCache"/>
-  </DetailBlock>
+    <trunkDelegate itemref="doc:MainTrunkDelegate"/>
+  </TrunkParentBlock>
 
-  <SidebarDetailViewCache itsName="MainDetailViewCache">
-  </SidebarDetailViewCache>
+  <TrunkDelegate itsName="MainTrunkDelegate">
+  </TrunkDelegate>
 
   <contentModel:Note itsName="WelcomeNote">
       <displayName value="Welcome to Chandler 0.4"/>



More information about the Commits mailing list