'From VisualWorks® NonCommercial, Release 5i.4 of August 9, 2001 on June 13, 2002 at 4:08:49 pm'! CormasNS.Kernel defineClass: #MenuSpaceInterfaces superclass: #{UI.ApplicationModel} indexedType: #none private: false instanceVariableNames: 'cheminMif listMifFiles listEntities processNeighbourhood envFilename attributesToBeSaved line column supervisor theOccupants occupantsList listASCFiles listAttributes attributesSavedASC xllcorner cellsize nodata yllcorner ' classInstanceVariableNames: '' imports: '' category: 'CormasKernel-Space'! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! !CormasNS.Kernel.MenuSpaceInterfaces class methodsFor: 'interface specs'! windowASC "UIPainter new openOnClass: self andSelector: #windowASC" ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: #(#{Kernel.UserMessage} #key: #ascWindow #defaultString: 'Load ASC files' ) #min: #(#{Core.Point} 517 174 ) #max: #(#{Core.Point} 517 174 ) #bounds: #(#{Graphics.Rectangle} 507 384 1024 558 ) #isEventDriven: true ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 310 25 ) #label: #(#{Kernel.UserMessage} #key: #filename #defaultString: 'File' ) ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 260 148 335 178 ) #model: #validateWindowASC #label: 'OK' #defaultable: true ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.Rectangle} 226 52 465 126 ) #model: #listASCFiles #multipleSelections: true #useModifierKeys: true #selectionType: #checkMark ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 351 146 432 177 ) #model: #cancelWindowASC #label: #(#{Kernel.UserMessage} #key: #cancel #defaultString: 'Annuler' ) #defaultable: true ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 7 54 ) #name: #Label1 #label: 'First of all, prepare the topology of your grid' ) ) ) )! windowGridSize "UIPainter new openOnClass: self andSelector: #windowGridSize" ^#(#FullSpec #window: #(#WindowSpec #label: #(#UserMessage #key: #gridsize #defaultString: 'Dimension grille' ) #min: #(#Point 200 147 ) #max: #(#Point 200 147 ) #bounds: #(#Rectangle 219 243 419 390 ) #isEventDriven: true ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 127 22 ) #label: #(#UserMessage #key: #lineTab #defaultString: 'Ligne' ) ) #(#LabelSpec #layout: #(#Point 128 54 ) #label: #(#UserMessage #key: #column #defaultString: 'Colonnes' ) ) #(#LabelSpec #layout: #(#Point 24 22 ) #label: #iconLine #hasCharacterOrientedLabel: false ) #(#LabelSpec #layout: #(#Point 32 46 ) #label: #iconColumn #hasCharacterOrientedLabel: false ) #(#InputFieldSpec #layout: #(#Rectangle 80 14 117 44 ) #model: #line #type: #number #formatString: '0' ) #(#InputFieldSpec #layout: #(#Rectangle 79 52 117 86 ) #model: #column #type: #number #formatString: '0' ) #(#ActionButtonSpec #layout: #(#Rectangle 31 106 161 131 ) #model: #validateWindowGridSize #label: #(#UserMessage #key: #valide #defaultString: 'Valider' ) #isDefault: true #defaultable: true ) ) ) )! windowMifMid "UIPainter new openOnClass: self andSelector: #windowMifMid" ^#(#FullSpec #window: #(#WindowSpec #label: #(#UserMessage #key: #mifWindow #defaultString: 'Importer fichiers mif (contours)' ) #min: #(#Point 517 174 ) #max: #(#Point 517 174 ) #bounds: #(#Rectangle 148 275 665 449 ) #isEventDriven: true ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 70 7 ) #label: #(#UserMessage #key: #filename #defaultString: 'Fichier' ) ) #(#LabelSpec #layout: #(#Point 321 7 ) #label: #(#UserMessage #key: #spatialEntity #defaultString: 'Spatial entity' ) ) #(#ActionButtonSpec #layout: #(#Rectangle 289 118 364 148 ) #model: #validateWindowMifMid #label: 'OK' #defaultable: true ) #(#SequenceViewSpec #layout: #(#Rectangle 13 31 249 104 ) #model: #listMifFiles #useModifierKeys: true #selectionType: #highlight ) #(#ActionButtonSpec #layout: #(#Rectangle 392 117 473 148 ) #model: #cancelWindowMifMid #label: #(#UserMessage #key: #cancel #defaultString: 'Annuler' ) #defaultable: true ) #(#SequenceViewSpec #layout: #(#Rectangle 272 30 497 108 ) #model: #listEntities #useModifierKeys: true #selectionType: #highlight ) #(#CheckBoxSpec #layout: #(#Point 42 114 ) #model: #processNeighbourhood #label: #(#UserMessage #key: #processNeighbourhood #defaultString: 'process neighbourhood' ) ) ) ) )! windowOccupants "UIPainter new openOnClass: self andSelector: #windowOccupants" ^#(#FullSpec #window: #(#WindowSpec #label: #(#UserMessage #key: #occupants #defaultString: 'occupants' ) #min: #(#Point 232 89 ) #max: #(#Point 327 104 ) #bounds: #(#Rectangle 85 210 317 299 ) #isEventDriven: true ) #component: #(#SpecCollection #collection: #( #(#SequenceViewSpec #layout: #(#LayoutFrame 0 0.0301724 0 0.0674157 0 0.965517 0 0.955056 ) #model: #occupantsList #callbacksSpec: #(#UIEventCallbackSubSpec #focusInSelector: #displayCharts #doubleClickSelector: #inspect ) #multipleSelections: false #selectionType: #highlight ) ) ) )! windowSaveASC "UIPainter new openOnClass: self andSelector: #windowSaveASC" ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'Save to ASC' #min: #(#{Core.Point} 266 339 ) #max: #(#{Core.Point} 266 339 ) #bounds: #(#{Graphics.Rectangle} 512 384 778 723 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.Rectangle} 41 41 231 142 ) #name: #List1 #model: #attributesSavedASC #multipleSelections: true #useModifierKeys: true #selectionType: #checkMark ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 34 8 ) #name: #Label1 #label: 'Attributes to be saved' ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 123 313 204 336 ) #name: #ActionButton1 #model: #cancelSaveToASC #label: 'Cancel' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 29 312 110 335 ) #name: #ActionButton2 #model: #validateSaveToASC #label: 'Ok' #defaultable: true ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 132 161 232 184 ) #name: #InputField1 #model: #xllcorner #helpText: '' #alignment: #right #type: #number ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 132 202 232 225 ) #name: #InputField2 #model: #yllcorner #alignment: #right #type: #number ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 132 239 232 262 ) #name: #InputField3 #model: #cellsize #alignment: #right #type: #number ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 56 161 ) #name: #Label2 #label: 'xllcorner' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 56 202 ) #name: #Label3 #label: 'yllcorner' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 56 239 ) #name: #Label4 #label: 'Cell size' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 56 276 ) #name: #Label5 #label: 'No data' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 132 276 232 299 ) #name: #InputField4 #model: #nodata #alignment: #right #type: #number ) ) ) )! windowSaveEnv "UIPainter new openOnClass: self andSelector: #saveEnv" ^#(#FullSpec #window: #(#WindowSpec #label: #(#UserMessage #key: #saveEnvironment #defaultString: 'Save the Environment') #bounds: #(#Rectangle 238 441 656 590) #isEventDriven: true) #component: #(#SpecCollection #collection: #(#(#SequenceViewSpec #layout: #(#Rectangle 30 34 203 122) #model: #attributesToBeSaved #multipleSelections: true #useModifierKeys: true #selectionType: #checkMark) #(#InputFieldSpec #layout: #(#Rectangle 242 58 391 82) #model: #envFilename) #(#ActionButtonSpec #layout: #(#Rectangle 248 96 315 121) #model: #accept #label: #(#UserMessage #key: #ok #defaultString: 'Ok') #defaultable: true) #(#LabelSpec #layout: #(#Point 34 12) #label: #(#UserMessage #key: #attributesToBeSaved #defaultString: 'Attributes to be saved')) #(#LabelSpec #layout: #(#Point 267 37) #label: #(#UserMessage #key: #filename #defaultString: 'Filename')) #(#ActionButtonSpec #layout: #(#Rectangle 324 95 384 121) #model: #cancel #label: #(#UserMessage #key: #cancel #defaultString: 'Cancel') #defaultable: true))))! ! !CormasNS.Kernel.MenuSpaceInterfaces class methodsFor: 'resources'! iconColumn "UIMaskEditor new openOnClass: self andSelector: #iconColonne" ^CachedImage on: (Image extent: 10 @ 30 depth: 1 bitsPerPixel: 1 palette: MonoMappedPalette blackWhite usingBits: #[0 0 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 0 0 0 0 127 128 0 0 127 128 0 0 127 128 0 0 127 128 0 0 255 192 0 0 127 128 0 0 127 128 0 0 127 128 0 0 255 192 0 0 127 128 0 0 127 128 0 0 255 192 0 0 127 128 0 0])! iconLine "UIMaskEditor new openOnClass: self andSelector: #iconneLigne" ^CachedImage on: (Image extent: 31 @ 10 depth: 1 bitsPerPixel: 1 palette: MonoMappedPalette blackWhite usingBits: #[0 0 2 36 127 255 191 254 127 255 191 254 127 255 191 254 127 255 191 254 127 255 191 254 127 255 191 254 127 255 191 254 127 255 191 254 0 0 2 36])! ! !CormasNS.Kernel.MenuSpaceInterfaces class methodsFor: 'instance creation'! new: uneListe ^super new initOccupants: uneListe! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! !CormasNS.Kernel.MenuSpaceInterfaces methodsFor: 'actions'! cancelSaveToASC "This stub method was generated by UIDefiner" self closeRequest! cancelWindowASC "This stub method was generated by UIDefiner" self closeRequest! cancelWindowMifMid self closeRequest! displayCharts | item class id agent | item := self occupantsList selection. item notNil ifTrue: [class := (item tokensBasedOn: Character space) first asSymbol. id := (item tokensBasedOn: $#) last asNumber. agent := theOccupants detect: [:a | a class name = class and: [a id = id]]. self halt. "self openChartsOn: idList"]! inspect | item class id | item := self occupantsList selection. item notNil ifTrue: [class := (item tokensBasedOn: Character space) first asSymbol. id := (item tokensBasedOn: $#) last asNumber. (theOccupants detect: [:a | a class name = class and: [a id = id]]) inspect]! openDialog: uneBoite with: sup | bdr win origin | self supervisor: sup. bdr := self allButOpenInterface: uneBoite. win := bdr window. origin := sup builder window globalOrigin. win openIn: (origin extent: win minimumSize)! requestForWindowClose self supervisor: nil. ^true! validateSaveToASC "This stub method was generated by UIDefiner" | l | l := List new. l add: xllcorner value printString. l add: yllcorner value printString. l add: cellsize value printString. l add: nodata value printString. self supervisor model saveAttributesASC: attributesSavedASC fileParameters: l. self closeRequest! validateWindowASC "This stub method was generated by UIDefiner" listASCFiles listHolder value do: [:f | self supervisor model getDataFromASCFile: f]. self supervisor model prepareAndRefreshView. self closeRequest! validateWindowGridSize self supervisor model resetSpatialEntities. self supervisor model line: self line value column: self column value. self supervisor model createCells. self supervisor model prepareAndRefreshView. self closeRequest! validateWindowMifMid self supervisor model loadMifMid: ((Cormas mapsPath: self supervisor model cormasModel class name) construct: self listMifFiles selection) entity: self listEntities selection neighbourhood: self processNeighbourhood value. self closeRequest.! ! !CormasNS.Kernel.MenuSpaceInterfaces methodsFor: 'initialize-release'! initASCParametres: model | liste | liste := Filename filesMatching: ((Cormas mapsPath: model name) construct: '*.asc') asString. liste := liste collect: [:f | (Filename splitPath: f) at: 2]. self listASCFiles list: liste asList.! initGridSizeLine: l column: c line := l asValue. column := c asValue! initOccupants: unDicoOccupants | labelsList | theOccupants := OrderedCollection new. labelsList := OrderedCollection new. unDicoOccupants values do: [:l | theOccupants addAll: l]. theOccupants do: [:a | labelsList add: a class name , ' #' , a id printString]. self occupantsList list: labelsList! initSaveASC: model | liste | liste := List new. liste addAllFirst: model cellClass instVarNames. (model cellClass inheritsFrom: SpatialEntityCell) ifTrue: [liste addFirst: 'state']. attributesSavedASC := MultiSelectionInList new list: liste. attributesSavedASC selectAll! initSaveEnv: model | liste | liste := List new. liste addAllFirst: model cellClass instVarNames. (model cellClass inheritsFrom: SpatialEntityCell) ifTrue: [liste addFirst: 'state']. attributesToBeSaved := MultiSelectionInList new list: liste. attributesToBeSaved selectAll. self envFilename value: 'filename.env'! initSigParametres: model | liste | liste := Filename filesMatching: ((Cormas mapsPath: model name) construct: '*.mif') asString. liste := liste collect: [:f | (Filename splitPath: f) at: 2]. self listMifFiles list: liste. self listMifFiles list isEmpty ifFalse: [self listMifFiles selection: self listMifFiles list first]. self listEntities list: model spatialClasses asList. self listEntities list isEmpty ifFalse: [self listEntities selection: self listEntities list first]. self processNeighbourhood value: false! ! !CormasNS.Kernel.MenuSpaceInterfaces methodsFor: 'aspects'! attributesSavedASC "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^attributesSavedASC! attributesToBeSaved ^attributesToBeSaved! cellsize "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^cellsize isNil ifTrue: [cellsize := 0 asValue] ifFalse: [cellsize]! cheminMif "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^cheminMif isNil ifTrue: [cheminMif := String new asValue] ifFalse: [cheminMif]! column "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^column isNil ifTrue: [column := 0 asValue] ifFalse: [column]! envFilename "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^envFilename isNil ifTrue: [envFilename := String new asValue] ifFalse: [envFilename]! line "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^line isNil ifTrue: [line := 0 asValue] ifFalse: [line]! listASCFiles "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^listASCFiles isNil ifTrue: [listASCFiles := MultiSelectionInList new] ifFalse: [listASCFiles]! listASCFiles: x listASCFiles := x! listAttributes "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^listAttributes isNil ifTrue: [listAttributes := SelectionInList new] ifFalse: [listAttributes]! listEntities "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^listEntities isNil ifTrue: [listEntities := SelectionInList new] ifFalse: [listEntities]! listMifFiles "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^listMifFiles isNil ifTrue: [listMifFiles := SelectionInList new] ifFalse: [listMifFiles]! nodata "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^nodata isNil ifTrue: [nodata := 0 asValue] ifFalse: [nodata]! occupantsList ^occupantsList isNil ifTrue: [occupantsList := SelectionInList new] ifFalse: [occupantsList]! processNeighbourhood "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^processNeighbourhood isNil ifTrue: [processNeighbourhood := false asValue] ifFalse: [processNeighbourhood]! xllcorner "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^xllcorner isNil ifTrue: [xllcorner := 0 asValue] ifFalse: [xllcorner]! yllcorner "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^yllcorner isNil ifTrue: [yllcorner := 0 asValue] ifFalse: [yllcorner]! ! !CormasNS.Kernel.MenuSpaceInterfaces methodsFor: 'accessing'! supervisor ^supervisor! supervisor: anObject supervisor := anObject! !