[Commits] (john) - UpdateUI events are send much less frequently
(only when blocks get rendered or change visibility)
commits at osafoundation.org
commits at osafoundation.org
Tue Aug 24 08:06:41 PDT 2004
Commit by: john
Modified files:
chandler/parcels/osaf/framework/blocks/ControlBlocks.py 1.104 1.105
chandler/parcels/osaf/framework/blocks/Block.py 1.63 1.64
chandler/parcels/osaf/framework/blocks/Views.py 1.39 1.40
chandler/Chandler.py 1.43 1.44
chandler/application/Application.py 1.261 1.262
chandler/application/Parcel.py 1.27 1.28
Log message:
- UpdateUI events are send much less frequently (only when blocks get rendered or change visibility)
- UpdateUI events are now processed 6 times faster
- removed calls to getattr that call slow repository code in cases where we are looking for methods
- Removed manual registration of attribute editors in table, since they are now automatically registered
- Added comments to Morgen's tools.timing temporary code so we don't forget to remove it from release Chandler (should probably be ifdefed)
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/ControlBlocks.py.diff?r1=text&tr1=1.104&r2=text&tr2=1.105
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Block.py.diff?r1=text&tr1=1.63&r2=text&tr2=1.64
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Views.py.diff?r1=text&tr1=1.39&r2=text&tr2=1.40
http://cvs.osafoundation.org/index.cgi/chandler/Chandler.py.diff?r1=text&tr1=1.43&r2=text&tr2=1.44
http://cvs.osafoundation.org/index.cgi/chandler/application/Application.py.diff?r1=text&tr1=1.261&r2=text&tr2=1.262
http://cvs.osafoundation.org/index.cgi/chandler/application/Parcel.py.diff?r1=text&tr1=1.27&r2=text&tr2=1.28
Index: chandler/parcels/osaf/framework/blocks/Views.py
diff -u chandler/parcels/osaf/framework/blocks/Views.py:1.39 chandler/parcels/osaf/framework/blocks/Views.py:1.40
--- chandler/parcels/osaf/framework/blocks/Views.py:1.39 Thu Aug 19 12:43:53 2004
+++ chandler/parcels/osaf/framework/blocks/Views.py Tue Aug 24 08:06:38 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.39 $"
-__date__ = "$Date: 2004/08/19 19:43:53 $"
+__version__ = "$Revision: 1.40 $"
+__date__ = "$Date: 2004/08/24 15:06:38 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -16,7 +16,7 @@
Call method named methodName on block
"""
try:
- member = getattr (block, methodName)
+ member = getattr (type(block), methodName)
except AttributeError:
return False
@@ -26,7 +26,7 @@
print "Calling %s" % methodName
"""
- member (notification)
+ member (block, notification)
return True
def bubleUpCallMethod (block, methodName, notification):
@@ -38,17 +38,17 @@
break
block = block.parentBlock
- def broadcast (block, methodName, notification, stopAtEventBoundary = True):
+ def broadcast (block, methodName, notification, childTest):
"""
Call method named methodName on every block and it's children
- who implements it, except for the block that posted the event,
+ who pass the childTest except for the block that posted the event,
to avoid recursive calls.
"""
if block != notification.data['sender']:
callMethod (block, methodName, notification)
for child in block.childrenBlocks:
- if child and not (stopAtEventBoundary and child.eventBoundary):
- broadcast (child, methodName, notification, stopAtEventBoundary)
+ if childTest (child):
+ broadcast (child, methodName, notification, childTest)
event = notification.event
"""
@@ -74,10 +74,18 @@
while (not block.eventBoundary and block.parentBlock):
block = block.parentBlock
- broadcast (block, methodName, notification)
+ broadcast (block,
+ methodName,
+ notification,
+ lambda child: (child is not None and child.isShown))
elif event.dispatchEnum == 'BroadcastEverywhere':
- broadcast (Globals.mainView, methodName, notification, stopAtEventBoundary = False)
+ broadcast (Globals.mainView,
+ methodName,
+ notification,
+ lambda child: (child is not None and
+ child.isShown and
+ not child.eventBoundary))
elif event.dispatchEnum == 'FocusBubbleUp':
block = self.getFocusBlock()
Index: chandler/Chandler.py
diff -u chandler/Chandler.py:1.43 chandler/Chandler.py:1.44
--- chandler/Chandler.py:1.43 Wed Jul 21 20:51:21 2004
+++ chandler/Chandler.py Tue Aug 24 08:06:38 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.43 $"
-__date__ = "$Date: 2004/07/22 03:51:21 $"
+__version__ = "$Revision: 1.44 $"
+__date__ = "$Date: 2004/08/24 15:06:38 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -50,6 +50,7 @@
#Reraising the exception, so wing catches it.
raise
+ #@@@Temporary testing tool written by Morgen -- DJA
# import tools.timing
# print "\nTiming results:\n"
# tools.timing.results()
Index: chandler/parcels/osaf/framework/blocks/Block.py
diff -u chandler/parcels/osaf/framework/blocks/Block.py:1.63 chandler/parcels/osaf/framework/blocks/Block.py:1.64
--- chandler/parcels/osaf/framework/blocks/Block.py:1.63 Fri Aug 20 12:35:19 2004
+++ chandler/parcels/osaf/framework/blocks/Block.py Tue Aug 24 08:06:38 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.63 $"
-__date__ = "$Date: 2004/08/20 19:35:19 $"
+__version__ = "$Revision: 1.64 $"
+__date__ = "$Date: 2004/08/24 15:06:38 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -27,14 +27,14 @@
def render (self):
try:
- instantiateWidgetMethod = getattr (self, "instantiateWidget")
+ instantiateWidgetMethod = getattr (type (self), "instantiateWidget")
except AttributeError:
- return
+ pass
else:
oldIgnoreSynchronizeWidget = Globals.wxApplication.ignoreSynchronizeWidget
Globals.wxApplication.ignoreSynchronizeWidget = True
try:
- widget = instantiateWidgetMethod()
+ widget = instantiateWidgetMethod (self)
finally:
Globals.wxApplication.ignoreSynchronizeWidget = oldIgnoreSynchronizeWidget
"""
@@ -44,6 +44,7 @@
"""
if widget:
+ Globals.wxApplication.needsUpdateUI = True
self.setPinned()
self.widget = widget
widget.blockItem = self
@@ -51,11 +52,11 @@
After the blocks are wired up, call OnInit if it exists.
"""
try:
- OnInitMethod = getattr (widget, "OnInit")
+ OnInitMethod = getattr (type (widget), "OnInit")
except AttributeError:
pass
else:
- OnInitMethod()
+ OnInitMethod (widget)
"""
For those blocks with contents, we need to subscribe to notice changes
to items in the contents.
@@ -157,6 +158,7 @@
delattr (self, 'widget')
self.setPinned (False)
+ Globals.wxApplication.needsUpdateUI = True
def widgetIDToBlock (theClass, wxID):
"""
@@ -235,8 +237,8 @@
operation = 'add'
else:
operation = 'remove'
- method = getattr (self.contents, operation)
- method (item)
+ method = getattr (type(self.contents), operation)
+ method (self.contents, item)
def synchronizeWidget (self):
"""
@@ -253,7 +255,7 @@
during shutdown to ignore events caused by the framework tearing down wxWidgets.
"""
try:
- method = getattr (self.widget, 'wxSynchronizeWidget')
+ method = getattr (type (self.widget), 'wxSynchronizeWidget')
except AttributeError:
pass
else:
@@ -261,7 +263,7 @@
oldIgnoreSynchronizeWidget = Globals.wxApplication.ignoreSynchronizeWidget
Globals.wxApplication.ignoreSynchronizeWidget = True
try:
- method()
+ method (self.widget)
finally:
Globals.wxApplication.ignoreSynchronizeWidget = oldIgnoreSynchronizeWidget
Index: chandler/application/Application.py
diff -u chandler/application/Application.py:1.261 chandler/application/Application.py:1.262
--- chandler/application/Application.py:1.261 Thu Aug 19 11:27:54 2004
+++ chandler/application/Application.py Tue Aug 24 08:06:39 2004
@@ -1,9 +1,9 @@
-__version__ = "$Revision: 1.261 $"
-__date__ = "$Date: 2004/08/19 18:27:54 $"
+__version__ = "$Revision: 1.262 $"
+__date__ = "$Date: 2004/08/24 15:06:39 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
-import gettext, os, sys, threading, tools.timing
+import gettext, os, sys, threading
from new import classobj
import wx
import Globals
@@ -12,6 +12,9 @@
from repository.persistence.XMLRepository import XMLRepository
from crypto import Crypto
+#@@@Temporary testing tool written by Morgen -- DJA
+import tools.timing
+
"""
Event used to post callbacks on the UI thread
@@ -123,8 +126,13 @@
"""
Main application initialization.
"""
- tools.timing.begin("wxApplication OnInit")
-
+ tools.timing.begin("wxApplication OnInit") #@@@Temporary testing tool written by Morgen -- DJA
+ """
+ Disable automatic calling of UpdateUIEvents. We will call them
+ manually when blocks get rendered, change visibility, etc.
+ """
+ wx.UpdateUIEvent.SetUpdateInterval (-1)
+ self.needsUpdateUI = True
"""
Install a custom displayhook to keep Python from setting the global
_ (underscore) to the value of the last evaluated expression. If
@@ -135,7 +143,6 @@
sys.stdout.write(str(obj))
sys.displayhook = _displayHook
-
"""
Find the directory that Chandler lives in by looking up the file that
the application module lives in.
@@ -327,7 +334,7 @@
self.mainFrame.Show()
- tools.timing.end("wxApplication OnInit")
+ tools.timing.end("wxApplication OnInit") #@@@Temporary testing tool written by Morgen -- DJA
return True #indicates we succeeded with initialization
return False #or failed.
@@ -348,11 +355,7 @@
wxID = event.GetId()
if wxID >= Block.MINIMUM_WX_ID and wxID <= Block.MAXIMUM_WX_ID:
block = Block.widgetIDToBlock (wxID)
-
- args = {}
- if event.GetEventType() == wx.EVT_UPDATE_UI.evtType[0]:
- args['UpdateUI'] = True
-
+ updateUIEvent = event.GetEventType() == wx.EVT_UPDATE_UI.evtType[0]
try:
blockEvent = block.event
except AttributeError:
@@ -361,11 +364,15 @@
then we'd better have a block event for it, otherwise
we can't post the event.
"""
- assert event.GetEventType() == wx.EVT_UPDATE_UI.evtType[0]
- pass
+ assert updateUIEvent
else:
+ args = {}
+ if updateUIEvent:
+ args['UpdateUI'] = True
+
block.Post (blockEvent, args)
- if event.GetEventType() == wx.EVT_UPDATE_UI.evtType[0]:
+
+ if updateUIEvent:
try:
event.Check (args ['Check'])
except KeyError:
@@ -395,7 +402,7 @@
"""
Giant hack. Calling event.GetEventObject while the object is being created cause the
object to get the wrong type because of a "feature" of SWIG. So we need to avoid
- OnShows in this case.
+ OnShows in this case by using ignoreSynchronizeWidget as a flag.
"""
if not Globals.wxApplication.ignoreSynchronizeWidget:
widget = event.GetEventObject()
@@ -424,6 +431,7 @@
else:
Globals.notificationManager.Unsubscribe (widget.subscribeWhenVisibleEventsUUID)
delattr (widget, 'subscribeWhenVisibleEventsUUID')
+ self.needsUpdateUI = True
event.Skip()
@@ -432,11 +440,19 @@
"""
Adding a handler for catching a set focus event doesn't catch
every change to the focus. It's difficult to preprocess every event
- so we check for focus changes in OnIdle
+ so we check for focus changes in OnIdle. Also call UpdateUI when
+ focus changes
"""
focus = wx.Window_FindFocus()
if self.focus != focus:
self.focus = focus
+ self.needsUpdateUI = True
+
+ if self.needsUpdateUI:
+ try:
+ self.mainFrame.UpdateWindowUI (wx.UPDATE_UI_FROMIDLE | wx.UPDATE_UI_RECURSE)
+ finally:
+ self.needsUpdateUI = False
event.Skip()
def OnExit(self):
Index: chandler/parcels/osaf/framework/blocks/ControlBlocks.py
diff -u chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.104 chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.105
--- chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.104 Mon Aug 23 18:48:53 2004
+++ chandler/parcels/osaf/framework/blocks/ControlBlocks.py Tue Aug 24 08:06:38 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.104 $"
-__date__ = "$Date: 2004/08/24 01:48:53 $"
+__version__ = "$Revision: 1.105 $"
+__date__ = "$Date: 2004/08/24 15:06:38 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -401,25 +401,15 @@
self.SetCellHighlightPenWidth (0)
self.SetCellHighlightROPenWidth (0)
- self.SetDefaultRenderer (GridCellAttributeRenderer("_default"))
- self.RegisterDataType ("String",
- GridCellAttributeRenderer("String"),
- GridCellAttributeEditor("String"))
- self.RegisterDataType ("DateTime",
- GridCellAttributeRenderer("DateTime"),
- GridCellAttributeEditor("DateTime"))
- self.RegisterDataType ("EmailAddress",
- GridCellAttributeRenderer("String"),
- GridCellAttributeEditor("String"))
- self.RegisterDataType ("ContentItem",
- GridCellAttributeRenderer("String"),
- GridCellAttributeEditor("String"))
- self.RegisterDataType ("Contact",
- GridCellAttributeRenderer("String"),
- GridCellAttributeEditor("String"))
- self.RegisterDataType ("ContactName",
- GridCellAttributeRenderer("ContactName"),
- GridCellAttributeEditor("ContactName"))
+ defaultName = "_default"
+ self.SetDefaultRenderer (GridCellAttributeRenderer (defaultName))
+ map = Globals.repository.findPath('//parcels/osaf/framework/attributeEditors/AttributeEditors')
+ for key in map.editorString.keys():
+ if key != defaultName:
+ self.RegisterDataType (key,
+ GridCellAttributeRenderer (key),
+ GridCellAttributeEditor (key))
+
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColumnDrag)
self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnWXSelectionChanged)
Index: chandler/application/Parcel.py
diff -u chandler/application/Parcel.py:1.27 chandler/application/Parcel.py:1.28
--- chandler/application/Parcel.py:1.27 Thu Aug 19 11:06:23 2004
+++ chandler/application/Parcel.py Tue Aug 24 08:06:39 2004
@@ -21,6 +21,7 @@
CORE = "%s/core" % NS_ROOT
CPIA = "%s/osaf/framework/blocks" % NS_ROOT
+#@@@Temporary testing tool written by Morgen -- DJA
timing = False
if timing: import tools.timing
@@ -296,7 +297,7 @@
parent.
Also check files for XML correctness (mismatched tags, etc).
"""
-
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.begin("Scan XML for namespaces")
class MappingHandler(xml.sax.ContentHandler):
@@ -436,6 +437,7 @@
self.saveExplanation(e.getMessage())
raise
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.end("Scan XML for namespaces")
def __walkParcels(self, rootParcel):
@@ -598,7 +600,7 @@
global globalDepth
globalDepth = 0
-
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.begin("Load parcels")
try:
@@ -630,6 +632,7 @@
self.__displayError()
raise
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.end("Load parcels")
def resetState(self):
@@ -1191,6 +1194,7 @@
The new item's kind is derived from (uri, local).
"""
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.begin("Creating items")
try:
@@ -1205,6 +1209,7 @@
self.saveExplanation(str(e))
raise
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.end("Creating items")
if item is None:
@@ -1232,6 +1237,7 @@
self.saveState(line=line, file=file)
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.begin("Attribute assignments")
if assignment["assignType"] == self._DELAYED_REFERENCE:
@@ -1400,6 +1406,7 @@
# Record this assignment in the new set of assignments
new.addAssignment(assignmentTuple)
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.end("Attribute assignments")
# Remove any assignments still remaining in the old value set, since
@@ -1770,6 +1777,7 @@
rep.commit()
rep.close()
+ #@@@Temporary testing tool written by Morgen -- DJA
if timing:
print "\nTiming results:"
tools.timing.results()
More information about the Commits
mailing list