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