author | Claus Gittinger <cg@exept.de> |
Mon, 14 Feb 2011 17:23:19 +0100 | |
changeset 9764 | 47b9c33465a1 |
parent 9470 | 7da2fbdd7dd3 |
child 10350 | 2e6715c12e41 |
permissions | -rw-r--r-- |
6179 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by 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 |
" |
|
5592 | 12 |
"{ Package: 'stx:libtool' }" |
5591 | 13 |
|
14 |
"{ NameSpace: Tools }" |
|
15 |
||
16 |
ClassCategoryList subclass:#HierarchicalClassCategoryList |
|
17 |
instanceVariableNames:'hierarchicalCategoryTree hierarchicalCategoryList |
|
18 |
hierarchicalCategorySelection categoryToItemDictionary' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Browsers-New' |
|
22 |
! |
|
23 |
||
6689 | 24 |
HierarchicalItemWithLabel subclass:#ClassCategoryItem |
25 |
instanceVariableNames:'category' |
|
5670
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
26 |
classVariableNames:'' |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
27 |
poolDictionaries:'' |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
28 |
privateIn:HierarchicalClassCategoryList |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
29 |
! |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
30 |
|
5591 | 31 |
!HierarchicalClassCategoryList class methodsFor:'documentation'! |
32 |
||
6179 | 33 |
copyright |
34 |
" |
|
35 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
36 |
All Rights Reserved |
|
37 |
||
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
46 |
||
5591 | 47 |
documentation |
48 |
" |
|
49 |
embeddable application displaying the classes as listed by |
|
50 |
the inputGenerator. |
|
51 |
Provides an outputGenerator, which enumerates the classes and |
|
52 |
their protocols (method-categories) in the selected classes. |
|
53 |
||
54 |
[author:] |
|
55 |
Claus Gittinger (cg@exept.de) |
|
56 |
" |
|
57 |
||
58 |
||
59 |
! ! |
|
60 |
||
61 |
!HierarchicalClassCategoryList class methodsFor:'interface specs'! |
|
62 |
||
63 |
windowSpec |
|
64 |
"This resource specification was automatically generated |
|
65 |
by the UIPainter of ST/X." |
|
66 |
||
67 |
"Do not manually edit this!! If it is corrupted, |
|
68 |
the UIPainter may not be able to read the specification." |
|
69 |
||
70 |
" |
|
71 |
UIPainter new openOnClass:HierarchicalClassCategoryList andSelector:#windowSpec |
|
72 |
HierarchicalClassCategoryList new openInterface:#windowSpec |
|
73 |
HierarchicalClassCategoryList open |
|
74 |
" |
|
75 |
||
76 |
<resource: #canvas> |
|
77 |
||
78 |
^ |
|
79 |
#(#FullSpec |
|
9470 | 80 |
#name: #windowSpec |
81 |
#window: |
|
5591 | 82 |
#(#WindowSpec |
9470 | 83 |
#label: 'ClassCategoryList' |
84 |
#name: 'ClassCategoryList' |
|
85 |
#min: #(#Point 0 0) |
|
86 |
#bounds: #(#Rectangle 16 46 316 346) |
|
87 |
) |
|
88 |
#component: |
|
5591 | 89 |
#(#SpecCollection |
9470 | 90 |
#collection: #( |
91 |
#(#HierarchicalListViewSpec |
|
92 |
#name: 'List' |
|
93 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
94 |
#tabable: true |
|
95 |
#model: #hierarchicalCategorySelection |
|
96 |
#menu: #menuHolder |
|
97 |
#hasHorizontalScrollBar: true |
|
98 |
#hasVerticalScrollBar: true |
|
99 |
#miniScrollerHorizontal: true |
|
100 |
#listModel: #hierarchicalCategoryList |
|
101 |
#multipleSelectOk: true |
|
102 |
#highlightMode: #line |
|
103 |
#doubleClickSelector: #doubleClicked: |
|
104 |
#showLines: false |
|
105 |
#indicatorSelector: #indicatorPressed: |
|
106 |
#useDefaultIcons: false |
|
107 |
#properties: |
|
108 |
#(#PropertyListDictionary |
|
109 |
#dragArgument: nil |
|
110 |
#dropArgument: nil |
|
111 |
#canDropSelector: #canDrop: |
|
112 |
#dropSelector: #doDrop: |
|
113 |
) |
|
114 |
) |
|
115 |
) |
|
5591 | 116 |
|
9470 | 117 |
) |
5591 | 118 |
) |
119 |
! ! |
|
120 |
||
121 |
!HierarchicalClassCategoryList class methodsFor:'plugIn spec'! |
|
122 |
||
123 |
aspectSelectors |
|
124 |
"This resource specification was automatically generated |
|
125 |
by the UIPainter of ST/X." |
|
126 |
||
127 |
"Do not manually edit this. If it is corrupted, |
|
128 |
the UIPainter may not be able to read the specification." |
|
129 |
||
130 |
"Return a description of exported aspects; |
|
131 |
these can be connected to aspects of an embedding application |
|
132 |
(if this app is embedded in a subCanvas)." |
|
133 |
||
134 |
^ #( |
|
135 |
#(#doubleClickChannel #action ) |
|
136 |
#forceGeneratorTrigger |
|
137 |
#hideUnloadedClasses |
|
138 |
#immediateUpdate |
|
139 |
#inGeneratorHolder |
|
140 |
#menuHolder |
|
141 |
#nameSpaceFilter |
|
142 |
#organizerMode |
|
143 |
#outGeneratorHolder |
|
144 |
#packageFilter |
|
145 |
#selectedCategories |
|
146 |
#selectionChangeCondition |
|
147 |
#slaveMode |
|
148 |
#updateTrigger |
|
149 |
). |
|
150 |
||
151 |
! ! |
|
152 |
||
153 |
!HierarchicalClassCategoryList methodsFor:'aspects'! |
|
154 |
||
155 |
addCategory:category |
|
156 |
|item path parentPath parentCategory parentItem| |
|
157 |
||
158 |
item:= categoryToItemDictionary at:category ifAbsent:nil. |
|
159 |
item isNil ifTrue:[ |
|
160 |
path := category asCollectionOfSubstringsSeparatedBy:$-. |
|
161 |
||
162 |
item := ClassCategoryItem new. |
|
163 |
item category:category. |
|
164 |
item label:(path last). |
|
165 |
categoryToItemDictionary at:category put:item. |
|
166 |
||
167 |
category size > 0 ifTrue:[ |
|
168 |
"/ find the parent ... |
|
169 |
parentPath := path copyWithoutLast:1. |
|
170 |
parentCategory := parentPath asStringWith:$-. |
|
171 |
||
172 |
parentItem := self addCategory:parentCategory . |
|
173 |
||
174 |
parentItem add:item sortBlock:[:i1 :i2 | i1 category asLowercase < i2 category asLowercase]. |
|
175 |
] |
|
176 |
]. |
|
177 |
^ item |
|
178 |
! |
|
179 |
||
180 |
generateHierarchicalCategoryTree |
|
181 |
|anchor| |
|
182 |
||
183 |
self categoryList value isNil ifTrue:[ |
|
184 |
self updateList. |
|
185 |
self categoryList value isNil ifTrue:[ |
|
186 |
^ nil. |
|
187 |
] |
|
188 |
]. |
|
189 |
||
190 |
anchor := ClassCategoryItem new. |
|
191 |
anchor category:nil. |
|
192 |
anchor label:nil. |
|
193 |
||
194 |
categoryToItemDictionary := Dictionary new. |
|
195 |
categoryToItemDictionary at:'' asSymbol put:anchor. |
|
196 |
||
197 |
self categoryList value do:[:eachCategory | |
|
198 |
(categoryToItemDictionary includesKey:eachCategory) ifFalse:[ |
|
199 |
self addCategory:eachCategory |
|
200 |
]. |
|
201 |
]. |
|
202 |
||
203 |
anchor recursiveSortChildren:[:i1 :i2 | i1 category asLowercase < i2 category asLowercase]. |
|
204 |
anchor expand. |
|
205 |
||
206 |
^ anchor |
|
207 |
! |
|
208 |
||
209 |
hierarchicalCategoryList |
|
210 |
|anchor | |
|
211 |
||
212 |
hierarchicalCategoryList isNil ifTrue:[ |
|
213 |
hierarchicalCategoryList := HierarchicalList new. |
|
214 |
hierarchicalCategoryList showRoot:false. |
|
215 |
||
216 |
(self slaveMode value ~~ true) ifTrue:[ |
|
217 |
anchor := self generateHierarchicalCategoryTree. |
|
218 |
hierarchicalCategoryList root:anchor. |
|
219 |
listValid := true |
|
220 |
] ifFalse:[ |
|
221 |
listValid := false |
|
222 |
] |
|
223 |
]. |
|
224 |
^ hierarchicalCategoryList |
|
225 |
! |
|
226 |
||
227 |
hierarchicalCategorySelection |
|
228 |
hierarchicalCategorySelection isNil ifTrue:[ |
|
229 |
hierarchicalCategorySelection := #() asValue. |
|
230 |
hierarchicalCategorySelection addDependent:self. |
|
231 |
]. |
|
232 |
^ hierarchicalCategorySelection. |
|
233 |
! ! |
|
234 |
||
235 |
!HierarchicalClassCategoryList methodsFor:'change & update'! |
|
236 |
||
237 |
delayedUpdate:something with:aParameter from:changedObject |
|
238 |
|cls sel oldMethod newMethod newPackage| |
|
239 |
||
240 |
self inSlaveModeOrInvisible ifTrue:[ |
|
241 |
super delayedUpdate:something with:aParameter from:changedObject. |
|
242 |
^ self. |
|
243 |
]. |
|
244 |
||
245 |
changedObject == updateTrigger ifTrue:[ |
|
246 |
hierarchicalCategoryTree := nil. |
|
247 |
self hierarchicalCategoryList. |
|
248 |
self updateTreeSelectionFromList. |
|
249 |
^ self |
|
250 |
]. |
|
251 |
||
252 |
changedObject == slaveMode ifTrue:[ |
|
253 |
listValid ~~ true ifTrue:[ |
|
254 |
self enqueueDelayedUpdateList |
|
255 |
]. |
|
256 |
"/ self invalidateList. |
|
257 |
^ self |
|
258 |
]. |
|
259 |
||
260 |
changedObject == hierarchicalCategorySelection ifTrue:[ |
|
261 |
self updateSelectionFromTree. |
|
262 |
^ self |
|
263 |
]. |
|
264 |
changedObject == self selectedCategories ifTrue:[ |
|
265 |
"/ update the trees selection as appropriate |
|
266 |
"/ self updateTreeSelection. |
|
267 |
self updateTreeSelectionFromList. |
|
268 |
]. |
|
269 |
changedObject == categoryList ifTrue:[ |
|
270 |
"/ update the tree |
|
271 |
self hierarchicalCategoryList root:(self generateHierarchicalCategoryTree). |
|
272 |
^ self. |
|
273 |
]. |
|
274 |
||
275 |
super delayedUpdate:something with:aParameter from:changedObject |
|
276 |
||
277 |
"Created: / 17.2.2000 / 23:41:02 / cg" |
|
278 |
"Modified: / 26.2.2000 / 01:21:49 / cg" |
|
279 |
! |
|
280 |
||
281 |
updateSelectionFromTree |
|
282 |
|treeSelection| |
|
283 |
||
284 |
treeSelection := hierarchicalCategorySelection value |
|
285 |
collect:[:eachIndex | |item| |
|
286 |
item := hierarchicalCategoryList at:eachIndex ifAbsent:nil. |
|
287 |
item category |
|
288 |
]. |
|
289 |
||
290 |
treeSelection asSet ~= (self selectedCategories value ? #()) asSet ifTrue:[ |
|
291 |
self selectedCategories value:treeSelection. |
|
292 |
] |
|
293 |
! |
|
294 |
||
295 |
updateTreeSelectionFromList |
|
296 |
|listSelection selectedTreeItems treeSelection| |
|
297 |
||
298 |
listSelection := self selectedCategories value. |
|
299 |
selectedTreeItems := listSelection collect:[:itemString | self treeItemForString:itemString string]. |
|
300 |
treeSelection := selectedTreeItems collect:[:eachItem | hierarchicalCategoryList identityIndexOf:eachItem]. |
|
301 |
treeSelection := treeSelection asOrderedCollection. |
|
302 |
"/hierarchicalCategorySelection value |
|
303 |
"/ collect:[:eachIndex | |item| |
|
304 |
"/ item := hierarchicalCategoryList at:eachIndex ifAbsent:nil. |
|
305 |
"/ item category |
|
306 |
"/ ]. |
|
307 |
"/ |
|
308 |
"/ treeSelection asSet ~= (self selectedCategories value ? #()) asSet ifTrue:[ |
|
309 |
"/ self selectedCategories value:treeSelection. |
|
310 |
"/ ] |
|
311 |
self hierarchicalCategorySelection value:treeSelection |
|
312 |
! ! |
|
313 |
||
314 |
!HierarchicalClassCategoryList methodsFor:'private'! |
|
315 |
||
316 |
makeItemVisible:itemString |
|
317 |
|treeItem idx listView| |
|
318 |
||
319 |
treeItem := self treeItemForString:itemString. |
|
320 |
idx := hierarchicalCategoryList identityIndexOf:treeItem. |
|
321 |
idx ~~ 0 ifTrue:[ |
|
322 |
(listView := self listView) notNil ifTrue:[ |
|
323 |
listView makeLineVisible:idx. |
|
324 |
] |
|
325 |
] |
|
326 |
! |
|
327 |
||
328 |
release |
|
329 |
super release. |
|
330 |
||
331 |
hierarchicalCategorySelection removeDependent:self. |
|
332 |
! |
|
333 |
||
334 |
treeItemForString:itemString |
|
335 |
|itemPath treeItem| |
|
336 |
||
337 |
itemPath := itemString string asCollectionOfSubstringsSeparatedBy:$-. |
|
338 |
treeItem := hierarchicalCategoryList root. |
|
339 |
[itemPath notEmpty] whileTrue:[ |
|
340 |
treeItem expand. |
|
341 |
treeItem := treeItem detect:[:childItem | childItem label string = itemPath first] ifNone:nil. |
|
342 |
itemPath := itemPath copyFrom:2. |
|
343 |
]. |
|
344 |
^ treeItem |
|
345 |
! ! |
|
346 |
||
347 |
!HierarchicalClassCategoryList methodsFor:'user actions'! |
|
348 |
||
349 |
doubleClicked:anIndex |
|
350 |
|item| |
|
351 |
||
352 |
item := hierarchicalCategoryList at:anIndex ifAbsent:nil. |
|
353 |
item isNil ifTrue:[ |
|
354 |
^ self |
|
355 |
]. |
|
356 |
||
357 |
(item canExpand not or:[item isExpanded]) ifTrue:[ |
|
358 |
doubleClickChannel notNil ifTrue:[ |
|
359 |
doubleClickChannel value:anIndex. |
|
360 |
] ifFalse:[ |
|
361 |
item collapse. |
|
362 |
]. |
|
363 |
^ self |
|
364 |
]. |
|
365 |
||
366 |
item expand. |
|
367 |
! |
|
368 |
||
369 |
indicatorPressed:anIndex |
|
370 |
|item sensor| |
|
371 |
||
372 |
item := hierarchicalCategoryList at:anIndex ifAbsent:nil. |
|
373 |
||
374 |
item isNil ifTrue:[ |
|
375 |
^ self |
|
376 |
]. |
|
377 |
||
378 |
sensor := self window sensor. |
|
379 |
(sensor ctrlDown or:[sensor shiftDown]) ifTrue:[ |
|
380 |
item recursiveToggleExpand |
|
381 |
] ifFalse:[ |
|
382 |
item toggleExpand |
|
383 |
]. |
|
384 |
! ! |
|
385 |
||
5793 | 386 |
!HierarchicalClassCategoryList::ClassCategoryItem methodsFor:'accessing'! |
5670
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
387 |
|
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
388 |
category |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
389 |
^ category |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
390 |
! |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
391 |
|
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
392 |
category:something |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
393 |
category := something. |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
394 |
! |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
395 |
|
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
396 |
icon |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
397 |
^ nil "/ SystemBrowser packageIcon |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
398 |
! ! |
e5c8a8e964dc
oops - private class got lost
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
399 |
|
5591 | 400 |
!HierarchicalClassCategoryList class methodsFor:'documentation'! |
401 |
||
402 |
version |
|
9470 | 403 |
^ '$Header: /cvs/stx/stx/libtool/Tools_HierarchicalClassCategoryList.st,v 1.8 2010-05-07 12:27:45 cg Exp $' |
404 |
! |
|
405 |
||
406 |
version_CVS |
|
407 |
^ '$Header: /cvs/stx/stx/libtool/Tools_HierarchicalClassCategoryList.st,v 1.8 2010-05-07 12:27:45 cg Exp $' |
|
5591 | 408 |
! ! |