author | Claus Gittinger <cg@exept.de> |
Mon, 11 Sep 2017 09:08:06 +0200 | |
changeset 17686 | c6fc2da19287 |
parent 17286 | 367515a3b9a4 |
child 17379 | 028adf14bc05 |
child 18710 | 518f0f70390b |
permissions | -rw-r--r-- |
10005 | 1 |
" |
2 |
COPYRIGHT (c) 2004 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 |
"{ Package: 'stx:libtool' }" |
|
13 |
||
14 |
"{ NameSpace: Tools }" |
|
15 |
||
16 |
ClassList subclass:#HierarchicalClassList |
|
17 |
instanceVariableNames:'topClassHolder' |
|
18 |
classVariableNames:'InheritedEntry' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Browsers-New' |
|
21 |
! |
|
22 |
||
23 |
!HierarchicalClassList class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
Like a ClassList, but shows classes hierarchical. |
|
42 |
||
43 |
If topClassHolders value is non-nil, only that classes hierarchy |
|
44 |
is shown. |
|
45 |
||
46 |
embeddable application displaying the classes as listed by |
|
47 |
the inputGenerator. |
|
48 |
Provides an outputGenerator, which enumerates the classes and |
|
49 |
their protocols (method-categories) in the selected classes. |
|
50 |
||
51 |
[author:] |
|
52 |
Claus Gittinger (cg@exept.de) |
|
53 |
" |
|
54 |
||
55 |
||
56 |
! ! |
|
57 |
||
58 |
!HierarchicalClassList class methodsFor:'initialization'! |
|
59 |
||
60 |
initialize |
|
61 |
InheritedEntry := '* inheritance *' |
|
62 |
||
63 |
"Created: / 24.2.2000 / 20:19:19 / cg" |
|
64 |
! ! |
|
65 |
||
66 |
!HierarchicalClassList class methodsFor:'queries-plugin'! |
|
67 |
||
68 |
aspectSelectors |
|
69 |
^ super aspectSelectors , |
|
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
70 |
#( |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
71 |
topClassHolder |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
72 |
) |
10005 | 73 |
|
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
74 |
"Modified: / 24-02-2014 / 10:38:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10005 | 75 |
! ! |
76 |
||
77 |
!HierarchicalClassList methodsFor:'accessing'! |
|
78 |
||
79 |
showMethodComplexity:aValueHolder |
|
80 |
||
81 |
"Created: / 05-11-2007 / 17:15:35 / cg" |
|
82 |
! |
|
83 |
||
84 |
showMethodInheritance:aValueHolder |
|
85 |
||
86 |
"Created: / 05-11-2007 / 17:15:23 / cg" |
|
87 |
! |
|
88 |
||
89 |
showMethodTypeIcon:aValueHolder |
|
90 |
||
91 |
"Created: / 05-11-2007 / 17:15:42 / cg" |
|
92 |
! ! |
|
93 |
||
94 |
!HierarchicalClassList methodsFor:'aspects'! |
|
95 |
||
96 |
methodVisibilityHolder:aValueHolder |
|
97 |
||
98 |
"Created: / 05-11-2007 / 17:15:48 / cg" |
|
99 |
! |
|
100 |
||
101 |
topClassHolder |
|
102 |
topClassHolder isNil ifTrue:[ |
|
103 |
topClassHolder := Object asValue. |
|
104 |
topClassHolder addDependent:self |
|
105 |
]. |
|
106 |
^ topClassHolder |
|
107 |
! |
|
108 |
||
109 |
topClassHolder:aValueHolder |
|
110 |
|oldTopClass newTopClass| |
|
111 |
||
112 |
oldTopClass := topClassHolder value. |
|
113 |
||
114 |
topClassHolder notNil ifTrue:[ |
|
115 |
topClassHolder removeDependent:self |
|
116 |
]. |
|
117 |
topClassHolder := aValueHolder. |
|
118 |
||
119 |
topClassHolder notNil ifTrue:[ |
|
120 |
topClassHolder isBehavior ifTrue:[self halt:'should not happen']. |
|
121 |
topClassHolder addDependent:self. |
|
122 |
]. |
|
123 |
||
124 |
newTopClass := topClassHolder value. |
|
125 |
newTopClass ~~ oldTopClass ifTrue:[ |
|
126 |
self enqueueDelayedUpdateList. |
|
127 |
]. |
|
128 |
! ! |
|
129 |
||
130 |
!HierarchicalClassList methodsFor:'change & update'! |
|
131 |
||
132 |
classDefinitionChanged:aClass |
|
133 |
|prevTop prevSelection newSelection selectedClassesHolder| |
|
134 |
||
135 |
listValid ifFalse:[^ self]. |
|
136 |
slaveMode value == true ifTrue:[ |
|
137 |
self invalidateList. |
|
138 |
^ self. |
|
139 |
]. |
|
140 |
||
141 |
selectedClassesHolder := self selectedClasses. |
|
142 |
prevSelection := selectedClassesHolder value copy. |
|
143 |
||
144 |
prevTop := self topClassHolder value. |
|
145 |
prevTop notNil ifTrue:[ |
|
146 |
(prevTop name = aClass name) ifTrue:[ |
|
147 |
"/ forced update |
|
148 |
topClassHolder value:aClass. |
|
149 |
] ifFalse:[ |
|
150 |
(prevTop name = aClass class name) ifTrue:[ |
|
151 |
"/ forced update |
|
152 |
topClassHolder value:aClass class. |
|
153 |
] |
|
154 |
] |
|
155 |
]. |
|
156 |
||
157 |
"/ must update the list (notice, that the hierarchy might have changed..) |
|
158 |
||
159 |
self updateList. |
|
160 |
||
161 |
selectedClassesHolder value ~= prevSelection ifTrue:[ |
|
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
162 |
newSelection := prevSelection collect:[:eachOldClass | environment classNamed:(eachOldClass name)]. |
10005 | 163 |
selectedClassesHolder value:newSelection. |
164 |
] |
|
165 |
||
166 |
"Modified: / 26.2.2000 / 01:17:01 / cg" |
|
167 |
! |
|
168 |
||
169 |
classRemoved:aClass |
|
170 |
|prevTop newTop prevSel nPrevSelected selectedClassesHolder newSelection wasMeta| |
|
171 |
||
172 |
prevTop := self topClassHolder value. |
|
173 |
||
174 |
prevTop notNil ifTrue:[ |
|
175 |
wasMeta := prevTop isMeta. |
|
176 |
newTop := prevTop theNonMetaclass. |
|
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
177 |
[newTop notNil and:[(environment at:newTop name) ~= newTop]] whileTrue:[ |
10005 | 178 |
newTop := newTop superclass. |
179 |
]. |
|
180 |
wasMeta ifTrue:[ |
|
181 |
newTop := newTop theMetaclass |
|
182 |
]. |
|
183 |
newTop ~~ prevTop ifTrue:[ |
|
184 |
self topClassHolder value:newTop. |
|
185 |
]. |
|
186 |
]. |
|
187 |
||
188 |
selectedClassesHolder := self selectedClasses. |
|
189 |
||
190 |
"/ if there is a single selection, |
|
191 |
"/ which is the old top, replace it. |
|
192 |
prevSel := selectedClassesHolder value. |
|
193 |
nPrevSelected := prevSel size. |
|
194 |
nPrevSelected > 0 ifTrue:[ |
|
195 |
nPrevSelected == 1 ifTrue:[ |
|
196 |
prevSel first == aClass ifTrue:[ |
|
197 |
newTop notNil ifTrue:[ |
|
198 |
newSelection := Array with:newTop. |
|
199 |
] ifFalse:[ |
|
200 |
newSelection := #(). |
|
201 |
] |
|
202 |
]. |
|
203 |
] ifFalse:[ |
|
204 |
nPrevSelected ~~ 0 ifTrue:[ |
|
205 |
"/ clear the selection |
|
206 |
newSelection := #(). |
|
207 |
] |
|
208 |
]. |
|
209 |
newSelection notNil ifTrue:[ |
|
210 |
selectedClassesHolder value:newSelection |
|
211 |
]. |
|
212 |
]. |
|
213 |
||
214 |
super classRemoved:aClass. |
|
215 |
! ! |
|
216 |
||
217 |
!HierarchicalClassList methodsFor:'private'! |
|
218 |
||
219 |
addTo:aList whereSuperclassIs:aSuperclass |
|
220 |
|theClasses| |
|
221 |
||
222 |
aSuperclass isNil ifTrue:[ |
|
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
223 |
theClasses := environment allClasses select:[:cls | cls superclass isNil] |
10005 | 224 |
] ifFalse:[ |
225 |
theClasses := aSuperclass subclasses. |
|
226 |
]. |
|
227 |
(self hideUnloadedClasses value) ifTrue:[ |
|
228 |
theClasses := theClasses select:[:cls | cls isLoaded]. |
|
229 |
]. |
|
230 |
||
231 |
theClasses := theClasses asOrderedCollection sort:[:a :b | (a name ? '??') < (b name ? '??')]. |
|
232 |
theClasses do:[:aClass | |
|
233 |
aList add:aClass. |
|
234 |
self addTo:aList whereSuperclassIs:aClass |
|
235 |
]. |
|
236 |
! |
|
237 |
||
238 |
defaultSlaveModeValue |
|
239 |
|mode| |
|
240 |
||
241 |
mode := self topApplication perform:#initialOrganizerMode ifNotUnderstood:nil. |
|
242 |
mode == OrganizerCanvas organizerModeClassHierarchy ifTrue:[^ false]. |
|
243 |
mode isNil ifTrue:[^ false]. |
|
244 |
||
245 |
self organizerMode value == OrganizerCanvas organizerModeCategory ifTrue:[^ true]. |
|
246 |
^ false |
|
247 |
! |
|
248 |
||
249 |
listOfClasses |
|
250 |
|classes top| |
|
251 |
||
252 |
classes := OrderedCollection new. |
|
253 |
(top := self topClassHolder value) notNil ifTrue:[ |
|
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
254 |
top := top theNonMetaclass. |
15534
b7f97664fc12
class: Tools::HierarchicalClassList
Claus Gittinger <cg@exept.de>
parents:
14286
diff
changeset
|
255 |
classes addAll:(top withAllSuperclasses reversed). |
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
256 |
|
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
257 |
"/ Must check whether environment contains the class and filter it out, |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
258 |
"/ if not. Think of limited environment to Java classes which should not |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
259 |
"/ show Object & JavaObject even if they are real superclasses of any Java |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
260 |
"/ class. |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
261 |
"/ Q: Should we rather ignore all superclasses after first class which is not |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
262 |
"/ in environment? |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
263 |
classes := classes select:[:class | (environment at: class name ifAbsent:[nil]) notNil ]. |
10005 | 264 |
]. |
265 |
self addTo:classes whereSuperclassIs:top. |
|
266 |
^ classes |
|
267 |
||
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
268 |
"Modified: / 24-02-2000 / 13:27:43 / cg" |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
269 |
"Modified (format): / 27-04-2014 / 20:47:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10005 | 270 |
! |
271 |
||
272 |
nameListEntryFor:aClass withNameSpace:useFullName |
|
273 |
|indent superClass nm| |
|
274 |
||
275 |
aClass == (self class nameListEntryForALL) ifTrue:[ ^ aClass ]. |
|
276 |
aClass == InheritedEntry ifTrue:[ ^ aClass ]. |
|
277 |
||
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
278 |
nm := aClass nameInBrowser. |
10005 | 279 |
nm isNil ifTrue:[^ '???']. |
280 |
||
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
281 |
aClass isLoaded ifFalse:[ |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
282 |
"/ nm := nm,(' (?) ' colorizeAllWith:Color grey). |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
283 |
] ifTrue:[ |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
284 |
aClass isAbstract ifTrue:[ nm := nm allItalic ]. |
17286 | 285 |
nm := nm,((' (%1+%2) ' bindWith:(aClass methodsCount) with:(aClass class methodsCount)) |
16496 | 286 |
withColor:self class pseudoEntryForegroundColor). |
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
287 |
]. |
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
288 |
|
10005 | 289 |
indent := 0. |
290 |
superClass := aClass superclass. |
|
291 |
[superClass notNil] whileTrue:[ |
|
292 |
indent := indent + 1. |
|
293 |
superClass := superClass superclass. |
|
294 |
]. |
|
295 |
||
296 |
indent == 0 ifTrue:[ |
|
297 |
^ nm |
|
298 |
]. |
|
299 |
||
300 |
indent <= 5 ifTrue:[ |
|
301 |
indent := #( |
|
302 |
'' |
|
303 |
' ' |
|
304 |
' ' |
|
305 |
' ' |
|
306 |
' ' |
|
307 |
' ' |
|
308 |
) at:indent+1. |
|
309 |
] ifFalse:[ |
|
310 |
indent := String new:indent*4 withAll:Character space. |
|
311 |
]. |
|
312 |
^ indent , nm |
|
313 |
||
314 |
"Modified: / 24.2.2000 / 20:19:47 / cg" |
|
315 |
! |
|
316 |
||
317 |
release |
|
318 |
super release. |
|
319 |
||
320 |
topClassHolder removeDependent:self. |
|
321 |
! ! |
|
322 |
||
323 |
!HierarchicalClassList class methodsFor:'documentation'! |
|
324 |
||
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
325 |
version |
16496 | 326 |
^ '$Header$' |
10005 | 327 |
! ! |
328 |
||
14286
badb3e840d06
Fix in #listOfClasses - must check whether all superclasses are actually in environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10005
diff
changeset
|
329 |
|
10005 | 330 |
HierarchicalClassList initialize! |