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