[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r10016 - in trunk/gnue-forms/src: . GFObjects
From: |
reinhard |
Subject: |
[gnue] r10016 - in trunk/gnue-forms/src: . GFObjects |
Date: |
Wed, 28 Oct 2009 09:41:59 -0500 (CDT) |
Author: reinhard
Date: 2009-10-28 09:41:59 -0500 (Wed, 28 Oct 2009)
New Revision: 10016
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFObjects/GFBlock.py
trunk/gnue-forms/src/GFObjects/GFButton.py
trunk/gnue-forms/src/GFObjects/GFGrid.py
trunk/gnue-forms/src/GFObjects/GFObj.py
trunk/gnue-forms/src/GFObjects/GFScrollBar.py
trunk/gnue-forms/src/GFObjects/GFTabStop.py
Log:
If an entry is linked to a grid, consider the grid's block the current block
while the entry has the focus. This is explicitly useful for entries in an
unbound block that serve as "search" filter for a grid.
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2009-10-28 11:46:40 UTC (rev 10015)
+++ trunk/gnue-forms/src/GFForm.py 2009-10-28 14:41:59 UTC (rev 10016)
@@ -1057,9 +1057,8 @@
self._currentEntry.validate()
if pageChange:
self._currentPage.validate()
- field = self._currentEntry.get_field()
- if field is not None:
- field.validate()
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.get_field().validate()
if blockChange:
if self._currentBlock is not None:
self._currentBlock.validate()
@@ -1068,9 +1067,8 @@
self._currentEntry.focus_out()
if pageChange:
self._currentPage.focus_out()
- field = self._currentEntry.get_field()
- if field is not None:
- field.focus_out()
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.get_field().focus_out()
if blockChange:
if self._currentBlock is not None:
self._currentBlock.focus_out()
@@ -1095,9 +1093,8 @@
if blockChange:
if self._currentBlock is not None:
self._currentBlock.focus_in()
- field = self._currentEntry.get_field()
- if field is not None:
- field.focus_in()
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.get_field().focus_in()
if pageChange:
self._currentPage.focus_in()
self._currentEntry.focus_in()
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2009-10-28 11:46:40 UTC (rev
10015)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2009-10-28 14:41:59 UTC (rev
10016)
@@ -30,6 +30,7 @@
from gnue.common.definitions import GParser
from gnue.common import events
+from gnue.forms.GFObjects.GFTabStop import GFFieldBound
from gnue.forms.GFObjects.GFContainer import GFContainer
from gnue.forms.GFObjects.GFDataSource import GFDataSource
@@ -1342,29 +1343,35 @@
def _focus_in(self):
- if self._form.get_focus_block() is self:
+ focus_object = self._form.get_focus_object()
+ if focus_object and focus_object.get_bound_block() is self:
self.focus_in()
- field = self._form.get_focus_object().get_field()
- if field is not None:
- field.focus_in()
+ if isinstance(focus_object, GFFieldBound):
+ focus_object.get_field().focus_in()
self._form.beginEditing()
+ elif self._form.get_focus_block() is self:
+ # Current object is not bound to this block, but still a "member"
+ # of theis block, like an entry linked to this block via grid_link.
+ # We want to update the record status.
+ self.__update_record_status()
+
# -------------------------------------------------------------------------
def _focus_out(self):
- if self._form.get_focus_block() is self:
+ focus_object = self._form.get_focus_object()
+ if focus_object and focus_object.get_bound_block() is self:
self._form.endEditing()
try:
- field = self._form.get_focus_object().get_field()
- if field is not None:
- field.validate()
- self.validate()
- if field is not None:
- field.focus_out()
+ if isinstance(focus_object, GFFieldBound):
+ focus_object.get_field().validate()
+ self.validate()
+ if isinstance(focus_object, GFFieldBound):
+ focus_object.get_field().focus_out()
self.focus_out()
except Exception:
self._form.beginEditing()
@@ -1468,9 +1475,12 @@
self._currentRecord = newRecord
self.__record_count = newRecordCount
- for entry in self._entryList:
- entry.recalculate_visible(adjustment, self._currentRecord,
- self.__record_count, refresh)
+ # We iterate through the fields' entries here, since our own _entryList
+ # also contains the entries that are bound to us via grid_link.
+ for field in self._fieldMap.itervalues():
+ for entry in field._entryList:
+ entry.recalculate_visible(adjustment, self._currentRecord,
+ self.__record_count, refresh)
self.__adjust_scrollbars()
Modified: trunk/gnue-forms/src/GFObjects/GFButton.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFButton.py 2009-10-28 11:46:40 UTC (rev
10015)
+++ trunk/gnue-forms/src/GFObjects/GFButton.py 2009-10-28 14:41:59 UTC (rev
10016)
@@ -63,7 +63,6 @@
GFTabStop._phase_1_init_(self)
- self._block = self.get_block()
if self._block:
self._block._entryList.append(self)
Modified: trunk/gnue-forms/src/GFObjects/GFGrid.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFGrid.py 2009-10-28 11:46:40 UTC (rev
10015)
+++ trunk/gnue-forms/src/GFObjects/GFGrid.py 2009-10-28 14:41:59 UTC (rev
10016)
@@ -58,7 +58,6 @@
def _phase_1_init_(self):
GFContainer._phase_1_init_(self)
- self._block = self.get_block()
self.__rows = int(getattr(self, "rows", 1))
self.walk(self.__init_rows_walker)
self._block._rows = self.__rows
Modified: trunk/gnue-forms/src/GFObjects/GFObj.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFObj.py 2009-10-28 11:46:40 UTC (rev
10015)
+++ trunk/gnue-forms/src/GFObjects/GFObj.py 2009-10-28 14:41:59 UTC (rev
10016)
@@ -126,7 +126,7 @@
#
--------------------------------------------------------------------------
- # Get a block from the block map
+ # Get the block this control is a member of
# -------------------------------------------------------------------------
def get_block(self):
@@ -139,44 +139,31 @@
listed in the block mapping of the logic instance
"""
- if getattr(self, 'block', None) is None:
- owner = self.getParent()
- while owner:
- self.block = getattr(owner, 'block', None)
- if self.block:
- break
- owner = owner.getParent()
- else:
- return None
+ # Sometimes other objects in the tree access in their own
+ # _phase_1_init_, so we have to make sure _block is initialized.
+ if not hasattr(self, '_block'):
+ self.__init_form_and_block()
- if not self.block in self._form._logic._blockMap:
- raise BlockNotFoundError, self
+ return self._block
- return self._form._logic._blockMap[self.block]
-
+ #
--------------------------------------------------------------------------
+ # Get the block this control is bound to
# -------------------------------------------------------------------------
- # Get a field
- # -------------------------------------------------------------------------
- def get_field(self):
+ def get_bound_block(self):
"""
- Returns the objects' field from the blocks' field mapping
+ Return the objects' block from the block mapping.
- @returns: GFField instance or None if the object does not support
fields
- @raises FieldNotFoundError: if the field is not available through the
- block
+ @returns: the block of the current object or None if the current object
+ does not support blocks.
+ @raises BlockNotFoundError: if the block specified by the object is not
+ listed in the block mapping of the logic instance
"""
- if not hasattr(self, 'field'):
- return None
+ return self._bound_block
- if not self.field in self._block._fieldMap:
- raise FieldNotFoundError, self
- return self._block._fieldMap[self.field]
-
-
# -------------------------------------------------------------------------
# Phase 1 initialization
# -------------------------------------------------------------------------
@@ -188,9 +175,38 @@
after construction of the objects.
"""
+ if not hasattr(self, '_block'):
+ self.__init_form_and_block()
+
+
+ # -------------------------------------------------------------------------
+ # Find block for this object
+ # -------------------------------------------------------------------------
+
+ def __init_form_and_block(self):
+
+ # The form this object is a member of.
self._form = self.findParentOfType('GFForm')
+ # The block this object is a member of. In case of an entry which is
+ # linked to a grid, this is the grid's block.
+ parent = self
+ while parent:
+ block_name = getattr(parent, 'block', None)
+ if block_name:
+ if not block_name in self._form._logic._blockMap:
+ raise BlockNotFoundError, parent
+ self._block = self._form._logic._blockMap[block_name]
+ break
+ parent = parent.getParent()
+ else:
+ self._block = None
+ # The block this object is bound to. In case of an entry which is
+ # linked to a grid, this is the entry's block.
+ self._bound_block = self._block
+
+
# -------------------------------------------------------------------------
# Indicate whether this widget makes use of the separate label column
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/GFObjects/GFScrollBar.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFScrollBar.py 2009-10-28 11:46:40 UTC
(rev 10015)
+++ trunk/gnue-forms/src/GFObjects/GFScrollBar.py 2009-10-28 14:41:59 UTC
(rev 10016)
@@ -54,7 +54,6 @@
GFObj._phase_1_init_(self)
- self._block = self.get_block()
self._block.register_scrollbar(self)
self._scrollrows = getattr(self, 'scrollrows', self._block._rows)
Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2009-10-28 11:46:40 UTC (rev
10015)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2009-10-28 14:41:59 UTC (rev
10016)
@@ -104,7 +104,12 @@
if not self.__grid_link:
self.__grid_link = self.findParentOfType('GFGrid')
+ if self.__grid_link:
+ self._block = self.__grid_link.get_block()
+ self._block._entryList.append(self)
+
+
# -------------------------------------------------------------------------
# UI events (called from UIEntry/UIButton)
# -------------------------------------------------------------------------
@@ -514,18 +519,6 @@
class GFFieldBound(GFTabStop):
# -------------------------------------------------------------------------
- # Constructor
- # -------------------------------------------------------------------------
-
- def __init__(self, parent, object_type):
-
- GFTabStop.__init__(self, parent, object_type)
-
- self._block = None
- self._field = None
-
-
- # -------------------------------------------------------------------------
# Phase 1 init
# -------------------------------------------------------------------------
@@ -533,10 +526,9 @@
GFTabStop._phase_1_init_(self)
- self._block = self.get_block()
- self._block._entryList.append(self)
-
- self._field = self.get_field()
+ if not self.field in self._bound_block._fieldMap:
+ raise FieldNotFoundError, self
+ self._field = self._bound_block._fieldMap[self.field]
self._field._entryList.append(self)
self._formatmask = ""
@@ -576,6 +568,22 @@
# -------------------------------------------------------------------------
+ # Get the field this object is bound to
+ # -------------------------------------------------------------------------
+
+ def get_field(self):
+ """
+ Returns the objects' field from the blocks' field mapping
+
+ @returns: GFField instance or None if the object does not support
fields
+ @raises FieldNotFoundError: if the field is not available through the
+ block
+ """
+
+ return self._field
+
+
+ # -------------------------------------------------------------------------
# Clipboard and selection
# -------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r10016 - in trunk/gnue-forms/src: . GFObjects,
reinhard <=