2520
|
1 |
ApplicationModel subclass:#ClassRevisionTree
|
2538
|
2 |
instanceVariableNames:'selectionHolder classHolder menuBlock selectionBlock
|
|
3 |
classItemClass listView semaphoreCritical revisionInfoList
|
|
4 |
revisionTask currentClassItemInTask'
|
2520
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Interface-Browsers'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!ClassRevisionTree class methodsFor:'interface spec'!
|
|
12 |
|
|
13 |
windowSpec
|
|
14 |
"This resource specification was automatically generated
|
|
15 |
by the UIPainter of ST/X."
|
|
16 |
|
|
17 |
"Do not manually edit this!! If it is corrupted,
|
|
18 |
the UIPainter may not be able to read the specification."
|
|
19 |
|
|
20 |
"
|
|
21 |
UIPainter new openOnClass:ClassRevisionTree andSelector:#windowSpec
|
|
22 |
ClassRevisionTree new openInterface:#windowSpec
|
|
23 |
ClassRevisionTree open
|
|
24 |
"
|
|
25 |
|
|
26 |
<resource: #canvas>
|
|
27 |
|
|
28 |
^
|
|
29 |
#(#FullSpec
|
|
30 |
#name: #windowSpec
|
|
31 |
#window:
|
|
32 |
#(#WindowSpec
|
|
33 |
#label: 'ClassVersionTree'
|
|
34 |
#name: 'ClassVersionTree'
|
|
35 |
#min: #(#Point 10 10)
|
|
36 |
#max: #(#Point 9999 9999)
|
2538
|
37 |
#bounds: #(#Rectangle 16 46 881 575)
|
2520
|
38 |
)
|
|
39 |
#component:
|
|
40 |
#(#SpecCollection
|
|
41 |
#collection: #(
|
|
42 |
#(#HierarchicalListViewSpec
|
|
43 |
#name: 'HierarchicalItemListView'
|
|
44 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
2538
|
45 |
#menu: #selectItemMenu
|
2520
|
46 |
#hasHorizontalScrollBar: true
|
|
47 |
#hasVerticalScrollBar: true
|
2538
|
48 |
#listModel: #listModel
|
2520
|
49 |
#multipleSelectOk: true
|
2538
|
50 |
#useIndex: false
|
2520
|
51 |
#highlightMode: #label
|
|
52 |
#doubleClickSelector: #doubleClick:
|
2538
|
53 |
#selectConditionSelector: #isItemSelectable:
|
2520
|
54 |
#indicatorSelector: #doubleClick:
|
|
55 |
#retrieveIconsSelector: #icons
|
|
56 |
)
|
|
57 |
)
|
|
58 |
|
|
59 |
)
|
|
60 |
)
|
|
61 |
! !
|
|
62 |
|
2538
|
63 |
!ClassRevisionTree class methodsFor:'protocol'!
|
2520
|
64 |
|
2538
|
65 |
classItemClass
|
2520
|
66 |
|
2538
|
67 |
^ClassItem
|
|
68 |
!
|
2520
|
69 |
|
2538
|
70 |
classItemRootClass
|
|
71 |
|
|
72 |
^ClassItemRoot
|
2520
|
73 |
! !
|
|
74 |
|
|
75 |
!ClassRevisionTree class methodsFor:'startup'!
|
|
76 |
|
2538
|
77 |
openOnClassHolder:aClassHolder
|
|
78 |
|
|
79 |
|theTree|
|
2520
|
80 |
|
|
81 |
theTree := self new.
|
|
82 |
theTree allButOpen.
|
2538
|
83 |
theTree classHolder:aClassHolder.
|
|
84 |
theTree openWindow.
|
2520
|
85 |
^theTree
|
|
86 |
|
|
87 |
"
|
2538
|
88 |
|theSelectionHolder theClassHolder theTree|
|
2520
|
89 |
|
|
90 |
theSelectionHolder := ValueHolder new.
|
2538
|
91 |
theClassHolder := ValueHolder new.
|
|
92 |
theSelectionHolder compute:[:coll |
|
|
93 |
coll do:[:each | Transcript showCR: each]].
|
|
94 |
theClassHolder value:(Smalltalk allClasses asOrderedCollection sort:[:x : y|x name < y name]).
|
|
95 |
theTree := ClassRevisionTree openOnClassHolder:theClassHolder.
|
|
96 |
theSelectionHolder value:(Array with:(theTree itemList children last)).
|
|
97 |
theTree selectionHolder:theSelectionHolder.
|
|
98 |
Delay waitForMilliseconds:1500.
|
|
99 |
theClassHolder value:(Project current changedClasses).
|
|
100 |
Delay waitForMilliseconds:1500.
|
|
101 |
theTree classHolder:nil.
|
|
102 |
Delay waitForMilliseconds:1500.
|
|
103 |
theTree classHolder:theClassHolder.
|
|
104 |
Delay waitForMilliseconds:1500.
|
|
105 |
theClassHolder value:(Smalltalk allClasses asOrderedCollection sort:[:x : y|x name < y name]).
|
2520
|
106 |
"
|
|
107 |
|
|
108 |
|
|
109 |
|
2538
|
110 |
!
|
|
111 |
|
|
112 |
openOnClasses:aClassColl
|
|
113 |
|
|
114 |
|theTree|
|
|
115 |
|
|
116 |
theTree := self new.
|
|
117 |
theTree allButOpen.
|
|
118 |
theTree classHolder value:aClassColl.
|
|
119 |
theTree openWindow.
|
|
120 |
^theTree
|
|
121 |
|
|
122 |
"
|
|
123 |
|theSelectionHolder theTree|
|
|
124 |
|
|
125 |
theSelectionHolder := ValueHolder new.
|
|
126 |
theSelectionHolder compute:[:coll |
|
|
127 |
coll do:[:each | Transcript showCR: each]].
|
|
128 |
theTree := ClassRevisionTree openOnClasses:(Smalltalk allClasses asOrderedCollection sort:[:x : y|x name < y name]).
|
|
129 |
theSelectionHolder value:(Array with:(theTree itemList children last)).
|
|
130 |
theTree selectionHolder:theSelectionHolder.
|
|
131 |
"
|
2520
|
132 |
! !
|
|
133 |
|
|
134 |
!ClassRevisionTree methodsFor:'accessing'!
|
|
135 |
|
2538
|
136 |
classItemClass
|
|
137 |
"return the value of the instance variable 'classItemClass' (automatically generated)"
|
|
138 |
|
|
139 |
^ classItemClass ifNil:[classItemClass := self class classItemClass]
|
|
140 |
!
|
|
141 |
|
|
142 |
classItemClass:something
|
|
143 |
"set the value of the instance variable 'classItemClass' (automatically generated)"
|
|
144 |
|
|
145 |
classItemClass := something.!
|
|
146 |
|
|
147 |
classItemRootClass
|
|
148 |
"return the value of the instance variable 'classItemClass' (automatically generated)"
|
|
149 |
|
|
150 |
^ self class classItemRootClass
|
2520
|
151 |
!
|
|
152 |
|
2538
|
153 |
itemForSelectionIndex:anIndex
|
|
154 |
""
|
|
155 |
^self listModel at:anIndex ifAbsent:nil
|
2520
|
156 |
!
|
|
157 |
|
2538
|
158 |
itemList
|
|
159 |
"automatically generated by UIPainter ..."
|
|
160 |
|
|
161 |
"*** the code below creates a default model when invoked."
|
|
162 |
"*** (which may not be the one you wanted)"
|
|
163 |
"*** Please change as required and accept it in the browser."
|
2520
|
164 |
|
2538
|
165 |
^ self listModel root
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
2520
|
171 |
!
|
|
172 |
|
|
173 |
revisionInfoList
|
|
174 |
"return the value of the instance variable 'revisionInfoList' (automatically generated)"
|
|
175 |
|
|
176 |
^ revisionInfoList ifNil:[revisionInfoList := IdentitySet new]
|
|
177 |
!
|
|
178 |
|
|
179 |
semaphoreCritical
|
|
180 |
"return the value of the instance variable 'semaphoreCritical' (automatically generated)"
|
|
181 |
|
|
182 |
^ semaphoreCritical ifNil:[semaphoreCritical := RecursionLock new]
|
|
183 |
! !
|
|
184 |
|
|
185 |
!ClassRevisionTree methodsFor:'actions'!
|
|
186 |
|
2538
|
187 |
doubleClick:anIndex
|
|
188 |
|
|
189 |
|theItem|
|
2520
|
190 |
|
2538
|
191 |
(((theItem := self itemForSelectionIndex:anIndex) isExpandableRevisionItem) and:[listView sensor shiftDown])
|
|
192 |
ifTrue: [theItem recursiveToggleExpand]
|
|
193 |
ifFalse:[theItem toggleExpand]
|
2520
|
194 |
!
|
|
195 |
|
|
196 |
getRevisionInfoForClassItem: aClassItem
|
|
197 |
|
|
198 |
self semaphoreCritical critical:[
|
|
199 |
|theList|
|
|
200 |
currentClassItemInTask == aClassItem ifTrue:[^self].
|
|
201 |
(theList := self revisionInfoList) removeIdentical:aClassItem ifAbsent:[nil].
|
|
202 |
theList add:aClassItem.
|
|
203 |
self startRevisionTask]
|
|
204 |
!
|
|
205 |
|
2538
|
206 |
isItemSelectable:anIndex
|
|
207 |
"
|
|
208 |
checks if an item at anIndex can be selected. If an selection block
|
|
209 |
is set, evaluate it with the selected item.
|
|
210 |
(Callback from the tree).
|
2520
|
211 |
|
2538
|
212 |
<return: Boolean>
|
|
213 |
"
|
|
214 |
selectionBlock ifNil:[^true].
|
|
215 |
^selectionBlock value:(self itemForSelectionIndex:anIndex)
|
2520
|
216 |
|
|
217 |
! !
|
|
218 |
|
|
219 |
!ClassRevisionTree methodsFor:'aspects'!
|
|
220 |
|
2538
|
221 |
icons
|
|
222 |
|icons|
|
2520
|
223 |
|
2538
|
224 |
icons := Dictionary new.
|
|
225 |
icons at:#loadedRevision put:(Image fromFile:'gifImages/artwork/dots/red_ball.gif').
|
|
226 |
icons at:#unloadedRevision put:(Image fromFile:'gifImages/artwork/dots/green_ball.gif').
|
|
227 |
icons at:#unloadedClassItem put:(Image fromFile:'xpmBitmaps/file_images/small_folder_yellow_grey1.xpm').
|
|
228 |
icons at:#loadingClassItem put:(Image fromFile:'xpmBitmaps/file_images/small_folder_yellow_search.xpm').
|
|
229 |
icons at:#loadedClassItem put:(Image fromFile:'xpmBitmaps/file_images/small_folder_yellow.xpm').
|
|
230 |
^icons
|
2520
|
231 |
!
|
|
232 |
|
2538
|
233 |
listModel
|
2520
|
234 |
"automatically generated by UIPainter ..."
|
|
235 |
|
|
236 |
"*** the code below creates a default model when invoked."
|
|
237 |
"*** (which may not be the one you wanted)"
|
|
238 |
"*** Please change as required and accept it in the browser."
|
|
239 |
|
|
240 |
|holder|
|
|
241 |
|
2538
|
242 |
(holder := builder bindingAt:#listModel) isNil ifTrue:[
|
|
243 |
holder := HierarchicalList new.
|
|
244 |
holder root:(self classItemRootClass new).
|
|
245 |
holder showRoot:false.
|
|
246 |
builder aspectAt:#listModel put:holder.
|
|
247 |
holder application:self.
|
2520
|
248 |
].
|
|
249 |
^ holder.
|
2538
|
250 |
! !
|
2520
|
251 |
|
2538
|
252 |
!ClassRevisionTree methodsFor:'change & update'!
|
2520
|
253 |
|
2538
|
254 |
update:something with:aParameter from:changedObject
|
|
255 |
|
|
256 |
changedObject == self classHolder
|
|
257 |
ifTrue:[self setUpItemList].
|
|
258 |
|
|
259 |
|
2520
|
260 |
! !
|
|
261 |
|
|
262 |
!ClassRevisionTree methodsFor:'interface opening'!
|
|
263 |
|
2538
|
264 |
postBuildWith: aBuilder
|
|
265 |
|
|
266 |
super postBuildWith: aBuilder.
|
|
267 |
listView := self builder componentAt:#HierarchicalItemListView.
|
|
268 |
selectionHolder notNil
|
|
269 |
ifTrue:[listView model:selectionHolder]
|
|
270 |
!
|
|
271 |
|
2520
|
272 |
postOpenWith: aBuilder
|
|
273 |
|
|
274 |
|
|
275 |
super postOpenWith: aBuilder.
|
2538
|
276 |
self itemList expand.
|
2520
|
277 |
!
|
|
278 |
|
|
279 |
release
|
|
280 |
|
|
281 |
self stopRevisionTask.
|
|
282 |
^super release
|
|
283 |
|
|
284 |
|
|
285 |
! !
|
|
286 |
|
2538
|
287 |
!ClassRevisionTree methodsFor:'menu actions'!
|
2520
|
288 |
|
2538
|
289 |
selectItemMenu
|
|
290 |
"
|
|
291 |
get the menu for the selected items.If a menuBlock is set then evalute this block
|
|
292 |
with the current selection.
|
2520
|
293 |
|
2538
|
294 |
<return: Menu|nil>
|
|
295 |
"
|
|
296 |
^ [ menuBlock value ]
|
|
297 |
! !
|
2520
|
298 |
|
2538
|
299 |
!ClassRevisionTree methodsFor:'private'!
|
2520
|
300 |
|
|
301 |
revisionTaskCycle
|
|
302 |
|
|
303 |
|theClassItem|
|
|
304 |
|
|
305 |
[
|
|
306 |
theClassItem := nil.
|
|
307 |
self semaphoreCritical critical:[
|
|
308 |
self revisionInfoList notEmpty
|
|
309 |
ifTrue:[theClassItem := self revisionInfoList remove:(self revisionInfoList last) ifAbsent:[nil]]
|
|
310 |
].
|
2538
|
311 |
(theClassItem notNil and:[theClassItem needsChildren])ifTrue:[
|
|
312 |
currentClassItemInTask:=theClassItem.
|
|
313 |
theClassItem computeRevisions.
|
|
314 |
currentClassItemInTask:=nil
|
2520
|
315 |
].
|
|
316 |
theClassItem notNil
|
|
317 |
] whileTrue.
|
|
318 |
!
|
|
319 |
|
2538
|
320 |
setUpItemList
|
|
321 |
|
|
322 |
|theClassColl theClassItemColl root|
|
|
323 |
|
|
324 |
root := self classItemRootClass new.
|
|
325 |
(theClassColl := self classHolder value) notNil ifTrue:[
|
|
326 |
theClassItemColl := theClassColl collect:[:eachClass |
|
|
327 |
|theClassItem theClass|
|
|
328 |
theClassItem := self classItemClass new.
|
|
329 |
theClass := Smalltalk resolveName:eachClass inClass:Smalltalk.
|
|
330 |
theClassItem myClass:theClass.
|
|
331 |
theClassItem].
|
|
332 |
root addAll: theClassItemColl.
|
|
333 |
].
|
|
334 |
self listModel root:root.
|
|
335 |
!
|
|
336 |
|
2520
|
337 |
startRevisionTask
|
|
338 |
|
|
339 |
self semaphoreCritical critical:[
|
|
340 |
revisionTask ifNil:[
|
|
341 |
revisionTask := Process for:[
|
|
342 |
self revisionTaskCycle
|
|
343 |
]
|
|
344 |
priority:(Processor userBackgroundPriority).
|
|
345 |
revisionTask addExitAction:[revisionTask := nil].
|
|
346 |
revisionTask resume.
|
|
347 |
].
|
|
348 |
].
|
|
349 |
!
|
|
350 |
|
|
351 |
stopRevisionTask
|
|
352 |
|task|
|
|
353 |
|
|
354 |
self semaphoreCritical critical:[
|
|
355 |
(task := revisionTask) notNil ifTrue:[
|
|
356 |
revisionTask := nil.
|
|
357 |
Exception handle:[:ex|] do:[
|
|
358 |
task terminateWithAllSubprocesses.
|
|
359 |
task waitUntilTerminated.
|
|
360 |
]
|
|
361 |
]
|
|
362 |
].
|
|
363 |
|
|
364 |
! !
|
|
365 |
|
2538
|
366 |
!ClassRevisionTree methodsFor:'protocol accessing'!
|
|
367 |
|
|
368 |
classHolder
|
|
369 |
"return the value of the instance variable 'classHolder' (automatically generated)"
|
|
370 |
|
|
371 |
^classHolder ifNil:[
|
|
372 |
classHolder := ValueHolder new.
|
|
373 |
classHolder addDependent:self
|
|
374 |
]
|
|
375 |
!
|
|
376 |
|
|
377 |
classHolder:aValueHolder
|
|
378 |
"set the value of the instance variable 'classHolder' (automatically generated)"
|
2520
|
379 |
|
2538
|
380 |
(classHolder ~~ aValueHolder) ifTrue:[
|
|
381 |
classHolder removeDependent:self.
|
|
382 |
classHolder := aValueHolder.
|
|
383 |
classHolder notNil ifTrue:[
|
|
384 |
classHolder addDependent:self.
|
|
385 |
].
|
|
386 |
self setUpItemList
|
|
387 |
].
|
|
388 |
!
|
2520
|
389 |
|
2538
|
390 |
menuBlock
|
|
391 |
"return the value of the instance variable 'menuBlock' (automatically generated)"
|
|
392 |
|
|
393 |
^ menuBlock
|
|
394 |
!
|
2520
|
395 |
|
2538
|
396 |
menuBlock:something
|
|
397 |
"set the value of the instance variable 'menuBlock' (automatically generated)"
|
|
398 |
|
|
399 |
menuBlock := something.!
|
|
400 |
|
|
401 |
selectionBlock
|
|
402 |
"return the value of the instance variable 'selectionBlock' (automatically generated)"
|
|
403 |
|
|
404 |
^ selectionBlock!
|
|
405 |
|
|
406 |
selectionBlock:something
|
|
407 |
"set the value of the instance variable 'selectionBlock' (automatically generated)"
|
|
408 |
|
|
409 |
selectionBlock := something.!
|
|
410 |
|
|
411 |
selectionHolder
|
2520
|
412 |
|
2538
|
413 |
^selectionHolder
|
|
414 |
!
|
|
415 |
|
|
416 |
selectionHolder:aValueHolder
|
|
417 |
"set the value of the instance variable 'revisionItemSelection' (automatically generated)"
|
|
418 |
|
|
419 |
selectionHolder := aValueHolder.
|
|
420 |
listView ifNil:[^self].
|
|
421 |
listView model:selectionHolder
|
|
422 |
! !
|
|
423 |
|
|
424 |
!ClassRevisionTree methodsFor:'protocol setup'!
|
|
425 |
|
|
426 |
setupOnClasses:aClassColl
|
|
427 |
|
|
428 |
self classHolder value:aClassColl.
|
2520
|
429 |
"
|
|
430 |
|theTree|
|
|
431 |
|
|
432 |
theTree := ClassRevisionTree new.
|
|
433 |
theTree open.
|
2538
|
434 |
theTree setupOnClasses:#(VersionDiffBrowser HierarchicalVersionDiffBrowser SourceRevisionItem Project)
|
2520
|
435 |
"
|
|
436 |
! !
|
|
437 |
|
|
438 |
!ClassRevisionTree class methodsFor:'documentation'!
|
|
439 |
|
|
440 |
version
|
2538
|
441 |
^ '$Header: /cvs/stx/stx/libtool/ClassRevisionTree.st,v 1.3 2000-01-14 10:51:09 ps Exp $'
|
2520
|
442 |
! !
|