--- a/VersionDiffBrowser.st Fri Dec 24 02:08:38 1999 +0100
+++ b/VersionDiffBrowser.st Mon Dec 27 15:16:34 1999 +0100
@@ -403,6 +403,13 @@
!VersionDiffBrowser class methodsFor:'startup'!
openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB
+"
+create an VersionDiffBrowser instance and set the class change set of the
+broswer. The class change set is genertated from two source files.
+
+<return: VersionDiffBrowser>
+"
+
|theBrowser|
theBrowser := self new.
@@ -411,12 +418,16 @@
theBrowser openWindow.
^ theBrowser.
- "
- self openOnClass:Array versionA:'1.116' versionB:'1.113'
- "
!
openOnClass:aClass versionA:aVersionA versionB:aVersionB
+"
+create an VersionDiffBrowser instance and set the class change set of the
+broswer. The class change set is generated from two class versions via
+the source code manager .
+
+<return: VersionDiffBrowser>
+"
|theBrowser|
theBrowser := self new.
@@ -455,35 +466,101 @@
!
classBeingCompared
+"
+gets the class from the change set which is compared.
+<return: Class>
+"
^ self classChangeSet classBeingCompared
!
classChangeSet
- "return the value of the instance variable 'classChangeSet' (automatically generated)"
+"
+returns the class change set which is the model of the version diff browser.
- ^ classChangeSet!
+<return: ClassChangeSet>
+"
+ ^ classChangeSet
+!
-classChangeSet:something
+classChangeSet:aClassChangeSet
"
+sets the class change set which is the model of the version diff browser.
+The labels, the lists, the visibility and the selection of the lists must be reseted
+when a new change set is given.
+<return: self>
"
- classChangeSet := something.
+ classChangeSet := aClassChangeSet.
self updateLabels.
self updateLists.
self resetSelectionHolders.
!
+selectedChangeInA
+"
+gets the selected method change for the 'method only in version A'.
+
+<return: MethodChange | nil>
+"
+ |sel change|
+
+ sel := self methodsOnlyInASelection value.
+ sel notNil ifTrue:[
+ change := (self changeSetA at:sel).
+ ].
+ ^ nil
+!
+
+selectedChangeInB
+"
+gets the selected method change for the 'method only in version B'.
+
+<return: MethodChange | nil>
+"
+ |sel change|
+
+ sel := self methodsOnlyInBSelection value.
+ sel notNil ifTrue:[
+ change := (self changeSetB at:sel).
+ ].
+ ^ nil
+!
+
+selectedChangesInM
+"
+get the two method changes for the selected 'changed method'.
+
+<return: <Array with:MethodChange with:MethodChange | nil>>
+"
+ |sel changeA changeB|
+
+ sel := self methodsChangedSelection value.
+ sel notNil ifTrue:[
+ changeA := (self classChangeSet methodsChanged at:sel) first.
+ changeB := (self classChangeSet methodsChanged at:sel) second.
+ ^ Array with:changeA
+ with:changeB
+ ].
+ ^ nil
+!
+
versionA
- "return the value of the instance variable 'versionA' (automatically generated)"
+"
+gets the first class version to be compared
+<return: String>
+"
^ self classChangeSet labelA
!
versionB
- "return the value of the instance variable 'versionB' (automatically generated)"
+"
+gets the second class version to be compared
+<return: String>
+"
^ self classChangeSet labelB
! !
@@ -491,6 +568,12 @@
!VersionDiffBrowser methodsFor:'actions'!
methodsChangedSelectionChanged
+"
+the selection in the list of the 'changed methods' changed.
+Reset the selection of the two other lists and calc the method change.
+
+<return: self>
+"
|sel idxA idxB changeA changeB|
sel := self methodsChangedSelection value.
@@ -504,54 +587,59 @@
self diffTextView moveToNextChanged
].
self showDiffTextView.
- ] ifFalse:[
- self diffTextView text1:'' text2:''.
]
"Modified: / 3.9.1999 / 15:01:30 / ps"
!
methodsOnlyInASelectionChanged
+"
+the selection in the list of the 'method only in version A' changed.
+Reset the selection of the two other lists and show the method in
+the text view.
+
+<return: self>
+"
|change sel|
sel := self methodsOnlyInASelection value.
sel notNil ifTrue:[
self methodsOnlyInBSelection value:nil.
self methodsChangedSelection value:nil.
-
change := self changeSetA at:sel.
self methodText value:(change source).
self showSingleTextView.
- ] ifFalse:[
- self methodText value:''.
]
!
methodsOnlyInBSelectionChanged
+"
+the selection in the list of the 'method only in version B' changed.
+Reset the selection of the two other lists and show the method in
+the text view.
+
+<return: self>
+"
|change sel|
sel := self methodsOnlyInBSelection value.
sel notNil ifTrue:[
self methodsOnlyInASelection value:nil.
self methodsChangedSelection value:nil.
-
change := self changeSetB at:sel.
self methodText value:(change source).
self showSingleTextView.
- ] ifFalse:[
- self methodText value:''.
]
! !
!VersionDiffBrowser methodsFor:'aspects'!
changedLabelHolder
- "automatically generated by UIPainter ..."
+"
+aspect for the label of the changed method box.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
-
+<return: ValueHolder on: nil>
+"
|holder|
(holder := builder bindingAt:#changedLabelHolder) isNil ifTrue:[
@@ -561,11 +649,11 @@
!
diffTextLabelA
- "automatically generated by UIPainter ..."
+"
+aspect for the label for version A.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -576,11 +664,11 @@
!
diffTextLabelB
- "automatically generated by UIPainter ..."
+"
+aspect for the label for version B.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -591,8 +679,11 @@
!
diffTextView
- "automatically generated by UIPainter ..."
+"
+return the component for the diff text view.
+<return: HVScrollableView>
+"
diffTextView isNil ifTrue:[
diffTextView := HVScrollableView
for:DiffTextView
@@ -603,12 +694,11 @@
!
methodText
- "automatically generated by UIPainter ..."
+"
+aspect for the text in the method text view.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
-
+<return: ValueHolder on: nil>
+"
|holder|
(holder := builder bindingAt:#methodText) isNil ifTrue:[
@@ -618,11 +708,11 @@
!
methodsChanged
- "automatically generated by UIPainter ..."
+"
+aspect for the 'changed method' list.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: List>
+"
|holder|
@@ -633,11 +723,11 @@
!
methodsChangedSelection
- "automatically generated by UIPainter ..."
+"
+aspect for the selection holder of 'changed method'-list.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -648,11 +738,11 @@
!
methodsOnlyInA
- "automatically generated by UIPainter ..."
+"
+aspect for the 'method only in version A' list.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: List>
+"
|holder|
@@ -663,11 +753,11 @@
!
methodsOnlyInASelection
- "automatically generated by UIPainter ..."
+"
+aspect for the selection holder of 'method only in version A'-list.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -678,11 +768,11 @@
!
methodsOnlyInB
- "automatically generated by UIPainter ..."
+"
+aspect for the 'method only in version B' list.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: List>
+"
|holder|
@@ -693,11 +783,11 @@
!
methodsOnlyInBSelection
- "automatically generated by UIPainter ..."
+"
+aspect for the selection holder of 'method only in version B'-list.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -708,11 +798,11 @@
!
onlyInALabelHolder
- "automatically generated by UIPainter ..."
+"
+aspect for the label for 'method only in version A'.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -723,11 +813,11 @@
!
onlyInBLabelHolder
- "automatically generated by UIPainter ..."
+"
+aspect for the label for 'method only in version B'.
- "*** the code below creates a default model when invoked."
- "*** (which may not be the one you wanted)"
- "*** Please change as required and accept in the browser."
+<return: ValueHolder on: nil>
+"
|holder|
@@ -740,15 +830,12 @@
!VersionDiffBrowser methodsFor:'initialization & release'!
postBuildWith:aBuilder
- "This is a hook method generated by the Browser.
- It will be invoked during the initialization of your app/dialog,
- after all of the visual components have been built,
- but BEFORE the top window is made visible.
- Add any app-specific actions here (reading files, setting up
- values etc.)"
+"
+components which are invisible should be ignored by the panel.
+Cannot be set via the interface builder.
- "/ add any code here ...
-
+<return: self>
+"
(aBuilder componentAt:#TopHorizontalPanel) ignoreInvisibleComponents:true.
^ super postBuildWith:aBuilder
! !
@@ -756,20 +843,40 @@
!VersionDiffBrowser methodsFor:'menu action'!
browseChange:aChange
+"
+browse the change in aChange
+
+<return: self>
+"
SystemBrowser
openInClass:aChange changeClass
selector:aChange changeSelector.
!
browseClassInA
+"
+browse the selected method.
+
+<return: self>
+"
self browseChange:(self selectedChangeInA).
!
browseClassInB
+"
+browse the selected method.
+
+<return: self>
+"
self browseChange:(self selectedChangeInB).
!
browseClassInM
+"
+browse the selected method.
+
+<return: self>
+"
self browseChange:(self selectedChangesInM first).
!
@@ -778,7 +885,7 @@
the new version (versionA)"
|oldVersion newVersion vsnMthdA vsnMthdB vsnA vsnB info|
-
+ self halt.
vsnMthdA := self changeSetA
detect:[:ch | ch isMethodChange
and:[ch changeClass isMeta
@@ -815,9 +922,7 @@
].
].
- (vsnA isNil
- or:[vsnB isNil
- or:[vsnA = vsnB]]) ifTrue:[
+ (vsnA isNil or:[vsnB isNil or:[vsnA = vsnB]]) ifTrue:[
self warn:'The generated patch file will not be able to validate/update the class version'.
].
@@ -826,14 +931,29 @@
!
inspectSelectedChangeInA
+"
+inspect the selected method change for the 'method only in version A'.
+
+<return: self>
+"
self selectedChangeInA inspect.
!
inspectSelectedChangeInB
+"
+inspect the selected method change for the 'method only in version B'.
+
+<return: self>
+"
self selectedChangeInB inspect.
!
inspectSelectedChangeInM
+"
+inspect the two method changes for the selected 'changed method'.
+
+<return: self>
+"
|changes|
changes := self selectedChangesInM.
@@ -843,77 +963,52 @@
!
mainMenu
+"
+if this application runs as an subapplication,
+the menu bar should not be used.
+
+<return: self>
+"
self masterApplication isNil ifTrue:[
^ self class mainMenu
].
^ nil
-!
-
-selectedChangeInA
- |sel change|
-
- sel := self methodsOnlyInASelection value.
- sel notNil ifTrue:[
- change := (self changeSetA at:sel).
- ].
- ^ change
-!
-
-selectedChangeInB
- |sel change|
-
- sel := self methodsOnlyInBSelection value.
- sel notNil ifTrue:[
- change := (self changeSetB at:sel).
- ].
- ^ change
-!
-
-selectedChangesInM
- |sel idxA idxB|
-
- sel := self methodsChangedSelection value.
- sel notNil ifTrue:[
- idxA := self indexFromChangedToA at:sel ifAbsent:nil.
- idxB := self indexFromChangedToB at:sel ifAbsent:nil.
-
- ^ Array with:(self changeSetA at:idxA)
- with:(self changeSetB at:idxB)
- ].
- ^ nil
! !
!VersionDiffBrowser methodsFor:'private'!
generator
+"
+generate a print string for a change.
- ^[:c |
+<return: Block>
+"
+ ^[:aChange |
|result mPkg cPkg cls m|
-
- c isClassDefinitionChange ifTrue:[
- result := c printStringWithoutClass
+ aChange isClassDefinitionChange ifTrue:[
+ result := aChange printStringWithoutClass
] ifFalse:[
- c isDoIt ifTrue:[
- result := c source , ' (doIt)'
+ aChange isDoIt ifTrue:[
+ result := aChange source , ' (doIt)'
] ifFalse:[
- c className = self classBeingCompared name ifTrue:[
- result := c printStringWithoutClass.
- c isMethodChange ifTrue:[
- cls := c changeClass.
+ aChange className = self classBeingCompared name ifTrue:[
+ result := aChange printStringWithoutClass.
+ aChange isMethodChange ifTrue:[
+ cls := aChange changeClass.
cls notNil ifTrue:[
- m := cls compiledMethodAt:c selector.
+ m := cls compiledMethodAt:aChange selector.
(m notNil
and:[m package ~= cls package]) ifTrue:[
- result := c printStringWithoutClass , ' [' , m package , ']'.
+ result := aChange printStringWithoutClass , ' [' , m package , ']'.
].
].
]
] ifFalse:[
"/ include name in private class changes
- (c className startsWith:(self classBeingCompared name , '::')) ifTrue:[
- result := (c className copyFrom:(self classBeingCompared name size + 3)) , ' ' , c printStringWithoutClass
+ (aChange className startsWith:(self classBeingCompared name , '::')) ifTrue:[
+ result := (aChange className copyFrom:(self classBeingCompared name size + 3)) , ' ' , aChange printStringWithoutClass
] ifFalse:[
- result := c printString
+ result := aChange printString
]
]
]
@@ -924,17 +1019,32 @@
!
resetSelectionHolders
+"
+reset all selection holders when a new change set is given.
+First set the selection to nil.
+
+<return: self>
+"
self methodsChangedSelection value:nil.
self methodsOnlyInASelection value:nil.
self methodsOnlyInBSelection value:nil.
- self methodsChangedSelectionChanged.
- self methodsOnlyInASelectionChanged.
- self methodsOnlyInBSelectionChanged.
+ self diffTextView text1:'' text2:''.
+ self methodText value:''.
+
+"/ self methodsChangedSelectionChanged.
+"/ self methodsOnlyInASelectionChanged.
+"/ self methodsOnlyInBSelectionChanged.
!
showDiffTextView
+"
+if a method change is selected, then show the diff text view.
+Add an accept entry to the popup menu.
+
+<return: self>
+"
(self builder componentAt:#diffTextViewBox) raise; beVisible.
(self builder componentAt:#singleTextView) beInvisible.
(self builder componentAt:#diffTextView) realizeAllSubViews.
@@ -942,6 +1052,14 @@
!
showSingleTextView
+"
+if a method is selected which is only in version A or B of the class,
+then show the text view.
+Add an accept entry to the popup menu.
+
+<return: self>
+"
+
(self builder componentAt:#singleTextView) raise; beVisible.
(self builder componentAt:#diffTextViewBox) beInvisible.
self addAcceptToTextViewMenus.
@@ -949,7 +1067,12 @@
!
updateLabels
+"
+update the labels of the diff text view. Show the version numbers
+of the class.
+<return: self>
+"
|theVersionA theVersionB|
@@ -966,7 +1089,13 @@
!
updateLists
- "walk over the two changeSets and add change to one of the tree lists"
+"walk over the two changeSets and add change to one of the tree lists.
+Methods which belong to the version A of the class or version B go
+to the list methodsOnlyInA or methodsOnlyInB.
+Methods which are changed from version A to B go to the list methodsChanged.
+
+<return: self>
+"
self methodsOnlyInA removeAll.
self methodsOnlyInA addAll: (self classChangeSet methodsOnlyInA collect:self generator).
@@ -975,37 +1104,42 @@
self methodsChanged removeAll.
self methodsChanged addAll: (self classChangeSet methodsChanged collect:[:arr| self generator value:(arr first)]).
- self methodsOnlyInA value isEmpty ifTrue:[
- (self builder componentAt:#BoxA) beInvisible.
- ] ifFalse:[
- (self builder componentAt:#BoxA) beVisible.
- ].
+ self methodsOnlyInA value isEmpty
+ ifTrue: [(self builder componentAt:#BoxA) beInvisible]
+ ifFalse:[(self builder componentAt:#BoxA) beVisible].
- self methodsOnlyInB value isEmpty ifTrue:[
- (self builder componentAt:#BoxB) beInvisible.
- ] ifFalse:[
- (self builder componentAt:#BoxB) beVisible.
- ].
+ self methodsOnlyInB value isEmpty
+ ifTrue: [(self builder componentAt:#BoxB) beInvisible]
+ ifFalse:[(self builder componentAt:#BoxB) beVisible].
- self methodsChanged value isEmpty ifTrue:[
- (self methodsOnlyInA value notEmpty or:[self methodsOnlyInB value notEmpty]) ifTrue:[
- (self builder componentAt:#BoxM) beInvisible.
- ]
- ] ifFalse:[
- (self builder componentAt:#BoxM) beVisible.
- ]
+ self methodsChanged value isEmpty
+ ifTrue: [(self methodsOnlyInA value notEmpty or:[self methodsOnlyInB value notEmpty])
+ ifTrue:[(self builder componentAt:#BoxM) beInvisible]]
+ ifFalse:[(self builder componentAt:#BoxM) beVisible]
! !
!VersionDiffBrowser methodsFor:'setup'!
setupForClass:aClass versionA:aVersionA versionB:aVersionB
+"
+compute the class change set for the class aClass and the versions A and B.
+When setting the class change set, the labels, list etc. of the receiver
+are updated.
+<return: self>
+"
self classChangeSet:(ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB)
! !
!VersionDiffBrowser methodsFor:'values'!
addAcceptToTextViewMenus
+"
+add to the standard diff text view or single text views menu an accept entry.
+
+<return: self>
+"
+
|m v|
(Array
@@ -1236,5 +1370,5 @@
!VersionDiffBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.15 1999-12-23 16:10:33 ps Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.16 1999-12-27 14:16:34 ps Exp $'
! !