2500
|
1 |
ApplicationModel subclass:#HierarchicalVersionDiffBrowser
|
2538
|
2 |
instanceVariableNames:'versionDiffBrowser classTree treeSelectionHolder classHolder'
|
2500
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Interface-Browsers'
|
|
6 |
!
|
|
7 |
|
2548
|
8 |
!HierarchicalVersionDiffBrowser class methodsFor:'documentation'!
|
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
documentation to be added.
|
|
13 |
|
|
14 |
[author:]
|
|
15 |
Pierre Schwarz (ps@exept.de)
|
|
16 |
|
|
17 |
[see also:]
|
|
18 |
|
|
19 |
[instance variables:]
|
|
20 |
|
|
21 |
[class variables:]
|
|
22 |
"
|
|
23 |
|
|
24 |
! !
|
2500
|
25 |
|
|
26 |
!HierarchicalVersionDiffBrowser class methodsFor:'interface specs'!
|
|
27 |
|
|
28 |
contentsSpecVersionDiffBrowser
|
|
29 |
"This resource specification was automatically generated
|
|
30 |
by the UIPainter of ST/X."
|
|
31 |
|
|
32 |
"Do not manually edit this!! If it is corrupted,
|
|
33 |
the UIPainter may not be able to read the specification."
|
|
34 |
|
|
35 |
"
|
2515
|
36 |
UIPainter new openOnClass:ClassRevisionTree andSelector:#contentsSpecVersionDiffBrowser
|
|
37 |
ClassRevisionTree new openInterface:#contentsSpecVersionDiffBrowser
|
2500
|
38 |
"
|
|
39 |
|
|
40 |
<resource: #canvas>
|
|
41 |
|
|
42 |
^
|
|
43 |
#(#FullSpec
|
2515
|
44 |
#name: #contentsSpecVersionDiffBrowser
|
|
45 |
#window:
|
2500
|
46 |
#(#WindowSpec
|
2515
|
47 |
#label: 'Hierarchical Version DiffBrowser'
|
|
48 |
#name: 'Hierarchical Version DiffBrowser'
|
|
49 |
#min: #(#Point 10 10)
|
|
50 |
#max: #(#Point 9999 9999)
|
|
51 |
#bounds: #(#Rectangle 12 22 877 551)
|
|
52 |
)
|
|
53 |
#component:
|
2500
|
54 |
#(#SpecCollection
|
2515
|
55 |
#collection: #(
|
|
56 |
#(#SubCanvasSpec
|
|
57 |
#name: 'VersionDiffBrowser'
|
|
58 |
#layout: #(#LayoutFrame 0 0.0 30 0.0 0 1.0 0 1.0)
|
|
59 |
#hasHorizontalScrollBar: false
|
|
60 |
#hasVerticalScrollBar: false
|
|
61 |
#majorKey: #VersionDiffBrowser
|
|
62 |
#minorKey: #windowSpec
|
|
63 |
#clientKey: #versionDiffBrowser
|
|
64 |
)
|
|
65 |
#(#LabelSpec
|
|
66 |
#name: 'Label1'
|
|
67 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 20 0)
|
|
68 |
#visibilityChannel: #''
|
|
69 |
#translateLabel: true
|
|
70 |
#labelChannel: #versionDiffModel
|
|
71 |
#resizeForLabel: false
|
|
72 |
#adjust: #left
|
|
73 |
)
|
|
74 |
)
|
2500
|
75 |
|
2515
|
76 |
)
|
2500
|
77 |
)
|
|
78 |
!
|
|
79 |
|
|
80 |
windowSpec
|
|
81 |
"This resource specification was automatically generated
|
|
82 |
by the UIPainter of ST/X."
|
|
83 |
|
|
84 |
"Do not manually edit this!! If it is corrupted,
|
|
85 |
the UIPainter may not be able to read the specification."
|
|
86 |
|
|
87 |
"
|
|
88 |
UIPainter new openOnClass:HierarchicalVersionDiffBrowser andSelector:#windowSpec
|
|
89 |
HierarchicalVersionDiffBrowser new openInterface:#windowSpec
|
|
90 |
HierarchicalVersionDiffBrowser open
|
|
91 |
"
|
|
92 |
|
|
93 |
<resource: #canvas>
|
|
94 |
|
|
95 |
^
|
|
96 |
#(#FullSpec
|
|
97 |
#name: #windowSpec
|
|
98 |
#window:
|
|
99 |
#(#WindowSpec
|
|
100 |
#label: 'Hierarchical Version DiffBrowser'
|
|
101 |
#name: 'Hierarchical Version DiffBrowser'
|
|
102 |
#min: #(#Point 10 10)
|
|
103 |
#max: #(#Point 9999 9999)
|
2508
|
104 |
#bounds: #(#Rectangle 16 46 881 575)
|
2500
|
105 |
)
|
|
106 |
#component:
|
|
107 |
#(#SpecCollection
|
|
108 |
#collection: #(
|
|
109 |
#(#MenuPanelSpec
|
|
110 |
#name: 'menuPanel'
|
|
111 |
#layout: #(#LayoutFrame 0 0 0 0 0 1.0 24 0)
|
|
112 |
#level: 1
|
|
113 |
#tabable: true
|
|
114 |
#style:
|
|
115 |
#(#Font
|
|
116 |
'helvetica' 'bold'
|
|
117 |
'oblique' 10
|
|
118 |
)
|
|
119 |
)
|
|
120 |
#(#VariableHorizontalPanelSpec
|
|
121 |
#name: 'VariableHorizontalPanel1'
|
2508
|
122 |
#layout: #(#LayoutFrame 0 0.0 25 0.0 0 1.0 0 1.0)
|
|
123 |
#level: 2
|
2500
|
124 |
#component:
|
|
125 |
#(#SpecCollection
|
|
126 |
#collection: #(
|
2515
|
127 |
#(#SubCanvasSpec
|
|
128 |
#name: 'ClassTree'
|
|
129 |
#hasHorizontalScrollBar: false
|
|
130 |
#hasVerticalScrollBar: false
|
|
131 |
#majorKey: #ClassRevisonTree
|
|
132 |
#minorKey: #windowSpec
|
|
133 |
#clientKey: #classTree
|
2500
|
134 |
)
|
|
135 |
#(#UISubSpecification
|
|
136 |
#name: 'SubSpecification1'
|
|
137 |
#majorKey: #HierarchicalVersionDiffBrowser
|
|
138 |
#minorKey: #contentsSpecVersionDiffBrowser
|
|
139 |
)
|
|
140 |
)
|
|
141 |
|
|
142 |
)
|
2538
|
143 |
#handles: #(#Any 0.310983 1.0)
|
2500
|
144 |
)
|
|
145 |
)
|
|
146 |
|
|
147 |
)
|
|
148 |
)
|
|
149 |
! !
|
|
150 |
|
2538
|
151 |
!HierarchicalVersionDiffBrowser class methodsFor:'menu specs'!
|
|
152 |
|
|
153 |
resourceClassItemMenu
|
|
154 |
"This resource specification was automatically generated
|
|
155 |
by the MenuEditor of ST/X."
|
|
156 |
|
|
157 |
"Do not manually edit this!! If it is corrupted,
|
|
158 |
the MenuEditor may not be able to read the specification."
|
|
159 |
|
|
160 |
"
|
|
161 |
MenuEditor new openOnClass:ClassRevisionTree andSelector:#resourceRevisonItemMenu
|
|
162 |
(Menu new fromLiteralArrayEncoding:(ClassRevisionTree resourceRevisonItemMenu)) startUp
|
|
163 |
"
|
|
164 |
|
|
165 |
<resource: #menu>
|
|
166 |
|
|
167 |
^
|
|
168 |
#(#Menu
|
|
169 |
#(
|
|
170 |
#(#MenuItem
|
|
171 |
#label: 'Browse Class'
|
|
172 |
#translateLabel: true
|
|
173 |
#value: #menuActionBrowseClass
|
|
174 |
)
|
|
175 |
)
|
|
176 |
nil
|
|
177 |
nil
|
|
178 |
)
|
|
179 |
|
|
180 |
!
|
|
181 |
|
|
182 |
resourceCompareChangesMenu
|
|
183 |
"This resource specification was automatically generated
|
|
184 |
by the MenuEditor of ST/X."
|
|
185 |
|
|
186 |
"Do not manually edit this!! If it is corrupted,
|
|
187 |
the MenuEditor may not be able to read the specification."
|
|
188 |
|
|
189 |
"
|
|
190 |
MenuEditor new openOnClass:ClassRevisionTree andSelector:#resourceCompareChangesMenu
|
|
191 |
(Menu new fromLiteralArrayEncoding:(ClassRevisionTree resourceCompareChangesMenu)) startUp
|
|
192 |
"
|
|
193 |
|
|
194 |
<resource: #menu>
|
|
195 |
|
|
196 |
^
|
|
197 |
#(#Menu
|
|
198 |
#(
|
|
199 |
#(#MenuItem
|
|
200 |
#label: 'Compare Changes'
|
|
201 |
#translateLabel: true
|
|
202 |
#value: #menuActionCompareChanges
|
|
203 |
)
|
|
204 |
)
|
|
205 |
nil
|
|
206 |
nil
|
|
207 |
)
|
|
208 |
|
|
209 |
!
|
|
210 |
|
|
211 |
resourceRevisonItemMenu
|
|
212 |
"This resource specification was automatically generated
|
|
213 |
by the MenuEditor of ST/X."
|
|
214 |
|
|
215 |
"Do not manually edit this!! If it is corrupted,
|
|
216 |
the MenuEditor may not be able to read the specification."
|
|
217 |
|
|
218 |
"
|
|
219 |
MenuEditor new openOnClass:ClassRevisionTree andSelector:#resourceRevisonItemMenu
|
|
220 |
(Menu new fromLiteralArrayEncoding:(ClassRevisionTree resourceRevisonItemMenu)) startUp
|
|
221 |
"
|
|
222 |
|
|
223 |
<resource: #menu>
|
|
224 |
|
|
225 |
^
|
|
226 |
#(#Menu
|
|
227 |
#(
|
|
228 |
#(#MenuItem
|
|
229 |
#label: 'Load Revision'
|
|
230 |
#translateLabel: true
|
|
231 |
#nameKey: #menuActionLoadRevision
|
|
232 |
#value: #menuActionLoadRevision
|
|
233 |
)
|
|
234 |
)
|
|
235 |
nil
|
|
236 |
nil
|
|
237 |
)
|
|
238 |
|
|
239 |
! !
|
|
240 |
|
|
241 |
!HierarchicalVersionDiffBrowser class methodsFor:'protocol'!
|
|
242 |
|
|
243 |
browserClass
|
|
244 |
|
|
245 |
^SystemBrowser
|
|
246 |
!
|
|
247 |
|
|
248 |
tree
|
|
249 |
|
|
250 |
^ClassRevisionTree
|
|
251 |
! !
|
|
252 |
|
2500
|
253 |
!HierarchicalVersionDiffBrowser class methodsFor:'startup'!
|
|
254 |
|
|
255 |
openOnClasses:aClassColl
|
2515
|
256 |
|theBrowser theTree|
|
2500
|
257 |
|
|
258 |
theBrowser := self new.
|
2538
|
259 |
theTree := self tree new.
|
|
260 |
theBrowser classTree:theTree.
|
2500
|
261 |
theBrowser allButOpen.
|
2538
|
262 |
theTree classHolder:(theBrowser classHolder value:aClassColl).
|
|
263 |
theTree selectionHolder:theBrowser treeSelectionHolder.
|
|
264 |
theTree menuBlock:theBrowser menuBlock.
|
2515
|
265 |
theBrowser openWindow.
|
2538
|
266 |
^theBrowser
|
2500
|
267 |
"
|
2538
|
268 |
|theBrowser|
|
|
269 |
theBrowser := self openOnClasses:#(VersionDiffBrowser FileBrowser Array).
|
|
270 |
Delay waitForMilliseconds:1500.
|
|
271 |
theBrowser classHolder value:(Smalltalk allClasses asOrderedCollection sort:[:x : y|x name < y name])
|
2500
|
272 |
"
|
|
273 |
! !
|
|
274 |
|
|
275 |
!HierarchicalVersionDiffBrowser methodsFor:'accessing'!
|
|
276 |
|
2538
|
277 |
classHolder
|
|
278 |
"return the value of the instance variable 'classHolder' (automatically generated)"
|
|
279 |
|
|
280 |
^ classHolder ifNil:[classHolder := ValueHolder new]
|
|
281 |
!
|
|
282 |
|
|
283 |
classHolder:something
|
|
284 |
"set the value of the instance variable 'classHolder' (automatically generated)"
|
|
285 |
|
|
286 |
classHolder := something.!
|
|
287 |
|
2515
|
288 |
classTree
|
2500
|
289 |
|
2515
|
290 |
^ classTree
|
2500
|
291 |
!
|
|
292 |
|
2515
|
293 |
classTree:something
|
|
294 |
"set the value of the instance variable 'classTree' (automatically generated)"
|
2509
|
295 |
|
2515
|
296 |
classTree := something.!
|
2509
|
297 |
|
2515
|
298 |
treeSelectionHolder
|
2500
|
299 |
|
2538
|
300 |
^treeSelectionHolder ifNil:[treeSelectionHolder := ValueHolder new]
|
2500
|
301 |
!
|
|
302 |
|
|
303 |
versionDiffBrowser
|
2515
|
304 |
|
2500
|
305 |
versionDiffBrowser isNil ifTrue:[
|
|
306 |
versionDiffBrowser := VersionDiffBrowser new.
|
|
307 |
versionDiffBrowser masterApplication:self.
|
|
308 |
].
|
|
309 |
^ versionDiffBrowser
|
|
310 |
! !
|
|
311 |
|
|
312 |
!HierarchicalVersionDiffBrowser methodsFor:'aspects'!
|
|
313 |
|
|
314 |
versionDiffModel
|
|
315 |
"automatically generated by UIPainter ..."
|
|
316 |
|
|
317 |
"*** the code below creates a default model when invoked."
|
|
318 |
"*** (which may not be the one you wanted)"
|
|
319 |
"*** Please change as required and accept it in the browser."
|
|
320 |
|
|
321 |
|holder|
|
|
322 |
|
|
323 |
(holder := builder bindingAt:#versionDiffModel) isNil ifTrue:[
|
|
324 |
holder := String new asValue.
|
|
325 |
builder aspectAt:#versionDiffModel put:holder.
|
|
326 |
].
|
|
327 |
^ holder.
|
|
328 |
! !
|
|
329 |
|
2538
|
330 |
!HierarchicalVersionDiffBrowser methodsFor:'menu'!
|
|
331 |
|
|
332 |
menuForClassItemSelected
|
|
333 |
"
|
|
334 |
<return: Menu>
|
|
335 |
"
|
|
336 |
|menu|
|
|
337 |
|
|
338 |
menu := Menu new fromLiteralArrayEncoding:(self class resourceClassItemMenu).
|
|
339 |
menu receiver:self.
|
|
340 |
^menu
|
|
341 |
|
|
342 |
!
|
|
343 |
|
|
344 |
menuForOneRevisionItemSelected
|
|
345 |
"
|
|
346 |
<return: Menu>
|
|
347 |
"
|
|
348 |
|menu theItemColl|
|
|
349 |
|
|
350 |
menu := Menu new fromLiteralArrayEncoding:(self class resourceRevisonItemMenu).
|
|
351 |
"disable load button, if version already loaded"
|
|
352 |
theItemColl := self treeSelectionHolder value.
|
|
353 |
theItemColl first isLoadedRevision
|
|
354 |
ifTrue:[menu allItemsDo:[:eachItem | eachItem nameKey == #menuActionLoadRevision
|
|
355 |
ifTrue:[eachItem isEnabled:false]].
|
|
356 |
].
|
|
357 |
menu receiver:self.
|
|
358 |
^menu
|
|
359 |
!
|
|
360 |
|
|
361 |
menuForTwoRevisionItemsSelected
|
|
362 |
"
|
|
363 |
<return: Menu>
|
|
364 |
"
|
|
365 |
|menu|
|
|
366 |
|
|
367 |
menu := Menu new fromLiteralArrayEncoding:(self class resourceCompareChangesMenu).
|
|
368 |
menu receiver:self.
|
|
369 |
^menu
|
|
370 |
|
|
371 |
! !
|
|
372 |
|
|
373 |
!HierarchicalVersionDiffBrowser methodsFor:'menu actions'!
|
|
374 |
|
|
375 |
menuActionBrowseClass
|
|
376 |
|
|
377 |
self class browserClass openInClass:self treeSelectionHolder value first myClass
|
|
378 |
|
|
379 |
!
|
|
380 |
|
|
381 |
menuActionCompareChanges
|
|
382 |
|
|
383 |
self updateVersionDiffBrowser
|
|
384 |
|
|
385 |
|
|
386 |
!
|
|
387 |
|
|
388 |
menuActionLoadRevision
|
|
389 |
|
|
390 |
|theSelectedItem theLoadedItem theChangeSetA theChangeSetB theChangeDic|
|
2500
|
391 |
|
2538
|
392 |
theSelectedItem := self treeSelectionHolder value first.
|
|
393 |
theLoadedItem := theSelectedItem parent loadedRevisionItem.
|
|
394 |
theChangeSetA := ChangeSet fromStream:(theSelectedItem sourceStream).
|
|
395 |
theChangeSetB := ChangeSet fromStream:(theLoadedItem sourceStream).
|
|
396 |
(theChangeSetA isNil or:[theChangeSetB isNil]) ifTrue:[^self].
|
|
397 |
theChangeDic := (theChangeSetA diffSetsAgainst:theChangeSetB).
|
|
398 |
self applyChangesIn:theChangeDic.
|
|
399 |
!
|
|
400 |
|
|
401 |
menuBlock
|
|
402 |
|
|
403 |
^[
|
|
404 |
|menu|
|
|
405 |
self checkIfTwoRevisionItemsSelected
|
|
406 |
ifTrue: [menu := self menuForTwoRevisionItemsSelected].
|
|
407 |
self checkIfOneRevisionItemSelected
|
|
408 |
ifTrue: [menu := self menuForOneRevisionItemSelected].
|
|
409 |
self checkIfClassItemSelected
|
|
410 |
ifTrue: [menu := self menuForClassItemSelected].
|
|
411 |
menu
|
|
412 |
]
|
|
413 |
|
|
414 |
! !
|
|
415 |
|
|
416 |
!HierarchicalVersionDiffBrowser methodsFor:'menu testing'!
|
|
417 |
|
|
418 |
checkIfClassItemSelected
|
|
419 |
|
|
420 |
|theItemColl|
|
|
421 |
|
|
422 |
theItemColl := self treeSelectionHolder value.
|
|
423 |
^(theItemColl size == 1) and:[theItemColl first isClassItem]
|
|
424 |
!
|
2500
|
425 |
|
2538
|
426 |
checkIfOneRevisionItemSelected
|
|
427 |
|
|
428 |
|theItemColl theItem|
|
|
429 |
|
|
430 |
theItemColl := self treeSelectionHolder value.
|
|
431 |
^(theItemColl size == 1) and:[(theItem := theItemColl first) isRevisionItem and:[theItem hasSourceStream]]
|
|
432 |
!
|
|
433 |
|
|
434 |
checkIfTwoRevisionItemsSelected
|
|
435 |
|
|
436 |
|theFirstItem theSecondItem theItemColl|
|
|
437 |
|
|
438 |
theItemColl := self treeSelectionHolder value.
|
|
439 |
theItemColl size ~~ 2
|
|
440 |
ifTrue:[^false].
|
|
441 |
theFirstItem := theItemColl first.
|
|
442 |
theSecondItem := theItemColl last.
|
|
443 |
|
|
444 |
^theFirstItem isRevisionItem and:[theSecondItem isRevisionItem and:
|
|
445 |
[theFirstItem hasSourceStream and:[theSecondItem hasSourceStream and:
|
|
446 |
[theFirstItem myClass == theSecondItem myClass]]]]
|
|
447 |
! !
|
|
448 |
|
|
449 |
!HierarchicalVersionDiffBrowser methodsFor:'private'!
|
|
450 |
|
|
451 |
applyChangesIn:aChangeDic
|
|
452 |
|
|
453 |
self halt.
|
|
454 |
(aChangeDic at:#onlyInReceiver) apply.
|
|
455 |
((aChangeDic at:#changed) collect:[:each | each first]) do:[:eachMethodChange | eachMethodChange apply].
|
|
456 |
(aChangeDic at:#onlyInArg) do:
|
|
457 |
[:eachChange | eachChange isMethodChange
|
|
458 |
ifTrue:[|theClass|
|
|
459 |
(theClass := eachChange changeClass) notNil
|
|
460 |
ifTrue:[theClass removeSelector:eachChange selector]]].
|
|
461 |
|
2500
|
462 |
|
|
463 |
! !
|
|
464 |
|
|
465 |
!HierarchicalVersionDiffBrowser methodsFor:'update'!
|
|
466 |
|
2515
|
467 |
updateVersionDiffBrowser
|
|
468 |
"
|
|
469 |
|
|
470 |
<return: self>
|
|
471 |
"
|
|
472 |
|theFirstTreeItem theSecondTreeItem theClass theFirstRevisionString theSecondRevisionString|
|
2500
|
473 |
|
2515
|
474 |
theFirstTreeItem := self treeSelectionHolder value first.
|
|
475 |
theSecondTreeItem := self treeSelectionHolder value last.
|
|
476 |
theClass := theFirstTreeItem myClass.
|
|
477 |
theFirstRevisionString := theFirstTreeItem revisionString.
|
|
478 |
theSecondRevisionString := theSecondTreeItem revisionString.
|
|
479 |
self updateVersionDiffLabelForClass:theClass andVersionA:theFirstRevisionString andVersionB:theSecondRevisionString.
|
|
480 |
self versionDiffBrowser setupForClass:theClass
|
|
481 |
labelA:theFirstRevisionString
|
|
482 |
sourceA:theFirstTreeItem sourceStream
|
|
483 |
labelB:theSecondRevisionString
|
|
484 |
sourceB:theSecondTreeItem sourceStream
|
|
485 |
!
|
2500
|
486 |
|
2515
|
487 |
updateVersionDiffLabelForClass:aClass andVersionA:aVersionA andVersionB:aVersionB
|
|
488 |
"
|
|
489 |
|
|
490 |
<return: self>
|
|
491 |
"
|
2500
|
492 |
|theStream|
|
|
493 |
|
|
494 |
theStream := WriteStream on:#String.
|
|
495 |
theStream nextPutAll:'Compare '.
|
|
496 |
theStream nextPutAll: aClass name.
|
|
497 |
theStream nextPutAll:' revision '''.
|
|
498 |
theStream nextPutAll: aVersionA.
|
|
499 |
theStream nextPutAll: ''' with revision '''.
|
|
500 |
theStream nextPutAll: aVersionB.
|
|
501 |
theStream nextPutAll: '''.'.
|
|
502 |
self versionDiffModel value:theStream contents
|
|
503 |
! !
|
|
504 |
|
|
505 |
!HierarchicalVersionDiffBrowser class methodsFor:'documentation'!
|
|
506 |
|
|
507 |
version
|
2548
|
508 |
^ '$Header: /cvs/stx/stx/libtool/HierarchicalVersionDiffBrowser.st,v 1.6 2000-01-14 15:57:42 cg Exp $'
|
2500
|
509 |
! !
|