author | Claus Gittinger <cg@exept.de> |
Tue, 21 Aug 2001 15:40:55 +0200 | |
changeset 1061 | b48afe9c91b1 |
parent 994 | fdfd49f4dc25 |
child 1670 | 99282e024c51 |
permissions | -rw-r--r-- |
906 | 1 |
" |
2 |
COPYRIGHT (c) 1998 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 |
||
13 |
||
14 |
||
969 | 15 |
"{ Package: 'stx:libbasic3' }" |
16 |
||
688 | 17 |
Object subclass:#SystemOrganizer |
901 | 18 |
instanceVariableNames:'categoryArray nameSpace' |
994 | 19 |
classVariableNames:'AllCategories CachedOrganizerForSmalltalk' |
688 | 20 |
poolDictionaries:'' |
21 |
category:'Kernel-Support' |
|
22 |
! |
|
23 |
||
901 | 24 |
!SystemOrganizer class methodsFor:'documentation'! |
25 |
||
906 | 26 |
copyright |
27 |
" |
|
28 |
COPYRIGHT (c) 1998 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 |
! |
|
41 |
||
901 | 42 |
documentation |
43 |
" |
|
44 |
In ST80, there is a systemOrganization, which groups classes |
|
45 |
to categories. |
|
46 |
All of this here is mimicri - ST/X keeps the category in the class. |
|
47 |
This class simulates the ST80 behavior. |
|
48 |
" |
|
49 |
! ! |
|
688 | 50 |
|
51 |
!SystemOrganizer class methodsFor:'instance creation'! |
|
52 |
||
1061 | 53 |
for:aNameSpaceOrNil |
901 | 54 |
"create & return a new instance of myself, to organize aNameSpace. |
55 |
All of this here is mimicri - ST/X keeps the category in the class." |
|
688 | 56 |
|
1061 | 57 |
(aNameSpaceOrNil isNil or:[aNameSpaceOrNil == Smalltalk]) ifTrue:[ |
994 | 58 |
CachedOrganizerForSmalltalk isNil ifTrue:[ |
1061 | 59 |
CachedOrganizerForSmalltalk := self new nameSpace:aNameSpaceOrNil. |
994 | 60 |
]. |
61 |
^ CachedOrganizerForSmalltalk |
|
62 |
]. |
|
1061 | 63 |
^ self new nameSpace:aNameSpaceOrNil. |
688 | 64 |
|
1061 | 65 |
"Modified: / 21.8.2001 / 15:22:20 / cg" |
688 | 66 |
! ! |
67 |
||
68 |
!SystemOrganizer methodsFor:'accessing'! |
|
69 |
||
901 | 70 |
addCategory:aCategory before:someOtherCategory |
71 |
(categoryArray isNil |
|
72 |
or:[(categoryArray includes:aCategory) not]) ifTrue:[ |
|
73 |
categoryArray := nil. |
|
74 |
AllCategories add:aCategory. |
|
75 |
]. |
|
76 |
||
77 |
"Created: / 6.2.2000 / 20:42:20 / cg" |
|
78 |
"Modified: / 6.2.2000 / 20:44:34 / cg" |
|
79 |
! |
|
80 |
||
688 | 81 |
categories |
82 |
"return a collection of my classes class-categories. |
|
83 |
If my nameSpace is nil, all classes' categories are included; |
|
84 |
otherwise, only the categories of that particular namespace." |
|
85 |
||
901 | 86 |
|addClassAction categorySet searchedNamespace allNames| |
688 | 87 |
|
901 | 88 |
categoryArray notNil ifTrue:[ |
89 |
^ categoryArray |
|
90 |
]. |
|
688 | 91 |
|
901 | 92 |
addClassAction := [:aClass | |
93 |
|cat| |
|
688 | 94 |
|
901 | 95 |
aClass isMeta ifFalse:[ |
925 | 96 |
(aClass isNameSpace not) ifTrue:[ |
901 | 97 |
cat := aClass category. |
98 |
cat isNil ifTrue:[ |
|
99 |
cat := '* no category *' |
|
100 |
]. |
|
101 |
cat ~= 'obsolete' ifTrue:[ |
|
102 |
categorySet add:cat |
|
688 | 103 |
] |
104 |
] |
|
105 |
]. |
|
901 | 106 |
]. |
107 |
||
108 |
AllCategories isNil ifTrue:[ |
|
109 |
categorySet := Set new. |
|
969 | 110 |
Smalltalk allClassesDo:addClassAction. |
901 | 111 |
AllCategories := categorySet. |
688 | 112 |
]. |
901 | 113 |
|
114 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
115 |
searchedNamespace := Smalltalk. |
|
116 |
]. |
|
1061 | 117 |
allNames := (searchedNamespace == Smalltalk). |
901 | 118 |
searchedNamespace == Smalltalk ifTrue:[ |
119 |
categorySet := AllCategories. |
|
120 |
] ifFalse:[ |
|
121 |
categorySet := Set new. |
|
969 | 122 |
searchedNamespace allClassesDo:addClassAction. |
901 | 123 |
]. |
124 |
categoryArray := categorySet asArray sort. |
|
688 | 125 |
^ categoryArray |
126 |
||
127 |
" |
|
128 |
(SystemOrganizer for:nil) categories |
|
129 |
(SystemOrganizer for:Smalltalk) categories |
|
130 |
(SystemOrganizer for:Demos) categories |
|
131 |
" |
|
132 |
||
1061 | 133 |
"Modified: / 21.8.2001 / 15:24:10 / cg" |
689 | 134 |
! |
135 |
||
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
136 |
categoryOfElement:aClassName |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
137 |
"return a classes category; |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
138 |
the argument is the classes name" |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
139 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
140 |
|cls| |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
141 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
142 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
901 | 143 |
cls notNil ifTrue:[ |
144 |
^ cls category |
|
145 |
]. |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
146 |
self error:'no such class'. |
901 | 147 |
|
148 |
"Modified: / 6.2.2000 / 20:12:10 / cg" |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
149 |
! |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
150 |
|
899 | 151 |
classify:aClassName under:newCategory |
152 |
"change a classes category; |
|
153 |
the argument is the classes name" |
|
154 |
||
901 | 155 |
|cls cats| |
899 | 156 |
|
157 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
|
901 | 158 |
cls notNil ifTrue:[ |
159 |
(AllCategories includes:newCategory) ifFalse:[ |
|
160 |
cats := AllCategories asOrderedCollection. |
|
161 |
cats add:newCategory. |
|
162 |
cats sort. |
|
163 |
AllCategories := cats. |
|
164 |
]. |
|
165 |
(categoryArray notNil and:[categoryArray includes:newCategory]) not |
|
166 |
ifTrue:[ |
|
167 |
categoryArray := nil. |
|
168 |
]. |
|
169 |
^ cls category:newCategory |
|
170 |
]. |
|
899 | 171 |
self error:'no such class'. |
172 |
||
173 |
"Created: / 4.2.2000 / 18:30:11 / cg" |
|
901 | 174 |
"Modified: / 6.2.2000 / 20:36:30 / cg" |
899 | 175 |
! |
176 |
||
689 | 177 |
listAtCategoryNamed:aCategory |
178 |
"return a collection of classes in aCategory." |
|
179 |
||
180 |
|set classSet searchedNamespace allNames| |
|
181 |
||
182 |
classSet := IdentitySet new. |
|
183 |
||
184 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
185 |
searchedNamespace := Smalltalk. |
|
186 |
]. |
|
1061 | 187 |
"/ hack to enable ported tools (RefactoryBrowser) to see all classes |
188 |
allNames := (searchedNamespace == Smalltalk). |
|
689 | 189 |
|
969 | 190 |
searchedNamespace allClassesDo:[:aClass | |
689 | 191 |
|cat| |
192 |
||
193 |
aClass isMeta ifFalse:[ |
|
925 | 194 |
(aClass isNameSpace not |
195 |
or:[aClass == NameSpace |
|
689 | 196 |
or:[aClass == Smalltalk]]) ifTrue:[ |
197 |
(allNames or:[aClass nameSpace == nameSpace]) ifTrue:[ |
|
198 |
cat := aClass category. |
|
199 |
cat = aCategory ifTrue:[ |
|
200 |
classSet add:aClass name |
|
201 |
] |
|
202 |
] |
|
203 |
] |
|
204 |
] |
|
205 |
]. |
|
206 |
^ classSet asArray sort. |
|
207 |
||
208 |
" |
|
209 |
(SystemOrganizer for:nil) listAtCategoryNamed:'Collections-Abstract' |
|
210 |
(SystemOrganizer for:Smalltalk) listAtCategoryNamed:'Collections-Abstract' |
|
211 |
(SystemOrganizer for:Demos) listAtCategoryNamed:'Collections-Abstract' |
|
212 |
" |
|
213 |
||
1061 | 214 |
"Modified: / 21.8.2001 / 15:23:52 / cg" |
688 | 215 |
! ! |
216 |
||
901 | 217 |
!SystemOrganizer methodsFor:'change and update'! |
218 |
||
219 |
update:something with:anArgument from:changedObject |
|
994 | 220 |
"/ flush cached categories ... |
901 | 221 |
categoryArray := nil. |
222 |
||
223 |
"Created: / 6.2.2000 / 20:08:52 / cg" |
|
224 |
"Modified: / 6.2.2000 / 20:10:21 / cg" |
|
225 |
! ! |
|
226 |
||
227 |
!SystemOrganizer methodsFor:'private accessing'! |
|
688 | 228 |
|
229 |
nameSpace:aNameSpace |
|
230 |
"set the nameSpace - nil is allowed and stands for: any" |
|
231 |
||
994 | 232 |
nameSpace := aNameSpace ? Smalltalk. |
233 |
nameSpace addDependent:self. |
|
234 |
nameSpace ~~ Smalltalk ifTrue:[Smalltalk addDependent:self]. |
|
688 | 235 |
|
236 |
" |
|
237 |
(SystemOrganizer for:nil) organization |
|
238 |
(SystemOrganizer for:Demos) organization |
|
239 |
" |
|
240 |
||
241 |
"Modified: / 20.6.1998 / 12:35:34 / cg" |
|
242 |
! ! |
|
243 |
||
244 |
!SystemOrganizer class methodsFor:'documentation'! |
|
245 |
||
246 |
version |
|
1061 | 247 |
^ '$Header: /cvs/stx/stx/libbasic3/SystemOrganizer.st,v 1.10 2001-08-21 13:40:55 cg Exp $' |
688 | 248 |
! ! |