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