author | Claus Gittinger <cg@exept.de> |
Sun, 03 Sep 2000 16:44:05 +0200 | |
changeset 969 | 3f3e9552e78b |
parent 925 | 95dda78c41a2 |
child 994 | fdfd49f4dc25 |
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' |
19 |
classVariableNames:'AllCategories' |
|
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 |
||
53 |
for:aNameSpace |
|
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 |
|
901 | 57 |
^ self new nameSpace:aNameSpace. |
688 | 58 |
|
901 | 59 |
"Modified: / 6.2.2000 / 20:25:50 / cg" |
688 | 60 |
! ! |
61 |
||
62 |
!SystemOrganizer methodsFor:'accessing'! |
|
63 |
||
901 | 64 |
addCategory:aCategory before:someOtherCategory |
65 |
(categoryArray isNil |
|
66 |
or:[(categoryArray includes:aCategory) not]) ifTrue:[ |
|
67 |
categoryArray := nil. |
|
68 |
AllCategories add:aCategory. |
|
69 |
]. |
|
70 |
||
71 |
"Created: / 6.2.2000 / 20:42:20 / cg" |
|
72 |
"Modified: / 6.2.2000 / 20:44:34 / cg" |
|
73 |
! |
|
74 |
||
688 | 75 |
categories |
76 |
"return a collection of my classes class-categories. |
|
77 |
If my nameSpace is nil, all classes' categories are included; |
|
78 |
otherwise, only the categories of that particular namespace." |
|
79 |
||
901 | 80 |
|addClassAction categorySet searchedNamespace allNames| |
688 | 81 |
|
901 | 82 |
categoryArray notNil ifTrue:[ |
83 |
^ categoryArray |
|
84 |
]. |
|
688 | 85 |
|
901 | 86 |
addClassAction := [:aClass | |
87 |
|cat| |
|
688 | 88 |
|
901 | 89 |
aClass isMeta ifFalse:[ |
925 | 90 |
(aClass isNameSpace not) ifTrue:[ |
901 | 91 |
cat := aClass category. |
92 |
cat isNil ifTrue:[ |
|
93 |
cat := '* no category *' |
|
94 |
]. |
|
95 |
cat ~= 'obsolete' ifTrue:[ |
|
96 |
categorySet add:cat |
|
688 | 97 |
] |
98 |
] |
|
99 |
]. |
|
901 | 100 |
]. |
101 |
||
102 |
AllCategories isNil ifTrue:[ |
|
103 |
categorySet := Set new. |
|
969 | 104 |
Smalltalk allClassesDo:addClassAction. |
901 | 105 |
AllCategories := categorySet. |
688 | 106 |
]. |
901 | 107 |
|
108 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
109 |
allNames := true. |
|
110 |
searchedNamespace := Smalltalk. |
|
111 |
]. |
|
112 |
searchedNamespace == Smalltalk ifTrue:[ |
|
113 |
categorySet := AllCategories. |
|
114 |
] ifFalse:[ |
|
115 |
categorySet := Set new. |
|
969 | 116 |
searchedNamespace allClassesDo:addClassAction. |
901 | 117 |
]. |
118 |
categoryArray := categorySet asArray sort. |
|
688 | 119 |
^ categoryArray |
120 |
||
121 |
" |
|
122 |
(SystemOrganizer for:nil) categories |
|
123 |
(SystemOrganizer for:Smalltalk) categories |
|
124 |
(SystemOrganizer for:Demos) categories |
|
125 |
" |
|
126 |
||
901 | 127 |
"Modified: / 6.2.2000 / 20:33:42 / cg" |
689 | 128 |
! |
129 |
||
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
130 |
categoryOfElement:aClassName |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
131 |
"return a classes category; |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
132 |
the argument is the classes name" |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
133 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
134 |
|cls| |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
135 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
136 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
901 | 137 |
cls notNil ifTrue:[ |
138 |
^ cls category |
|
139 |
]. |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
140 |
self error:'no such class'. |
901 | 141 |
|
142 |
"Modified: / 6.2.2000 / 20:12:10 / cg" |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
143 |
! |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
144 |
|
899 | 145 |
classify:aClassName under:newCategory |
146 |
"change a classes category; |
|
147 |
the argument is the classes name" |
|
148 |
||
901 | 149 |
|cls cats| |
899 | 150 |
|
151 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
|
901 | 152 |
cls notNil ifTrue:[ |
153 |
(AllCategories includes:newCategory) ifFalse:[ |
|
154 |
cats := AllCategories asOrderedCollection. |
|
155 |
cats add:newCategory. |
|
156 |
cats sort. |
|
157 |
AllCategories := cats. |
|
158 |
]. |
|
159 |
(categoryArray notNil and:[categoryArray includes:newCategory]) not |
|
160 |
ifTrue:[ |
|
161 |
categoryArray := nil. |
|
162 |
]. |
|
163 |
^ cls category:newCategory |
|
164 |
]. |
|
899 | 165 |
self error:'no such class'. |
166 |
||
167 |
"Created: / 4.2.2000 / 18:30:11 / cg" |
|
901 | 168 |
"Modified: / 6.2.2000 / 20:36:30 / cg" |
899 | 169 |
! |
170 |
||
689 | 171 |
listAtCategoryNamed:aCategory |
172 |
"return a collection of classes in aCategory." |
|
173 |
||
174 |
|set classSet searchedNamespace allNames| |
|
175 |
||
176 |
classSet := IdentitySet new. |
|
177 |
||
178 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
179 |
allNames := true. |
|
180 |
searchedNamespace := Smalltalk. |
|
181 |
]. |
|
182 |
||
969 | 183 |
searchedNamespace allClassesDo:[:aClass | |
689 | 184 |
|cat| |
185 |
||
186 |
aClass isMeta ifFalse:[ |
|
925 | 187 |
(aClass isNameSpace not |
188 |
or:[aClass == NameSpace |
|
689 | 189 |
or:[aClass == Smalltalk]]) ifTrue:[ |
190 |
(allNames or:[aClass nameSpace == nameSpace]) ifTrue:[ |
|
191 |
cat := aClass category. |
|
192 |
cat = aCategory ifTrue:[ |
|
193 |
classSet add:aClass name |
|
194 |
] |
|
195 |
] |
|
196 |
] |
|
197 |
] |
|
198 |
]. |
|
199 |
^ classSet asArray sort. |
|
200 |
||
201 |
" |
|
202 |
(SystemOrganizer for:nil) listAtCategoryNamed:'Collections-Abstract' |
|
203 |
(SystemOrganizer for:Smalltalk) listAtCategoryNamed:'Collections-Abstract' |
|
204 |
(SystemOrganizer for:Demos) listAtCategoryNamed:'Collections-Abstract' |
|
205 |
" |
|
206 |
||
207 |
"Modified: / 20.6.1998 / 13:34:19 / cg" |
|
688 | 208 |
! ! |
209 |
||
901 | 210 |
!SystemOrganizer methodsFor:'change and update'! |
211 |
||
212 |
update:something with:anArgument from:changedObject |
|
213 |
categoryArray := nil. |
|
214 |
||
215 |
"Created: / 6.2.2000 / 20:08:52 / cg" |
|
216 |
"Modified: / 6.2.2000 / 20:10:21 / cg" |
|
217 |
! ! |
|
218 |
||
219 |
!SystemOrganizer methodsFor:'private accessing'! |
|
688 | 220 |
|
221 |
nameSpace:aNameSpace |
|
222 |
"set the nameSpace - nil is allowed and stands for: any" |
|
223 |
||
224 |
nameSpace := aNameSpace. |
|
225 |
Smalltalk addDependent:self. |
|
226 |
||
227 |
" |
|
228 |
(SystemOrganizer for:nil) organization |
|
229 |
(SystemOrganizer for:Demos) organization |
|
230 |
" |
|
231 |
||
232 |
"Modified: / 20.6.1998 / 12:35:34 / cg" |
|
233 |
! ! |
|
234 |
||
235 |
!SystemOrganizer class methodsFor:'documentation'! |
|
236 |
||
237 |
version |
|
969 | 238 |
^ '$Header: /cvs/stx/stx/libbasic3/SystemOrganizer.st,v 1.8 2000-09-03 14:44:05 cg Exp $' |
688 | 239 |
! ! |