2520
|
1 |
ApplicationModel subclass:#ClassRevisionTree
|
|
2 |
instanceVariableNames:'selectionHolder semaphoreCritical revisionInfoList revisionTask
|
|
3 |
currentClassItemInTask'
|
|
4 |
classVariableNames:''
|
|
5 |
poolDictionaries:''
|
|
6 |
category:'Interface-Browsers'
|
|
7 |
!
|
|
8 |
|
|
9 |
|
|
10 |
!ClassRevisionTree class methodsFor:'interface spec'!
|
|
11 |
|
|
12 |
windowSpec
|
|
13 |
"This resource specification was automatically generated
|
|
14 |
by the UIPainter of ST/X."
|
|
15 |
|
|
16 |
"Do not manually edit this!! If it is corrupted,
|
|
17 |
the UIPainter may not be able to read the specification."
|
|
18 |
|
|
19 |
"
|
|
20 |
UIPainter new openOnClass:ClassRevisionTree andSelector:#windowSpec
|
|
21 |
ClassRevisionTree new openInterface:#windowSpec
|
|
22 |
ClassRevisionTree open
|
|
23 |
"
|
|
24 |
|
|
25 |
<resource: #canvas>
|
|
26 |
|
|
27 |
^
|
|
28 |
#(#FullSpec
|
|
29 |
#name: #windowSpec
|
|
30 |
#window:
|
|
31 |
#(#WindowSpec
|
|
32 |
#label: 'ClassVersionTree'
|
|
33 |
#name: 'ClassVersionTree'
|
|
34 |
#min: #(#Point 10 10)
|
|
35 |
#max: #(#Point 9999 9999)
|
|
36 |
#bounds: #(#Rectangle 16 51 881 580)
|
|
37 |
)
|
|
38 |
#component:
|
|
39 |
#(#SpecCollection
|
|
40 |
#collection: #(
|
|
41 |
#(#HierarchicalListViewSpec
|
|
42 |
#name: 'HierarchicalItemListView'
|
|
43 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
44 |
#model: #hierarchicalItemSelectionAspect
|
|
45 |
#menu: #selectHierarchicalItemMenu
|
|
46 |
#hasHorizontalScrollBar: true
|
|
47 |
#hasVerticalScrollBar: true
|
|
48 |
#listModel: #hierarchicalItemListModel
|
|
49 |
#multipleSelectOk: true
|
|
50 |
#highlightMode: #label
|
|
51 |
#doubleClickSelector: #doubleClick:
|
|
52 |
#selectConditionSelector: #isHierarchicalItemSelectable:
|
|
53 |
#indicatorSelector: #doubleClick:
|
|
54 |
#retrieveIconsSelector: #icons
|
|
55 |
)
|
|
56 |
)
|
|
57 |
|
|
58 |
)
|
|
59 |
)
|
|
60 |
! !
|
|
61 |
|
|
62 |
!ClassRevisionTree class methodsFor:'menu specs'!
|
|
63 |
|
|
64 |
resourceItemMenu
|
|
65 |
"This resource specification was automatically generated
|
|
66 |
by the MenuEditor of ST/X."
|
|
67 |
|
|
68 |
"Do not manually edit this!! If it is corrupted,
|
|
69 |
the MenuEditor may not be able to read the specification."
|
|
70 |
|
|
71 |
"
|
|
72 |
MenuEditor new openOnClass:ClassRevisionTree andSelector:#resourceItemMenu
|
|
73 |
(Menu new fromLiteralArrayEncoding:(ClassRevisionTree resourceItemMenu)) startUp
|
|
74 |
"
|
|
75 |
|
|
76 |
<resource: #menu>
|
|
77 |
|
|
78 |
^
|
|
79 |
#(#Menu
|
|
80 |
#(
|
|
81 |
#(#MenuItem
|
|
82 |
#label: 'Compare Changes'
|
|
83 |
#translateLabel: true
|
|
84 |
#value: #menuActionCompareChanges
|
|
85 |
)
|
|
86 |
)
|
|
87 |
nil
|
|
88 |
nil
|
|
89 |
)
|
|
90 |
! !
|
|
91 |
|
|
92 |
!ClassRevisionTree class methodsFor:'startup'!
|
|
93 |
|
|
94 |
openOnClasses:aClassColl withSelectionHolder:aValueHolder
|
|
95 |
|theTree theClassItemColl|
|
|
96 |
|
|
97 |
theTree := self new.
|
|
98 |
theTree allButOpen.
|
|
99 |
theClassItemColl := aClassColl collect:[:eachClass |
|
|
100 |
|theClassItem theClass|
|
|
101 |
theClassItem := ClassItem new.
|
|
102 |
theClass := Smalltalk resolveName:eachClass inClass:self.
|
|
103 |
theClassItem myClass:theClass.
|
|
104 |
theClassItem].
|
|
105 |
theTree hierarchicalItemList addAll: theClassItemColl.
|
|
106 |
theTree selectionHolder:aValueHolder.
|
|
107 |
theTree openWindow.
|
|
108 |
^theTree
|
|
109 |
|
|
110 |
"
|
|
111 |
|theSelectionHolder|
|
|
112 |
|
|
113 |
theSelectionHolder := ValueHolder new.
|
|
114 |
theSelectionHolder compute:[:el |
|
|
115 |
Transcript showCR: el first revisionString.
|
|
116 |
Transcript showCR: el second revisionString].
|
|
117 |
ClassRevisionTree openOnClasses:(Smalltalk allClasses asOrderedCollection sort:[:x : y|x name < y name])
|
|
118 |
withSelectionHolder:theSelectionHolder.
|
|
119 |
"
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
! !
|
|
124 |
|
|
125 |
!ClassRevisionTree methodsFor:'accessing'!
|
|
126 |
|
|
127 |
hierarchicalListItemForSelectionIndex: anIndex
|
|
128 |
|
|
129 |
^self hierarchicalItemListModel at:anIndex ifAbsent:nil
|
|
130 |
!
|
|
131 |
|
|
132 |
hierarchicalListSelectionIndexColl
|
|
133 |
|
|
134 |
^self hierarchicalItemSelectionAspect value
|
|
135 |
!
|
|
136 |
|
|
137 |
hierarchicalListSelectionIndexColl:anArray
|
|
138 |
|
|
139 |
^self hierarchicalItemSelectionAspect value:anArray
|
|
140 |
!
|
|
141 |
|
|
142 |
revisionInfoList
|
|
143 |
"return the value of the instance variable 'revisionInfoList' (automatically generated)"
|
|
144 |
|
|
145 |
^ revisionInfoList ifNil:[revisionInfoList := IdentitySet new]
|
|
146 |
!
|
|
147 |
|
|
148 |
selectionHolder
|
|
149 |
"return the value of the instance variable 'selectionHolder' (automatically generated)"
|
|
150 |
|
|
151 |
^ selectionHolder!
|
|
152 |
|
|
153 |
selectionHolder:something
|
|
154 |
"set the value of the instance variable 'revisionItemSelection' (automatically generated)"
|
|
155 |
|
|
156 |
selectionHolder := something.
|
|
157 |
!
|
|
158 |
|
|
159 |
semaphoreCritical
|
|
160 |
"return the value of the instance variable 'semaphoreCritical' (automatically generated)"
|
|
161 |
|
|
162 |
^ semaphoreCritical ifNil:[semaphoreCritical := RecursionLock new]
|
|
163 |
! !
|
|
164 |
|
|
165 |
!ClassRevisionTree methodsFor:'actions'!
|
|
166 |
|
|
167 |
doubleClick: anIndex
|
|
168 |
"automatically generated by UIPainter ..."
|
|
169 |
|
|
170 |
"*** the code below performs no action"
|
|
171 |
"*** (except for some feedback on the Transcript)"
|
|
172 |
"*** Please change as required and accept in the browser."
|
|
173 |
|
|
174 |
"action to be added ..."
|
|
175 |
|
|
176 |
(self hierarchicalItemListModel at: anIndex) toggleExpand
|
|
177 |
!
|
|
178 |
|
|
179 |
getRevisionInfoForClassItem: aClassItem
|
|
180 |
|
|
181 |
self semaphoreCritical critical:[
|
|
182 |
|theList|
|
|
183 |
currentClassItemInTask == aClassItem ifTrue:[^self].
|
|
184 |
(theList := self revisionInfoList) removeIdentical:aClassItem ifAbsent:[nil].
|
|
185 |
theList add:aClassItem.
|
|
186 |
Transcript showCR:theList.
|
|
187 |
self startRevisionTask]
|
|
188 |
!
|
|
189 |
|
|
190 |
isHierarchicalItemSelectable: anIndex
|
|
191 |
|
|
192 |
|theSelectionIndexColl theSelectionIndexSize theSelectedItem|
|
|
193 |
|
|
194 |
"nur eine Revision kann selektiert werden"
|
|
195 |
(theSelectedItem := self hierarchicalListItemForSelectionIndex: anIndex) isRevisionItem
|
|
196 |
ifFalse:[^false].
|
|
197 |
"ist keine selektiert ist alles ok -> mit true zurueck"
|
|
198 |
(theSelectionIndexColl := self hierarchicalListSelectionIndexColl) size == 0
|
|
199 |
ifTrue:[^true].
|
|
200 |
"wurde deselektiert"
|
|
201 |
(self window sensor ctrlDown)
|
|
202 |
ifTrue: [
|
|
203 |
"ist eine Rev selektiert und die Klassen sind nicht gleich, dann falsch"
|
|
204 |
(self hierarchicalListItemForSelectionIndex:theSelectionIndexColl first) parent myClass == theSelectedItem parent myClass
|
|
205 |
ifFalse:[^false].
|
|
206 |
theSelectionIndexColl size ~~ 2
|
|
207 |
ifTrue:[^true].
|
|
208 |
(theSelectionIndexColl includes:anIndex)
|
|
209 |
ifTrue: [^true]
|
|
210 |
ifFalse:[self hierarchicalListSelectionIndexColl:(Array with:theSelectionIndexColl first).
|
|
211 |
^true]]
|
|
212 |
ifFalse:[
|
|
213 |
(theSelectionIndexColl size == 2)
|
|
214 |
ifTrue:[self hierarchicalListSelectionIndexColl:(Array with:anIndex)].
|
|
215 |
^true]
|
|
216 |
!
|
|
217 |
|
|
218 |
menuActionCompareChanges
|
|
219 |
|
|
220 |
|theSelectionIndexColl theFirstRevisionItem theSecondRevisionItem|
|
|
221 |
|
|
222 |
theSelectionIndexColl := self hierarchicalListSelectionIndexColl.
|
|
223 |
theFirstRevisionItem := self hierarchicalListItemForSelectionIndex:theSelectionIndexColl first.
|
|
224 |
theSecondRevisionItem := self hierarchicalListItemForSelectionIndex:theSelectionIndexColl last.
|
|
225 |
self selectionHolder notNil
|
|
226 |
ifTrue:[self selectionHolder value:(Array with:theFirstRevisionItem with:theSecondRevisionItem)]
|
|
227 |
!
|
|
228 |
|
|
229 |
selectHierarchicalItemMenu
|
|
230 |
"
|
|
231 |
<return: Block>
|
|
232 |
"
|
|
233 |
|
|
234 |
^[|menu|
|
|
235 |
self checkIfTwoResourceItemsSelected
|
|
236 |
ifFalse:[menu := nil]
|
|
237 |
ifTrue: [menu := Menu new fromLiteralArrayEncoding:(self class resourceItemMenu).
|
|
238 |
menu receiver:self].
|
|
239 |
menu
|
|
240 |
]
|
|
241 |
! !
|
|
242 |
|
|
243 |
!ClassRevisionTree methodsFor:'aspects'!
|
|
244 |
|
|
245 |
hierarchicalItemList
|
|
246 |
"automatically generated by UIPainter ..."
|
|
247 |
|
|
248 |
"*** the code below creates a default model when invoked."
|
|
249 |
"*** (which may not be the one you wanted)"
|
|
250 |
"*** Please change as required and accept it in the browser."
|
|
251 |
|
|
252 |
^ self hierarchicalItemListModel root
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
!
|
|
259 |
|
|
260 |
hierarchicalItemListModel
|
|
261 |
"automatically generated by UIPainter ..."
|
|
262 |
|
|
263 |
"*** the code below creates a default model when invoked."
|
|
264 |
"*** (which may not be the one you wanted)"
|
|
265 |
"*** Please change as required and accept it in the browser."
|
|
266 |
|
|
267 |
|holder|
|
|
268 |
|
|
269 |
(holder := builder bindingAt:#hierarchicalItemListModel) isNil ifTrue:[
|
|
270 |
holder := HierarchicalList new.
|
|
271 |
holder root:(ClassItemRoot new).
|
|
272 |
holder showRoot:false.
|
|
273 |
builder aspectAt:#hierarchicalItemListModel put:holder.
|
|
274 |
holder application:self.
|
|
275 |
].
|
|
276 |
|
|
277 |
^ holder.
|
|
278 |
|
|
279 |
!
|
|
280 |
|
|
281 |
hierarchicalItemSelectionAspect
|
|
282 |
"automatically generated by UIPainter ..."
|
|
283 |
|
|
284 |
"*** the code below creates a default model when invoked."
|
|
285 |
"*** (which may not be the one you wanted)"
|
|
286 |
"*** Please change as required and accept it in the browser."
|
|
287 |
|
|
288 |
|holder|
|
|
289 |
|
|
290 |
(holder := builder bindingAt:#hierarchicalItemSelectionAspect) isNil ifTrue:[
|
|
291 |
holder := ValueHolder new.
|
|
292 |
builder aspectAt:#hierarchicalItemSelectionAspect put:holder.
|
|
293 |
holder addDependent: self.
|
|
294 |
].
|
|
295 |
^ holder.
|
|
296 |
|
|
297 |
!
|
|
298 |
|
|
299 |
icons
|
|
300 |
|icons|
|
|
301 |
icons := Dictionary new.
|
|
302 |
icons at:#loadedRevision put:Icon leftIcon.
|
|
303 |
icons at:#notLoadedRevision put:Icon rightIcon.
|
|
304 |
^icons
|
|
305 |
! !
|
|
306 |
|
|
307 |
!ClassRevisionTree methodsFor:'interface opening'!
|
|
308 |
|
|
309 |
postOpenWith: aBuilder
|
|
310 |
|
|
311 |
|
|
312 |
super postOpenWith: aBuilder.
|
|
313 |
self hierarchicalItemList expand.
|
|
314 |
!
|
|
315 |
|
|
316 |
release
|
|
317 |
|
|
318 |
self stopRevisionTask.
|
|
319 |
^super release
|
|
320 |
|
|
321 |
|
|
322 |
! !
|
|
323 |
|
|
324 |
!ClassRevisionTree methodsFor:'private'!
|
|
325 |
|
|
326 |
computeChildrenForClassItem:aClassItem
|
|
327 |
|
|
328 |
|theRevisionLog|
|
|
329 |
theRevisionLog := self computeRevisionInfoForClassItem:aClassItem.
|
|
330 |
aClassItem setChildrensForRevisionInfo:theRevisionLog
|
|
331 |
!
|
|
332 |
|
|
333 |
computeRevisionInfoForClassItem:aClassItem
|
|
334 |
|
|
335 |
|theClass theSourceCodeManager|
|
|
336 |
|
|
337 |
theClass := aClassItem myClass.
|
|
338 |
theSourceCodeManager:=theClass sourceCodeManager.
|
|
339 |
^theSourceCodeManager revisionLogOf:theClass.
|
|
340 |
!
|
|
341 |
|
|
342 |
revisionTaskCycle
|
|
343 |
|
|
344 |
|theClassItem|
|
|
345 |
|
|
346 |
[
|
|
347 |
theClassItem := nil.
|
|
348 |
self semaphoreCritical critical:[
|
|
349 |
self revisionInfoList notEmpty
|
|
350 |
ifTrue:[theClassItem := self revisionInfoList remove:(self revisionInfoList last) ifAbsent:[nil]]
|
|
351 |
].
|
|
352 |
theClassItem notNil ifTrue:[
|
|
353 |
theClassItem isExpanded
|
|
354 |
ifTrue: [currentClassItemInTask:=theClassItem.
|
|
355 |
self computeChildrenForClassItem:theClassItem]
|
|
356 |
ifFalse:[currentClassItemInTask:=nil]
|
|
357 |
].
|
|
358 |
theClassItem notNil
|
|
359 |
] whileTrue.
|
|
360 |
!
|
|
361 |
|
|
362 |
startRevisionTask
|
|
363 |
|
|
364 |
self semaphoreCritical critical:[
|
|
365 |
revisionTask ifNil:[
|
|
366 |
revisionTask := Process for:[
|
|
367 |
self revisionTaskCycle
|
|
368 |
]
|
|
369 |
priority:(Processor userBackgroundPriority).
|
|
370 |
revisionTask addExitAction:[revisionTask := nil].
|
|
371 |
revisionTask resume.
|
|
372 |
].
|
|
373 |
].
|
|
374 |
!
|
|
375 |
|
|
376 |
stopRevisionTask
|
|
377 |
|task|
|
|
378 |
|
|
379 |
self semaphoreCritical critical:[
|
|
380 |
(task := revisionTask) notNil ifTrue:[
|
|
381 |
revisionTask := nil.
|
|
382 |
Exception handle:[:ex|] do:[
|
|
383 |
task terminateWithAllSubprocesses.
|
|
384 |
task waitUntilTerminated.
|
|
385 |
]
|
|
386 |
]
|
|
387 |
].
|
|
388 |
|
|
389 |
! !
|
|
390 |
|
|
391 |
!ClassRevisionTree methodsFor:'setup'!
|
|
392 |
|
|
393 |
setupOnClasses:aClassColl withSelectionHolder:aValueHolder
|
|
394 |
|
|
395 |
|theClassItemColl|
|
|
396 |
|
|
397 |
theClassItemColl := aClassColl collect:[:eachClass |
|
|
398 |
|theClassItem theClass|
|
|
399 |
theClassItem := ClassItem new.
|
|
400 |
theClass := Smalltalk resolveName:eachClass inClass:Smalltalk.
|
|
401 |
theClassItem myClass:theClass.
|
|
402 |
theClassItem].
|
|
403 |
self hierarchicalItemList addAll: theClassItemColl.
|
|
404 |
self selectionHolder:aValueHolder.
|
|
405 |
|
|
406 |
"
|
|
407 |
|theTree|
|
|
408 |
|
|
409 |
theTree := ClassRevisionTree new.
|
|
410 |
theTree open.
|
|
411 |
theTree setupOnClasses:#(VersionDiffBrowser HierarchicalVersionDiffBrowser SourceRevisionItem Project) withSelectionHolder:nil.
|
|
412 |
"
|
|
413 |
! !
|
|
414 |
|
|
415 |
!ClassRevisionTree methodsFor:'testing'!
|
|
416 |
|
|
417 |
checkIfTwoResourceItemsSelected
|
|
418 |
|
|
419 |
|theSelectionIndexColl|
|
|
420 |
|
|
421 |
((theSelectionIndexColl := self hierarchicalListSelectionIndexColl) isNil or:
|
|
422 |
[theSelectionIndexColl size ~~ 2])
|
|
423 |
ifTrue:[^false].
|
|
424 |
^((self hierarchicalListItemForSelectionIndex:theSelectionIndexColl first) isRevisionItem
|
|
425 |
and:[(self hierarchicalListItemForSelectionIndex:theSelectionIndexColl last) isRevisionItem])
|
|
426 |
! !
|
|
427 |
|
|
428 |
!ClassRevisionTree class methodsFor:'documentation'!
|
|
429 |
|
|
430 |
version
|
|
431 |
^ '$Header: /cvs/stx/stx/libtool/ClassRevisionTree.st,v 1.1 1999-12-29 15:32:17 ps Exp $'
|
|
432 |
! !
|