Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dialog class and aspectBuffer

34 views
Skip to first unread message

vin...@gmail.com

unread,
Mar 20, 2021, 7:11:05 AM3/20/21
to
I have a class Guest, which has parameters #isAttending (Boolean) and #person (Person class). Person class has the given names, family name and title.

Guest UI is a Dialog that contains #isAttending (a checkbox) and Person (a Presenter).

In Guest>>#model: I have an aspectBuffer to buffer changes. However the changes to person are always written even if I send #cancel. The change to #isAttending is always buffered.

Is there a way around this? I followed the PersonalMoney example, specifically PersonalAccountTransactionDialog>>#model: where the aspectBuffer is used.

Vince

vin...@gmail.com

unread,
Mar 23, 2021, 7:10:04 AM3/23/21
to
I had to override copy. The changes in the Dialog are correctly buffered and discarded when I press 'Cancel' and written to the backing model when I press 'Save'.

The structure is as follows. The models:

Model subclass: #Guest
instanceVariableNames: 'person isAttending'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''

Model subclass: #Person
instanceVariableNames: 'title givenNames familyName dateOfBirth'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''

Guest>>#person
^ person ifNil: [ person := Person new ]

The Ui classes:

Presenter subclass: #PersonUi
instanceVariableNames: 'title givenNames familyName dateOfBirth'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''

Dialog subclass: #NppGuestView
instanceVariableNames: 'person isAttending'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''

Guest>>#model: anObject
| aspectBuffer |

super model: anObject.
aspectBuffer := self model.
self person model: (aspectBuffer aspectValue: #person).
self isAttending model: (aspectBuffer aspectValue: #isAttending)

The class comment for AspectBuffer says: "In order to be correctly used with an AspectBuffer, a subject object must be able to be sensibly duplicated using #copy."

So I implemented the following:

Guest>>#copy
^ self species new
person: self person copy;
isAttending: self isAttending copy

Vince
0 new messages