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