[Commits] (john) - Put Events in Collections for easy lookup

commits at osafoundation.org commits at osafoundation.org
Thu Jan 15 18:10:48 PST 2004


Commit by: john
Modified files:
osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml 1.24 1.25
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml 1.9 1.10
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py 1.2 1.3
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml 1.26 1.27
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py 1.31 1.32
osaf/chandler/Chandler/application/ApplicationNew.py 1.22 1.23

Log message:
- Put Events in Collections for easy lookup
- Fix yet another focus bug with menus
- Add attribute to Events specifying the name of the method to call when dispatched
- Removed name from Events and fix all the notification manager dependencies
- Fix UpdateUI events which broke when I fixed yesterday's focus bug
- Lookup event from the notification instead of passing it as an argument


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml.diff?r1=text&tr1=1.24&r2=text&tr2=1.25
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml.diff?r1=text&tr1=1.9&r2=text&tr2=1.10
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml.diff?r1=text&tr1=1.26&r2=text&tr2=1.27
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py.diff?r1=text&tr1=1.31&r2=text&tr2=1.32
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/application/ApplicationNew.py.diff?r1=text&tr1=1.22&r2=text&tr2=1.23

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.31 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.32
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.31	Thu Jan 15 13:36:48 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py	Thu Jan 15 18:10:16 2004
@@ -162,12 +162,12 @@
             return newChild.render (parent, parentWindow)
         return None, None, None
     
-    def on_chandler_SwitchEmbeddedChild (self, notification):
+    def OnSwitchEmbeddedChildEvent (self, notification):
         oldChild = Globals.repository.find (self.contentSpec.data)
         wxOldChild = Globals.association[oldChild.getUUID()]
         self.getParentBlock(self.wxParentWindow).removeFromContainer(self.wxParent, wxOldChild)
                 
-        self.contentSpec.data = notification.data['event'].choice
+        self.contentSpec.data = notification.event.choice
         newChild = Globals.repository.find (self.contentSpec.data)
         if newChild:
             newChild.render (self.wxParent, self.wxParentWindow)
@@ -336,7 +336,7 @@
         counterpart = Globals.repository.find (self.counterpartUUID)
         counterpart.size.width = self.GetSize().x
         counterpart.size.height = self.GetSize().y
-        counterpart.setDirty()
+        counterpart.setDirty()   # Temporary repository hack -- DJA
 
 
 class SplitWindow(RectangularChild):
@@ -450,9 +450,9 @@
                 window.AddPage(child, self.tabNames[childNameIndex])
                 childNameIndex = childNameIndex + 1
 
-    def on_block_TabChoice (self, notification):
+    def OnChooseTabEvent (self, notification):
         tabbedContainer = Globals.association[self.getUUID()]
-        choice = notification.data ['event'].choice
+        choice = notification.event.choice
         for index in xrange (tabbedContainer.GetPageCount()):
             if tabbedContainer.GetPageText(index) == choice:
                 tabbedContainer.SetSelection (index)
@@ -511,11 +511,11 @@
           Load the items in the tree only when they are visible.
         """
         arguments = {'node':TreeNode (event.GetItem(), self),
-                     'event':Globals.repository.find('//parcels/OSAF/framework/blocks/Events/GetTreeListData'),
                      'type':'Normal'}
-        notification = Notification('block/GetTreeListData', None, None)
+        event = Globals.repository.find('//parcels/OSAF/framework/blocks/Events/GetTreeListData')
+        notification = Notification(event, None, None)
         notification.SetData(arguments)
-        Globals.topView.dispatchEvent(notification)
+        Globals.notificationManager.PostNotification (notification)
 
     def OnColumnDrag(self, event):
         counterpart = Globals.repository.find (self.counterpartUUID)
@@ -533,11 +533,11 @@
             treeList.AddColumnInfo(info)
 
         arguments = {'node':TreeNode (None, treeList),
-                     'event':Globals.repository.find('//parcels/OSAF/framework/blocks/Events/GetTreeListData'),
                      'type':'Normal'}
-        notification = Notification("block/GetTreeListData", None, None)
+        event = Globals.repository.find('//parcels/OSAF/framework/blocks/Events/GetTreeListData')
+        notification = Notification(event, None, None)
         notification.SetData(arguments)
-        Globals.topView.dispatchEvent(notification)
+        Globals.notificationManager.PostNotification (notification)
 
         self.getParentBlock(parentWindow).addToContainer(parent, treeList, 1, self.Calculate_wxFlag(), self.Calculate_wxBorder())
         return treeList, None, None

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml:1.26 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml:1.27
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml:1.26	Thu Jan 15 13:36:48 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/parcel.xml	Thu Jan 15 18:10:16 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.26 $ -->
-<!-- $Date: 2004/01/15 21:36:48 $ -->
+<!-- $Revision: 1.27 $ -->
+<!-- $Date: 2004/01/16 02:10:16 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -147,7 +147,7 @@
 
 
   <!--
-    Events
+    Block Events
   -->
 
   <Kind itemName="BlockEvent">
@@ -168,11 +168,15 @@
       <type itemref="docSchema:Block"/>
     </Attribute>
 
+    <Attribute itemName="methodName">
+      <type itemref="String"/>
+    </Attribute>
+
     <attributes itemref="docSchema:BlockEvent/dispatchEnum"/>
     <attributes itemref="docSchema:BlockEvent/dispatchToBlock"/>
+    <attributes itemref="docSchema:BlockEvent/methodName"/>
   </Kind>
 
-
   <Kind itemName="ChoiceEvent">
     <classes key="python">OSAF.framework.blocks.Block.ChoiceEvent</classes>
     <superKinds itemref="docSchema:BlockEvent"/>
@@ -184,6 +188,15 @@
     <attributes itemref="docSchema:ChoiceEvent/choice"/>
   </Kind>
 
+  <Attribute itemName="blockEvents">
+    <type itemref="docSchema:BlockEvent"/>
+    <cardinality>list</cardinality>
+  </Attribute>
+
+  <Kind itemName="EventData">
+    <attributes itemref="docSchema:blockEvents"/>
+  </Kind>
+
   <!--
     Block
   -->
@@ -231,6 +244,8 @@
   <Kind itemName="View">
     <classes key="python">OSAF.framework.blocks.View.View</classes>
     <superKinds itemref="docSchema:BoxContainer"/>
+
+    <attributes itemref="docSchema:blockEvents"/>
   </Kind>
 
   <!--

Index: osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml:1.24 osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml:1.25
--- osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml:1.24	Thu Jan 15 13:36:48 2004
+++ osaf/chandler/Chandler/parcels/OSAF/templates/top/parcel.xml	Thu Jan 15 18:10:14 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.24 $ -->
-<!-- $Date: 2004/01/15 21:36:48 $ -->
+<!-- $Revision: 1.25 $ -->
+<!-- $Date: 2004/01/16 02:10:14 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -147,31 +147,31 @@
     <helpString></helpString>
   </MenuItem>
 
-  <ChoiceEvent itemName="ChooseButtons">
-    <name>block/TabChoice</name>
+  <ChoiceEvent itemName="ChooseButtonsTab">
     <dispatchEnum>SendToBlock</dispatchEnum>
     <dispatchToBlock itemref="doc:Tabs"/>
+    <methodName>OnChooseTabEvent</methodName>
     <choice>Buttons</choice>
   </ChoiceEvent>
 
-  <ChoiceEvent itemName="ChooseControls">
-    <name>block/TabChoice</name>
+  <ChoiceEvent itemName="ChooseControlsTab">
     <dispatchEnum>SendToBlock</dispatchEnum>
     <dispatchToBlock itemref="doc:Tabs"/>
+    <methodName>OnChooseTabEvent</methodName>
     <choice>Controls</choice>
   </ChoiceEvent>
 
-  <ChoiceEvent itemName="ChooseData">
-    <name>block/TabChoice</name>
+  <ChoiceEvent itemName="ChooseDataTab">
     <dispatchEnum>SendToBlock</dispatchEnum>
     <dispatchToBlock itemref="doc:Tabs"/>
+    <methodName>OnChooseTabEvent</methodName>
     <choice>Data</choice>
   </ChoiceEvent>
-  
-  <ChoiceEvent itemName="ChooseEmbedded">
-    <name>chandler/TabChoice</name>
+
+  <ChoiceEvent itemName="ChooseEmbeddedTab">
     <dispatchEnum>SendToBlock</dispatchEnum>
     <dispatchToBlock itemref="doc:Tabs"/>
+    <methodName>OnChooseTabEvent</methodName>
     <choice>Embedded</choice>
   </ChoiceEvent>
 
@@ -182,7 +182,7 @@
     <itemLocation></itemLocation>
     <menuItemKind>Radio</menuItemKind>
     <accel></accel>
-    <event itemref="doc:ChooseButtons"/>
+    <event itemref="doc:ChooseButtonsTab"/>
     <helpString></helpString>
   </MenuItem>
 
@@ -193,7 +193,7 @@
     <itemLocation></itemLocation>
     <menuItemKind>Radio</menuItemKind>
     <accel></accel>
-    <event itemref="doc:ChooseControls"/>
+    <event itemref="doc:ChooseControlsTab"/>
     <helpString></helpString>
   </MenuItem>
 
@@ -204,7 +204,7 @@
     <itemLocation></itemLocation>
     <menuItemKind>Radio</menuItemKind>
     <accel></accel>
-    <event itemref="doc:ChooseData"/>
+    <event itemref="doc:ChooseDataTab"/>
     <helpString></helpString>
   </MenuItem>
 
@@ -215,7 +215,7 @@
     <itemLocation></itemLocation>
     <menuItemKind>Radio</menuItemKind>
     <accel></accel>
-    <event itemref="doc:ChooseEmbedded"/>
+    <event itemref="doc:ChooseEmbeddedTab"/>
     <helpString></helpString>
   </MenuItem>
 
@@ -230,10 +230,10 @@
   </MenuItem>
 
   <ChoiceEvent itemName="SwitchEmbeddedChild">
-    <name>chandler/SwitchEmbeddedChild</name>
     <dispatchEnum>SendToBlock</dispatchEnum>
     <dispatchToBlock itemref="doc:EmbeddedTitle"/>
-    <choice>parcels/OSAF/templates/top/LeftText</choice>
+    <methodName>OnSwitchEmbeddedChildEvent</methodName>
+    <choice>parcels/OSAF/templages/top/LeftText</choice>
   </ChoiceEvent>  
   
   <MenuItem itemName="SwitchViewItem">
@@ -785,6 +785,13 @@
 
     <childrenBlocks itemref="doc:Header"/>
     <childrenBlocks itemref="doc:ContentBox"/>
+
+    <blockEvents itemref="doc:ChooseButtonsTab"/>
+    <blockEvents itemref="doc:ChooseControlsTab"/>
+    <blockEvents itemref="doc:ChooseDataTab"/>
+    <blockEvents itemref="doc:SwitchEmbeddedChild"/>
+    <blockEvents itemref="doc:ChooseEmbeddedTab"/>
+
     <open>True</open>
 
     <size>912,512</size>

Index: osaf/chandler/Chandler/application/ApplicationNew.py
diff -u osaf/chandler/Chandler/application/ApplicationNew.py:1.22 osaf/chandler/Chandler/application/ApplicationNew.py:1.23
--- osaf/chandler/Chandler/application/ApplicationNew.py:1.22	Tue Jan 13 14:04:20 2004
+++ osaf/chandler/Chandler/application/ApplicationNew.py	Thu Jan 15 18:10:17 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.22 $"
-__date__ = "$Date: 2004/01/13 22:04:20 $"
+__version__ = "$Revision: 1.23 $"
+__date__ = "$Date: 2004/01/16 02:10:17 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -48,7 +48,7 @@
         counterpart = Globals.repository.find (self.counterpartUUID)
         counterpart.size.width = self.GetSize().x
         counterpart.size.height = self.GetSize().y
-        counterpart.setDirty()
+        counterpart.setDirty()   # Temporary repository hack -- DJA
 
 
 class wxApplicationNew (wxApp):
@@ -202,12 +202,15 @@
             self.mainFrame.counterpartUUID = topView.getUUID()
             EVT_SIZE(self.mainFrame, self.mainFrame.OnSize)
 
-            events = Globals.repository.find('//parcels/OSAF/framework/blocks/Events')
-            names = []
-            for child in events:
-                names.append (child.name)
-            
-            Globals.notificationManager.Subscribe (names,
+            GlobalEvents = Globals.repository.find('//parcels/OSAF/framework/blocks/Events/GlobalEvents')
+
+            events = []
+            for event in GlobalEvents.blockEvents:
+                events.append (event)
+            for event in topView.blockEvents:
+                events.append (event)
+
+            Globals.notificationManager.Subscribe (events,
                                                    Globals.topView.getUUID(),
                                                    Globals.topView.dispatchEvent)
 
@@ -231,15 +234,14 @@
 
             if isinstance (blockEvent, BlockEvent):
                 assert isinstance (blockEvent, BlockEvent)
-                data = {'event':blockEvent}
                 if event.GetEventType() == wxEVT_UPDATE_UI:
-                    data ['type'] = 'UpdateUI'
+                    data = {'type':'UpdateUI'}
                 else:
-                    data ['type'] = 'Normal'
+                    data = {'type':'Normal'}
 
-                notification = Notification(blockEvent.name, None, None)
+                notification = Notification(blockEvent, None, None)
                 notification.SetData(data)
-                Globals.topView.dispatchEvent(notification)
+                Globals.notificationManager.PostNotification (notification)
                 if event.GetEventType() == wxEVT_UPDATE_UI:
                     try:
                         event.Check (data ['Check'])
@@ -268,6 +270,7 @@
         if self.focus != focus:
             self.focus = focus
             Globals.topView.onSetFocus()
+        event.Skip()
 
     def OnExit(self):
         """

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml:1.9 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml:1.10
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml:1.9	Tue Jan 13 14:04:18 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml	Thu Jan 15 18:10:15 2004
@@ -1,67 +1,87 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.9 $ -->
-<!-- $Date: 2004/01/13 22:04:18 $ -->
+<!-- $Revision: 1.10 $ -->
+<!-- $Date: 2004/01/16 02:10:15 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
 <core:Parcel describes="//parcels/OSAF/framework/blocks/Events"
              itemName="Events"
              xmlns:core="//Schema/Core"
-             xmlns="//parcels/OSAF/framework/blocks">
+             xmlns="//parcels/OSAF/framework/blocks"
+             xmlns:events="//parcels/OSAF/framework/blocks/Events">
 
   <description>Events, need to be defined in a different parcel than the schema because 
 of a limitation of the XML format, which will be eliminated</description>
   <version>0.3</version>
-  
+
+  <EventData itemName="GlobalEvents">
+    <blockEvents itemref="events:Quit"/>
+    <blockEvents itemref="events:Undo"/>
+    <blockEvents itemref="events:Redo"/>
+    <blockEvents itemref="events:Cut"/>
+    <blockEvents itemref="events:Copy"/>
+    <blockEvents itemref="events:Paste"/>
+    <blockEvents itemref="events:GetTreeListData"/>
+    <blockEvents itemref="events:Preferences"/>
+    <blockEvents itemref="events:Right"/>
+    <blockEvents itemref="events:Left"/>
+    <blockEvents itemref="events:SelectionChanged"/>
+  </EventData>
+
   <BlockEvent itemName="Quit">
-    <name>block/Quit</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnQuitEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Undo">
-    <name>block/Undo</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnUndoEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Redo">
-    <name>block/Redo</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnRedoEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Cut">
-    <name>block/Cut</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnCutEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Copy">
-    <name>block/Copy</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnCopyEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Paste">
-    <name>block/Paste</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnPasteEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="GetTreeListData">
-    <name>block/GetTreeListData</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnGetTreeListDataEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Preferences">
-    <name>block/Preferences</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnPreferencesEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Right">
-    <name>block/Right</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnRightEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="Left">
-    <name>block/Left</name>
     <dispatchEnum>BubbleUp</dispatchEnum>
+    <methodName>OnLeftEvent</methodName>
+  </BlockEvent>
+
+  <BlockEvent itemName="SelectionChanged">
+    <dispatchEnum>Broadcast</dispatchEnum>
+    <methodName>OnSelectionChangedEvent</methodName>
   </BlockEvent>
 
 

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py:1.2 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py:1.3
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py:1.2	Tue Jan 13 14:04:19 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/View.py	Thu Jan 15 18:10:16 2004
@@ -28,18 +28,18 @@
             for child in block.childrenBlocks:
                 broadcast (child, methodName, event)
 
-        event = notification.data['event']
+        event = notification.event
         """
           Find the block with the focus
         """
         block = self.getFocusBlock()
         """
-          Construct method name based upon the name of the event.
+          Construct method name based upon the type of the event.
         """
-        methodName = 'on_' + event.name.replace ('/', '_')
+        methodName = event.methodName
 
         if notification.data['type'] == 'UpdateUI':
-            methodName += '_UpdateUI'
+            methodName += 'UpdateUI'
 
         if event.dispatchEnum == 'SendToBlock':
             callMethod (event.dispatchToBlock, methodName, notification)
@@ -81,26 +81,26 @@
                     if parent != Globals.wxApplication.menuParent:
                         Globals.wxApplication.menuParent = parent
                         Menu.rebuildMenus(parent)
-                        return
+                    return
             block = block.parentBlock
 
 
-    def on_block_Quit (self, notification):
+    def OnQuitEvent (self, notification):
         Globals.wxApplication.mainFrame.Close ()
         
-    def on_block_Undo_UpdateUI (self, notification):
+    def OnUndoEventUpdateUI (self, notification):
         notification.data ['Text'] = 'Undo Command\tCtrl+Z'
 
-    def on_block_Cut_UpdateUI (self, notification):
+    def OnCutEventUpdateUI (self, notification):
         notification.data ['Enable'] = False
 
-    def on_block_Copy_UpdateUI (self, notification):
+    def OnCopyEventUpdateUI (self, notification):
         notification.data ['Enable'] = False
 
-    def on_block_Paste_UpdateUI (self, notification):
+    def OnPasteEventUpdateUI (self, notification):
         notification.data ['Enable'] = False
 
-    def on_block_GetTreeListData (self, notification):
+    def OnGetTreeListData (self, notification):
         node = notification.data['node']
         item = node.GetData()
         if item:



More information about the Commits mailing list