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