1443
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2003 by eXept Software AG
|
1673
|
3 |
All Rights Reserved
|
1443
|
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 |
|
1231
|
13 |
"{ Package: 'stx:libbasic3' }"
|
|
14 |
|
|
15 |
"{ NameSpace: Packages }"
|
|
16 |
|
|
17 |
AbstractPackageManager subclass:#PackageManager
|
1268
|
18 |
instanceVariableNames:'workingPackage defaultPackage'
|
1231
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Package-Managers'
|
|
22 |
!
|
|
23 |
|
|
24 |
PackageManager class instanceVariableNames:'currentPackage currentManager imageChanges'
|
|
25 |
|
|
26 |
"
|
|
27 |
No other class instance variables are inherited by this class.
|
|
28 |
"
|
|
29 |
!
|
|
30 |
|
|
31 |
!PackageManager class methodsFor:'documentation'!
|
|
32 |
|
1443
|
33 |
copyright
|
|
34 |
"
|
|
35 |
COPYRIGHT (c) 2003 by eXept Software AG
|
1673
|
36 |
All Rights Reserved
|
1443
|
37 |
|
|
38 |
This software is furnished under a license and may be used
|
|
39 |
only in accordance with the terms of that license and with the
|
|
40 |
inclusion of the above copyright notice. This software may not
|
|
41 |
be provided or otherwise made available to, or used by, any
|
|
42 |
other person. No title to or ownership of the software is
|
|
43 |
hereby transferred.
|
|
44 |
"
|
|
45 |
!
|
|
46 |
|
1231
|
47 |
documentation
|
|
48 |
"
|
|
49 |
PackageManager smalltalkPackageManager
|
|
50 |
|
|
51 |
[author:]
|
1673
|
52 |
(james@miraculix)
|
1231
|
53 |
|
|
54 |
[instance variables:]
|
|
55 |
|
|
56 |
[class variables:]
|
|
57 |
|
|
58 |
[see also:]
|
|
59 |
|
|
60 |
"
|
|
61 |
!
|
|
62 |
|
|
63 |
documentation_exceptions
|
|
64 |
"
|
|
65 |
|
1673
|
66 |
ClassDescription fileOutErrorSignal
|
|
67 |
can occur when a class within a package is autoloaded. Handle in application
|
1231
|
68 |
|
|
69 |
[author:]
|
1673
|
70 |
(james@miraculix)
|
|
71 |
|
1231
|
72 |
"
|
|
73 |
!
|
|
74 |
|
|
75 |
examples
|
|
76 |
"
|
|
77 |
|
|
78 |
more examples to be added:
|
1673
|
79 |
[exBegin]
|
|
80 |
... add code fragment for
|
1231
|
81 |
... executable example here ...
|
1673
|
82 |
[exEnd]
|
1231
|
83 |
"
|
|
84 |
!
|
|
85 |
|
|
86 |
history
|
|
87 |
"Created: / 27.1.2003 / 13:57:50 / james"
|
|
88 |
! !
|
|
89 |
|
|
90 |
!PackageManager class methodsFor:'instance creation'!
|
|
91 |
|
|
92 |
initialize
|
|
93 |
"Uninitialize Singleton"
|
|
94 |
currentManager ifNotNil:[
|
1673
|
95 |
currentManager uninitialize.
|
|
96 |
currentManager := nil.
|
|
97 |
currentPackage := nil.
|
1231
|
98 |
]
|
|
99 |
|
|
100 |
"
|
|
101 |
self initialize
|
|
102 |
"
|
|
103 |
!
|
|
104 |
|
|
105 |
newManagerOfCurrentImage
|
|
106 |
| anInstance |
|
|
107 |
anInstance := self new.
|
|
108 |
|
|
109 |
self basicPackagesInImage do:[:aPackage |
|
1673
|
110 |
package isInstalled:true.
|
|
111 |
anInstance addPackage:aPackage
|
1231
|
112 |
].
|
|
113 |
^ anInstance
|
|
114 |
|
|
115 |
"
|
|
116 |
currentManager := self newManagerOfCurrentImage.
|
|
117 |
"
|
|
118 |
! !
|
|
119 |
|
1268
|
120 |
!PackageManager class methodsFor:'* As yet uncategorized *'!
|
|
121 |
|
|
122 |
basePackageNames
|
1673
|
123 |
^ (Array with:(Project noProjectID)) ,
|
|
124 |
#(
|
|
125 |
#'stx:clients/AddrBook'
|
|
126 |
#'stx:clients/Animation'
|
|
127 |
#'stx:clients/Clock'
|
|
128 |
#'stx:clients/Demos'
|
|
129 |
#'stx:clients/DirView'
|
|
130 |
#'stx:clients/DocTool'
|
|
131 |
#'stx:clients/DrawTool'
|
|
132 |
#'stx:clients/GLdemos'
|
|
133 |
#'stx:clients/GuessingGame'
|
|
134 |
#'stx:clients/LogicTool'
|
|
135 |
#'stx:clients/MailTool'
|
|
136 |
#'stx:clients/NewsTool'
|
|
137 |
#'stx:clients/PingPong'
|
|
138 |
#'stx:clients/Tetris'
|
|
139 |
#'stx:clients/TicTacToe'
|
|
140 |
#'stx:clients/TicTacToe3D'
|
|
141 |
#'stx:clients/Tools'
|
|
142 |
#'stx:goodies'
|
|
143 |
#'stx:goodies/benchmarks'
|
|
144 |
#'stx:goodies/benchmarks/deltaBlue'
|
|
145 |
#'stx:goodies/benchmarks/dhrystones'
|
|
146 |
#'stx:goodies/benchmarks/misc'
|
|
147 |
#'stx:goodies/benchmarks/richards'
|
|
148 |
#'stx:goodies/benchmarks/self'
|
|
149 |
#'stx:goodies/communication'
|
|
150 |
#'stx:goodies/dhbNumeric'
|
|
151 |
#'stx:goodies/distributions'
|
|
152 |
#'stx:goodies/glorp'
|
|
153 |
#'stx:goodies/lisp'
|
|
154 |
#'stx:goodies/math/fibonacci'
|
|
155 |
#'stx:goodies/measurement'
|
|
156 |
#'stx:goodies/minneStore'
|
|
157 |
#'stx:goodies/obsolete'
|
|
158 |
#'stx:goodies/persistency'
|
|
159 |
#'stx:goodies/postscript'
|
|
160 |
#'stx:goodies/prolog'
|
|
161 |
#'stx:goodies/rdoit'
|
|
162 |
#'stx:goodies/refactoryBrowser'
|
|
163 |
#'stx:goodies/regex'
|
|
164 |
#'stx:goodies/remoteObjects'
|
|
165 |
#'stx:goodies/screenSavers'
|
|
166 |
#'stx:goodies/sif'
|
|
167 |
#'stx:goodies/smaCC'
|
|
168 |
#'stx:goodies/soap'
|
|
169 |
#'stx:goodies/soap/examples'
|
|
170 |
#'stx:goodies/soap/opera'
|
|
171 |
#'stx:goodies/soap/splash'
|
|
172 |
#'stx:goodies/soap/spray'
|
|
173 |
#'stx:goodies/soap/wsdl'
|
|
174 |
#'stx:goodies/soap/xe'
|
|
175 |
#'stx:goodies/soap/xmlsig'
|
|
176 |
#'stx:goodies/sound'
|
|
177 |
#'stx:goodies/stmath'
|
|
178 |
#'stx:goodies/stxInExternalWindow'
|
|
179 |
#'stx:goodies/sunit'
|
|
180 |
#'stx:goodies/swazoo'
|
|
181 |
#'stx:goodies/tgen'
|
|
182 |
#'stx:goodies/webServer'
|
|
183 |
#'stx:goodies/webServer/pwsSwiki'
|
|
184 |
#'stx:goodies/xml-indelv'
|
|
185 |
#'stx:goodies/xml-vw'
|
|
186 |
#'stx:goodies/xml-yaxo'
|
|
187 |
#'stx:libbasic'
|
|
188 |
#'stx:libbasic2'
|
|
189 |
#'stx:libbasic3'
|
|
190 |
#'stx:libboss'
|
|
191 |
#'stx:libcomp'
|
|
192 |
#'stx:libcompat'
|
|
193 |
#'stx:libhtml'
|
|
194 |
#'stx:libjava'
|
|
195 |
#'stx:libjava/examples'
|
|
196 |
#'stx:libjavascript'
|
|
197 |
#'stx:libodbc'
|
|
198 |
#'stx:libopengl'
|
|
199 |
#'stx:libsnmp'
|
|
200 |
#'stx:libtable'
|
|
201 |
#'stx:libtool'
|
|
202 |
#'stx:libtool2'
|
|
203 |
#'stx:libui'
|
|
204 |
#'stx:libview'
|
|
205 |
#'stx:libview2'
|
|
206 |
#'stx:libwidg'
|
|
207 |
#'stx:libwidg2'
|
|
208 |
#'stx:libwidg3'
|
1268
|
209 |
)
|
|
210 |
! !
|
|
211 |
|
1231
|
212 |
!PackageManager class methodsFor:'accessing'!
|
|
213 |
|
|
214 |
changes
|
|
215 |
imageChanges ifNil:[
|
1673
|
216 |
imageChanges := OrderedCollection new.
|
1231
|
217 |
].
|
|
218 |
^ imageChanges
|
|
219 |
!
|
|
220 |
|
|
221 |
smalltalkPackageManager
|
|
222 |
"/ to clear the singleton for the moment
|
|
223 |
| workingPackage packagesInImage|
|
|
224 |
|
|
225 |
"/ self initialize.
|
1673
|
226 |
currentManager
|
|
227 |
ifNil:[
|
|
228 |
currentManager := self new.
|
1231
|
229 |
|
1673
|
230 |
packagesInImage := self basicPackagesInImage.
|
|
231 |
workingPackage := packagesInImage removeKey:(Project noProjectID).
|
1231
|
232 |
|
1673
|
233 |
currentManager addPackages:(packagesInImage).
|
|
234 |
currentManager defaultPackage:workingPackage.
|
|
235 |
].
|
1231
|
236 |
^ currentManager
|
|
237 |
! !
|
|
238 |
|
|
239 |
!PackageManager class methodsFor:'defaults'!
|
|
240 |
|
|
241 |
defaultPackages
|
|
242 |
^ DictionaryStack new.
|
|
243 |
! !
|
|
244 |
|
|
245 |
!PackageManager class methodsFor:'factory'!
|
|
246 |
|
1268
|
247 |
defaultPackage
|
|
248 |
^ (Packages::Package named:#'__NoProject__')
|
|
249 |
!
|
|
250 |
|
1231
|
251 |
packageClass
|
|
252 |
^ Package
|
|
253 |
! !
|
|
254 |
|
|
255 |
!PackageManager class methodsFor:'temporary'!
|
|
256 |
|
|
257 |
basicPackagesInImage
|
|
258 |
"builds up dictionary of the packages in the system taking the information of the classes and
|
|
259 |
methods so we have a complete picture but without the prerequisite information.
|
|
260 |
returns the dictionary"
|
|
261 |
| packagesInImage extentions clsPkg |
|
|
262 |
|
|
263 |
packagesInImage := Dictionary new.
|
|
264 |
extentions := Dictionary new.
|
|
265 |
|
|
266 |
"collect the classes and mark where the extentions are"
|
|
267 |
Smalltalk allClasses do:[:aClass |
|
1673
|
268 |
aClass isNameSpace ifFalse:[
|
|
269 |
clsPkg := aClass package.
|
|
270 |
((packagesInImage at: clsPkg
|
|
271 |
ifAbsentPut:[clsPkg == #'__NoProject__' ifTrue:[
|
|
272 |
(Package named:clsPkg)
|
|
273 |
] ifFalse:[(Package named:clsPkg)
|
|
274 |
]. ])
|
|
275 |
addedClass:aClass).
|
1231
|
276 |
|
|
277 |
"/ aClass hasExtensions ifTrue:[
|
1673
|
278 |
aClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|
|
279 |
|mthdPkg|
|
|
280 |
mthdPkg := mthd package.
|
|
281 |
mthdPkg ~= clsPkg ifTrue:[| methodPackage |
|
|
282 |
"this is found out when you add a class!!"
|
1231
|
283 |
"/ (packagesInImage at: clsPkg) removeMethod:mthd. "does not belong to the package"
|
1673
|
284 |
methodPackage :=
|
|
285 |
(packagesInImage at: mthdPkg ifAbsentPut:[
|
|
286 |
mthdPkg == #'__NoProject__' ifTrue:[
|
|
287 |
(Package named:mthdPkg)
|
|
288 |
] ifFalse:[(Package named:mthdPkg)
|
|
289 |
].
|
|
290 |
]).
|
|
291 |
methodPackage addedMethod:mthd
|
1231
|
292 |
|
1673
|
293 |
].
|
1231
|
294 |
"/ ].
|
1673
|
295 |
]
|
|
296 |
]
|
1231
|
297 |
].
|
1268
|
298 |
"/ packagesInImage removeKey:#''. "remove namespaces"
|
1231
|
299 |
packagesInImage do:[:aPackage |
|
1673
|
300 |
aPackage initializeInstalled.
|
1231
|
301 |
].
|
1244
|
302 |
"the following is needed in a fresh image!!"
|
1268
|
303 |
packagesInImage at:#'__NoProject__' ifAbsentPut:[(Package named:#'__NoProject__')].
|
1231
|
304 |
^ packagesInImage
|
|
305 |
! !
|
|
306 |
|
|
307 |
!PackageManager methodsFor:'accessing'!
|
|
308 |
|
1268
|
309 |
allClassCategories
|
1673
|
310 |
| allClassCategories |
|
1268
|
311 |
allClassCategories := SortedCollection new.
|
|
312 |
|
|
313 |
self packagesDo:[:aPackage |
|
1673
|
314 |
allClassCategories addAll:aPackage classCategories
|
1268
|
315 |
].
|
|
316 |
|
|
317 |
^ allClassCategories
|
|
318 |
!
|
|
319 |
|
|
320 |
allPackageCategories
|
|
321 |
^ (self packages collect:[:aPackage | aPackage category]) asSet.
|
|
322 |
!
|
|
323 |
|
1231
|
324 |
changes
|
|
325 |
^ self class changes
|
|
326 |
!
|
|
327 |
|
1268
|
328 |
defaultPackage
|
|
329 |
"return the value of the instance variable 'defaultPackage' (automatically generated)"
|
|
330 |
|
|
331 |
^ defaultPackage
|
|
332 |
!
|
|
333 |
|
|
334 |
defaultPackage:something
|
|
335 |
"set the value of the instance variable 'defaultPackage' if the current default package
|
|
336 |
is also the working package. Change the working package "
|
|
337 |
|
|
338 |
workingPackage == defaultPackage ifTrue:[
|
1673
|
339 |
workingPackage := something.
|
1231
|
340 |
].
|
1268
|
341 |
|
|
342 |
defaultPackage := something.
|
|
343 |
!
|
|
344 |
|
|
345 |
packageNamed:anIdentifier
|
|
346 |
^ self packageNamed:anIdentifier ifAbsent:[nil]
|
|
347 |
!
|
|
348 |
|
|
349 |
packageNamed:anIdentifier ifAbsent:aBlock
|
|
350 |
anIdentifier ifNil:[
|
1673
|
351 |
^ aBlock value
|
1231
|
352 |
].
|
1268
|
353 |
defaultPackage name == anIdentifier ifTrue:[
|
1673
|
354 |
^ defaultPackage
|
1268
|
355 |
].
|
|
356 |
^ packages atKey:anIdentifier ifAbsent:aBlock
|
|
357 |
!
|
|
358 |
|
1673
|
359 |
packagesAtCategoryName:aCategoryName
|
1268
|
360 |
^ self packages select:[:aPackage |
|
1673
|
361 |
(aPackage isInCategoryNamed:aCategoryName)
|
1268
|
362 |
].
|
1231
|
363 |
!
|
|
364 |
|
1673
|
365 |
packagesNamed:aCollectionOfPackageNames
|
1231
|
366 |
|
1268
|
367 |
^ (aCollectionOfPackageNames collect:[:aName |
|
1673
|
368 |
self packageNamed:aName
|
1231
|
369 |
]).
|
|
370 |
!
|
|
371 |
|
1279
|
372 |
smalltalkChanges
|
|
373 |
^ self class changes
|
|
374 |
!
|
|
375 |
|
1231
|
376 |
workingPackage
|
|
377 |
"return the value of the instance variable 'workingPackage' (automatically generated)"
|
|
378 |
|
|
379 |
^ workingPackage
|
|
380 |
!
|
|
381 |
|
|
382 |
workingPackage:aPackage
|
1268
|
383 |
((aPackage == defaultPackage) or:[self includesPackage:aPackage]) ifFalse:[
|
1673
|
384 |
self error:'Trying to make a package that i do not know about the workingPackage!!'
|
1268
|
385 |
].
|
|
386 |
|
1231
|
387 |
workingPackage removeDependent:self.
|
|
388 |
workingPackage:= aPackage.
|
|
389 |
workingPackage addDependent:self.
|
|
390 |
! !
|
|
391 |
|
|
392 |
!PackageManager methodsFor:'adding & removing'!
|
|
393 |
|
|
394 |
addChange:aChange
|
|
395 |
^ self class changes add:aChange.
|
|
396 |
!
|
|
397 |
|
|
398 |
addPackage:aPackage
|
|
399 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
400 |
aPackage addDependent:self.
|
|
401 |
self basicAddPackage:aPackage.
|
|
402 |
self changed:#addPackage: with:aPackage
|
|
403 |
!
|
|
404 |
|
|
405 |
addPackages:aPackages
|
|
406 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
407 |
aPackages do:[:aPackage |
|
1673
|
408 |
self basicAddPackage:aPackage.
|
1231
|
409 |
].
|
|
410 |
self changed:#addPackages: with:aPackages
|
|
411 |
!
|
|
412 |
|
|
413 |
basicAddPackage:aPackage
|
|
414 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
415 |
packages push:aPackage.
|
|
416 |
!
|
|
417 |
|
|
418 |
basicRemovePackage:aPackage
|
|
419 |
^ packages removeKey:aPackage name
|
|
420 |
!
|
|
421 |
|
|
422 |
removeChange:aChange
|
|
423 |
^ self class changes remove:aChange.
|
|
424 |
!
|
|
425 |
|
|
426 |
removePackage:aPackage
|
|
427 |
"the reciever needs to be dependent on the packages just in case they change"
|
|
428 |
aPackage removeDependent:self.
|
|
429 |
self basicRemovePackage:aPackage.
|
|
430 |
self changed:#removePackage: with:aPackage
|
|
431 |
!
|
|
432 |
|
|
433 |
removePackageNamed:aPackageName
|
|
434 |
| aPackage |
|
|
435 |
aPackage := (packages removeKey:aPackageName).
|
|
436 |
aPackage removeDependent:self.
|
|
437 |
self changed:#removePackage: with:aPackage
|
|
438 |
! !
|
|
439 |
|
|
440 |
!PackageManager methodsFor:'api'!
|
|
441 |
|
1268
|
442 |
addClass:aClass toPackage:newPackage
|
|
443 |
"A manager type of the method which should not be called from Smalltalk changes"
|
|
444 |
| oldPackageName oldPackage |
|
|
445 |
|
|
446 |
(self includesPackage:newPackage) ifFalse:[
|
1673
|
447 |
self error:'The package manager does not know of the package ', newPackage name.
|
1231
|
448 |
].
|
1268
|
449 |
oldPackageName := aClass package.
|
|
450 |
oldPackage := self packageNamed:oldPackageName.
|
|
451 |
|
|
452 |
(oldPackageName == newPackage name) ifTrue:["error??"
|
1673
|
453 |
newPackage addedClass:aClass.
|
|
454 |
^ self
|
1268
|
455 |
].
|
|
456 |
|
1673
|
457 |
self setClass:aClass toPackage:newPackage.
|
1268
|
458 |
PackageError handle:[:ex |
|
1673
|
459 |
self setClass:aClass toPackage:oldPackage.
|
|
460 |
ex raise.
|
|
461 |
] do:[
|
|
462 |
newPackage addedClass:aClass.
|
|
463 |
oldPackage overrideClassNamed:aClass name byPackageNamed:newPackage name.
|
1268
|
464 |
].
|
1231
|
465 |
!
|
|
466 |
|
1268
|
467 |
addMethod:aMethod toPackage:newPackage
|
|
468 |
| oldPackageName oldPackage|
|
|
469 |
|
|
470 |
(self includesPackage:newPackage) ifFalse:[
|
1673
|
471 |
self error:'The package manager does not know of the package ', newPackage name.
|
1231
|
472 |
].
|
1268
|
473 |
"/ self moveClass:aClass toPackage:newPackage.
|
|
474 |
oldPackageName := aMethod package.
|
|
475 |
oldPackage := self packageNamed:oldPackageName.
|
|
476 |
|
|
477 |
(oldPackageName == newPackage name) ifTrue:[
|
1673
|
478 |
newPackage addedMethod:aMethod.
|
|
479 |
^ self "error??"
|
1268
|
480 |
].
|
|
481 |
|
1673
|
482 |
aMethod setPackage:newPackage name.
|
1268
|
483 |
|
1673
|
484 |
newPackage addedMethod:aMethod.
|
1268
|
485 |
oldPackage overrideMethod:aMethod byPackageNamed:newPackage name.
|
1231
|
486 |
!
|
|
487 |
|
1673
|
488 |
installPackage:aPackage
|
1231
|
489 |
"installs a package that the receiver is aware of into the image if not raise an error
|
|
490 |
for the sender to catch so it is able to handle it"
|
|
491 |
(self includesPackage:aPackage) ifFalse:[
|
1673
|
492 |
self error:'The package manager does not know of the package ', aPackage name,' so it cannot be installed!!'
|
1231
|
493 |
].
|
|
494 |
^ (self getPackageHandlerForPackage:aPackage) installPackageIn:self
|
|
495 |
!
|
|
496 |
|
1673
|
497 |
loadPackageFromFile:aFilename
|
1231
|
498 |
"install a starter package which comes from a file. This is the
|
|
499 |
a state where the package has not yet entered the image but it
|
|
500 |
is a package that the receiver is aware of and has some initial
|
|
501 |
information about. Return the installed Package"
|
|
502 |
|
|
503 |
^ (self getPackageReaderForFile:aFilename) loadPackageIn:self .
|
|
504 |
!
|
|
505 |
|
1673
|
506 |
moveClass:aClass toPackage:newOwnerPackage
|
1231
|
507 |
"i have the responsibilty to set aClasses new variable (newOwnerPackage name) and
|
|
508 |
all the methods in aClass with the same package name!!
|
|
509 |
"
|
1268
|
510 |
| oldOwnerPackage|
|
1231
|
511 |
|
1268
|
512 |
oldOwnerPackage := self packageNamed:aClass package.
|
1231
|
513 |
|
|
514 |
oldOwnerPackage ifNil:[
|
1673
|
515 |
"error handling - if a package has accidentially been removed
|
|
516 |
and i do not know about it. Fake it and put it in the default package"
|
1268
|
517 |
oldOwnerPackage := defaultPackage.
|
|
518 |
self setClass:aClass toPackage:defaultPackage.
|
|
519 |
(defaultPackage includesPackagedClassNamed:aClass name) ifTrue:[
|
1673
|
520 |
defaultPackage removedClassNamed:aClass name.
|
1268
|
521 |
].
|
|
522 |
defaultPackage addedClass:aClass.
|
|
523 |
].
|
|
524 |
|
|
525 |
oldOwnerPackage == newOwnerPackage ifTrue:[
|
1673
|
526 |
(oldOwnerPackage includesPackagedClassNamed:aClass name) ifFalse:[
|
|
527 |
self setClass:aClass toPackage:newOwnerPackage.
|
|
528 |
oldOwnerPackage addedClass:aClass.
|
|
529 |
].
|
|
530 |
^ self.
|
1268
|
531 |
].
|
|
532 |
"change the value of package to the new name... not sure if this is the correct place for this"
|
|
533 |
(oldOwnerPackage notNil
|
1673
|
534 |
and:[aClass package == oldOwnerPackage name]) ifTrue:[
|
|
535 |
self setClass:aClass toPackage:newOwnerPackage.
|
1231
|
536 |
].
|
|
537 |
|
1268
|
538 |
self moveClassNamed:aClass name fromPackage:oldOwnerPackage toPackage:newOwnerPackage.
|
1231
|
539 |
!
|
|
540 |
|
1673
|
541 |
moveClassNamed:aClassName fromPackage:fromPackage toPackage:newOwnerPackage
|
1268
|
542 |
"i have the responsibilty to set aClasses new variable (newOwnerPackage name) and
|
|
543 |
all the methods in aClass with the same package name!!
|
|
544 |
"
|
|
545 |
| oldOwnerPackage oldOwnerPackageIncludesMovingClass oldPackageMovingClass newPackagedClass |
|
|
546 |
|
|
547 |
oldOwnerPackage := fromPackage.
|
|
548 |
oldPackageMovingClass := (oldOwnerPackage packagedClassNamed:aClassName).
|
|
549 |
oldOwnerPackageIncludesMovingClass := oldPackageMovingClass notNil.
|
|
550 |
|
|
551 |
oldOwnerPackageIncludesMovingClass ifFalse:[
|
1673
|
552 |
self error:'Error ', fromPackage name, ' does not know this class!!'.
|
|
553 |
^ self.
|
1268
|
554 |
].
|
1231
|
555 |
|
1268
|
556 |
(oldOwnerPackage == newOwnerPackage) ifTrue:[
|
1673
|
557 |
"Mmm interesting. There is not much to do here. oldOwnerPackage knows the class already"
|
|
558 |
^ self
|
1268
|
559 |
].
|
|
560 |
(newPackagedClass := newOwnerPackage packagedClassNamed:aClassName) ifNotNil:[
|
1673
|
561 |
PackageError raiseErrorString:newOwnerPackage name, ' already knows a class with this name. Remove this class from here first!!'.
|
|
562 |
^ self.
|
1268
|
563 |
].
|
|
564 |
oldOwnerPackage movedClassNamed:aClassName toPackage:newOwnerPackage
|
|
565 |
!
|
|
566 |
|
1673
|
567 |
moveMethod:aMethod toPackage:newOwnerPackage
|
1268
|
568 |
|oldOwnerPackage|
|
|
569 |
|
|
570 |
aMethod mclass ifNil:[
|
1673
|
571 |
self error:'Cannot move a method without an owning class!!'
|
1268
|
572 |
].
|
|
573 |
|
|
574 |
oldOwnerPackage := self packageNamed:aMethod package ifAbsent:[defaultPackage].
|
|
575 |
|
1673
|
576 |
self setMethod:aMethod toPackage:newOwnerPackage.
|
1279
|
577 |
(oldOwnerPackage definesSelector:aMethod name forClassNamed:(aMethod mclass name asSymbol)) ifFalse:[
|
1673
|
578 |
newOwnerPackage addedMethod:aMethod.
|
|
579 |
^ self
|
1268
|
580 |
].
|
1231
|
581 |
oldOwnerPackage movedMethod:aMethod toPackage:newOwnerPackage
|
|
582 |
!
|
|
583 |
|
1268
|
584 |
removeClassNamed:aClass fromPackage:fromPackage
|
|
585 |
^ self removeClassNamed:aClass fromPackage:fromPackage moveToDefaultPackage:true.
|
|
586 |
!
|
|
587 |
|
|
588 |
removeClassNamed:removeClassName fromPackage:fromPackage moveToDefaultPackage:moveToDefaultPackage
|
|
589 |
"this is different from removing a class from a system. If you want to do that do
|
|
590 |
aClass removeFromSystem and the package manager will react!!
|
|
591 |
|
|
592 |
This is an administration remove on the packages and just moves aClass to the responsibility
|
|
593 |
of the package manager's default class and removes all responsibilites from fromPackage.
|
|
594 |
|
|
595 |
"
|
|
596 |
| overriddingPackage overriddingPackageName removingPackagedClass |
|
|
597 |
removingPackagedClass := (fromPackage packagedClassNamed:removeClassName).
|
|
598 |
(self includesPackage:fromPackage) ifFalse:[
|
1673
|
599 |
self error:'The package manager does not know of the package ', fromPackage name.
|
1268
|
600 |
].
|
|
601 |
|
|
602 |
fromPackage == defaultPackage ifTrue:[
|
1673
|
603 |
"when the packaged class is in the defaultClass it is removed from the system!!!!"
|
|
604 |
^ removingPackagedClass removeFromSystem.
|
1231
|
605 |
].
|
1268
|
606 |
"if the fromPackage has been overridden all that needs to be done is that the
|
|
607 |
packages that the fromPackage has overridden needs to be swapped to the package that
|
|
608 |
the fromPackage has been overridden by. Then it can be removed from the fromPackage"
|
|
609 |
removingPackagedClass isInSmalltalk ifFalse:[
|
1673
|
610 |
overriddingPackageName := (fromPackage overriddingPackageNameAtClassName:removeClassName).
|
|
611 |
overriddingPackage := self packageNamed:overriddingPackageName.
|
|
612 |
overriddingPackage ifNotNil:[
|
|
613 |
self packagesDo:[:aPackage |
|
|
614 |
(fromPackage ~= aPackage and:[aPackage ~= defaultPackage]) ifTrue:[
|
|
615 |
((aPackage overriddenClassNamesByPackage:fromPackage) includes:removeClassName) ifTrue:[
|
|
616 |
"to keep class in smalltalk"
|
1268
|
617 |
|
1673
|
618 |
aPackage changePackageOverrideFromPackage:fromPackage toPackage:overriddingPackage
|
|
619 |
forClassNamed:removeClassName.
|
|
620 |
].
|
|
621 |
].
|
|
622 |
].
|
|
623 |
^ removingPackagedClass removeFromPackage.
|
|
624 |
].
|
1268
|
625 |
].
|
|
626 |
|
|
627 |
"when we are here the fromPackage holds the currentRepresentation of the class in Smalltalk"
|
|
628 |
moveToDefaultPackage ifTrue:[ | return |
|
1673
|
629 |
self setClass:removingPackagedClass classInSmalltalk toPackage:defaultPackage.
|
|
630 |
self packagesDo:[:aPackage |
|
|
631 |
((aPackage overriddenClassNamesByPackage:fromPackage) includes:removeClassName) ifTrue:[
|
|
632 |
"to keep class in smalltalk"
|
|
633 |
aPackage changePackageOverrideFromPackage:fromPackage toPackage:defaultPackage
|
|
634 |
forClassNamed:removeClassName.
|
|
635 |
].
|
|
636 |
].
|
|
637 |
return := removingPackagedClass removeFromPackage.
|
|
638 |
removingPackagedClass package:defaultPackage.
|
|
639 |
defaultPackage addedPackagedClass:removingPackagedClass.
|
|
640 |
^ return
|
1268
|
641 |
].
|
|
642 |
|
|
643 |
^ removingPackagedClass removeFromSystem.
|
1231
|
644 |
!
|
|
645 |
|
|
646 |
removeMethod:aMethod fromPackage:aPackage
|
|
647 |
"add method to a package. At this point it is determined to be a loose method or not"
|
|
648 |
(self includesPackage:aPackage) ifFalse:[
|
1673
|
649 |
self error:'The package manager does not know of the package ', aPackage name.
|
1231
|
650 |
].
|
|
651 |
aPackage removedMethod:aMethod
|
|
652 |
!
|
|
653 |
|
1673
|
654 |
savePackage:aPackage
|
1231
|
655 |
self savePackage:aPackage as:aPackage filename.
|
|
656 |
!
|
|
657 |
|
|
658 |
savePackage:aPackage as:aFilename
|
|
659 |
"saves a package that the receiver is aware of if not raise an error
|
|
660 |
for the sender to catch so it is able to handle it"
|
|
661 |
(self includesPackage:aPackage) ifFalse:[
|
1673
|
662 |
self error:'This package manager is not responsible of the package ', aPackage name,' so it cannot be saved!!'
|
1231
|
663 |
].
|
|
664 |
|
|
665 |
(self getPackageHandlerForPackage:aPackage) savePackageAs:aFilename.
|
|
666 |
^ aPackage.
|
|
667 |
!
|
|
668 |
|
1673
|
669 |
uninstallPackage:aPackage
|
1231
|
670 |
"need to include the restoration of packages aPackage has overridden!!!!!!!!"
|
|
671 |
(self includesPackage:aPackage) ifFalse:[
|
1673
|
672 |
self error:'The package manager does not know of the package ', aPackage name,' so it cannot be uninstalled!!'
|
1231
|
673 |
].
|
|
674 |
|
1268
|
675 |
(self isBasePackage:aPackage) ifTrue:[
|
1673
|
676 |
self error:aPackage name asString, ' is a base package and cannot be uninstalled!!'.
|
1268
|
677 |
].
|
|
678 |
|
|
679 |
aPackage uninstallFromManager:self.
|
1231
|
680 |
!
|
|
681 |
|
1673
|
682 |
unloadPackage:aPackage
|
1231
|
683 |
"unloads the package from the receiver.Does not need to
|
|
684 |
make any checks here as it is not installed."
|
|
685 |
|
|
686 |
(self includesPackage:aPackage) ifFalse:[
|
1673
|
687 |
self error:'The package manager does not know of the package ', aPackage name.
|
1231
|
688 |
].
|
|
689 |
|
1268
|
690 |
(self isBasePackage:aPackage) ifTrue:[
|
1673
|
691 |
self error:aPackage name asString, ' is a base package and cannot be unloaded!!'.
|
1268
|
692 |
].
|
|
693 |
|
1231
|
694 |
aPackage isInstalled ifTrue:[
|
1673
|
695 |
self uninstallPackage:aPackage.
|
1231
|
696 |
].
|
|
697 |
self removePackage:aPackage.
|
1279
|
698 |
aPackage removeFromSystem.
|
1268
|
699 |
self changed:#unloadPackage: with:aPackage.
|
1231
|
700 |
^ aPackage.
|
1268
|
701 |
!
|
|
702 |
|
1673
|
703 |
unloadPackageNamed:aPackageName
|
1268
|
704 |
"unloads the package from the receiver.Does not need to
|
|
705 |
make any checks here as it is not installed."
|
|
706 |
| aPackage |
|
|
707 |
(self includesPackageNamed:aPackageName) ifFalse:[
|
1673
|
708 |
self error:'The package manager does not know of the package ', aPackageName.
|
1268
|
709 |
].
|
|
710 |
aPackage := self packageNamed:aPackageName.
|
|
711 |
aPackage == workingPackage ifTrue:[
|
1673
|
712 |
PackageNotification raiseUnloadingWorkingPackage:aPackageName.
|
|
713 |
workingPackage := defaultPackage.
|
1268
|
714 |
].
|
|
715 |
|
|
716 |
self unloadPackage:aPackage.
|
|
717 |
! !
|
|
718 |
|
|
719 |
!PackageManager methodsFor:'basic admin'!
|
|
720 |
|
1673
|
721 |
setClass:aClass toPackage:newOwnerPackage
|
1268
|
722 |
"sets the variable package in both class and methods belonging to the class
|
|
723 |
but only with the same name as the classes old package"
|
|
724 |
|oldOwnerPackageName newOwnerPackageName|
|
|
725 |
newOwnerPackageName := newOwnerPackage name.
|
|
726 |
oldOwnerPackageName := aClass package.
|
1673
|
727 |
aClass setPackage:newOwnerPackageName.
|
1268
|
728 |
aClass methodDictionary copy keysAndValuesDo:[:aMethodName :aMethod |
|
1673
|
729 |
aMethod package == oldOwnerPackageName ifTrue:[
|
|
730 |
aMethod setPackage:newOwnerPackageName
|
|
731 |
].
|
1268
|
732 |
].
|
1279
|
733 |
|
|
734 |
aClass class methodDictionary copy keysAndValuesDo:[:aMethodName :aMethod |
|
1673
|
735 |
aMethod package == oldOwnerPackageName ifTrue:[
|
|
736 |
aMethod setPackage:newOwnerPackageName
|
|
737 |
].
|
1279
|
738 |
].
|
1268
|
739 |
!
|
|
740 |
|
1673
|
741 |
setMethod:aMethod toPackage:newOwnerPackage
|
1268
|
742 |
"sets the variable package"
|
1673
|
743 |
aMethod setPackage:newOwnerPackage name.
|
1231
|
744 |
! !
|
|
745 |
|
|
746 |
!PackageManager methodsFor:'change & update'!
|
|
747 |
|
|
748 |
changeSetChanged:something with:aChange from:changedObject
|
|
749 |
"find out what type of change it is and send the packages the corresponding
|
|
750 |
message to is if they are affected. If they are they should (if they are behaving)
|
|
751 |
send me a change notification to inform me about it(see packageChanged:with:from:)!!
|
|
752 |
"
|
1268
|
753 |
| classNameOfChange packageName changeClass changeMethod |
|
1231
|
754 |
aChange isCollection ifTrue:[
|
1673
|
755 |
something == #removeAll: ifTrue:[
|
|
756 |
"happens after checking in"
|
1279
|
757 |
"/ self smalltalkChanges removeAll:aChange
|
1673
|
758 |
].
|
|
759 |
^ self "do i need to do anything???"
|
1231
|
760 |
].
|
|
761 |
(aChange isClassChange) ifFalse:[
|
1673
|
762 |
self error:' What is this???'.
|
|
763 |
].
|
1231
|
764 |
|
1268
|
765 |
(aChange isKindOf:self methodPackageChangeClass) ifTrue:[| aMethod methodOwnedClass oldPackageName |
|
1673
|
766 |
aMethod := aChange previousVersion.
|
|
767 |
methodOwnedClass := aChange changeClass.
|
|
768 |
oldPackageName := aChange oldPackageName.
|
|
769 |
self methodPackageChange:aMethod class:methodOwnedClass oldPackageName:oldPackageName.
|
|
770 |
^ self
|
1268
|
771 |
].
|
|
772 |
(aChange isKindOf:self classPackageChangeClass) ifTrue:[| classToMove oldPackageName |
|
1673
|
773 |
classToMove := aChange changeClass.
|
|
774 |
oldPackageName := aChange oldPackageName.
|
|
775 |
self classPackageChange:classToMove oldPackageName:oldPackageName.
|
|
776 |
^ self
|
1268
|
777 |
].
|
|
778 |
|
1231
|
779 |
(aChange isMethodCategoryChange) ifTrue:[
|
1673
|
780 |
self packagesDo:[:aPackage |
|
|
781 |
"(aPackage isDependentOnMethodNamed:aChange selector forClassNamed:aChange className)" false ifTrue:[
|
|
782 |
aPackage methodCategoryChange:aChange.
|
|
783 |
].
|
|
784 |
].
|
|
785 |
^ self
|
1231
|
786 |
].
|
|
787 |
|
|
788 |
"the following is similar to the one above"
|
|
789 |
(aChange isMethodCategoryRenameChange) ifTrue:[
|
1673
|
790 |
self packagesDo:[:aPackage |
|
|
791 |
"(aPackage isDependentOnMethodNamed:aChange selector forClassNamed:aChange className)" false ifTrue:[
|
|
792 |
aPackage methodCategoryRenameChange:aChange.
|
|
793 |
].
|
|
794 |
].
|
|
795 |
^ self
|
1231
|
796 |
].
|
|
797 |
|
1268
|
798 |
(aChange isMethodRemoveChange) ifTrue:[
|
1673
|
799 |
self packagesDo:[:aPackage |
|
|
800 |
(aPackage isDependentOnMethodNamed:aChange selector forClassNamed:aChange className) ifTrue:[
|
|
801 |
aChange previousVersion ifNotNil:[
|
|
802 |
aPackage methodRemoveChange:aChange.
|
|
803 |
].
|
|
804 |
].
|
|
805 |
].
|
|
806 |
^ self
|
1231
|
807 |
].
|
|
808 |
|
1268
|
809 |
(aChange isMethodChange) ifTrue:[
|
1673
|
810 |
"A new created method or a modified method"
|
|
811 |
changeMethod := aChange changeMethod.
|
|
812 |
packageName := changeMethod package.
|
1268
|
813 |
|
1673
|
814 |
self packagesDo:[:aPackage |
|
|
815 |
(Switch new)
|
|
816 |
if:[(aPackage name == packageName)] then:[
|
|
817 |
self addMethod:changeMethod toPackage:aPackage];
|
|
818 |
if:[(aPackage isDependentOnMethodNamed:aChange selector forClassNamed:aChange className)] then:[
|
|
819 |
aPackage methodChanged:aChange];
|
|
820 |
value.
|
|
821 |
].
|
|
822 |
^ self
|
1231
|
823 |
].
|
|
824 |
|
|
825 |
aChange isClassChange ifTrue:[
|
1673
|
826 |
(aChange isClassRemoveChange) ifTrue:[
|
|
827 |
"results in one package being overridden by Smalltalk"
|
|
828 |
classNameOfChange := aChange className asSymbol.
|
|
829 |
self packagesDo:[:aPackage |
|
|
830 |
(Switch new)
|
|
831 |
if:[(aPackage isDependentOnClassNamed:classNameOfChange)] then:[
|
|
832 |
aPackage classRemoveChange:aChange];
|
|
833 |
value.
|
|
834 |
].
|
|
835 |
^ self
|
|
836 |
].
|
1231
|
837 |
|
1673
|
838 |
(aChange isClassDefinitionChange) ifTrue:[
|
|
839 |
"This change is not added to the working class"
|
|
840 |
"changes to instance variables, classVariableNames, poolDictionaries, category"
|
1268
|
841 |
|
1673
|
842 |
classNameOfChange := aChange className asSymbol.
|
|
843 |
changeClass := aChange changeClass.
|
|
844 |
packageName := changeClass package.
|
1268
|
845 |
|
1673
|
846 |
self packagesDo:[:aPackage |
|
|
847 |
(Switch new)
|
|
848 |
if:[(aPackage name == packageName)] then:[
|
|
849 |
(aPackage includesPackagedClassNamed:classNameOfChange) ifTrue:[
|
|
850 |
aPackage removedClassNamed:classNameOfChange.
|
|
851 |
].
|
|
852 |
aPackage addedClass:changeClass];
|
|
853 |
if:[(aPackage isDependentOnClassNamed:classNameOfChange)] then:[
|
|
854 |
aPackage classDefinitionChange:aChange];
|
|
855 |
value.
|
1268
|
856 |
|
1673
|
857 |
].
|
|
858 |
^ self
|
1231
|
859 |
|
1673
|
860 |
].
|
|
861 |
(aChange isClassInstVarDefinitionChange) ifTrue:[
|
|
862 |
"This change is not added to the working class"
|
|
863 |
"changes to instance variables, classVariableNames, poolDictionaries, category"
|
1268
|
864 |
|
1673
|
865 |
classNameOfChange := aChange className.
|
|
866 |
changeClass := aChange changeClass.
|
|
867 |
packageName := changeClass package.
|
1268
|
868 |
|
1673
|
869 |
self packagesDo:[:aPackage |
|
|
870 |
(Switch new)
|
|
871 |
if:[(aPackage name == packageName) ] then:[
|
|
872 |
aPackage addedClass:changeClass];
|
|
873 |
if:[(aPackage isDependentOnClassNamed:classNameOfChange) ] then:[
|
|
874 |
aPackage classInstVarDefinitionChange:aChange].
|
|
875 |
].
|
|
876 |
^ self
|
|
877 |
].
|
|
878 |
(aChange isClassRenameChange) ifTrue:[
|
|
879 |
"This change is not added to the working class"
|
|
880 |
classNameOfChange := aChange className.
|
|
881 |
changeClass := aChange changeClass.
|
|
882 |
packageName := changeClass package.
|
1268
|
883 |
|
1673
|
884 |
self packagesDo:[:aPackage |
|
|
885 |
(Switch new)
|
|
886 |
if:[(aPackage name == packageName) ] then:[
|
|
887 |
aPackage addedClass:changeClass];
|
|
888 |
if:[(aPackage isDependentOnClassNamed:classNameOfChange) ] then:[
|
|
889 |
aPackage classRenameChange:aChange];
|
|
890 |
value.
|
|
891 |
].
|
|
892 |
^ self
|
|
893 |
].
|
1231
|
894 |
|
1673
|
895 |
self breakPoint:''.
|
1231
|
896 |
].
|
1244
|
897 |
self breakPoint:''.
|
1231
|
898 |
!
|
|
899 |
|
1268
|
900 |
classPackageChange:classToOverride oldPackageName:oldPackageName
|
1231
|
901 |
"reacts to a class package change
|
|
902 |
Assertion:
|
1673
|
903 |
aClass package ~= oldPackageName
|
1231
|
904 |
"
|
1673
|
905 |
|
|
906 |
self setClass:classToOverride toPackage:(self packageNamed:oldPackageName).
|
1268
|
907 |
self error:'Sorry, this function is no longer available other than within the packageBrowser. ', Character cr asString,
|
1673
|
908 |
Character cr asString, ' This action has done nothing!!'.
|
1231
|
909 |
|
1268
|
910 |
"/ | newPackageName newOwnerPackage|
|
|
911 |
"/ newPackageName := classToOverride package.
|
1673
|
912 |
"/ newOwnerPackage := self packageNamed:newPackageName ifAbsent:[self newPackageNamed:newPackageName].
|
1268
|
913 |
"/
|
|
914 |
"/ "fake this... maybe this is a kludge..."
|
1673
|
915 |
"/ self setClass:classToOverride toPackage:(self packageNamed:oldPackageName).
|
1268
|
916 |
"/
|
|
917 |
"/ self addClass:classToOverride toPackage:newOwnerPackage.
|
1231
|
918 |
!
|
|
919 |
|
|
920 |
methodPackageChange:aMethod class:methodOwnedClass oldPackageName:oldPackageName
|
|
921 |
|
1673
|
922 |
self setMethod:aMethod toPackage:(self packageNamed:oldPackageName).
|
1279
|
923 |
Transcript nextPutAll:'Sorry, this function is no longer available other than within the packageBrowser. ', Character cr asString,
|
1673
|
924 |
Character cr asString, ' This action has done nothing!! >>methodPackageChange:aMethod class:methodOwnedClass oldPackageName:oldPackageName'.
|
1268
|
925 |
|
1231
|
926 |
|
1268
|
927 |
"/ | newPackageName oldOwnerPackage newOwnerPackage|
|
|
928 |
"/
|
|
929 |
"/ newPackageName := aMethod package.
|
|
930 |
"/ oldOwnerPackage :=(self packageNamed:oldPackageName).
|
|
931 |
"/ newOwnerPackage := (self packageNamed:newPackageName).
|
|
932 |
"/
|
|
933 |
"/ newOwnerPackage ifNil:[
|
|
934 |
"/ PackageError raiseErrorString:'The package ', newPackageName, ' is not known',
|
|
935 |
"/ ' to this packageManager', ' and so cannot realise this methodPackageChange'
|
|
936 |
"/
|
|
937 |
"/ ].
|
|
938 |
"/
|
|
939 |
"/ oldOwnerPackage ifNil:[
|
|
940 |
"/ PackageError raiseErrorString:'The package ', oldPackageName, ' is not known',
|
|
941 |
"/ ' to this packageManager', ' and so cannot realise this methodPackageChange'
|
|
942 |
"/ ].
|
|
943 |
"/
|
|
944 |
"/ oldOwnerPackage movedMethod:aMethod toPackage:newOwnerPackage
|
1231
|
945 |
!
|
|
946 |
|
|
947 |
packageChanged:something with:aParameter from:changedObject
|
|
948 |
"maybe send a change notification for views here???"
|
|
949 |
"/ self halt.
|
1268
|
950 |
self addChange:aParameter.
|
|
951 |
self changed:#packagedChanged with:changedObject
|
1231
|
952 |
!
|
|
953 |
|
|
954 |
update:something with:aParameter from:changedObject
|
1268
|
955 |
|
|
956 |
(self includesPackage:changedObject) ifTrue:[
|
1673
|
957 |
self packageChanged:something with:aParameter from:changedObject.
|
|
958 |
^ self.
|
1231
|
959 |
].
|
|
960 |
(changedObject == ChangeSet current) ifTrue:[
|
1673
|
961 |
self changeSetChanged:something with:aParameter from:changedObject.
|
|
962 |
^ self.
|
1231
|
963 |
].
|
|
964 |
! !
|
|
965 |
|
|
966 |
!PackageManager methodsFor:'checks'!
|
|
967 |
|
1673
|
968 |
canLoadPackage:aPackage
|
1231
|
969 |
""
|
|
970 |
(self includesPackage:aPackage) ifTrue:[
|
1673
|
971 |
Notification raise.
|
1231
|
972 |
].
|
|
973 |
! !
|
|
974 |
|
|
975 |
!PackageManager methodsFor:'enumarating'!
|
|
976 |
|
|
977 |
packagesDo:aOneArgBlock
|
1268
|
978 |
"should this or should this not include the defaultPackage??? should it
|
|
979 |
be treated seperately?"
|
1673
|
980 |
aOneArgBlock value:defaultPackage.
|
1231
|
981 |
super packagesDo:aOneArgBlock.
|
1268
|
982 |
!
|
|
983 |
|
|
984 |
packagesSelect:aOneArgBlock
|
|
985 |
"should this or should this not include the defaultPackage??? should it
|
|
986 |
be treated seperately?"
|
|
987 |
| selectedPackages |
|
|
988 |
selectedPackages := (self packages select:aOneArgBlock).
|
|
989 |
|
|
990 |
(aOneArgBlock value:defaultPackage) ifTrue:[
|
1673
|
991 |
selectedPackages add:defaultPackage.
|
1268
|
992 |
].
|
|
993 |
^ selectedPackages
|
1231
|
994 |
! !
|
|
995 |
|
|
996 |
!PackageManager methodsFor:'errors'!
|
|
997 |
|
|
998 |
recoveryHandlerDo:aBlock forException:packageErrorClass
|
|
999 |
"an atomic action is about to happen. This should succeed or
|
|
1000 |
fail and return to the previous state."
|
1673
|
1001 |
|
1231
|
1002 |
"to do - this could be done by an extra class.
|
|
1003 |
could save the state of the receiver before this action is done
|
|
1004 |
along with a 'transaction number' held in the receivers class to make
|
|
1005 |
sure we are consistant. The hard copy could then be the backup. This
|
|
1006 |
all depends on how long it takes to make the backup and how often
|
|
1007 |
we are going to do this.
|
|
1008 |
"
|
|
1009 |
packageErrorClass handle:[:ex |
|
1673
|
1010 |
Transcript show:ex errorString.
|
1231
|
1011 |
] do:[
|
1673
|
1012 |
aBlock value
|
1231
|
1013 |
]
|
|
1014 |
! !
|
|
1015 |
|
|
1016 |
!PackageManager methodsFor:'factory'!
|
|
1017 |
|
1268
|
1018 |
classPackageChangeClass
|
|
1019 |
^ Smalltalk classNamed:#'Packages::ChangeFaker::ClassPackageChange'
|
|
1020 |
!
|
|
1021 |
|
1673
|
1022 |
getPackageSaverForPackage:aPackage
|
|
1023 |
^ StxPackageFileWriter forPackage:aPackage
|
1231
|
1024 |
!
|
|
1025 |
|
1268
|
1026 |
methodPackageChangeClass
|
|
1027 |
^ Smalltalk classNamed:#'Packages::ChangeFaker::MethodPackageChange'
|
|
1028 |
!
|
|
1029 |
|
1673
|
1030 |
newPackageNamed:aString
|
1231
|
1031 |
| newPackage |
|
|
1032 |
|
|
1033 |
(self includesPackageNamed:aString) ifTrue:[
|
1673
|
1034 |
PackageError raiseCannotAddAsPackageManagerAlreadyIncludesPackageNamed:aString
|
1231
|
1035 |
].
|
1673
|
1036 |
|
1231
|
1037 |
newPackage := self packageClass named:aString addToManager:self.
|
|
1038 |
newPackage initializeInstalled.
|
|
1039 |
^ newPackage
|
|
1040 |
!
|
|
1041 |
|
|
1042 |
packageClass
|
|
1043 |
^ Package
|
|
1044 |
! !
|
|
1045 |
|
|
1046 |
!PackageManager methodsFor:'initialization'!
|
|
1047 |
|
|
1048 |
initialize
|
1268
|
1049 |
defaultPackage := self class defaultPackage.
|
|
1050 |
workingPackage := defaultPackage.
|
1231
|
1051 |
super initialize.
|
|
1052 |
!
|
|
1053 |
|
|
1054 |
uninitialize
|
|
1055 |
|
|
1056 |
self packagesDo:[:aPackage |
|
1673
|
1057 |
self removeDependent:aPackage.
|
1231
|
1058 |
].
|
1268
|
1059 |
defaultPackage removeDependent:self.
|
1231
|
1060 |
|
|
1061 |
packages := nil.
|
|
1062 |
super uninitialize.
|
|
1063 |
! !
|
|
1064 |
|
|
1065 |
!PackageManager methodsFor:'private-opening'!
|
|
1066 |
|
1673
|
1067 |
getPackageHandlerForPackage:aPackage
|
1231
|
1068 |
|
|
1069 |
| aPackageHandler |
|
|
1070 |
|
|
1071 |
(aPackageHandler := aPackage packageHandler) ifNil:[
|
1673
|
1072 |
aPackageHandler := PackageHandler forPackage:aPackage.
|
1231
|
1073 |
].
|
|
1074 |
|
|
1075 |
^ aPackageHandler
|
|
1076 |
!
|
|
1077 |
|
1673
|
1078 |
getPackageReaderForFile:aFilename
|
1231
|
1079 |
^ StxPackageFileReader forFilename:aFilename
|
|
1080 |
! !
|
|
1081 |
|
|
1082 |
!PackageManager methodsFor:'queries'!
|
|
1083 |
|
1673
|
1084 |
includesPackage:anObject
|
1268
|
1085 |
^ ((packages includes:anObject)or:[defaultPackage == anObject])
|
|
1086 |
!
|
|
1087 |
|
|
1088 |
isBasePackage:aPackage
|
|
1089 |
|
|
1090 |
^ self class basePackageNames includes:aPackage name.
|
1231
|
1091 |
! !
|
|
1092 |
|
|
1093 |
!PackageManager class methodsFor:'documentation'!
|
|
1094 |
|
|
1095 |
version
|
1673
|
1096 |
^ '$Header: /cvs/stx/stx/libbasic3/packages/PackageManager.st,v 1.9 2006-08-24 08:38:42 cg Exp $'
|
1231
|
1097 |
! !
|
|
1098 |
|
|
1099 |
PackageManager initialize!
|