author | Claus Gittinger <cg@exept.de> |
Thu, 13 Apr 2006 17:21:40 +0200 | |
changeset 6765 | bc3cd5c94ac4 |
parent 6745 | 8f0c86593679 |
child 6794 | c55a036a249e |
permissions | -rw-r--r-- |
5591 | 1 |
" |
2 |
COPYRIGHT (c) 2000 by eXept Software AG |
|
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 |
||
5592 | 13 |
"{ Package: 'stx:libtool' }" |
5591 | 14 |
|
15 |
"{ NameSpace: Tools }" |
|
16 |
||
17 |
BrowserList subclass:#NamespaceList |
|
18 |
instanceVariableNames:'namespaceNameList namespaceList' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Browsers-New' |
|
22 |
! |
|
23 |
||
24 |
!NamespaceList class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2000 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! ! |
|
39 |
||
40 |
!NamespaceList class methodsFor:'interface specs'! |
|
41 |
||
42 |
singleNameSpaceWindowSpec |
|
43 |
"This resource specification was automatically generated |
|
44 |
by the UIPainter of ST/X." |
|
45 |
||
46 |
"Do not manually edit this!! If it is corrupted, |
|
47 |
the UIPainter may not be able to read the specification." |
|
48 |
||
49 |
" |
|
50 |
UIPainter new openOnClass:ClassCategoryList andSelector:#singleCategoryWindowSpec |
|
51 |
ClassCategoryList new openInterface:#singleCategoryWindowSpec |
|
52 |
" |
|
53 |
||
54 |
<resource: #canvas> |
|
55 |
||
56 |
^ |
|
57 |
#(#FullSpec |
|
5592 | 58 |
#name: #singleNameSpaceWindowSpec |
59 |
#window: |
|
5591 | 60 |
#(#WindowSpec |
5592 | 61 |
#label: 'NameSpaceList' |
62 |
#name: 'NameSpaceList' |
|
63 |
#min: #(#Point 0 0) |
|
64 |
#max: #(#Point 1024 721) |
|
65 |
#bounds: #(#Rectangle 218 175 518 475) |
|
66 |
) |
|
67 |
#component: |
|
5591 | 68 |
#(#SpecCollection |
5592 | 69 |
#collection: #( |
70 |
#(#LabelSpec |
|
71 |
#label: 'NameSpaceName' |
|
72 |
#name: 'NameSpaceLabel' |
|
73 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 25 0) |
|
74 |
#translateLabel: true |
|
75 |
#labelChannel: #nameSpaceLabelHolder |
|
76 |
#menu: #menuHolder |
|
77 |
) |
|
78 |
) |
|
5591 | 79 |
|
5592 | 80 |
) |
5591 | 81 |
) |
82 |
! |
|
83 |
||
84 |
windowSpec |
|
85 |
"This resource specification was automatically generated |
|
86 |
by the UIPainter of ST/X." |
|
87 |
||
88 |
"Do not manually edit this!! If it is corrupted, |
|
89 |
the UIPainter may not be able to read the specification." |
|
90 |
||
91 |
" |
|
92 |
UIPainter new openOnClass:ProjectList andSelector:#windowSpec |
|
93 |
ProjectList new openInterface:#windowSpec |
|
94 |
ProjectList open |
|
95 |
" |
|
96 |
||
97 |
<resource: #canvas> |
|
98 |
||
99 |
^ |
|
100 |
#(#FullSpec |
|
5592 | 101 |
#name: #windowSpec |
102 |
#window: |
|
5591 | 103 |
#(#WindowSpec |
5592 | 104 |
#label: 'NamespaceList' |
105 |
#name: 'NamespaceList' |
|
106 |
#min: #(#Point 0 0) |
|
107 |
#max: #(#Point 1024 721) |
|
108 |
#bounds: #(#Rectangle 13 23 313 323) |
|
109 |
) |
|
110 |
#component: |
|
5591 | 111 |
#(#SpecCollection |
5592 | 112 |
#collection: #( |
113 |
#(#SequenceViewSpec |
|
114 |
#name: 'List' |
|
115 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
116 |
#tabable: true |
|
117 |
#model: #selectedNamespaces |
|
118 |
#menu: #menuHolder |
|
119 |
#hasHorizontalScrollBar: true |
|
120 |
#hasVerticalScrollBar: true |
|
121 |
#miniScrollerHorizontal: true |
|
122 |
#isMultiSelect: true |
|
123 |
#valueChangeSelector: #selectionChangedByClick |
|
124 |
#useIndex: false |
|
125 |
#sequenceList: #nameSpaceList |
|
126 |
#doubleClickChannel: #doubleClickChannel |
|
127 |
) |
|
128 |
) |
|
5591 | 129 |
|
5592 | 130 |
) |
5591 | 131 |
) |
132 |
||
133 |
"Created: / 18.2.2000 / 01:06:05 / cg" |
|
134 |
"Modified: / 18.2.2000 / 01:24:50 / cg" |
|
135 |
! ! |
|
136 |
||
137 |
!NamespaceList class methodsFor:'queries-plugin'! |
|
138 |
||
139 |
aspectSelectors |
|
140 |
^ #( |
|
141 |
#(#doubleClickChannel #action ) |
|
142 |
immediateUpdate |
|
143 |
selectedNamespaces |
|
144 |
menuHolder |
|
145 |
inGeneratorHolder |
|
146 |
outGeneratorHolder |
|
147 |
selectionChangeCondition |
|
148 |
updateTrigger |
|
149 |
forceGeneratorTrigger |
|
150 |
hideUnloadedClasses |
|
151 |
organizerMode |
|
152 |
slaveMode |
|
153 |
) |
|
154 |
||
155 |
"Created: / 18.2.2000 / 01:06:27 / cg" |
|
156 |
"Modified: / 25.2.2000 / 22:32:20 / cg" |
|
157 |
! ! |
|
158 |
||
159 |
!NamespaceList methodsFor:'aspects'! |
|
160 |
||
161 |
nameSpaceLabelHolder |
|
162 |
^ self pseudoListLabelHolder |
|
163 |
! |
|
164 |
||
165 |
nameSpaceList |
|
166 |
namespaceList isNil ifTrue:[ |
|
167 |
namespaceList := ValueHolder new |
|
168 |
]. |
|
169 |
^ namespaceList |
|
170 |
||
171 |
"Created: / 18.2.2000 / 00:59:01 / cg" |
|
172 |
! |
|
173 |
||
174 |
selectedNamespaces |
|
175 |
^ self selectionHolder |
|
176 |
||
177 |
! |
|
178 |
||
179 |
selectedNamespaces:aValueHolder |
|
180 |
^ self selectionHolder:aValueHolder |
|
181 |
||
182 |
! ! |
|
183 |
||
184 |
!NamespaceList methodsFor:'change & update'! |
|
185 |
||
186 |
delayedUpdate:something with:aParameter from:changedObject |
|
187 |
||
188 |
self inSlaveModeOrInvisible |
|
189 |
ifTrue:[ |
|
190 |
changedObject == Smalltalk ifTrue:[ |
|
191 |
something == #classComment ifTrue:[^ self]. |
|
192 |
]. |
|
193 |
self invalidateList. |
|
194 |
^ self |
|
195 |
]. |
|
196 |
||
197 |
changedObject == slaveMode ifTrue:[ |
|
198 |
listValid ~~ true ifTrue:[ |
|
199 |
self enqueueDelayedUpdateList |
|
200 |
]. |
|
201 |
"/ self invalidateList. |
|
202 |
^ self |
|
203 |
]. |
|
204 |
||
205 |
changedObject == Smalltalk ifTrue:[ |
|
206 |
something == #newClass ifTrue:[ |
|
207 |
listValid == true ifTrue:[ |
|
208 |
aParameter isNameSpace ifTrue:[ |
|
209 |
(namespaceList value includes:aParameter name) ifFalse:[ |
|
210 |
self invalidateList. |
|
211 |
] |
|
212 |
]. |
|
213 |
]. |
|
214 |
^ self |
|
215 |
]. |
|
216 |
something == #classRemove ifTrue:[ |
|
217 |
listValid == true ifTrue:[ |
|
218 |
aParameter isNameSpace ifTrue:[ |
|
219 |
self invalidateList. |
|
220 |
]. |
|
221 |
]. |
|
222 |
^ self |
|
223 |
]. |
|
224 |
^ self |
|
225 |
]. |
|
226 |
||
227 |
super delayedUpdate:something with:aParameter from:changedObject |
|
228 |
||
229 |
"Created: / 18.2.2000 / 01:00:07 / cg" |
|
230 |
"Modified: / 26.2.2000 / 01:10:46 / cg" |
|
231 |
! |
|
232 |
||
233 |
selectionChangedByClick |
|
234 |
"we are not interested in that - get another notification |
|
235 |
via the changed valueHolder" |
|
236 |
||
237 |
"Created: / 18.2.2000 / 01:00:14 / cg" |
|
238 |
! |
|
239 |
||
240 |
update:something with:aParameter from:changedObject |
|
241 |
changedObject == Smalltalk ifTrue:[ |
|
242 |
something == #methodDictionary ifTrue:[ |
|
243 |
^ self |
|
244 |
]. |
|
245 |
something == #methodTrap ifTrue:[ |
|
246 |
^ self |
|
247 |
]. |
|
248 |
something == #methodInClass ifTrue:[ |
|
249 |
^ self |
|
250 |
]. |
|
251 |
something == #classVariables ifTrue:[ |
|
252 |
^ self |
|
253 |
]. |
|
254 |
something == #classComment ifTrue:[ |
|
255 |
^ self. |
|
256 |
]. |
|
257 |
something == #methodInClassRemoved ifTrue:[ |
|
258 |
^ self. |
|
259 |
]. |
|
260 |
]. |
|
261 |
super update:something with:aParameter from:changedObject |
|
262 |
! ! |
|
263 |
||
264 |
!NamespaceList methodsFor:'generators'! |
|
265 |
||
266 |
makeGenerator |
|
267 |
"return a generator which enumerates the classes from the selected namespace(s)." |
|
268 |
||
269 |
|spaceNames hideUnloadedClasses| |
|
270 |
||
271 |
spaceNames := self selectedNamespaces value. |
|
272 |
spaceNames size == 0 ifTrue:[ |
|
273 |
^ #() |
|
274 |
]. |
|
275 |
||
276 |
hideUnloadedClasses := self hideUnloadedClasses value. |
|
277 |
||
278 |
(spaceNames includes:(self class nameListEntryForALL)) ifTrue:[ |
|
279 |
hideUnloadedClasses ifTrue:[ |
|
280 |
^ Iterator on:[:whatToDo | |
|
281 |
Smalltalk allClassesDo:[:cls | |
|
282 |
cls isLoaded ifTrue:[ |
|
283 |
cls isNameSpace ifFalse:[ |
|
284 |
whatToDo value:cls |
|
285 |
] |
|
286 |
] |
|
287 |
] |
|
288 |
] |
|
289 |
]. |
|
290 |
^ Iterator on:[:whatToDo | |
|
291 |
Smalltalk allClassesDo:whatToDo |
|
292 |
] |
|
293 |
]. |
|
294 |
||
295 |
(spaceNames size == 1 |
|
296 |
and:[spaceNames first = 'Smalltalk']) ifTrue:[ |
|
297 |
"/ somewhat tuned - quick look if classes name |
|
298 |
"/ includes colons ... |
|
299 |
^ Iterator on:[:whatToDo | |
|
300 |
Smalltalk allClassesDo:[:cls | |
|
301 |
|includeIt| |
|
302 |
||
303 |
includeIt := (cls name includes:$:) not. |
|
304 |
includeIt := includeIt |
|
305 |
or:[(cls isPrivate not |
|
306 |
and:[(cls nameSpace == Smalltalk)])]. |
|
307 |
includeIt := includeIt |
|
308 |
or:[(cls isPrivate |
|
309 |
and:[(cls topOwningClass nameSpace == Smalltalk)])]. |
|
310 |
||
311 |
includeIt := includeIt |
|
312 |
and:[hideUnloadedClasses not |
|
313 |
or:[cls isLoaded]]. |
|
314 |
includeIt ifTrue:[ |
|
315 |
cls isNameSpace ifFalse:[ |
|
316 |
whatToDo value:cls |
|
317 |
] |
|
318 |
] |
|
319 |
] |
|
320 |
] |
|
321 |
]. |
|
322 |
||
323 |
^ Iterator on:[:whatToDo | |
|
324 |
Smalltalk allClassesDo:[:cls | |
|
325 |
|spaceOfClass spaceNameOfClass includeIt| |
|
326 |
||
327 |
spaceOfClass := cls isPrivate ifTrue:[cls topOwningClass nameSpace] ifFalse:[cls nameSpace]. |
|
328 |
spaceNameOfClass := spaceOfClass name. |
|
329 |
||
330 |
includeIt := spaceNames contains:[:nm | nm = spaceNameOfClass |
|
331 |
or:[spaceNameOfClass startsWith:(nm , '::')]]. |
|
332 |
||
333 |
hideUnloadedClasses ifTrue:[ |
|
334 |
includeIt := includeIt and:[cls isLoaded]. |
|
335 |
]. |
|
336 |
includeIt ifTrue:[ |
|
337 |
cls isNameSpace ifFalse:[ |
|
338 |
whatToDo value:cls |
|
339 |
] |
|
340 |
] |
|
341 |
] |
|
342 |
] |
|
343 |
||
344 |
"Created: / 18.2.2000 / 01:01:58 / cg" |
|
345 |
"Modified: / 24.2.2000 / 13:42:58 / cg" |
|
346 |
! ! |
|
347 |
||
348 |
!NamespaceList methodsFor:'private'! |
|
349 |
||
350 |
defaultSlaveModeValue |
|
6710 | 351 |
|mode| |
352 |
||
353 |
mode := self topApplication perform:#initialOrganizerMode ifNotUnderstood:nil. |
|
6735
72cb810a8786
magic constants (organizerMode) removed
Claus Gittinger <cg@exept.de>
parents:
6710
diff
changeset
|
354 |
mode == OrganizerCanvas organizerModeNamespace ifTrue:[^ false]. |
72cb810a8786
magic constants (organizerMode) removed
Claus Gittinger <cg@exept.de>
parents:
6710
diff
changeset
|
355 |
"/ self organizerMode value == OrganizerCanvas organizerModeCategory ifTrue:[^ true]. |
5591 | 356 |
"/ ^ false |
6745 | 357 |
mode isNil ifTrue:[^ false]. |
5591 | 358 |
^ true |
359 |
! |
|
360 |
||
361 |
initialOrganizerMode |
|
6735
72cb810a8786
magic constants (organizerMode) removed
Claus Gittinger <cg@exept.de>
parents:
6710
diff
changeset
|
362 |
^ OrganizerCanvas organizerModeNamespace |
5591 | 363 |
! |
364 |
||
365 |
listOfNamespaces |
|
366 |
|allNamespaces showAllNamespaces generator| |
|
367 |
||
368 |
showAllNamespaces := false. |
|
369 |
allNamespaces := IdentitySet new. |
|
370 |
||
371 |
inGeneratorHolder isNil ifTrue:[ |
|
6675 | 372 |
(self hideUnloadedClasses value) ifTrue:[ |
373 |
Smalltalk allClassesDo:[:eachClass | |
|
374 |
eachClass isLoaded ifTrue:[ |
|
375 |
allNamespaces add:(eachClass theNonMetaclass topNameSpace) |
|
376 |
]. |
|
377 |
] |
|
378 |
] ifFalse:[ |
|
6679 | 379 |
allNamespaces := NameSpace allNamespaces. |
6675 | 380 |
]. |
5591 | 381 |
|
6675 | 382 |
showAllNamespaces ifFalse:[ |
383 |
"/ only topLevel namespaces are shown |
|
384 |
"/ i.e. ignore subspaces |
|
5591 | 385 |
|
6675 | 386 |
allNamespaces := allNamespaces select:[:ns | ns isTopLevelNameSpace]. |
387 |
]. |
|
388 |
allNamespaces := allNamespaces collect:[:ns | ns name]. |
|
5591 | 389 |
] ifFalse:[ |
6675 | 390 |
generator := inGeneratorHolder value. |
391 |
generator isNil ifTrue:[^ #() ]. |
|
392 |
generator do:[:ns | allNamespaces add:ns]. |
|
5591 | 393 |
]. |
394 |
||
395 |
allNamespaces := allNamespaces asOrderedCollection. |
|
396 |
allNamespaces sort. |
|
397 |
allNamespaces size == 1 ifTrue:[ |
|
6675 | 398 |
self nameSpaceLabelHolder value:(LabelAndIcon icon:(self class nameSpaceIcon) string:allNamespaces first). |
5591 | 399 |
]. |
400 |
allNamespaces addFirst:(self class nameListEntryForALL). |
|
401 |
^ allNamespaces |
|
402 |
||
403 |
"Created: / 18.2.2000 / 01:04:27 / cg" |
|
404 |
"Modified: / 25.2.2000 / 22:11:29 / cg" |
|
405 |
! |
|
406 |
||
407 |
makeDependent |
|
408 |
Smalltalk addDependent:self |
|
409 |
||
410 |
"Created: / 18.2.2000 / 01:04:36 / cg" |
|
411 |
! |
|
412 |
||
413 |
makeIndependent |
|
414 |
Smalltalk removeDependent:self. |
|
415 |
||
416 |
"Created: / 18.2.2000 / 01:04:42 / cg" |
|
417 |
! |
|
418 |
||
419 |
updateList |
|
420 |
|newList oldSelection newSelection selectedNamespacesHolder| |
|
421 |
||
422 |
selectedNamespacesHolder := self selectedNamespaces. |
|
423 |
oldSelection := selectedNamespacesHolder value. |
|
424 |
newList := self listOfNamespaces. |
|
425 |
newList ~= namespaceList value ifTrue:[ |
|
426 |
"/ oldSelection size > 0 ifTrue:[ |
|
427 |
"/ selectedNamespacesHolder removeDependent:self. |
|
428 |
"/ selectedNamespacesHolder value:#(). |
|
429 |
"/ selectedNamespacesHolder addDependent:self. |
|
430 |
"/ ]. |
|
431 |
self nameSpaceList value:newList. |
|
432 |
||
433 |
oldSelection size > 0 ifTrue:[ |
|
434 |
newSelection := oldSelection select:[:nm | |
|
435 |
(nm = self class nameListEntryForALL) |
|
436 |
or:[ (Smalltalk at:nm asSymbol) isNameSpace] |
|
437 |
]. |
|
438 |
newSelection ~= oldSelection ifTrue:[ |
|
439 |
selectedNamespacesHolder value:newSelection. |
|
440 |
] |
|
441 |
] |
|
442 |
]. |
|
443 |
listValid := true. |
|
444 |
! ! |
|
445 |
||
446 |
!NamespaceList class methodsFor:'documentation'! |
|
447 |
||
448 |
version |
|
6765 | 449 |
^ '$Header: /cvs/stx/stx/libtool/Tools_NamespaceList.st,v 1.8 2006-04-13 15:21:40 cg Exp $' |
5591 | 450 |
! ! |