continued

A next step is the editing of existing instances.
In the DOPartiesList, we need to use a NewListModel instead of the ListModel,
as that understands doubleClick actions.

DOPartiesList>initializeWidgets
-       list := self newList.
+       list := self instantiate: NewListModel.
 
To edit a party, we modify addPartyBlockIn: anEditor to create editParty:in:. 
We set the data values and the title. In the okAction we don't have to add the 
party.

DOPartiesList>editParty: aParty in: anEditor
        aParty class fields do: [ :field |
                (anEditor model perform: field) text: (aParty perform: field) ].

        anEditor title: 'Edit ',aParty fullName.

        anEditor okAction: [ 
                anEditor model partyClass fields do: [ :field |
                        aParty perform: (field asMutator) with: (anEditor model 
perform: field) text ].
                self refreshItems ].

In initializePresenter, we can then add an edit action. The list currently needs
to know that it should handle doubleClicks, and then call a partyeditor 

DOPartiesList>initializePresenter
+       list handlesDoubleClick: true.
+       list doubleClickAction: [ |party edit|
+               party := list selectedItem.
+               edit := (DOPartyEditor on:  party class) openDialogWithSpec.
+               self editParty: party in: edit]


Reply via email to