88
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
57
|
13 |
'From Smalltalk/X, Version:2.10.4 on 5-feb-1995 at 11:48:18 pm'!
|
0
|
14 |
|
|
15 |
StandardSystemView subclass:#ProjectView
|
45
|
16 |
instanceVariableNames:'myProject toggle'
|
|
17 |
classVariableNames:'ActiveProjectView'
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-Smalltalk'
|
0
|
20 |
!
|
|
21 |
|
88
|
22 |
!ProjectView class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
!
|
|
37 |
|
|
38 |
version
|
|
39 |
"
|
111
|
40 |
$Header: /cvs/stx/stx/libtool/ProjectView.st,v 1.17 1995-08-10 18:38:22 claus Exp $
|
88
|
41 |
"
|
|
42 |
! !
|
|
43 |
|
0
|
44 |
!ProjectView class methodsFor:'instance creation'!
|
|
45 |
|
|
46 |
for:aProject
|
|
47 |
|newView|
|
|
48 |
|
|
49 |
newView := super new.
|
|
50 |
newView setProject:aProject.
|
|
51 |
^ newView
|
|
52 |
|
|
53 |
"ProjectView for:(Project new)"
|
|
54 |
! !
|
|
55 |
|
57
|
56 |
!ProjectView methodsFor:'menu actions'!
|
|
57 |
|
|
58 |
browseChanges
|
|
59 |
|b|
|
|
60 |
|
|
61 |
b := ChangeSetBrowser openOn:(myProject changeSet).
|
|
62 |
b label:'Changes in ' , myProject name
|
|
63 |
!
|
|
64 |
|
|
65 |
browsePackage
|
|
66 |
"launch browsers for all classes/methods which are defined in this package"
|
|
67 |
|
|
68 |
self topView withWaitCursorDo:[
|
105
|
69 |
|classes packageName methods methodList|
|
57
|
70 |
|
85
|
71 |
packageName := myProject packageName.
|
|
72 |
classes := myProject classes.
|
|
73 |
classes notNil ifTrue:[
|
|
74 |
SystemBrowser browseClasses:classes
|
|
75 |
title:'classes in package ' , packageName.
|
57
|
76 |
|
85
|
77 |
classes := classes asIdentitySet.
|
|
78 |
classes addAll:(classes collect:[:c | c class]).
|
|
79 |
] ifFalse:[
|
|
80 |
classes := #()
|
|
81 |
].
|
105
|
82 |
"/ SystemBrowser browseMethodsWhere:[:cls :mthd :sel |
|
|
83 |
"/ mthd package = packageName
|
|
84 |
"/ and:[(classes includes:cls) not]
|
|
85 |
"/ ]
|
|
86 |
"/ title:'individual methods in package ' , packageName.
|
|
87 |
|
|
88 |
methods := myProject individualMethods.
|
|
89 |
methodList := methods collect:[:m |
|
|
90 |
|who|
|
|
91 |
|
|
92 |
who := m who.
|
|
93 |
(who at:1) name , ' ' , (who at:2)
|
|
94 |
].
|
|
95 |
SystemBrowser browseMethods:methodList
|
|
96 |
title:'individual methods in package ' , packageName.
|
57
|
97 |
]
|
|
98 |
!
|
|
99 |
|
|
100 |
projectDirectory
|
|
101 |
|box d|
|
|
102 |
|
|
103 |
box := FilenameEnterBox new.
|
85
|
104 |
box directoriesOnly.
|
57
|
105 |
box title:(resources string:'Directory of project (fileOuts will go there):').
|
|
106 |
(d := myProject directory) notNil ifTrue:[
|
|
107 |
box initialText:d
|
|
108 |
].
|
|
109 |
box action:[:dirName |
|
|
110 |
(OperatingSystem isDirectory:dirName) ifFalse:[
|
|
111 |
(OperatingSystem isValidPath:dirName) ifTrue:[
|
|
112 |
self warn:(resources string:'%1 is not a valid directory' with:dirName).
|
|
113 |
^ self
|
|
114 |
].
|
|
115 |
(self confirm:(resources string:'%1 does not exist\\create ?' with:dirName) withCRs) ifTrue:[
|
|
116 |
(OperatingSystem recursiveCreateDirectory:dirName) ifFalse:[
|
|
117 |
self warn:(resources string:'cannot create %1' with:dirName)
|
|
118 |
]
|
|
119 |
].
|
|
120 |
].
|
|
121 |
"did it work ?"
|
|
122 |
(OperatingSystem isDirectory:dirName) ifTrue:[
|
|
123 |
myProject directory:dirName
|
|
124 |
].
|
|
125 |
].
|
|
126 |
box showAtPointer
|
|
127 |
!
|
|
128 |
|
|
129 |
projectPackage
|
|
130 |
self topView withWaitCursorDo:[
|
85
|
131 |
|box p existingPackages|
|
57
|
132 |
|
85
|
133 |
existingPackages := Set new.
|
|
134 |
Smalltalk allClassesDo:[:aClass |
|
|
135 |
|p|
|
57
|
136 |
|
85
|
137 |
(p := aClass package) notNil ifTrue:[
|
|
138 |
existingPackages add:(p asString)
|
110
|
139 |
].
|
|
140 |
aClass methodArray do:[:aMethod |
|
|
141 |
(p := aMethod package) notNil ifTrue:[
|
|
142 |
existingPackages add:(p asString)
|
|
143 |
]
|
|
144 |
].
|
|
145 |
aClass class methodArray do:[:aMethod |
|
|
146 |
(p := aMethod package) notNil ifTrue:[
|
|
147 |
existingPackages add:(p asString)
|
|
148 |
]
|
|
149 |
].
|
85
|
150 |
].
|
57
|
151 |
|
85
|
152 |
box := ListSelectionBox title:'Package (new classes/methods will be put into that):'.
|
|
153 |
box list:(existingPackages asOrderedCollection sort).
|
|
154 |
(p := myProject packageName) notNil ifTrue:[
|
|
155 |
box initialText:p
|
|
156 |
].
|
|
157 |
box action:[:packageName |
|
|
158 |
myProject packageName:packageName
|
|
159 |
].
|
|
160 |
box showAtPointer
|
57
|
161 |
]
|
110
|
162 |
!
|
57
|
163 |
|
110
|
164 |
removePackage
|
|
165 |
"remove all classes and individual methods from the system.
|
|
166 |
Currently, this cannot fully restore the state to before
|
|
167 |
the time the package was loaded (redefined methods are lost).
|
|
168 |
In the future, we may keep a backref of overwritten methods
|
|
169 |
and restore them from their source ..."
|
57
|
170 |
|
110
|
171 |
|classesToRemove methodsToRemove theProject|
|
|
172 |
|
|
173 |
(myProject isNil
|
|
174 |
or:[(theProject := myProject packageName) isNil]) ifTrue:[
|
|
175 |
self warn:'No current package'.
|
|
176 |
^ self
|
|
177 |
].
|
|
178 |
|
|
179 |
classesToRemove := IdentitySet new.
|
|
180 |
methodsToRemove := IdentitySet new.
|
|
181 |
|
|
182 |
Smalltalk allClassesDo:[:aClass |
|
|
183 |
|p|
|
|
184 |
|
|
185 |
(p := aClass package) notNil ifTrue:[
|
|
186 |
p = theProject ifTrue:[
|
|
187 |
classesToRemove add:aClass
|
|
188 |
]
|
|
189 |
].
|
|
190 |
].
|
|
191 |
Smalltalk allClassesDo:[:aClass |
|
|
192 |
|p|
|
|
193 |
|
|
194 |
(classesToRemove includes:aClass) ifFalse:[
|
|
195 |
aClass methodArray do:[:aMethod |
|
|
196 |
(p := aMethod package) notNil ifTrue:[
|
|
197 |
p = theProject ifTrue:[
|
|
198 |
methodsToRemove add:aMethod
|
|
199 |
]
|
|
200 |
]
|
|
201 |
].
|
|
202 |
aClass class methodArray do:[:aMethod |
|
|
203 |
(p := aMethod package) notNil ifTrue:[
|
|
204 |
p = theProject ifTrue:[
|
|
205 |
methodsToRemove add:aMethod
|
|
206 |
]
|
|
207 |
]
|
|
208 |
].
|
|
209 |
].
|
|
210 |
].
|
|
211 |
|
|
212 |
(classesToRemove isEmpty
|
|
213 |
and:[methodsToRemove isEmpty]) ifTrue:[
|
|
214 |
self warn:('Nothing found in ' , theProject).
|
|
215 |
^ self
|
|
216 |
].
|
|
217 |
|
|
218 |
(self confirm:('About to remove '
|
|
219 |
, classesToRemove size printString
|
|
220 |
, ' classes and '
|
|
221 |
, methodsToRemove size printString
|
|
222 |
, ' additional methods.\\Are you certain you want this ?') withCRs)
|
|
223 |
ifTrue:[
|
|
224 |
classesToRemove do:[:aClass |
|
|
225 |
('PROJECT: removing ' , aClass name) infoPrintNL.
|
|
226 |
Smalltalk removeClass:aClass.
|
|
227 |
].
|
|
228 |
methodsToRemove do:[:aMethod |
|
|
229 |
|where|
|
|
230 |
|
|
231 |
('PROJECT: removing ' , aMethod displayString) infoPrintNL.
|
|
232 |
where := aMethod who.
|
|
233 |
where isNil ifTrue:[
|
|
234 |
'PROJECT: oops, some method is gone' infoPrintNL.
|
|
235 |
] ifFalse:[
|
|
236 |
(where at:1) removeSelector:(where at:2)
|
|
237 |
]
|
|
238 |
]
|
|
239 |
].
|
57
|
240 |
!
|
|
241 |
|
|
242 |
showProject
|
|
243 |
ActiveProjectView notNil ifTrue:[
|
|
244 |
ActiveProjectView hideProject
|
|
245 |
].
|
|
246 |
ActiveProjectView := self.
|
|
247 |
|
|
248 |
myProject showViews.
|
|
249 |
Project current:myProject.
|
|
250 |
toggle turnOn
|
|
251 |
!
|
|
252 |
|
|
253 |
browseProps
|
|
254 |
"will look better, once property inspector runs ..."
|
|
255 |
|
|
256 |
myProject properties inspect
|
|
257 |
!
|
|
258 |
|
|
259 |
saveProjectFiles
|
|
260 |
self topView withWaitCursorDo:[
|
85
|
261 |
|dir|
|
57
|
262 |
|
85
|
263 |
dir := myProject directory.
|
|
264 |
(self confirm:'create source files in: ' , dir , ' ?') ifTrue:[
|
|
265 |
myProject createProjectFiles.
|
|
266 |
]
|
57
|
267 |
].
|
|
268 |
!
|
|
269 |
|
|
270 |
hideProject
|
|
271 |
myProject hideViews.
|
|
272 |
ActiveProjectView := nil.
|
93
|
273 |
toggle turnOff.
|
|
274 |
Project setDefaultProject.
|
57
|
275 |
!
|
|
276 |
|
|
277 |
renameProject
|
|
278 |
|box|
|
|
279 |
|
|
280 |
box := EnterBox new.
|
|
281 |
box title:'new name of project:'.
|
|
282 |
box okText:'rename'.
|
|
283 |
box initialText:(myProject name).
|
|
284 |
box action:[:newName |
|
|
285 |
myProject name:newName.
|
85
|
286 |
self setProject:myProject.
|
|
287 |
self windowGroup process name:'Project: ' , newName.
|
57
|
288 |
].
|
|
289 |
box showAtPointer
|
|
290 |
!
|
|
291 |
|
|
292 |
buildProject
|
|
293 |
self topView withWaitCursorDo:[
|
85
|
294 |
|dir|
|
57
|
295 |
|
85
|
296 |
self saveProjectFiles.
|
|
297 |
(self confirm:'make object files in: ' , dir , ' ?') ifTrue:[
|
|
298 |
myProject buildProject.
|
|
299 |
]
|
57
|
300 |
].
|
|
301 |
!
|
|
302 |
|
|
303 |
destroyProject
|
|
304 |
|box|
|
|
305 |
|
|
306 |
box := YesNoBox new.
|
|
307 |
box title:'Destroying a project will discard all changes made
|
|
308 |
for that project and destroy all views opened for it.
|
|
309 |
|
|
310 |
Do you really want to do this ?'.
|
|
311 |
box okText:'yes'.
|
|
312 |
box yesAction:[
|
|
313 |
self doDestroyProject
|
|
314 |
].
|
|
315 |
box showAtPointer
|
|
316 |
!
|
|
317 |
|
|
318 |
doDestroy
|
|
319 |
self hideProject.
|
|
320 |
myProject := nil.
|
|
321 |
super destroy
|
|
322 |
!
|
|
323 |
|
|
324 |
destroy
|
|
325 |
(myProject views notNil
|
|
326 |
and:[myProject views notEmpty]) ifTrue:[
|
|
327 |
|box|
|
|
328 |
|
|
329 |
box := YesNoBox new.
|
|
330 |
box title:'Destroying a project will discard all changes made
|
|
331 |
for that project and destroy all views opened for it.
|
|
332 |
|
|
333 |
Do you really want to do this ?'.
|
|
334 |
box okText:'yes'.
|
|
335 |
(box confirm) ifFalse:[^ self]
|
|
336 |
].
|
|
337 |
|
|
338 |
self doDestroy
|
|
339 |
! !
|
|
340 |
|
|
341 |
!ProjectView methodsFor:'initialization'!
|
|
342 |
|
|
343 |
initialize
|
|
344 |
super initialize.
|
110
|
345 |
|
|
346 |
"/
|
|
347 |
"/ create the toggle ...
|
|
348 |
"/
|
57
|
349 |
toggle := Toggle in:self.
|
|
350 |
toggle borderWidth:0.
|
|
351 |
toggle pressAction:[self showProject].
|
|
352 |
toggle releaseAction:[self hideProject].
|
110
|
353 |
|
|
354 |
"/
|
|
355 |
"/ and give it a menu
|
|
356 |
"/
|
|
357 |
|
57
|
358 |
toggle middleButtonMenu:(
|
|
359 |
PopUpMenu
|
|
360 |
labels:(resources array:
|
106
|
361 |
#('rename ...'
|
57
|
362 |
'changes'
|
|
363 |
'browse'
|
106
|
364 |
'directory ...'
|
|
365 |
'package ...'
|
57
|
366 |
"
|
|
367 |
'properties'
|
|
368 |
"
|
|
369 |
'-'
|
|
370 |
'save project code'
|
|
371 |
'build'
|
|
372 |
'-'
|
|
373 |
'show'
|
|
374 |
'hide'
|
|
375 |
'-'
|
110
|
376 |
'remove package'
|
57
|
377 |
'destroy'
|
|
378 |
)
|
|
379 |
)
|
|
380 |
selectors:#(renameProject
|
|
381 |
browseChanges
|
|
382 |
browsePackage
|
|
383 |
projectDirectory
|
|
384 |
projectPackage
|
|
385 |
"
|
|
386 |
browseProps
|
|
387 |
"
|
|
388 |
nil
|
|
389 |
saveProjectFiles
|
|
390 |
buildProject
|
|
391 |
nil
|
|
392 |
showProject
|
|
393 |
hideProject
|
|
394 |
nil
|
110
|
395 |
removePackage
|
57
|
396 |
destroy
|
|
397 |
)
|
|
398 |
receiver:self
|
|
399 |
)
|
|
400 |
!
|
|
401 |
|
|
402 |
addToCurrentProject
|
|
403 |
"ignored here"
|
|
404 |
|
|
405 |
^ self
|
|
406 |
! !
|
|
407 |
|
0
|
408 |
!ProjectView methodsFor:'private accessing'!
|
|
409 |
|
|
410 |
setProject:aProject
|
|
411 |
|name e|
|
|
412 |
|
|
413 |
name := aProject name.
|
|
414 |
self label:name.
|
17
|
415 |
self iconLabel:name.
|
0
|
416 |
toggle label:'Project: ' , name.
|
|
417 |
toggle resize.
|
|
418 |
myProject := aProject.
|
|
419 |
e := (toggle width @ toggle height).
|
29
|
420 |
drawableId isNil ifTrue:[
|
45
|
421 |
self minExtent:e.
|
|
422 |
self maxExtent:e.
|
|
423 |
self open
|
29
|
424 |
] ifFalse:[
|
45
|
425 |
self unrealize.
|
|
426 |
self minExtent:e.
|
|
427 |
self maxExtent:e.
|
|
428 |
self extent:e.
|
|
429 |
self rerealize
|
29
|
430 |
]
|
0
|
431 |
! !
|
|
432 |
|