Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Simulations are like miniskirts, they show a lot and hide the essentials. -- Hubert Kirrman


programming / comp.lang.smalltalk.dolphin / Re: Dialog class and aspectBuffer

SubjectAuthor
o Re: Dialog class and aspectBuffervin...@gmail.com

1
Subject: Re: Dialog class and aspectBuffer
From: vin...@gmail.com
Newsgroups: comp.lang.smalltalk.dolphin
Date: Tue, 23 Mar 2021 11:10 UTC
References: 1
X-Received: by 2002:aed:2c41:: with SMTP id f59mr3710637qtd.222.1616497803769;
Tue, 23 Mar 2021 04:10:03 -0700 (PDT)
X-Received: by 2002:aca:4a95:: with SMTP id x143mr2850736oia.59.1616497803288;
Tue, 23 Mar 2021 04:10:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.smalltalk.dolphin
Date: Tue, 23 Mar 2021 04:10:03 -0700 (PDT)
In-Reply-To: <7501699f-05c5-40ed-a5a9-8bf4f9ad3ac5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=114.198.46.77; posting-account=5_w1_goAAAB1Y5P4_YBwBlB76XHrI38U
NNTP-Posting-Host: 114.198.46.77
References: <7501699f-05c5-40ed-a5a9-8bf4f9ad3ac5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5ccaa3b7-f987-47f8-8024-5bcefd748c54n@googlegroups.com>
Subject: Re: Dialog class and aspectBuffer
From: vin...@gmail.com (vin...@gmail.com)
Injection-Date: Tue, 23 Mar 2021 11:10:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 50
View all headers
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


1
rocksolid light 0.7.2
clearneti2ptor