dabo Commit
Revision 2804
Date: 2007-02-11 12:38:12 -0800 (Sun, 11 Feb 2007)
Author: Paul

Changed:
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dGrid.py
U   trunk/dabo/ui/uiwx/dPemMixin.py

Log:
Fixed dGrid to trap and respond to BusinessRuleViolations when moving the
row number. This should fix tracker 0293. If the BusinessRuleViolation is
raised by the bizobj, the grid will revert back to the prior row after
notifying the user.


Diff:
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2007-02-10 19:30:33 UTC (rev 2803)
+++ trunk/dabo/ui/uiwx/dForm.py 2007-02-11 20:38:12 UTC (rev 2804)
@@ -523,18 +523,7 @@
                """ Set the SQL for the bizobj."""
                self.getBizobj(dataSource).setSQL(sql)
                
-       
-       def notifyUser(self, msg, title="Notice", severe=False):
-               """ Displays an alert messagebox for the user. You can customize
-               this in your own classes if you prefer a different display.
-               """
-               if severe:
-                       func = dabo.ui.stop
-               else:
-                       func = dabo.ui.info
-               func(message=msg, title=title)
 
-
        def _connectionLostMsg(self, err):
                return _("""The connection to the database has closed for 
unknown reasons.
 Any unsaved changes to the data will be lost.

Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2007-02-10 19:30:33 UTC (rev 2803)
+++ trunk/dabo/ui/uiwx/dGrid.py 2007-02-11 20:38:12 UTC (rev 2804)
@@ -2962,7 +2962,6 @@
 
        def _onGridCellSelected(self, evt):
                """ Occurs when the grid's cell focus has changed."""
-
                ## pkm 2005-09-28: This works around a nasty segfault:
                self.HideCellEditControl()
                ## but periodically test it. My current version: 2.6.1.1pre
@@ -2988,13 +2987,12 @@
                if oldRow != newRow:
                        bizobj = self.getBizobj()
                        if bizobj:
-                               if bizobj.RowCount > newRow:
-                                       # First attempt to go through the form.
-                                       if self.Form and hasattr(self.Form, 
"moveToRowNumber"):
-                                                       
self.Form.moveToRowNumber(newRow, dataSource=bizobj.DataSource)
-                                       else:
-                                               # set the RowNumber on the 
bizobj directly
+                               if bizobj.RowCount > newRow and 
bizobj.RowNumber != newRow:
+                                       try:
                                                bizobj.RowNumber = newRow
+                                       except 
dException.BusinessRuleViolation, e:
+                                               self.notifyUser(e)
+                                               dabo.ui.callAfter(self.refresh)
                                else:
                                        # We are probably trying to select row 
0 when there are no records
                                        # in the bizobj.
@@ -3002,8 +3000,8 @@
                                        ##     unneccesary.
                                        #self.SetGridCursor(0,0)
                                        pass
-               if self.Form is not None:
-                       dabo.ui.callAfter(self.Form.update)
+                       if self.Form is not None:
+                               dabo.ui.callAfter(self.Form.update)
 
 
        def _checkSelectionType(self):

Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py     2007-02-10 19:30:33 UTC (rev 2803)
+++ trunk/dabo/ui/uiwx/dPemMixin.py     2007-02-11 20:38:12 UTC (rev 2804)
@@ -597,6 +597,17 @@
                self.raiseEvent(dEvents.Resize, evt)
 
 
+       def notifyUser(self, msg, title="Notice", severe=False):
+               """ Displays an alert messagebox for the user. You can customize
+               this in your own classes if you prefer a different display.
+               """
+               if severe:
+                       func = dabo.ui.stop
+               else:
+                       func = dabo.ui.info
+               func(message=msg, title=title)
+
+
        def bindKey(self, keyCombo, callback, **kwargs):
                """Bind a key combination such as "ctrl+c" to a callback 
function.
 




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to