From VisualWorks® NonCommercial, 7.4.1 of May 30, 2006 on November 17, 2006 at 7:36:39 am ExtremeEcode Smalltalk false private Smalltalk.* Ecode Ecode EcodeTest ExtremeEcode XProgramming.SUnit.TestCase false none ecode Ecode Ecode Project ExtremeEcode Core.Object false none name classes goals scenarios Ecode Ecode EcodeProjectChooser ExtremeEcode UI.ApplicationModel false none projectList ecode Ecode Ecode ProjectTest ExtremeEcode XProgramming.SUnit.TestCase false none project Ecode Ecode Ecode ExtremeEcode Core.Object false none projects Ecode Ecode ExtremeEcode.ProjectTest testing testGetSet self assert: (project name = 'TestProject'). testLookupClass | res | res := project lookupClass: 'c2'. self assert: ( res = 'c2'). testAddClass self assert: (project classes size = 3). self assert: (project classes includes: 'c1'). testRemoveClass project deleteClass: 'c2'. self assert: (project classes size = 2). self assert: (project classes includes: 'c1'). self deny: (project classes includes: 'c2'). ExtremeEcode.ProjectTest initialize-release setUp project := Project new. project name: 'TestProject'. project addClass: 'c1'. project addClass: 'c2'. project addClass: 'c3'. ExtremeEcode.Project class instance creation new "Answer a newly created and initialized instance." ^super new initialize ExtremeEcode.Project dependents collection deleteClass: aClass classes remove: aClass. addClass: aClass classes add: aClass. lookupClass: aClass | res | res := classes detect: [ :e | e = aClass ]. ^res. ExtremeEcode.Project initialize-release initialize "Initialize a newly created instance. This method must answer the receiver." " *** Edit the following to properly initialize instance variables ***" name := 'DefaultProject'. classes := OrderedCollection new. goals := OrderedCollection new. scenarios := OrderedCollection new. " *** And replace this comment with additional initialization code *** " ^self ExtremeEcode.Project accessing name ^name goals ^goals scenarios: aCollection scenarios := aCollection. classes: aCollection classes := aCollection displayString ^ name. classes ^classes goals: aCollection goals := aCollection name: anObject name := anObject scenarios ^scenarios ExtremeEcode.Ecode class instance creation new "Answer a newly created and initialized instance." ^super new initialize ExtremeEcode.Ecode dependents collection lookupProject: aProjectName | res | res := projects detect: [ :e | e name = aProjectName]. ^ res. addProject: aProjectName |p| p := Project new. p name: aProjectName. projects add: p. self changed: #projects. deleteProject: aProjectName | res | res := self lookupProject: aProjectName. projects remove: res. self changed: #projects. ExtremeEcode.Ecode fileIn/Out load |filename bos objects| " filename := Dialog requestFileName: 'Open Ecode'." bos := BinaryObjectStorage onOld: 'ecode.data' asFilename readStream. [objects := bos contents] ensure: [bos close]. projects removeAllSuchThat: [ :e | true ]. objects do: [ :e | projects add: e ]. self changed: #projects. save |filename bos| "filename := Dialog requestFileName: 'Open Ecode'." bos := BinaryObjectStorage onNew: 'ecode.data' asFilename writeStream. [bos nextPutAll: projects] ensure: [bos close]. ExtremeEcode.Ecode initialize-release initialize "Initialize a newly created instance. This method must answer the receiver." " *** Edit the following to properly initialize instance variables ***" projects := OrderedCollection new. " *** And replace this comment with additional initialization code *** " ^self ExtremeEcode.Ecode accessing projectNames ^ projects collect: [ :e | e name ]. projects ^projects ExtremeEcode.EcodeTest testing testRemoveProject |names| ecode deleteProject: 'p2'. names := ecode projectNames. self assert: (names size = 2). self deny: (names includes: 'p2'). self assert: (names includes: 'p3'). testAddProject |names| names := ecode projectNames. self assert: (names size = 3). self assert: (names includes: 'p2'). testProjectNames |names| names := ecode projectNames. self assert: (names size = 3). self assert: (names includes: 'p2'). testLookupProject |res| res := ecode lookupProject: 'p2'. self assert: (res name = 'p2'). testLoadSave | names | ecode save. ecode := Ecode new. ecode load. names := ecode projectNames. self assert: (ecode projects size = 3). self assert: (names includes: 'Foo'). ecode addProject: 'p4'. self assert: (ecode projects size = 4). ExtremeEcode.EcodeTest initialize-release setUp ecode := Ecode new. ecode addProject: 'Foo'. ecode addProject: 'p2'. ecode addProject: 'p3'. ExtremeEcode.EcodeProjectChooser class interface specs windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'Ecode Project Chooser' #bounds: #(#{Graphics.Rectangle} 512 384 868 728 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.Rectangle} 6 5 223 338 ) #name: #List1 #model: #projectList #useModifierKeys: true #selectionType: #highlight ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 247 11 331 44 ) #name: #ActionButton1 #model: #openProject #label: 'Open Project' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 247 58 333 94 ) #name: #ActionButton2 #model: #createProject #label: 'Create Project' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 249 108 334 145 ) #name: #ActionButton3 #model: #deleteProject #label: 'Delete Project' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 252 161 333 200 ) #name: #ActionButton4 #model: #loadProjects #label: 'Load Projects' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 249 216 336 255 ) #name: #ActionButton5 #model: #saveProjects #label: 'Save Projects' #defaultable: true ) ) ) ) ExtremeEcode.EcodeProjectChooser class instance creation new ^ super new initialize ExtremeEcode.EcodeProjectChooser events changedProject ExtremeEcode.EcodeProjectChooser aspects projectList |list| list := AspectAdaptor subject: ecode. list forAspect: #projects. ^projectList isNil ifTrue: [projectList := SelectionInList new listHolder: list] ifFalse: [projectList] ExtremeEcode.EcodeProjectChooser initialize-release initialize |adaptor| ecode := Ecode new. projectList := SelectionInList new. adaptor := AspectAdaptor subject: ecode. adaptor forAspect: #projects. adaptor subjectSendsUpdates: true. projectList listHolder: adaptor. projectList selectionIndexHolder onChangeSend: #changedProject to: self. ExtremeEcode.EcodeProjectChooser actions saveProjects ecode save. openProject |select| select := projectList selection. Dialog warn: 'Opening project: ' , select name. loadProjects |test| Transcript show: 'Loading Projects'. ecode load. test := self projectList list. test do: [ :e | Transcript show: e name ; show: ' ' ; cr.] createProject | name list selectionList p | name := Dialog request: 'Enter a project name' initialAnswer: 'DefaultProject'. selectionList := self projectList. list := selectionList list. p := Project new. p name: name. list add: p. selectionList selectionIndex: list size. deleteProject |sel | sel := projectList selection. ecode deleteProject: sel name.