author | Claus Gittinger <cg@exept.de> |
Mon, 07 Feb 2000 12:16:03 +0100 | |
changeset 901 | 8fd26c5e8e8f |
parent 899 | 7b65d6f2b0f0 |
child 906 | 862b6903fbf3 |
permissions | -rw-r--r-- |
688 | 1 |
Object subclass:#SystemOrganizer |
901 | 2 |
instanceVariableNames:'categoryArray nameSpace' |
3 |
classVariableNames:'AllCategories' |
|
688 | 4 |
poolDictionaries:'' |
5 |
category:'Kernel-Support' |
|
6 |
! |
|
7 |
||
901 | 8 |
!SystemOrganizer class methodsFor:'documentation'! |
9 |
||
10 |
documentation |
|
11 |
" |
|
12 |
In ST80, there is a systemOrganization, which groups classes |
|
13 |
to categories. |
|
14 |
All of this here is mimicri - ST/X keeps the category in the class. |
|
15 |
This class simulates the ST80 behavior. |
|
16 |
" |
|
17 |
! ! |
|
688 | 18 |
|
19 |
!SystemOrganizer class methodsFor:'instance creation'! |
|
20 |
||
21 |
for:aNameSpace |
|
901 | 22 |
"create & return a new instance of myself, to organize aNameSpace. |
23 |
All of this here is mimicri - ST/X keeps the category in the class." |
|
688 | 24 |
|
901 | 25 |
^ self new nameSpace:aNameSpace. |
688 | 26 |
|
901 | 27 |
"Modified: / 6.2.2000 / 20:25:50 / cg" |
688 | 28 |
! ! |
29 |
||
30 |
!SystemOrganizer methodsFor:'accessing'! |
|
31 |
||
901 | 32 |
addCategory:aCategory before:someOtherCategory |
33 |
(categoryArray isNil |
|
34 |
or:[(categoryArray includes:aCategory) not]) ifTrue:[ |
|
35 |
categoryArray := nil. |
|
36 |
AllCategories add:aCategory. |
|
37 |
]. |
|
38 |
||
39 |
"Created: / 6.2.2000 / 20:42:20 / cg" |
|
40 |
"Modified: / 6.2.2000 / 20:44:34 / cg" |
|
41 |
! |
|
42 |
||
688 | 43 |
categories |
44 |
"return a collection of my classes class-categories. |
|
45 |
If my nameSpace is nil, all classes' categories are included; |
|
46 |
otherwise, only the categories of that particular namespace." |
|
47 |
||
901 | 48 |
|addClassAction categorySet searchedNamespace allNames| |
688 | 49 |
|
901 | 50 |
categoryArray notNil ifTrue:[ |
51 |
^ categoryArray |
|
52 |
]. |
|
688 | 53 |
|
901 | 54 |
addClassAction := [:aClass | |
55 |
|cat| |
|
688 | 56 |
|
901 | 57 |
aClass isMeta ifFalse:[ |
58 |
(aClass isNamespace not) ifTrue:[ |
|
59 |
cat := aClass category. |
|
60 |
cat isNil ifTrue:[ |
|
61 |
cat := '* no category *' |
|
62 |
]. |
|
63 |
cat ~= 'obsolete' ifTrue:[ |
|
64 |
categorySet add:cat |
|
688 | 65 |
] |
66 |
] |
|
67 |
]. |
|
901 | 68 |
]. |
69 |
||
70 |
AllCategories isNil ifTrue:[ |
|
71 |
categorySet := Set new. |
|
72 |
Smalltalk allBehaviorsDo:addClassAction. |
|
73 |
AllCategories := categorySet. |
|
688 | 74 |
]. |
901 | 75 |
|
76 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
77 |
allNames := true. |
|
78 |
searchedNamespace := Smalltalk. |
|
79 |
]. |
|
80 |
searchedNamespace == Smalltalk ifTrue:[ |
|
81 |
categorySet := AllCategories. |
|
82 |
] ifFalse:[ |
|
83 |
categorySet := Set new. |
|
84 |
searchedNamespace allBehaviorsDo:addClassAction. |
|
85 |
]. |
|
86 |
categoryArray := categorySet asArray sort. |
|
688 | 87 |
^ categoryArray |
88 |
||
89 |
" |
|
90 |
(SystemOrganizer for:nil) categories |
|
91 |
(SystemOrganizer for:Smalltalk) categories |
|
92 |
(SystemOrganizer for:Demos) categories |
|
93 |
" |
|
94 |
||
901 | 95 |
"Modified: / 6.2.2000 / 20:33:42 / cg" |
689 | 96 |
! |
97 |
||
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
98 |
categoryOfElement:aClassName |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
99 |
"return a classes category; |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
100 |
the argument is the classes name" |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
101 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
102 |
|cls| |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
103 |
|
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
104 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
901 | 105 |
cls notNil ifTrue:[ |
106 |
^ cls category |
|
107 |
]. |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
108 |
self error:'no such class'. |
901 | 109 |
|
110 |
"Modified: / 6.2.2000 / 20:12:10 / cg" |
|
895
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
111 |
! |
f8702324cc12
added #categoryOfElement - for RB
Claus Gittinger <cg@exept.de>
parents:
689
diff
changeset
|
112 |
|
899 | 113 |
classify:aClassName under:newCategory |
114 |
"change a classes category; |
|
115 |
the argument is the classes name" |
|
116 |
||
901 | 117 |
|cls cats| |
899 | 118 |
|
119 |
cls := Smalltalk at:aClassName ifAbsent:nil. |
|
901 | 120 |
cls notNil ifTrue:[ |
121 |
(AllCategories includes:newCategory) ifFalse:[ |
|
122 |
cats := AllCategories asOrderedCollection. |
|
123 |
cats add:newCategory. |
|
124 |
cats sort. |
|
125 |
AllCategories := cats. |
|
126 |
]. |
|
127 |
(categoryArray notNil and:[categoryArray includes:newCategory]) not |
|
128 |
ifTrue:[ |
|
129 |
categoryArray := nil. |
|
130 |
]. |
|
131 |
^ cls category:newCategory |
|
132 |
]. |
|
899 | 133 |
self error:'no such class'. |
134 |
||
135 |
"Created: / 4.2.2000 / 18:30:11 / cg" |
|
901 | 136 |
"Modified: / 6.2.2000 / 20:36:30 / cg" |
899 | 137 |
! |
138 |
||
689 | 139 |
listAtCategoryNamed:aCategory |
140 |
"return a collection of classes in aCategory." |
|
141 |
||
142 |
|set classSet searchedNamespace allNames| |
|
143 |
||
144 |
classSet := IdentitySet new. |
|
145 |
||
146 |
(searchedNamespace := nameSpace) isNil ifTrue:[ |
|
147 |
allNames := true. |
|
148 |
searchedNamespace := Smalltalk. |
|
149 |
]. |
|
150 |
||
151 |
searchedNamespace allBehaviorsDo:[:aClass | |
|
152 |
|cat| |
|
153 |
||
154 |
aClass isMeta ifFalse:[ |
|
155 |
(aClass isNamespace not |
|
156 |
or:[aClass == Namespace |
|
157 |
or:[aClass == Smalltalk]]) ifTrue:[ |
|
158 |
(allNames or:[aClass nameSpace == nameSpace]) ifTrue:[ |
|
159 |
cat := aClass category. |
|
160 |
cat = aCategory ifTrue:[ |
|
161 |
classSet add:aClass name |
|
162 |
] |
|
163 |
] |
|
164 |
] |
|
165 |
] |
|
166 |
]. |
|
167 |
^ classSet asArray sort. |
|
168 |
||
169 |
" |
|
170 |
(SystemOrganizer for:nil) listAtCategoryNamed:'Collections-Abstract' |
|
171 |
(SystemOrganizer for:Smalltalk) listAtCategoryNamed:'Collections-Abstract' |
|
172 |
(SystemOrganizer for:Demos) listAtCategoryNamed:'Collections-Abstract' |
|
173 |
" |
|
174 |
||
175 |
"Modified: / 20.6.1998 / 13:34:19 / cg" |
|
688 | 176 |
! ! |
177 |
||
901 | 178 |
!SystemOrganizer methodsFor:'change and update'! |
179 |
||
180 |
update:something with:anArgument from:changedObject |
|
181 |
categoryArray := nil. |
|
182 |
||
183 |
"Created: / 6.2.2000 / 20:08:52 / cg" |
|
184 |
"Modified: / 6.2.2000 / 20:10:21 / cg" |
|
185 |
! ! |
|
186 |
||
187 |
!SystemOrganizer methodsFor:'private accessing'! |
|
688 | 188 |
|
189 |
nameSpace:aNameSpace |
|
190 |
"set the nameSpace - nil is allowed and stands for: any" |
|
191 |
||
192 |
nameSpace := aNameSpace. |
|
193 |
Smalltalk addDependent:self. |
|
194 |
||
195 |
" |
|
196 |
(SystemOrganizer for:nil) organization |
|
197 |
(SystemOrganizer for:Demos) organization |
|
198 |
" |
|
199 |
||
200 |
"Modified: / 20.6.1998 / 12:35:34 / cg" |
|
201 |
! ! |
|
202 |
||
203 |
!SystemOrganizer class methodsFor:'documentation'! |
|
204 |
||
205 |
version |
|
901 | 206 |
^ '$Header: /cvs/stx/stx/libbasic3/SystemOrganizer.st,v 1.5 2000-02-07 11:16:03 cg Exp $' |
688 | 207 |
! ! |