"
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
StandardSystemView subclass:#ProjectView
instanceVariableNames:'myProject toggle'
classVariableNames:'ActiveProjectView'
poolDictionaries:''
category:'Interface-Smalltalk'
!
!ProjectView class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
! !
!ProjectView class methodsFor:'instance creation'!
for:aProject
|newView|
newView := super new.
newView setProject:aProject.
^ newView
"ProjectView for:(Project new)"
! !
!ProjectView methodsFor:'initialization'!
addToCurrentProject
"ignored here"
^ self
!
initialize
super initialize.
"/
"/ create the toggle ...
"/
toggle := Toggle in:self.
toggle borderWidth:0.
toggle pressAction:[self showProject].
toggle releaseAction:[self hideProject].
"/
"/ and give it a menu
"/
toggle middleButtonMenu:(
PopUpMenu
labels:(resources array:
#('rename ...'
'changes'
'browse'
'fileOut directory ...'
'repository directory ...'
'package ...'
"
'properties'
"
'-'
'save project code'
'build'
'-'
'show'
'hide'
'-'
'remove package'
'destroy'
)
)
selectors:#(renameProject
browseChanges
browsePackage
projectDirectory
projectRepository
projectPackage
"
browseProps
"
nil
saveProjectFiles
buildProject
nil
showProject
hideProject
nil
removePackage
destroy
)
receiver:self
)
"Created: 25.11.1995 / 18:06:32 / cg"
!
initializeMenu
|labels selectors|
SourceCodeManager isNil ifTrue:[
labels := #(
'rename ...'
'changes'
'browse'
'fileOut directory ...'
'package ...'
'-'
'show'
'hide'
'-'
'remove package classes/methods'
'destroy'
).
selectors := #(
renameProject
browseChanges
browsePackage
projectDirectory
projectPackage
nil
showProject
hideProject
nil
removePackage
destroy
)
] ifFalse:[
labels := #(
'rename ...'
'changes'
'browse'
'fileOut directory ...'
'repository directory ...'
'package ...'
"/ '-'
"/ 'save project code'
"/ 'build'
'-'
'show'
'hide'
'-'
'remove package classes/methods'
'destroy'
).
selectors := #(
renameProject
browseChanges
browsePackage
projectDirectory
projectRepository
projectPackage
"/ nil
"/ saveProjectFiles
"/ buildProject
nil
showProject
hideProject
nil
removePackage
destroy
)
].
toggle middleButtonMenu:(
PopUpMenu
labels:labels
selectors:selectors
receiver:self
)
"Created: 25.11.1995 / 18:06:32 / cg"
"Modified: 25.11.1995 / 18:18:36 / cg"
! !
!ProjectView methodsFor:'menu actions'!
browseChanges
|b|
b := ChangeSetBrowser openOn:(myProject changeSet).
b label:'Changes in ' , myProject name
!
browsePackage
"launch browsers for all classes/methods which are defined in this package"
self topView withWaitCursorDo:[
|classes packageName methods methodList|
packageName := myProject packageName.
classes := myProject classes.
classes notNil ifTrue:[
SystemBrowser browseClasses:classes
title:'classes in package ' , packageName.
classes := classes asIdentitySet.
classes addAll:(classes collect:[:c | c class]).
] ifFalse:[
classes := #()
].
"/ SystemBrowser browseMethodsWhere:[:cls :mthd :sel |
"/ mthd package = packageName
"/ and:[(classes includes:cls) not]
"/ ]
"/ title:'individual methods in package ' , packageName.
methods := myProject individualMethods.
methodList := methods collect:[:m |
|who|
who := m who.
(who at:1) name , ' ' , (who at:2)
].
SystemBrowser browseMethods:methodList
title:'individual methods in package ' , packageName.
]
!
browseProps
"will look better, once property inspector runs ..."
myProject properties inspect
!
buildProject
self topView withWaitCursorDo:[
|dir|
self saveProjectFiles.
(self confirm:'make object files in: ' , dir , ' ?') ifTrue:[
myProject buildProject.
]
].
!
destroy
(myProject views notNil
and:[myProject views notEmpty]) ifTrue:[
|box|
box := YesNoBox new.
box title:'Destroying a project will discard all changes made
for that project and destroy all views opened for it.
Do you really want to do this ?'.
box okText:'yes'.
(box confirm) ifFalse:[^ self]
].
self doDestroy
!
destroyProject
|box|
box := YesNoBox new.
box title:'Destroying a project will discard all changes made
for that project and destroy all views opened for it.
Do you really want to do this ?'.
box okText:'yes'.
box yesAction:[
self doDestroyProject
].
box showAtPointer
!
doDestroy
self hideProject.
myProject := nil.
super destroy
!
hideProject
myProject hideViews.
ActiveProjectView := nil.
toggle turnOff.
Project setDefaultProject.
!
projectDirectory
|box d|
box := FilenameEnterBox new.
box directoriesOnly.
box title:(resources string:'Directory of project (fileOuts will go there):').
(d := myProject directory) notNil ifTrue:[
box initialText:d
].
box action:[:dirName |
(OperatingSystem isDirectory:dirName) ifFalse:[
(OperatingSystem isValidPath:dirName) ifTrue:[
self warn:(resources string:'%1 is not a valid directory' with:dirName).
^ self
].
(self confirm:(resources string:'%1 does not exist\\create ?' with:dirName) withCRs) ifTrue:[
(OperatingSystem recursiveCreateDirectory:dirName) ifFalse:[
self warn:(resources string:'cannot create %1' with:dirName)
]
].
].
"did it work ?"
(OperatingSystem isDirectory:dirName) ifTrue:[
myProject directory:dirName
].
].
box showAtPointer
!
projectPackage
self topView withWaitCursorDo:[
|box p existingPackages allClasses|
existingPackages := Set new.
(allClasses := Smalltalk allClasses) do:[:aClass |
|p|
(p := aClass package) notNil ifTrue:[
existingPackages add:(p asString)
].
aClass methodArray do:[:aMethod |
(p := aMethod package) notNil ifTrue:[
existingPackages add:(p asString)
]
].
aClass class methodArray do:[:aMethod |
(p := aMethod package) notNil ifTrue:[
existingPackages add:(p asString)
]
].
].
box := ListSelectionBox title:'Package (new classes/methods will be put into that):'.
box list:(existingPackages asOrderedCollection sort).
(p := myProject packageName) notNil ifTrue:[
box initialText:p
].
box action:[:packageName |
|someClass module directory|
"/ (try) to extract the module & repository directory from someClass which
"/ is already contained in that package
Smalltalk allClasses
detect:[:cls |
|info|
(cls package = packageName) ifTrue:[
(info := cls packageSourceCodeInfo) notNil ifTrue:[
module := info at:#module ifAbsent:nil.
directory := info at:#directory ifAbsent:nil.
]
].
module notNil and:[directory notNil].
].
module notNil ifTrue:[
myProject repositoryModule:module
].
directory notNil ifTrue:[
myProject repositoryDirectory:directory
].
myProject packageName:packageName.
].
box showAtPointer
]
"Created: 9.12.1995 / 16:50:45 / cg"
"Modified: 9.12.1995 / 17:13:22 / cg"
!
projectRepository
|box d|
box := FilenameEnterBox new.
box directoriesOnly.
box title:(resources string:'Relative path of repository (source containers will go there):').
(d := myProject repositoryDirectory) notNil ifTrue:[
box initialText:d
].
box action:[:dirName |
myProject repositoryDirectory:dirName
].
box showAtPointer
"Created: 25.11.1995 / 18:07:51 / cg"
"Modified: 25.11.1995 / 18:19:46 / cg"
!
removePackage
"remove all classes and individual methods from the system.
Currently, this cannot fully restore the state to before
the time the package was loaded (redefined methods are lost).
In the future, we may keep a backref of overwritten methods
and restore them from their source ..."
|classesToRemove methodsToRemove theProject|
(myProject isNil
or:[(theProject := myProject packageName) isNil]) ifTrue:[
self warn:'No current package'.
^ self
].
classesToRemove := IdentitySet new.
methodsToRemove := IdentitySet new.
Smalltalk allClassesDo:[:aClass |
|p|
(p := aClass package) notNil ifTrue:[
p = theProject ifTrue:[
classesToRemove add:aClass
]
].
].
Smalltalk allClassesDo:[:aClass |
|p|
(classesToRemove includes:aClass) ifFalse:[
aClass methodArray do:[:aMethod |
(p := aMethod package) notNil ifTrue:[
p = theProject ifTrue:[
methodsToRemove add:aMethod
]
]
].
aClass class methodArray do:[:aMethod |
(p := aMethod package) notNil ifTrue:[
p = theProject ifTrue:[
methodsToRemove add:aMethod
]
]
].
].
].
(classesToRemove isEmpty
and:[methodsToRemove isEmpty]) ifTrue:[
self warn:('Nothing found in ' , theProject).
^ self
].
(self confirm:('About to remove '
, classesToRemove size printString
, ' classes and '
, methodsToRemove size printString
, ' additional methods.\\Are you certain you want this ?') withCRs)
ifTrue:[
classesToRemove do:[:aClass |
('PROJECT: removing ' , aClass name) infoPrintNL.
Smalltalk removeClass:aClass.
].
methodsToRemove do:[:aMethod |
|where|
('PROJECT: removing ' , aMethod displayString) infoPrintNL.
where := aMethod who.
where isNil ifTrue:[
'PROJECT: oops, some method is gone' infoPrintNL.
] ifFalse:[
(where at:1) removeSelector:(where at:2)
]
]
].
!
renameProject
|box|
box := EnterBox new.
box title:'new name of project:'.
box okText:'rename'.
box initialText:(myProject name).
box action:[:newName |
myProject name:newName.
self setProject:myProject.
self windowGroup process name:'Project: ' , newName.
].
box showAtPointer
!
saveProjectFiles
self topView withWaitCursorDo:[
|dir|
dir := myProject directory.
(self confirm:'create source files in: ' , dir , ' ?') ifTrue:[
myProject createProjectFiles.
]
].
!
showProject
ActiveProjectView notNil ifTrue:[
ActiveProjectView hideProject
].
ActiveProjectView := self.
myProject showViews.
Project current:myProject.
toggle turnOn
! !
!ProjectView methodsFor:'private accessing'!
setProject:aProject
|name e|
name := aProject name.
self label:name.
self iconLabel:name.
toggle label:'Project: ' , name.
toggle resize.
myProject := aProject.
e := (toggle width @ toggle height).
drawableId isNil ifTrue:[
self minExtent:e.
self maxExtent:e.
self open
] ifFalse:[
self unrealize.
self minExtent:e.
self maxExtent:e.
self extent:e.
self rerealize
]
! !
!ProjectView class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/Attic/ProjectV.st,v 1.22 1995-12-09 17:41:15 cg Exp $'! !