Thanks Stephan.


---
Philippe Back
Dramatic Performance Improvements
Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027
Mail:phil@highoctane.be | Web: http://philippeback.eu
Blog: http://philippeback.be | Twitter: @philippeback
Youtube: http://www.youtube.com/user/philippeback/videos

High Octane SPRL
rue cour Boisacq 101 | 1301 Bierges | Belgium

Featured on the Software Process and Measurement Cast
http://spamcast.libsyn.com
Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller



On Mon, Jul 8, 2013 at 5:48 PM, Stephan Eggermont <stephan@stack.nl> wrote:
Some snippets of a working glamour application loading excel files (Moose 4.8)
MNU on SmallInteger could be a broken VM

A separate class to represent the csv file, storing the rows:

ANExcelModel >> on: aFilename
� � � � ^self new
� � � � � � � � rows: (NeoCSVReader on: (FileSystem root / aFilename) readStream) upToEnd ;
� � � � � � � � yourself

The domain model has an announcer letting the browser know when something changed

AModel>loadFrom: aFileName
� � � � |excel regel � �|
� � � � excel := ANExcelModel on: aFileName .
� � � � excel rows allButFirstDo: [ :row |
� � � � � � � � regel := ANRegel new.
� � � � � � � � regel thema: (self findIn: row at: 1 key: #thema).
� � � � � � � � regel onderwerp: (self findIn: row at: 3 key: #onderwerp).
� � � � � � � � regel addTo: self.
� � � � � � � � �].
� � � � self announce: ANChanged


ANModel>announce: anAnnouncement
� � � � ^self announcer announce: anAnnouncement


Part of the browser construction, loading a file:

� � � � browser transmit to: #thema; andShow: [ :a |
� � � � � � � � a list
� � � � � � � � � � � � title: 'Themas';
� � � � � � � � � � � � display: [ (self model dimensies at: #thema) items ];
� � � � � � � � � � � � updateOn: SVChanged from: SVModel default announcer;
� � � � � � � � � � � � act: [ : b | self loadExcel ] entitled: 'Laad csv';
� � � � � � � � � � � � selectionAct: [ :list |
� � � � � � � � � � � � � � � � self addOnderwerpTo: list selection]
� � � � � � � � � � � � � � � � on: $o
� � � � � � � � � � � � � � � � entitled: 'Voeg onderwerp toe'.
� � � � � � � � a text
� � � � � � � � � � � � title: '?';
� � � � � � � � � � � � display: [ self helpThema ].
� � � � � � � � � � � � ].


ANBrowser>loadExcel
� � � � |excel|
� � � � excel := MorphicUIManager new chooseFullFileName: �'Selecteer een .csv bestand' extensions: nil path: nil preview: nil.

� � � � excel isEmptyOrNil ifFalse:[
� � � � � � � � self model loadFrom: excel]