[Chandler-dev] Dashboard domain model questions
Bryan Stearns
stearns at osafoundation.org
Thu Jun 29 15:54:35 PDT 2006
Grant Baillie wrote:
> On 29 Jun, 2006, at 15:16, Bryan Stearns wrote:
>> - there's a list of dependent attributes, allowing us to set up
>> item/attribute notifications to keep things up to date in the UI. If
>> we use Calculateds for indexing, we might need the repository to hook
>> into this so that indexes get updated when dependent attributes
>> change - we'll talk about this more later.
> Interesting: What parts of the UI (tables, attribute editors, ...) set
> up these notifications?
Block :-)
Any Block that implements onItemNotification, has a viewAttribute
attribute, and has an item in 'contents', will get that
onItemNotification method called if the attribute with that name changes
on that item while the block is rendered. This "viewAttribute on the
contents item" thing is the default behavior implemented by
Block.getWatchList; if more attributes (or even attributes on other
items) need to be watched, the block can override getWatchList to add
other item/attribute pairs (or replace the list completely).
You can see many of these overrides in Detail.py: this is how, for
instance, item-dependent visibility is handled (so when you toggle the
"all day" checkbox, the actual attribute change fires a synchronous
notification through this mechanism, which notifies the blocks that want
to update the detail view display of an event's start & end time as
you're dragging it around the calendar, or show or hide themselves based
on the allDay attribute.
Fun fact to know and tell: It turns out that there are seven blocks who
need to update themselves when allDay changes: the two "time" parts of
start & end time, the "at" labels before each of them, the status and
timezone popups (we don't show it for allday events), and the block
containing the allday label/checkbox itself (which hides itself on
read-only non-allday events).
Because this mechanism is centralized in Block, there's only one
repository item-watcher set up, even though there are six subscribers,
which reduces overhead for Andi.
One caveat: Be careful not to change attribute values in your
onItemNotification method, unless you want to spend forever there.
...Bryan
More information about the chandler-dev
mailing list