ProjectBrowser.st
changeset 1248 fc64935b7ff9
parent 1242 243b06d0e230
child 1251 379bd54db35b
equal deleted inserted replaced
1247:6fb170b75302 1248:fc64935b7ff9
  1847        #(#WindowSpec
  1847        #(#WindowSpec
  1848           #label: 'ProjectBrowser'
  1848           #label: 'ProjectBrowser'
  1849           #name: 'ProjectBrowser'
  1849           #name: 'ProjectBrowser'
  1850           #min: #(#Point 10 10)
  1850           #min: #(#Point 10 10)
  1851           #max: #(#Point 1024 768)
  1851           #max: #(#Point 1024 768)
  1852           #bounds: #(#Rectangle 10 20 613 571)
  1852           #bounds: #(#Rectangle 509 332 1112 883)
  1853           #menu: #mainMenu
  1853           #menu: #mainMenu
  1854           #icon: #bigProjectBrowserIcon
  1854           #icon: #bigProjectBrowserIcon
  1855         )
  1855         )
  1856         #component: 
  1856         #component: 
  1857        #(#SpecCollection
  1857        #(#SpecCollection
  1860               #name: 'ToolBar1'
  1860               #name: 'ToolBar1'
  1861               #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
  1861               #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
  1862               #menu: #menu
  1862               #menu: #menu
  1863               #textDefault: true
  1863               #textDefault: true
  1864             )
  1864             )
  1865            #(#VariableHorizontalPanelSpec
  1865            #(#VariableVerticalPanelSpec
  1866               #name: 'VariableHorizontalPanel1'
  1866               #name: 'VariableVerticalPanel1'
  1867               #layout: #(#LayoutFrame 0 0.0 40 0.0 0 1.0 -24 1.0)
  1867               #layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 -24 1.0)
  1868               #handles: 
  1868               #level: 1
  1869              #(#OrderedCollection
       
  1870                 #Any 0.379433
       
  1871                 1.0
       
  1872               )
       
  1873               #component: 
  1869               #component: 
  1874              #(#SpecCollection
  1870              #(#SpecCollection
  1875                 #collection: #(
  1871                 #collection: #(
  1876                  #(#SelectionInTreeViewSpec
  1872                  #(#VariableHorizontalPanelSpec
  1877                     #name: 'TreeList1'
  1873                     #name: 'VariableHorizontalPanel1'
  1878                     #model: #selectedTreeNodeHolder
  1874                     #component: 
  1879                     #menu: #itemMenuHolder
  1875                    #(#SpecCollection
  1880                     #performer: #itemMenuPerformer
  1876                       #collection: #(
  1881                     #hasHorizontalScrollBar: true
  1877                        #(#SelectionInTreeViewSpec
  1882                     #hasVerticalScrollBar: true
  1878                           #name: 'TreeList1'
  1883                     #miniScrollerHorizontal: true
  1879                           #model: #selectedTreeNodeHolder
  1884                     #showRoot: false
  1880                           #menu: #itemMenuHolder
  1885                     #showDirectoryIndicatorForRoot: false
  1881                           #performer: #itemMenuPerformer
  1886                     #showDirectoryIndicator: true
  1882                           #hasHorizontalScrollBar: true
  1887                     #valueChangeSelector: #itemSelected:
  1883                           #hasVerticalScrollBar: true
  1888                     #doubleClickSelector: #itemDoubleClicked:
  1884                           #miniScrollerHorizontal: true
  1889                     #hierarchicalList: #projectTreeHolder
  1885                           #showRoot: false
  1890                     #selectConditionSelector: #selectionChangeAllowed:
  1886                           #showDirectoryIndicatorForRoot: false
  1891                     #highlightMode: #label
  1887                           #showDirectoryIndicator: true
       
  1888                           #valueChangeSelector: #itemSelected:
       
  1889                           #doubleClickSelector: #itemDoubleClicked:
       
  1890                           #hierarchicalList: #projectTreeHolder
       
  1891                           #selectConditionSelector: #selectionChangeAllowed:
       
  1892                           #highlightMode: #label
       
  1893                         )
       
  1894                        #(#SubCanvasSpec
       
  1895                           #name: 'SubCanvas1'
       
  1896                           #hasHorizontalScrollBar: false
       
  1897                           #hasVerticalScrollBar: false
       
  1898                           #specHolder: #currentCanvasHolder
       
  1899                         )
       
  1900                        )
       
  1901                      
       
  1902                     )
       
  1903                     #handles: #(#Any 0.389718 1.0)
  1892                   )
  1904                   )
  1893                  #(#SubCanvasSpec
  1905                  #(#ArbitraryComponentSpec
  1894                     #name: 'SubCanvas1'
  1906                     #name: 'ArbitraryComponent1'
  1895                     #hasHorizontalScrollBar: false
  1907                     #hasBorder: false
  1896                     #hasVerticalScrollBar: false
       
  1897                     #specHolder: #currentCanvasHolder
       
  1898                   )
  1908                   )
  1899                  )
  1909                  )
  1900                
  1910                
  1901               )
  1911               )
       
  1912               #handles: #(#Any 0.987879 1.0)
  1902             )
  1913             )
  1903            #(#UISubSpecification
  1914            #(#UISubSpecification
  1904               #name: 'infoBarSubSpec'
  1915               #name: 'infoBarSubSpec'
  1905               #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
  1916               #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
       
  1917               #level: 1
  1906               #majorKey: #ToolApplicationModel
  1918               #majorKey: #ToolApplicationModel
  1907               #minorKey: #windowSpecForInfoBar
  1919               #minorKey: #windowSpecForInfoBar
  1908             )
  1920             )
  1909            )
  1921            )
  1910          
  1922          
  2120                   #label: 'CheckIn All'
  2132                   #label: 'CheckIn All'
  2121                   #translateLabel: true
  2133                   #translateLabel: true
  2122                   #value: #checkInProject
  2134                   #value: #checkInProject
  2123                   #enabled: #hasProjectSelectedAndProjectFilenameHolderAndProjectCodeIsLoaded
  2135                   #enabled: #hasProjectSelectedAndProjectFilenameHolderAndProjectCodeIsLoaded
  2124                 )
  2136                 )
       
  2137                #(#MenuItem
       
  2138                   #label: '-'
       
  2139                 )
       
  2140                #(#MenuItem
       
  2141                   #label: 'CheckIn Classes'
       
  2142                   #translateLabel: true
       
  2143                   #value: #checkInAllClasses
       
  2144                   #enabled: #hasProjectSelectedAndProjectFilenameHolderAndProjectCodeIsLoaded
       
  2145                 )
       
  2146                #(#MenuItem
       
  2147                   #label: 'CheckIn Extensions'
       
  2148                   #translateLabel: true
       
  2149                   #value: #checkInMethods
       
  2150                   #enabled: #hasProjectSelectedAndProjectFilenameHolderAndProjectCodeIsLoaded
       
  2151                 )
       
  2152                #(#MenuItem
       
  2153                   #label: 'CheckIn Project File'
       
  2154                   #translateLabel: true
       
  2155                   #value: #checkInProjectFile
       
  2156                   #enabled: #hasProjectSelectedAndProjectFilenameHolderAndProjectCodeIsLoaded
       
  2157                 )
       
  2158                #(#MenuItem
       
  2159                   #label: 'CheckIn Makefiles'
       
  2160                   #translateLabel: true
       
  2161                   #value: #checkInMakefiles
       
  2162                   #enabled: #hasProjectSelectedAndProjectFilenameHolderAndProjectCodeIsLoaded
       
  2163                 )
  2125                )
  2164                )
  2126               nil
  2165               nil
  2127               nil
  2166               nil
  2128             )
  2167             )
  2129           )
  2168           )
  2275          #(#MenuItem
  2314          #(#MenuItem
  2276             #label: 'Browse Full'
  2315             #label: 'Browse Full'
  2277             #translateLabel: true
  2316             #translateLabel: true
  2278             #value: #browseMethodFull
  2317             #value: #browseMethodFull
  2279           )
  2318           )
       
  2319          #(#MenuItem
       
  2320             #label: '-'
       
  2321           )
       
  2322          #(#MenuItem
       
  2323             #label: 'Remove...'
       
  2324             #translateLabel: true
       
  2325             #value: #removeMethod
       
  2326           )
       
  2327          #(#MenuItem
       
  2328             #label: 'Remove from Project...'
       
  2329             #translateLabel: true
       
  2330             #value: #removeMethodFromProject
       
  2331           )
       
  2332          #(#MenuItem
       
  2333             #label: 'Move to Project...'
       
  2334             #translateLabel: true
       
  2335             #value: #moveMethodToProject
       
  2336           )
  2280          )
  2337          )
  2281         nil
  2338         nil
  2282         nil
  2339         nil
  2283       )
  2340       )
  2284 !
  2341 !
  4053 
  4110 
  4054     "Created: / 23.3.1999 / 14:16:12 / cg"
  4111     "Created: / 23.3.1999 / 14:16:12 / cg"
  4055     "Modified: / 23.3.1999 / 14:18:38 / cg"
  4112     "Modified: / 23.3.1999 / 14:18:38 / cg"
  4056 !
  4113 !
  4057 
  4114 
       
  4115 selectedMethod
       
  4116     |node methodInfo classOrClassName cls mthd text|
       
  4117 
       
  4118     self hasMethodNodeSelected ifFalse:[^ nil].
       
  4119 
       
  4120     node := self selectedTreeNode.
       
  4121     methodInfo := node contents value.
       
  4122     mthd := methodInfo method.
       
  4123     mthd isNil ifTrue:[
       
  4124         self valueOfInfoLabel value:'The method is not (yet) loaded.'.
       
  4125     ].
       
  4126     ^ mthd
       
  4127 !
       
  4128 
  4058 updateProjectTree
  4129 updateProjectTree
  4059     |tree moduleRoots root showWhat|
  4130     |tree moduleRoots root showWhat|
  4060 
  4131 
  4061     self withCursor:Cursor execute do:[
  4132     self withCursor:Cursor execute do:[
  4062         showWhat := self showWhat value.
  4133         showWhat := self showWhat value.
  4260     ^ pInfo methodSelector
  4331     ^ pInfo methodSelector
  4261 ! !
  4332 ! !
  4262 
  4333 
  4263 !ProjectBrowser methodsFor:'user actions'!
  4334 !ProjectBrowser methodsFor:'user actions'!
  4264 
  4335 
  4265 addClass
       
  4266     "ask fo, and add a single class"
       
  4267 
       
  4268     |p className cls|
       
  4269 
       
  4270     p := self currentProject.
       
  4271 
       
  4272     className := Dialog request:'Class to add:'.
       
  4273     className size == 0 ifTrue:[^ self].
       
  4274     cls := Smalltalk classNamed:className.
       
  4275     cls isNil ifTrue:[
       
  4276         "/ a new one
       
  4277         (self confirm:'This is a new class. Add ?') ifFalse:[
       
  4278             ^ self      
       
  4279         ].
       
  4280         p
       
  4281             addClass:className
       
  4282             classFileName:((Smalltalk fileNameForClass:className) , '.st').
       
  4283     ] ifFalse:[
       
  4284         cls package ~= p package ifTrue:[
       
  4285             "/ a new one
       
  4286             (self confirm:'Change the classes package from ' , cls package , ' to ' , p package , ' ?') ifFalse:[
       
  4287                 ^ self      
       
  4288             ].
       
  4289             cls package:p package.
       
  4290         ].
       
  4291         p
       
  4292             addClass:cls name
       
  4293             classFileName:(cls classFilename 
       
  4294                             ? ((Smalltalk fileNameForClass:cls) , '.st')).
       
  4295     ].
       
  4296 
       
  4297     self updateClassListForProject:p
       
  4298 
       
  4299 !
       
  4300 
       
  4301 addClasses
  4336 addClasses
  4302     "ask fo, and add a single class"
  4337     "ask for, and add a single class"
  4303 
  4338 
  4304     |p className cls oldPackage|
  4339     |p className cls oldPackage|
  4305 
  4340 
  4306     p := self currentProject.
  4341     p := self currentProject.
  4307 
  4342 
  4338 
  4373 
  4339     self updateClassListForProject:p
  4374     self updateClassListForProject:p
  4340 
  4375 
  4341 !
  4376 !
  4342 
  4377 
  4343 addClassesFromFilesInDirectory
       
  4344     self addClassesFromFilesInDirectoryWithFilter:nil
       
  4345 !
       
  4346 
       
  4347 addClassesFromFilesInDirectoryIfPresentInImage
       
  4348     self addClassesFromFilesInDirectoryWithFilter:[:classOrName | classOrName isBehavior]
       
  4349 
       
  4350 !
       
  4351 
       
  4352 addClassesFromFilesInDirectoryWithFilter:aFilterBlockOrNil
       
  4353     |project existingClasses prjDirectory anyChange numSTFilesFound|
       
  4354 
       
  4355     project := self currentProject.
       
  4356 
       
  4357     existingClasses := project classInfo.
       
  4358     anyChange := false.
       
  4359     numSTFilesFound := 0.
       
  4360 
       
  4361     prjDirectory := project directory asFilename.
       
  4362     (prjDirectory exists and:[prjDirectory isDirectory]) ifFalse:[
       
  4363         self warn:'Invalid project directory: ' , prjDirectory pathName.
       
  4364         ^ self
       
  4365     ].
       
  4366 
       
  4367     prjDirectory directoryContents do:[:fn |
       
  4368         |f oldInfo cls|
       
  4369 
       
  4370         f := prjDirectory construct:fn.
       
  4371         (f hasSuffix:'st') ifTrue:[
       
  4372             numSTFilesFound := numSTFilesFound + 1.
       
  4373 
       
  4374             oldInfo := existingClasses 
       
  4375                             detect:[:clsInfo |
       
  4376                                         clsInfo classFileName = fn
       
  4377                                    ] 
       
  4378                             ifNone:nil.
       
  4379             oldInfo isNil ifTrue:[
       
  4380                 "/ extract className from fileName ...
       
  4381                 cls := Smalltalk filenameAbbreviations keyAtValue:(f withoutSuffix baseName ).
       
  4382                 cls isNil ifTrue:[
       
  4383                     cls := f withoutSuffix baseName asSymbol.
       
  4384                     project defaultNameSpace notNil ifTrue:[
       
  4385                         cls := (project defaultNameSpace name , '::' , cls) asSymbol
       
  4386                     ]
       
  4387                 ].
       
  4388                 (aFilterBlockOrNil isNil 
       
  4389                 or:[aFilterBlockOrNil value:cls]) ifTrue:[
       
  4390                     project addClass:cls classFileName:fn.
       
  4391                     anyChange := true.
       
  4392 Transcript showCR:'added ' , fn , ' as class: ' , cls printString.
       
  4393                 ] ifFalse:[
       
  4394 Transcript showCR:'skipped ' , fn , ' as class: ' , cls printString.
       
  4395                 ]
       
  4396 
       
  4397             ]
       
  4398         ]
       
  4399     ].
       
  4400 
       
  4401     anyChange ifTrue:[
       
  4402         self updateClassListForProject:project
       
  4403     ] ifFalse:[
       
  4404         numSTFilesFound == 0 ifTrue:[
       
  4405             self information:'No st-sourcefiles found in ' , prjDirectory pathName.
       
  4406         ]
       
  4407     ]
       
  4408 !
       
  4409 
       
  4410 addClassesFromImage
       
  4411     "add classes with this packageId found in the image"
       
  4412 
       
  4413     |project|
       
  4414 
       
  4415     project := self currentProject.
       
  4416     Smalltalk allClassesDo:[:aClass |
       
  4417         aClass isMeta ifFalse:[
       
  4418             (aClass isNamespace not or:[aClass == Smalltalk]) ifTrue:[
       
  4419                 aClass package = project package ifTrue:[
       
  4420                     (project classInfoFor:aClass) isNil ifTrue:[
       
  4421                         project 
       
  4422                             addClass:aClass name
       
  4423                             classFileName:(aClass classFilename 
       
  4424                                             ? ((Smalltalk fileNameForClass:aClass) , '.st')).
       
  4425                     ]
       
  4426                  ]
       
  4427              ]
       
  4428         ]
       
  4429     ].                 
       
  4430 
       
  4431     self updateClassListForProject:project
       
  4432 
       
  4433 !
       
  4434 
       
  4435 browseClasses
       
  4436     |ns p classes nBad uniqueClasses|
       
  4437 
       
  4438     p := self currentProject.
       
  4439     classes := p classes
       
  4440                 collect:[:clsOrName |
       
  4441                             |cls realName|
       
  4442 
       
  4443                             clsOrName isSymbol ifTrue:[
       
  4444                                 realName := clsOrName.
       
  4445                                 (realName includes:$:) ifTrue:[
       
  4446                                     (realName startsWith:'Smalltalk::') ifTrue:[
       
  4447                                         realName := (realName copyFrom:'Smalltalk::' size + 1) asSymbol
       
  4448                                     ]
       
  4449                                 ].
       
  4450                                 cls := Smalltalk at:realName
       
  4451                             ] ifFalse:[
       
  4452                                 cls := clsOrName
       
  4453                             ].
       
  4454                             cls
       
  4455                         ].
       
  4456 
       
  4457     "/ remove duplicates - but want to preserve order
       
  4458     "/ thats why we do not use asIdentitySet asOrderedCollection
       
  4459     uniqueClasses := OrderedCollection new.
       
  4460     classes do:[:cls | (uniqueClasses includesIdentical:cls) ifFalse:[uniqueClasses add:cls]].
       
  4461 
       
  4462     nBad := classes inject:0 into:[:sum :el | el isNil ifTrue:[sum+1] ifFalse:[sum]].
       
  4463     nBad ~~ 0 ifTrue:[
       
  4464         classes := classes select:[:cls | cls notNil].
       
  4465         self warn:('Oops - %1 classes could not be found.\\You should probably load them first.' bindWith:nBad) withCRs.
       
  4466     ].
       
  4467 
       
  4468 
       
  4469     SystemBrowser
       
  4470         browseClasses:classes title:('Classes in ' , p name) sort:true.
       
  4471 
       
  4472 
       
  4473 
       
  4474 !
       
  4475 
       
  4476 buildAll
       
  4477     |p|
       
  4478 
       
  4479     p := self currentProject.
       
  4480     p isNil ifTrue:[
       
  4481         self information:'No project selected'.
       
  4482         ^ self
       
  4483     ].
       
  4484 
       
  4485     self withCursor:Cursor wait do:[
       
  4486         "/ prepare the building ...
       
  4487 
       
  4488         (p propertyAt:#deliverLoadAllFile) == true ifTrue:[
       
  4489             p createLoadAllFile
       
  4490         ].
       
  4491 
       
  4492         (p propertyAt:#deliverSources) == true ifTrue:[
       
  4493             p createSourceFiles
       
  4494         ].
       
  4495 
       
  4496         (p propertyAt:#deliverMakefiles) == true ifTrue:[
       
  4497             self buildMakefiles
       
  4498         ].
       
  4499 
       
  4500         (p propertyAt:#deliverCompiledBinary) == true ifTrue:[
       
  4501             self buildCompiledClassLibrary
       
  4502         ].
       
  4503 
       
  4504         (p propertyAt:#deliverByteCode) == true ifTrue:[
       
  4505             self buildByteCodeClassLibrary
       
  4506         ].
       
  4507 
       
  4508         "/ now, deploy ...
       
  4509 
       
  4510         (p propertyAt:#deliverZipArchive) == true ifTrue:[
       
  4511             p buildZipArchive
       
  4512         ].
       
  4513 
       
  4514         (p propertyAt:#deliverTarArchive) == true ifTrue:[
       
  4515             p buildTarArchive
       
  4516         ].
       
  4517 
       
  4518         (p propertyAt:#deliverGZipArchive) == true ifTrue:[
       
  4519             p buildGZipArchive
       
  4520         ].
       
  4521     ].
       
  4522 
       
  4523 
       
  4524 !
       
  4525 
       
  4526 buildCompiledClassLibrary
       
  4527     "compile a binary class library in the projects directory"
       
  4528     |p diagnosticFile diagnostic error textBox|
       
  4529 
       
  4530     p := self currentProject.
       
  4531     p isNil ifTrue:[
       
  4532         self information:'No project selected'.
       
  4533         ^ self
       
  4534     ].
       
  4535 
       
  4536     "/ check for directory ...
       
  4537     (self checkForProjectDirectoryFor:p) ifFalse:[
       
  4538         ^ self
       
  4539     ].
       
  4540 
       
  4541     "/ check for Make.proto ...
       
  4542     (self checkForMakeProtoFor:p) ifFalse:[
       
  4543         ^ self
       
  4544     ].
       
  4545 
       
  4546     "/ check for Makefile ...
       
  4547     (self checkForMakefileFor:p) ifFalse:[
       
  4548         ^ self
       
  4549     ].
       
  4550 
       
  4551     "/ now, execute the makefile found there ...
       
  4552     diagnosticFile := Filename newTemporary.
       
  4553     diagnostic := diagnosticFile writeStream.
       
  4554     error := false.
       
  4555 
       
  4556     [
       
  4557         self withCursor:Cursor wait do:[
       
  4558             OperatingSystem
       
  4559                 executeCommand:'make' 
       
  4560                 inputFrom:nil 
       
  4561                 outputTo:diagnostic 
       
  4562                 errorTo:diagnostic 
       
  4563                 inDirectory:(p directory asFilename pathName) 
       
  4564                 onError:[error := true].
       
  4565         ].
       
  4566 
       
  4567         diagnostic close.
       
  4568 
       
  4569         textBox := TextBox new.
       
  4570         textBox initialText:(diagnosticFile readStream contents).
       
  4571         textBox title:'Make Diagnostic output:'.
       
  4572         textBox readOnly:true.
       
  4573         textBox noCancel.
       
  4574         textBox label:'Make Diagnostic output'.
       
  4575         textBox extent:(600@250); sizeFixed:true.
       
  4576         textBox showAtPointer.
       
  4577 
       
  4578     ] valueNowOrOnUnwindDo:[
       
  4579         diagnosticFile delete
       
  4580     ].
       
  4581 
       
  4582 
       
  4583 !
       
  4584 
       
  4585 buildLoadAllFile
       
  4586     |p |
       
  4587 
       
  4588     p := self currentProject.
       
  4589     p isNil ifTrue:[
       
  4590         self information:'No project selected'.
       
  4591         ^ self
       
  4592     ].
       
  4593 
       
  4594     self withCursor:Cursor wait do:[
       
  4595         p createLoadAllFile.
       
  4596     ]
       
  4597 !
       
  4598 
       
  4599 buildMakefiles
       
  4600     |p |
       
  4601 
       
  4602     p := self currentProject.
       
  4603     p isNil ifTrue:[
       
  4604         self information:'No project selected'.
       
  4605         ^ self
       
  4606     ].
       
  4607 
       
  4608     self withCursor:Cursor wait do:[
       
  4609         p createProtoMakefile.
       
  4610         p createMakefile
       
  4611     ].
       
  4612 !
       
  4613 
       
  4614 checkInProject
       
  4615     |p classes methods anyMethodMissing|
       
  4616 
       
  4617     p := self currentProject.
       
  4618     p isNil ifTrue:[
       
  4619         self information:'No project selected'.
       
  4620         ^ self
       
  4621     ].
       
  4622 
       
  4623     "/ check in classes ...
       
  4624 
       
  4625     classes := p classes.
       
  4626     classes do:[:aClass |
       
  4627         |clsName|
       
  4628 
       
  4629         aClass isBehavior ifFalse:[
       
  4630             aClass isSymbol ifTrue:[
       
  4631                 clsName := aClass
       
  4632             ] ifFalse:[
       
  4633                 clsName := aClass className
       
  4634             ].
       
  4635             Transcript showCR:('ProjectBrowser: cannot checkIn unloaded class: ' , clsName).
       
  4636         ] ifTrue:[
       
  4637             aClass isLoaded ifFalse:[
       
  4638                 Transcript showCR:('ProjectBrowser: cannot checkIn unloaded class: ' , aClass name).
       
  4639             ] ifTrue:[
       
  4640                 aClass owningClass isNil ifTrue:[ "/ skip private classes
       
  4641                     Transcript showCR:('ProjectBrowser: checking in class: ' , aClass name).
       
  4642                     self checkInClass:aClass.
       
  4643                 ]
       
  4644             ]
       
  4645         ]
       
  4646     ].
       
  4647 
       
  4648     "/ check methods ...
       
  4649 
       
  4650     anyMethodMissing := false.
       
  4651     methods := p methods.
       
  4652     methods size > 0 ifTrue:[
       
  4653         methods do:[:aMethod |
       
  4654             aMethod isMethod ifFalse:[
       
  4655                 Transcript showCR:('ProjectBrowser: cannot checkIn unloaded method: ' , aMethod className , ' ' , aMethod methodName).
       
  4656                 anyMethodMissing := true.
       
  4657             ]
       
  4658         ].
       
  4659         anyMethodMissing ifTrue:[
       
  4660             Transcript showCR:'ProjectBrowser: cannot save method patches & extensions due to missing method(s)'.
       
  4661         ] ifFalse:[
       
  4662             Transcript showCR:('ProjectBrowser: checking in patches & extensions').
       
  4663             self checkInMethods:methods
       
  4664         ].
       
  4665     ].
       
  4666 
       
  4667     "/ check in the project file itself
       
  4668     self checkInProjectFile.
       
  4669 
       
  4670 !
       
  4671 
       
  4672 inspectCurrentProject
       
  4673     "inspect the current project"
       
  4674 
       
  4675     self hasProjectSelected ifTrue:[
       
  4676         self currentProject inspect.
       
  4677     ]
       
  4678 !
       
  4679 
       
  4680 itemDoubleClicked:index
  4378 itemDoubleClicked:index
  4681     |node classOrClassName cls|
  4379     |node classOrClassName cls|
  4682 
  4380 
  4683     self hasClassNodeSelected ifTrue:[
  4381     self hasClassNodeSelected ifTrue:[
  4684         node := self selectedTreeNode.
  4382         node := self selectedTreeNode.
  4726 
  4424 
  4727     self hasProjectSelectedHolder value:self hasProjectSelected.
  4425     self hasProjectSelectedHolder value:self hasProjectSelected.
  4728     modifiedChannel value:false.
  4426     modifiedChannel value:false.
  4729 
  4427 
  4730     "Modified: / 26.4.1999 / 22:49:20 / cg"
  4428     "Modified: / 26.4.1999 / 22:49:20 / cg"
  4731 !
       
  4732 
       
  4733 loadClassesFromDirectory
       
  4734     "load all classes as contained in the project into the system"
       
  4735 
       
  4736     self withReadCursorDo:[
       
  4737         self currentProject loadClassesFromProjectDirectory.
       
  4738     ].
       
  4739 
       
  4740 !
  4429 !
  4741 
  4430 
  4742 loadFromProjectFile:aFilenameString
  4431 loadFromProjectFile:aFilenameString
  4743     |oldNode newProject|
  4432     |oldNode newProject|
  4744 
  4433 
  4860         project isLoaded:true.
  4549         project isLoaded:true.
  4861         self readAspectsFromProject
  4550         self readAspectsFromProject
  4862     ]
  4551     ]
  4863 !
  4552 !
  4864 
  4553 
  4865 makeCurrentProject
       
  4866     "make the selected Project the current project"
       
  4867 
       
  4868     |project|
       
  4869 
       
  4870     self hasProjectSelected ifTrue:[
       
  4871         project := self currentProject.
       
  4872 
       
  4873         Project current:project.
       
  4874         self showWhat value == #current ifTrue:[
       
  4875             self updateProjectTree
       
  4876         ]
       
  4877     ]
       
  4878 !
       
  4879 
       
  4880 methodPatchDoubleClick:arg
  4554 methodPatchDoubleClick:arg
  4881 self halt.
  4555 self halt.
  4882 !
       
  4883 
       
  4884 newProject
       
  4885     self newProject:Project new.
       
  4886 
       
  4887 !
       
  4888 
       
  4889 newProject:newProject
       
  4890     |newNode|
       
  4891 
       
  4892     newNode := self nodeFor:newProject.
       
  4893     self addProjectNodeToTree:newNode.
       
  4894     self projectTreeHolder root:projectTree.
       
  4895 "/    self projectTreeHolder selectNode:newNode.
       
  4896 "/    self projectTreeHolder expand:newNode.
       
  4897 
       
  4898     self readAspectsFromProject.
       
  4899     newProject wasLoadedFromFile ifFalse:[
       
  4900          self updateListOfRequiredPrerequisiteClasses.
       
  4901     ]
       
  4902 !
       
  4903 
       
  4904 newSubProject
       
  4905     |projectNode subProjectsNode newNode parentProject newProject|
       
  4906 
       
  4907     projectNode := self currentProjectNode.
       
  4908 
       
  4909     projectNode notNil ifTrue:[
       
  4910         parentProject := projectNode contents.
       
  4911         subProjectsNode := projectNode children detect:[:child | child contents == #subprojects].
       
  4912 self halt.
       
  4913         parentProject notNil ifTrue:[
       
  4914             newProject := Project new.
       
  4915             newNode := self nodeFor:newProject.
       
  4916 
       
  4917             parentProject addSubProject:newProject.
       
  4918             subProjectsNode add:newNode.
       
  4919             self projectTreeHolder root:projectTree.
       
  4920             self projectTreeHolder selectNode:newNode.
       
  4921         ]    
       
  4922     ]    
       
  4923 
       
  4924 !
       
  4925 
       
  4926 openDocumentation
       
  4927     self openHTMLDocument: 'tools/pbrowser/TOP.html'
       
  4928 
       
  4929 !
       
  4930 
       
  4931 openProject
       
  4932     |fn|
       
  4933 
       
  4934     fn := Dialog 
       
  4935         requestFileName:'filename:' 
       
  4936         default:nil
       
  4937         ifFail:nil
       
  4938         pattern:'*.prj'
       
  4939         fromDirectory:(FileSelectionBox lastFileSelectionDirectory).
       
  4940 
       
  4941     fn notNil ifTrue:[
       
  4942         self loadFromProjectFile:fn.
       
  4943     ]
       
  4944 !
  4556 !
  4945 
  4557 
  4946 projectFilterChanged
  4558 projectFilterChanged
  4947     |theNode|
  4559     |theNode|
  4948 
  4560 
  4956             self projectTreeHolder expand:theNode.
  4568             self projectTreeHolder expand:theNode.
  4957             theNode := theNode parent.
  4569             theNode := theNode parent.
  4958         ].
  4570         ].
  4959 
  4571 
  4960     ].
  4572     ].
  4961 !
       
  4962 
       
  4963 removeProject
       
  4964     |projectToRemove selectedNode subNode newNode parentNode parentProject newProject|
       
  4965 
       
  4966     self hasProjectNodeSelected ifTrue:[
       
  4967         selectedNode := self selectedTreeNode.
       
  4968         projectToRemove := selectedNode contents.
       
  4969 
       
  4970         (self confirm:'Really remove the project ?') ifTrue:[
       
  4971             self withExecuteCursorDo:[
       
  4972                 self projectTreeHolder removeSelection.
       
  4973                 projectToRemove removeFromSystem.
       
  4974             ]
       
  4975         ]
       
  4976     ]
       
  4977 !
       
  4978 
       
  4979 renameProject
       
  4980     |nm projectNode selectedProject|
       
  4981 
       
  4982     projectNode := self currentProjectNode.
       
  4983     projectNode notNil ifTrue:[
       
  4984         selectedProject := projectNode contents.
       
  4985 
       
  4986         nm := Dialog 
       
  4987                 request:'Rename to:'
       
  4988                 initialAnswer:selectedProject name.
       
  4989 
       
  4990         nm size > 0 ifTrue:[
       
  4991             selectedProject name:nm.
       
  4992 "/            selectedNode name:nm.
       
  4993 "/            selectedNode changed.
       
  4994         ]
       
  4995     ]
       
  4996 !
       
  4997 
       
  4998 saveProjectFile
       
  4999     |d p|
       
  5000 
       
  5001     self modifiedChannel value ifTrue:[
       
  5002         (self confirm:'Changes not confirmed; save anyway ?') ifFalse:[^ self]
       
  5003     ].
       
  5004 
       
  5005     p := self currentProject.
       
  5006     p isNil ifTrue:[
       
  5007         self information:'Select a project first.'.
       
  5008         ^self
       
  5009     ].
       
  5010     p directory isNil ifTrue:[
       
  5011         d := (Dialog request:'Project Directory:').
       
  5012         d size == 0 ifTrue:[
       
  5013             ^ self
       
  5014         ].
       
  5015         p directory:d
       
  5016     ].
       
  5017 
       
  5018     self withCursor:Cursor write do:[
       
  5019         p saveAsProjectFile.
       
  5020     ]
       
  5021 
       
  5022     "Modified: / 26.4.1999 / 22:43:57 / cg"
       
  5023 !
  4573 !
  5024 
  4574 
  5025 selectionChangeAllowed:newNode
  4575 selectionChangeAllowed:newNode
  5026     |answer|
  4576     |answer|
  5027 
  4577 
  5258     l := self patchesList.
  4808     l := self patchesList.
  5259     l removeAll.
  4809     l removeAll.
  5260     l addAll:methodInfo.
  4810     l addAll:methodInfo.
  5261 
  4811 
  5262 
  4812 
  5263 !
       
  5264 
       
  5265 validateAgainstClassesInImage
       
  5266     "validate classes in project against classes found in the image"
       
  5267 
       
  5268     |project classesInProjectOnly classesInImageOnly bindings|
       
  5269 
       
  5270     project := self currentProject.
       
  5271     classesInImageOnly := IdentitySet new.
       
  5272     classesInProjectOnly := IdentitySet new.
       
  5273 
       
  5274     Smalltalk allClassesDo:[:aClass |
       
  5275         aClass isMeta ifFalse:[
       
  5276             (aClass isNamespace not or:[aClass == Smalltalk]) ifTrue:[
       
  5277                 aClass package = project package ifTrue:[
       
  5278                     (project classInfoFor:aClass) isNil ifTrue:[
       
  5279                         classesInImageOnly add:aClass name.
       
  5280                     ]
       
  5281                  ]
       
  5282              ]
       
  5283         ]
       
  5284     ].
       
  5285     project classInfo do:[:clsInfo |
       
  5286         |clsName cls|
       
  5287 
       
  5288         clsName := clsInfo className.
       
  5289         cls := Smalltalk at:clsName asSymbol.
       
  5290         (cls isBehavior not) ifTrue:[
       
  5291             classesInProjectOnly add:clsName
       
  5292         ].
       
  5293     ].
       
  5294 
       
  5295     (classesInImageOnly isEmpty and:[classesInProjectOnly isEmpty]) ifTrue:[
       
  5296         self information:'Set of classes in project and image are equal.'.
       
  5297         ^ self.
       
  5298     ].
       
  5299 
       
  5300     classesInImageOnly := classesInImageOnly asOrderedCollection sort.
       
  5301     classesInProjectOnly := classesInProjectOnly asOrderedCollection sort.
       
  5302 
       
  5303     bindings := IdentityDictionary new.
       
  5304     bindings at:#classesInImageOnly put:classesInImageOnly.
       
  5305     bindings at:#classesInProjectOnly put:classesInProjectOnly.
       
  5306 
       
  5307     SimpleDialog
       
  5308         openDialogInterfaceSpec:(self class classValidationDialogSpec)
       
  5309         withBindings:bindings
       
  5310 
       
  5311     "Modified: / 26.9.1999 / 16:03:50 / cg"
       
  5312 ! !
  4813 ! !
  5313 
  4814 
  5314 !ProjectBrowser methodsFor:'user actions - canvas'!
  4815 !ProjectBrowser methodsFor:'user actions - canvas'!
  5315 
  4816 
  5316 accept
  4817 accept
  5504         ].
  5005         ].
  5505     ].
  5006     ].
  5506     self valueOfInfoLabel value:nil
  5007     self valueOfInfoLabel value:nil
  5507 ! !
  5008 ! !
  5508 
  5009 
       
  5010 !ProjectBrowser methodsFor:'user actions - menu'!
       
  5011 
       
  5012 addClass
       
  5013     "ask for, and add a single class"
       
  5014 
       
  5015     |p className cls|
       
  5016 
       
  5017     p := self currentProject.
       
  5018 
       
  5019     className := Dialog request:'Class to add:'.
       
  5020     className size == 0 ifTrue:[^ self].
       
  5021     cls := Smalltalk classNamed:className.
       
  5022     cls isNil ifTrue:[
       
  5023         "/ a new one
       
  5024         (self confirm:'This is a new class. Add ?') ifFalse:[
       
  5025             ^ self      
       
  5026         ].
       
  5027         p
       
  5028             addClass:className
       
  5029             classFileName:((Smalltalk fileNameForClass:className) , '.st').
       
  5030     ] ifFalse:[
       
  5031         cls package ~= p package ifTrue:[
       
  5032             "/ a new one
       
  5033             (self confirm:'Change the classes package from ' , cls package , ' to ' , p package , ' ?') ifFalse:[
       
  5034                 ^ self      
       
  5035             ].
       
  5036             cls package:p package.
       
  5037         ].
       
  5038         p
       
  5039             addClass:cls name
       
  5040             classFileName:(cls classFilename 
       
  5041                             ? ((Smalltalk fileNameForClass:cls) , '.st')).
       
  5042     ].
       
  5043 
       
  5044     self updateClassListForProject:p
       
  5045 
       
  5046 !
       
  5047 
       
  5048 addClassesFromFilesInDirectory
       
  5049     "add all classes found from files in the project directory"
       
  5050 
       
  5051     self addClassesFromFilesInDirectoryWithFilter:nil
       
  5052 !
       
  5053 
       
  5054 addClassesFromFilesInDirectoryIfPresentInImage
       
  5055     "add all classes found from files in the project directory,
       
  5056      but only if class is currently present in the image."
       
  5057 
       
  5058     self addClassesFromFilesInDirectoryWithFilter:[:classOrName | classOrName isBehavior]
       
  5059 
       
  5060 !
       
  5061 
       
  5062 addClassesFromFilesInDirectoryWithFilter:aFilterBlockOrNil
       
  5063     "helper to add all classes found from files in the project directory"
       
  5064 
       
  5065     |project existingClasses prjDirectory anyChange numSTFilesFound|
       
  5066 
       
  5067     project := self currentProject.
       
  5068 
       
  5069     existingClasses := project classInfo.
       
  5070     anyChange := false.
       
  5071     numSTFilesFound := 0.
       
  5072 
       
  5073     prjDirectory := project directory asFilename.
       
  5074     (prjDirectory exists and:[prjDirectory isDirectory]) ifFalse:[
       
  5075         self warn:'Invalid project directory: ' , prjDirectory pathName.
       
  5076         ^ self
       
  5077     ].
       
  5078 
       
  5079     prjDirectory directoryContents do:[:fn |
       
  5080         |f oldInfo cls|
       
  5081 
       
  5082         f := prjDirectory construct:fn.
       
  5083         (f hasSuffix:'st') ifTrue:[
       
  5084             numSTFilesFound := numSTFilesFound + 1.
       
  5085 
       
  5086             oldInfo := existingClasses 
       
  5087                             detect:[:clsInfo |
       
  5088                                         clsInfo classFileName = fn
       
  5089                                    ] 
       
  5090                             ifNone:nil.
       
  5091             oldInfo isNil ifTrue:[
       
  5092                 "/ extract className from fileName ...
       
  5093                 cls := Smalltalk filenameAbbreviations keyAtValue:(f withoutSuffix baseName ).
       
  5094                 cls isNil ifTrue:[
       
  5095                     cls := f withoutSuffix baseName asSymbol.
       
  5096                     project defaultNameSpace notNil ifTrue:[
       
  5097                         cls := (project defaultNameSpace name , '::' , cls) asSymbol
       
  5098                     ]
       
  5099                 ].
       
  5100                 (aFilterBlockOrNil isNil 
       
  5101                 or:[aFilterBlockOrNil value:cls]) ifTrue:[
       
  5102                     project addClass:cls classFileName:fn.
       
  5103                     anyChange := true.
       
  5104 Transcript showCR:'added ' , fn , ' as class: ' , cls printString.
       
  5105                 ] ifFalse:[
       
  5106 Transcript showCR:'skipped ' , fn , ' as class: ' , cls printString.
       
  5107                 ]
       
  5108 
       
  5109             ]
       
  5110         ]
       
  5111     ].
       
  5112 
       
  5113     anyChange ifTrue:[
       
  5114         self updateClassListForProject:project
       
  5115     ] ifFalse:[
       
  5116         numSTFilesFound == 0 ifTrue:[
       
  5117             self information:'No st-sourcefiles found in ' , prjDirectory pathName.
       
  5118         ]
       
  5119     ]
       
  5120 !
       
  5121 
       
  5122 addClassesFromImage
       
  5123     "add classes with this packageId found in the image"
       
  5124 
       
  5125     |project|
       
  5126 
       
  5127     project := self currentProject.
       
  5128     Smalltalk allClassesDo:[:aClass |
       
  5129         aClass isMeta ifFalse:[
       
  5130             (aClass isNamespace not or:[aClass == Smalltalk]) ifTrue:[
       
  5131                 aClass package = project package ifTrue:[
       
  5132                     (project classInfoFor:aClass) isNil ifTrue:[
       
  5133                         project 
       
  5134                             addClass:aClass name
       
  5135                             classFileName:(aClass classFilename 
       
  5136                                             ? ((Smalltalk fileNameForClass:aClass) , '.st')).
       
  5137                     ]
       
  5138                  ]
       
  5139              ]
       
  5140         ]
       
  5141     ].                 
       
  5142 
       
  5143     self updateClassListForProject:project
       
  5144 
       
  5145 !
       
  5146 
       
  5147 browseClasses
       
  5148     "browse the projects classes"
       
  5149 
       
  5150     |ns p classes nBad uniqueClasses|
       
  5151 
       
  5152     p := self currentProject.
       
  5153     classes := p classes
       
  5154                 collect:[:clsOrName |
       
  5155                             |cls realName|
       
  5156 
       
  5157                             clsOrName isSymbol ifTrue:[
       
  5158                                 realName := clsOrName.
       
  5159                                 (realName includes:$:) ifTrue:[
       
  5160                                     (realName startsWith:'Smalltalk::') ifTrue:[
       
  5161                                         realName := (realName copyFrom:'Smalltalk::' size + 1) asSymbol
       
  5162                                     ]
       
  5163                                 ].
       
  5164                                 cls := Smalltalk at:realName
       
  5165                             ] ifFalse:[
       
  5166                                 cls := clsOrName
       
  5167                             ].
       
  5168                             cls
       
  5169                         ].
       
  5170 
       
  5171     "/ remove duplicates - but want to preserve order
       
  5172     "/ thats why we do not use asIdentitySet asOrderedCollection
       
  5173     uniqueClasses := OrderedCollection new.
       
  5174     classes do:[:cls | (uniqueClasses includesIdentical:cls) ifFalse:[uniqueClasses add:cls]].
       
  5175 
       
  5176     nBad := classes inject:0 into:[:sum :el | el isNil ifTrue:[sum+1] ifFalse:[sum]].
       
  5177     nBad ~~ 0 ifTrue:[
       
  5178         classes := classes select:[:cls | cls notNil].
       
  5179         self warn:('Oops - %1 classes could not be found.\\You should probably load them first.' bindWith:nBad) withCRs.
       
  5180     ].
       
  5181 
       
  5182 
       
  5183     SystemBrowser
       
  5184         browseClasses:classes title:('Classes in ' , p name) sort:true.
       
  5185 
       
  5186 
       
  5187 
       
  5188 !
       
  5189 
       
  5190 buildAll
       
  5191     "build all as specified in the deployment section"
       
  5192 
       
  5193     |p|
       
  5194 
       
  5195     p := self currentProject.
       
  5196     p isNil ifTrue:[
       
  5197         self information:'No project selected'.
       
  5198         ^ self
       
  5199     ].
       
  5200 
       
  5201     self withCursor:Cursor wait do:[
       
  5202         "/ prepare the building ...
       
  5203 
       
  5204         (p propertyAt:#deliverLoadAllFile) == true ifTrue:[
       
  5205             p createLoadAllFile
       
  5206         ].
       
  5207 
       
  5208         (p propertyAt:#deliverSources) == true ifTrue:[
       
  5209             p createSourceFiles
       
  5210         ].
       
  5211 
       
  5212         (p propertyAt:#deliverMakefiles) == true ifTrue:[
       
  5213             self buildMakefiles
       
  5214         ].
       
  5215 
       
  5216         (p propertyAt:#deliverCompiledBinary) == true ifTrue:[
       
  5217             self buildCompiledClassLibrary
       
  5218         ].
       
  5219 
       
  5220         (p propertyAt:#deliverByteCode) == true ifTrue:[
       
  5221             self buildByteCodeClassLibrary
       
  5222         ].
       
  5223 
       
  5224         "/ now, deploy ...
       
  5225 
       
  5226         (p propertyAt:#deliverZipArchive) == true ifTrue:[
       
  5227             p buildZipArchive
       
  5228         ].
       
  5229 
       
  5230         (p propertyAt:#deliverTarArchive) == true ifTrue:[
       
  5231             p buildTarArchive
       
  5232         ].
       
  5233 
       
  5234         (p propertyAt:#deliverGZipArchive) == true ifTrue:[
       
  5235             p buildGZipArchive
       
  5236         ].
       
  5237     ].
       
  5238 
       
  5239 
       
  5240 !
       
  5241 
       
  5242 buildCompiledClassLibrary
       
  5243     "compile a binary class library in the projects directory"
       
  5244 
       
  5245     |p diagnosticFile diagnostic error textBox|
       
  5246 
       
  5247     p := self currentProject.
       
  5248     p isNil ifTrue:[
       
  5249         self information:'No project selected'.
       
  5250         ^ self
       
  5251     ].
       
  5252 
       
  5253     "/ check for directory ...
       
  5254     (self checkForProjectDirectoryFor:p) ifFalse:[
       
  5255         ^ self
       
  5256     ].
       
  5257 
       
  5258     "/ check for Make.proto ...
       
  5259     (self checkForMakeProtoFor:p) ifFalse:[
       
  5260         ^ self
       
  5261     ].
       
  5262 
       
  5263     "/ check for Makefile ...
       
  5264     (self checkForMakefileFor:p) ifFalse:[
       
  5265         ^ self
       
  5266     ].
       
  5267 
       
  5268     "/ now, execute the makefile found there ...
       
  5269     diagnosticFile := Filename newTemporary.
       
  5270     diagnostic := diagnosticFile writeStream.
       
  5271     error := false.
       
  5272 
       
  5273     [
       
  5274         self withCursor:Cursor wait do:[
       
  5275             OperatingSystem
       
  5276                 executeCommand:'make' 
       
  5277                 inputFrom:nil 
       
  5278                 outputTo:diagnostic 
       
  5279                 errorTo:diagnostic 
       
  5280                 inDirectory:(p directory asFilename pathName) 
       
  5281                 onError:[error := true].
       
  5282         ].
       
  5283 
       
  5284         diagnostic close.
       
  5285 
       
  5286         textBox := TextBox new.
       
  5287         textBox initialText:(diagnosticFile readStream contents).
       
  5288         textBox title:'Make Diagnostic output:'.
       
  5289         textBox readOnly:true.
       
  5290         textBox noCancel.
       
  5291         textBox label:'Make Diagnostic output'.
       
  5292         textBox extent:(600@250); sizeFixed:true.
       
  5293         textBox showAtPointer.
       
  5294 
       
  5295     ] valueNowOrOnUnwindDo:[
       
  5296         diagnosticFile delete
       
  5297     ].
       
  5298 
       
  5299 
       
  5300 !
       
  5301 
       
  5302 buildLoadAllFile
       
  5303     "generate a loadAll file in the projects directory"
       
  5304 
       
  5305     |p |
       
  5306 
       
  5307     p := self currentProject.
       
  5308     p isNil ifTrue:[
       
  5309         self information:'No project selected'.
       
  5310         ^ self
       
  5311     ].
       
  5312 
       
  5313     self withCursor:Cursor wait do:[
       
  5314         p createLoadAllFile.
       
  5315     ]
       
  5316 !
       
  5317 
       
  5318 buildMakefiles
       
  5319     "generate a Make.proto and Makefile in the projects directory"
       
  5320 
       
  5321     |p |
       
  5322 
       
  5323     p := self currentProject.
       
  5324     p isNil ifTrue:[
       
  5325         self information:'No project selected'.
       
  5326         ^ self
       
  5327     ].
       
  5328 
       
  5329     self withCursor:Cursor wait do:[
       
  5330         p createProtoMakefile.
       
  5331         p createMakefile
       
  5332     ].
       
  5333 !
       
  5334 
       
  5335 checkInAllClasses
       
  5336     "check in all classes"
       
  5337 
       
  5338     |p classes methods anyMethodMissing|
       
  5339 
       
  5340     p := self currentProject.
       
  5341     p isNil ifTrue:[
       
  5342         self information:'No project selected'.
       
  5343         ^ self
       
  5344     ].
       
  5345 
       
  5346     "/ check in classes ...
       
  5347 
       
  5348     classes := p classes.
       
  5349     classes do:[:aClass |
       
  5350         |clsName|
       
  5351 
       
  5352         aClass isBehavior ifFalse:[
       
  5353             aClass isSymbol ifTrue:[
       
  5354                 clsName := aClass
       
  5355             ] ifFalse:[
       
  5356                 clsName := aClass className
       
  5357             ].
       
  5358             Transcript showCR:('ProjectBrowser: cannot checkIn unloaded class: ' , clsName).
       
  5359         ] ifTrue:[
       
  5360             aClass isLoaded ifFalse:[
       
  5361                 Transcript showCR:('ProjectBrowser: cannot checkIn unloaded class: ' , aClass name).
       
  5362             ] ifTrue:[
       
  5363                 aClass owningClass isNil ifTrue:[ "/ skip private classes
       
  5364                     Transcript showCR:('ProjectBrowser: checking in class: ' , aClass name).
       
  5365                     self checkInClass:aClass.
       
  5366                 ]
       
  5367             ]
       
  5368         ]
       
  5369     ].
       
  5370 
       
  5371 
       
  5372 !
       
  5373 
       
  5374 checkInMethods
       
  5375     "check in all extensions (patches)"
       
  5376 
       
  5377     |p  methods anyMethodMissing|
       
  5378 
       
  5379     p := self currentProject.
       
  5380     p isNil ifTrue:[
       
  5381         self information:'No project selected'.
       
  5382         ^ self
       
  5383     ].
       
  5384 
       
  5385     "/ check methods ...
       
  5386 
       
  5387     anyMethodMissing := false.
       
  5388     methods := p methods.
       
  5389     methods size > 0 ifTrue:[
       
  5390         methods do:[:aMethod |
       
  5391             aMethod isMethod ifFalse:[
       
  5392                 Transcript showCR:('ProjectBrowser: cannot checkIn unloaded method: ' , aMethod className , ' ' , aMethod methodName).
       
  5393                 anyMethodMissing := true.
       
  5394             ]
       
  5395         ].
       
  5396         anyMethodMissing ifTrue:[
       
  5397             Transcript showCR:'ProjectBrowser: cannot save method patches & extensions due to missing method(s)'.
       
  5398         ] ifFalse:[
       
  5399             Transcript showCR:('ProjectBrowser: checking in patches & extensions').
       
  5400             self checkInMethods:methods
       
  5401         ].
       
  5402     ].
       
  5403 
       
  5404 !
       
  5405 
       
  5406 checkInProject
       
  5407     "check in all classes and extensions"
       
  5408 
       
  5409     |p|
       
  5410 
       
  5411     p := self currentProject.
       
  5412     p isNil ifTrue:[
       
  5413         self information:'No project selected'.
       
  5414         ^ self
       
  5415     ].
       
  5416 
       
  5417     "/ check in classes ...
       
  5418     self checkInAllClasses.
       
  5419 
       
  5420     "/ check methods ...
       
  5421     self checkInMethods.
       
  5422 
       
  5423     "/ check in the project file itself
       
  5424     self checkInProjectFile.
       
  5425 
       
  5426 !
       
  5427 
       
  5428 inspectCurrentProject
       
  5429     "inspect the current project"
       
  5430 
       
  5431     self hasProjectSelected ifTrue:[
       
  5432         self currentProject inspect.
       
  5433     ]
       
  5434 !
       
  5435 
       
  5436 loadClassesFromDirectory
       
  5437     "load all classes as contained in the project into the system"
       
  5438 
       
  5439     self withReadCursorDo:[
       
  5440         self currentProject loadClassesFromProjectDirectory.
       
  5441     ].
       
  5442 
       
  5443 !
       
  5444 
       
  5445 makeCurrentProject
       
  5446     "make the selected Project the current project"
       
  5447 
       
  5448     |project|
       
  5449 
       
  5450     self hasProjectSelected ifTrue:[
       
  5451         project := self currentProject.
       
  5452 
       
  5453         Project current:project.
       
  5454         self showWhat value == #current ifTrue:[
       
  5455             self updateProjectTree
       
  5456         ]
       
  5457     ]
       
  5458 !
       
  5459 
       
  5460 moveMethodToProject
       
  5461     |p mthd newPackage|
       
  5462 
       
  5463     p := self currentProject.
       
  5464 
       
  5465     mthd := self selectedMethod.
       
  5466     mthd notNil ifTrue:[
       
  5467         newPackage := Dialog request:'Move to project:'.
       
  5468         (newPackage size > 0 and:[newPackage ~= p package]) ifTrue:[
       
  5469             mthd package:newPackage asSymbol.
       
  5470             p removeMethod:mthd.
       
  5471             self updatePatchesListForProject:p.
       
  5472             self projectTree remove:self selectedTreeNode.
       
  5473         ]
       
  5474     ].
       
  5475 !
       
  5476 
       
  5477 newProject
       
  5478     self newProject:Project new.
       
  5479 
       
  5480 !
       
  5481 
       
  5482 newProject:newProject
       
  5483     |newNode|
       
  5484 
       
  5485     newNode := self nodeFor:newProject.
       
  5486     self addProjectNodeToTree:newNode.
       
  5487     self projectTreeHolder root:projectTree.
       
  5488 "/    self projectTreeHolder selectNode:newNode.
       
  5489 "/    self projectTreeHolder expand:newNode.
       
  5490 
       
  5491     self readAspectsFromProject.
       
  5492     newProject wasLoadedFromFile ifFalse:[
       
  5493          self updateListOfRequiredPrerequisiteClasses.
       
  5494     ]
       
  5495 !
       
  5496 
       
  5497 newSubProject
       
  5498     |projectNode subProjectsNode newNode parentProject newProject|
       
  5499 
       
  5500     projectNode := self currentProjectNode.
       
  5501 
       
  5502     projectNode notNil ifTrue:[
       
  5503         parentProject := projectNode contents.
       
  5504         subProjectsNode := projectNode children detect:[:child | child contents == #subprojects].
       
  5505 self halt.
       
  5506         parentProject notNil ifTrue:[
       
  5507             newProject := Project new.
       
  5508             newNode := self nodeFor:newProject.
       
  5509 
       
  5510             parentProject addSubProject:newProject.
       
  5511             subProjectsNode add:newNode.
       
  5512             self projectTreeHolder root:projectTree.
       
  5513             self projectTreeHolder selectNode:newNode.
       
  5514         ]    
       
  5515     ]    
       
  5516 
       
  5517 !
       
  5518 
       
  5519 openDocumentation
       
  5520     self openHTMLDocument: 'tools/pbrowser/TOP.html'
       
  5521 
       
  5522 !
       
  5523 
       
  5524 openProject
       
  5525     |fn|
       
  5526 
       
  5527     fn := Dialog 
       
  5528         requestFileName:'filename:' 
       
  5529         default:nil
       
  5530         ifFail:nil
       
  5531         pattern:'*.prj'
       
  5532         fromDirectory:(FileSelectionBox lastFileSelectionDirectory).
       
  5533 
       
  5534     fn notNil ifTrue:[
       
  5535         self loadFromProjectFile:fn.
       
  5536     ]
       
  5537 !
       
  5538 
       
  5539 removeMethod
       
  5540     |p mthd|
       
  5541 
       
  5542     p := self currentProject.
       
  5543 
       
  5544     mthd := self selectedMethod.
       
  5545     mthd notNil ifTrue:[
       
  5546         (self confirm:'Really remove the method (from both project and image) ?') ifTrue:[
       
  5547             p removeMethod:mthd.
       
  5548             mthd who methodClass removeSelector:mthd who methodSelector.
       
  5549             self updatePatchesListForProject:p.
       
  5550             self projectTree remove:self selectedTreeNode.
       
  5551         ]
       
  5552     ].
       
  5553 !
       
  5554 
       
  5555 removeMethodFromProject
       
  5556     |p mthd|
       
  5557 
       
  5558     p := self currentProject.
       
  5559 
       
  5560     mthd := self selectedMethod.
       
  5561     mthd notNil ifTrue:[
       
  5562         (self confirm:'Really remove the method (from the project) ?') ifTrue:[
       
  5563             mthd package:#unknown.
       
  5564             p removeMethod:mthd.
       
  5565             self updatePatchesListForProject:p.
       
  5566             self projectTree remove:self selectedTreeNode.
       
  5567         ]
       
  5568     ].
       
  5569 !
       
  5570 
       
  5571 removeProject
       
  5572     |projectToRemove selectedNode subNode newNode parentNode parentProject newProject|
       
  5573 
       
  5574     self hasProjectNodeSelected ifTrue:[
       
  5575         selectedNode := self selectedTreeNode.
       
  5576         projectToRemove := selectedNode contents.
       
  5577 
       
  5578         (self confirm:'Really remove the project ?') ifTrue:[
       
  5579             self withExecuteCursorDo:[
       
  5580                 self projectTreeHolder removeSelection.
       
  5581                 projectToRemove removeFromSystem.
       
  5582             ]
       
  5583         ]
       
  5584     ]
       
  5585 !
       
  5586 
       
  5587 renameProject
       
  5588     |nm projectNode selectedProject|
       
  5589 
       
  5590     projectNode := self currentProjectNode.
       
  5591     projectNode notNil ifTrue:[
       
  5592         selectedProject := projectNode contents.
       
  5593 
       
  5594         nm := Dialog 
       
  5595                 request:'Rename to:'
       
  5596                 initialAnswer:selectedProject name.
       
  5597 
       
  5598         nm size > 0 ifTrue:[
       
  5599             selectedProject name:nm.
       
  5600 "/            selectedNode name:nm.
       
  5601 "/            selectedNode changed.
       
  5602         ]
       
  5603     ]
       
  5604 !
       
  5605 
       
  5606 saveProjectFile
       
  5607     "save the project file in the project directory"
       
  5608 
       
  5609     |d p|
       
  5610 
       
  5611     self modifiedChannel value ifTrue:[
       
  5612         (self confirm:'Changes not confirmed; save anyway ?') ifFalse:[^ self]
       
  5613     ].
       
  5614 
       
  5615     p := self currentProject.
       
  5616     p isNil ifTrue:[
       
  5617         self information:'Select a project first.'.
       
  5618         ^self
       
  5619     ].
       
  5620     p directory isNil ifTrue:[
       
  5621         d := (Dialog request:'Project Directory:').
       
  5622         d size == 0 ifTrue:[
       
  5623             ^ self
       
  5624         ].
       
  5625         p directory:d
       
  5626     ].
       
  5627 
       
  5628     self withCursor:Cursor write do:[
       
  5629         p saveAsProjectFile.
       
  5630     ]
       
  5631 
       
  5632     "Modified: / 26.4.1999 / 22:43:57 / cg"
       
  5633 !
       
  5634 
       
  5635 validateAgainstClassesInImage
       
  5636     "validate classes in project against classes found in the image"
       
  5637 
       
  5638     |project classesInProjectOnly classesInImageOnly bindings|
       
  5639 
       
  5640     project := self currentProject.
       
  5641     classesInImageOnly := IdentitySet new.
       
  5642     classesInProjectOnly := IdentitySet new.
       
  5643 
       
  5644     Smalltalk allClassesDo:[:aClass |
       
  5645         aClass isMeta ifFalse:[
       
  5646             (aClass isNamespace not or:[aClass == Smalltalk]) ifTrue:[
       
  5647                 aClass package = project package ifTrue:[
       
  5648                     (project classInfoFor:aClass) isNil ifTrue:[
       
  5649                         classesInImageOnly add:aClass name.
       
  5650                     ]
       
  5651                  ]
       
  5652              ]
       
  5653         ]
       
  5654     ].
       
  5655     project classInfo do:[:clsInfo |
       
  5656         |clsName cls|
       
  5657 
       
  5658         clsName := clsInfo className.
       
  5659         cls := Smalltalk at:clsName asSymbol.
       
  5660         (cls isBehavior not) ifTrue:[
       
  5661             classesInProjectOnly add:clsName
       
  5662         ].
       
  5663     ].
       
  5664 
       
  5665     (classesInImageOnly isEmpty and:[classesInProjectOnly isEmpty]) ifTrue:[
       
  5666         self information:'Set of classes in project and image are equal.'.
       
  5667         ^ self.
       
  5668     ].
       
  5669 
       
  5670     classesInImageOnly := classesInImageOnly asOrderedCollection sort.
       
  5671     classesInProjectOnly := classesInProjectOnly asOrderedCollection sort.
       
  5672 
       
  5673     bindings := IdentityDictionary new.
       
  5674     bindings at:#classesInImageOnly put:classesInImageOnly.
       
  5675     bindings at:#classesInProjectOnly put:classesInProjectOnly.
       
  5676 
       
  5677     SimpleDialog
       
  5678         openDialogInterfaceSpec:(self class classValidationDialogSpec)
       
  5679         withBindings:bindings
       
  5680 
       
  5681     "Modified: / 26.9.1999 / 16:03:50 / cg"
       
  5682 ! !
       
  5683 
  5509 !ProjectBrowser::ProjectTreeItem methodsFor:'accessing'!
  5684 !ProjectBrowser::ProjectTreeItem methodsFor:'accessing'!
  5510 
  5685 
  5511 action
  5686 action
  5512     "return the value of the instance variable 'action' (automatically generated)"
  5687     "return the value of the instance variable 'action' (automatically generated)"
  5513 
  5688