VersionDiffBrowser.st
changeset 2695 6cf8801118a3
parent 2694 a19deafda6b0
child 2697 b4f4e431b71e
--- a/VersionDiffBrowser.st	Thu Aug 10 11:50:49 2000 +0200
+++ b/VersionDiffBrowser.st	Fri Aug 11 19:35:06 2000 +0200
@@ -21,7 +21,7 @@
 !
 
 HierarchicalItem subclass:#ClassChangeSet
-	instanceVariableNames:'classBeingCompared labelA labelB changeSet onlyInA onlyInB
+	instanceVariableNames:'classBeingCompared labelA labelB diffSet onlyInA onlyInB
 		changedMethods'
 	classVariableNames:''
 	poolDictionaries:''
@@ -92,7 +92,7 @@
           #name: 'Version DiffBrowser'
           #min: #(#Point 10 10)
           #max: #(#Point nil nil)
-          #bounds: #(#Rectangle 294 23 1159 527)
+          #bounds: #(#Rectangle 12 22 877 526)
           #menu: #mainMenu
         )
         #component: 
@@ -452,12 +452,34 @@
       )
 ! !
 
+!VersionDiffBrowser class methodsFor:'plugIn spec'!
+
+aspectSelectors
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this. If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "Return a description of exported aspects;
+     these can be connected to aspects of an embedding application
+     (if this app is embedded in a subCanvas)."
+
+    ^ #(
+        #changedLabelHolder
+        #onlyInALabelHolder
+        #onlyInBLabelHolder
+      ).
+
+! !
+
 !VersionDiffBrowser class methodsFor:'startup'!
 
-openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB 
+openOnClass:aClass againstVersion:aVersionA 
 "
 create an VersionDiffBrowser instance and set the class change set of the
-broswer. The class change set is generated from two source files.
+browser. The class diff set is generated from classes current against some version
+via the source code manager .
 
 <return: VersionDiffBrowser>
 "
@@ -465,16 +487,42 @@
 
     theBrowser := self new.
     theBrowser allButOpen.
-    theBrowser classChangeSet:(ClassChangeSet newForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB).
+    theBrowser setupForClass:aClass againstVersion:aVersionA.
     theBrowser openWindow.
     ^ theBrowser.
 
+    "
+     self openOnClass:Array againstVersion:'1.116'
+     self openOnClass:Array againstVersion:nil            - against the version on which Array is based upon
+     self openOnClass:Array againstVersion:#newest        - against the newest repository version
+
+     self openOnClass:VersionDiffBrowser againstVersion:nil
+     self openOnClass:VersionDiffBrowser againstVersion:#newest
+    "
+!
+
+openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB 
+"
+create an VersionDiffBrowser instance and set the class change set of the
+browser. The class diff set is generated from two source files.
+
+<return: VersionDiffBrowser>
+"
+    |theBrowser|
+
+    theBrowser := self new.
+    theBrowser allButOpen.
+    theBrowser setupForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB.
+    theBrowser openWindow.
+    ^ theBrowser.
+
+
 !
 
 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
+browser. The class diff set is generated from two class versions via
 the source code manager .
 
 <return: VersionDiffBrowser>
@@ -483,7 +531,7 @@
 
     theBrowser := self new.
     theBrowser allButOpen.
-    theBrowser classChangeSet:(ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB).
+    theBrowser setupForClass:aClass versionA:aVersionA versionB:aVersionB.
     theBrowser openWindow.
     ^ theBrowser.
 
@@ -627,14 +675,15 @@
 
 <return: self>
 "
-    |sel idxA idxB changeA changeB|
+    |sel idxA idxB changeA changeB methodsChanged|
 
     sel := self methodsChangedSelection value.
     sel notNil ifTrue:[
         self methodsOnlyInASelection value:nil.
         self methodsOnlyInBSelection value:nil.
-        changeA := (self classChangeSet methodsChanged at:sel) first.
-        changeB := (self classChangeSet methodsChanged at:sel) second.
+        methodsChanged := self classChangeSet methodsChanged.
+        changeA := (methodsChanged at:sel) first.
+        changeB := (methodsChanged at:sel) second.
         self withReadCursorDo:[
             self diffTextView text1:changeA source text2:changeB source.
             self diffTextView moveToNextChanged
@@ -907,6 +956,75 @@
     ^ holder.
 ! !
 
+!VersionDiffBrowser methodsFor:'aspects - exported'!
+
+changedLabelHolder:aValueHolder
+    builder aspectAt:#changedLabelHolder put:aValueHolder.
+
+!
+
+classHolder:aValueHolder
+    |holder|
+
+    (holder := builder bindingAt:#classHolder) notNil ifTrue:[
+        holder removeDependent:self
+    ].
+    builder aspectAt:#classHolder put:aValueHolder.
+    aValueHolder notNil ifTrue:[
+        aValueHolder addDependent:self
+    ]
+!
+
+onlyInALabelHolder:aValueHolder
+    builder aspectAt:#onlyInALabelHolder put:aValueHolder.
+!
+
+onlyInBLabelHolder:aValueHolder
+    builder aspectAt:#onlyInBLabelHolder put:aValueHolder.
+!
+
+versionAHolder:aValueHolder
+    |holder|
+
+    (holder := builder bindingAt:#versionAHolder) notNil ifTrue:[
+        holder removeDependent:self
+    ].
+    builder aspectAt:#versionAHolder put:aValueHolder.
+    aValueHolder notNil ifTrue:[
+        aValueHolder addDependent:self
+    ]
+!
+
+versionBHolder:aValueHolder
+    |holder|
+
+    (holder := builder bindingAt:#versionBHolder) notNil ifTrue:[
+        holder removeDependent:self
+    ].
+    builder aspectAt:#versionBHolder put:aValueHolder.
+    aValueHolder notNil ifTrue:[
+        aValueHolder addDependent:self
+    ]
+! !
+
+!VersionDiffBrowser methodsFor:'change & update'!
+
+update:something with:parameter from:changedObject
+    |classHolder versionAHolder versionBHolder|
+
+    classHolder := self classHolder.
+    versionAHolder := self versionAHolder.
+    versionBHolder := self versionBHolder.
+
+    (changedObject == classHolder 
+    or:[changedObject == versionAHolder
+    or:[changedObject == versionBHolder]]) ifTrue:[
+        self setupForClass:(classHolder value) versionA:(versionAHolder value) versionB:(versionBHolder value)
+.        ^ self
+    ].
+    super update:something with:parameter from:changedObject
+! !
+
 !VersionDiffBrowser methodsFor:'initialization & release'!
 
 postBuildWith:aBuilder
@@ -1215,6 +1333,17 @@
 
 !VersionDiffBrowser methodsFor:'setup'!
 
+setupForClass:aClass againstVersion:aVersionA
+"
+compute the class change set for the class aClass of its current version against the repository version A.
+When setting the class change set, the labels, list etc. of the receiver
+are updated.
+
+<return: self>
+"
+    self classChangeSet:(ClassChangeSet newForClass:aClass againstVersion:aVersionA)
+!
+
 setupForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB
 "
 generate the class change set from the two source files A and B.
@@ -1299,6 +1428,23 @@
 
 !VersionDiffBrowser::ClassChangeSet class methodsFor:'instance creation'!
 
+changeSetForClass:aClass 
+"return a ChangeSet for the class aClass and its current source.
+The source is generated into a stream and then the change set is generated
+from the source stream.
+
+<return: ChangeSet|nil>
+"
+    |theChangeSet source s|
+
+    s := '' writeStream.
+    aClass fileOutOn:s.
+    source := s contents.
+
+    theChangeSet := ChangeSet fromStream:(source readStream).
+    ^theChangeSet
+!
+
 changeSetForClass:aClass andRevision:aVersion
 "return a ChangeSet for the class aClass and version aVersion.
 The version from the class source stream is checked out from the repositiory
@@ -1334,6 +1480,38 @@
     ^theChangeSet
 !
 
+newForClass:aClass againstVersion:aVersionA
+"return a ClassChangeSet for the class aClass against some verison in the repository.
+A new instance of ClassChangeSet is generated containing 
+the correspondenting changes.
+
+<return: ClassChangeSet>
+"
+    |theChangeSetA theChangeSetB theClassChangeSet versionCompared|
+
+    theClassChangeSet := self new.
+    theClassChangeSet classBeingCompared:aClass.
+    versionCompared := aVersionA.
+    aVersionA isNil ifTrue:[
+        theClassChangeSet labelA:(versionCompared := aClass revision).
+    ] ifFalse:[
+        aVersionA == #newest ifTrue:[
+            theClassChangeSet labelA:'newest'.
+        ] ifFalse:[
+            theClassChangeSet labelA:versionCompared.
+        ]
+    ].
+    theClassChangeSet labelB:'current'.
+    theChangeSetA := self changeSetForClass: aClass andRevision: versionCompared.
+    theChangeSetB := self changeSetForClass: aClass.
+    theChangeSetA isNil
+        ifTrue: [theChangeSetA := ChangeSet new].
+    theChangeSetB isNil
+        ifTrue: [theChangeSetB := ChangeSet new].
+    ^theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
+
+!
+
 newForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB
 "return a ClassChangeSet for the class aClass and the two sources.
 The two classes are compared via the source files. A new instance of 
@@ -1353,7 +1531,7 @@
         ifTrue: [theChangeSetA := ChangeSet new].
     theChangeSetB isNil
         ifTrue: [theChangeSetB := ChangeSet new].
-    ^theClassChangeSet changeSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
+    ^theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
 !
 
 newForClass:aClass versionA:aVersionA versionB:aVersionB
@@ -1376,39 +1554,12 @@
         ifTrue: [theChangeSetA := ChangeSet new].
     theChangeSetB isNil
         ifTrue: [theChangeSetB := ChangeSet new].
-    ^theClassChangeSet changeSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
+    ^theClassChangeSet diffSet:(theChangeSetA diffSetsAgainst:theChangeSetB)
 
 ! !
 
 !VersionDiffBrowser::ClassChangeSet methodsFor:'accessing'!
 
-changeSet
-"returns a identity dictionary containing the different changes.
-key:            value:
-#changed        OrderedCollection of arrays containing ChangeSets for methods 
-                which are changed and exists in the class versionA and versionB
-#onlyInArg      ChangeSet for the methods which exists only in the class versionB
-#onlyInReceiver ChangeSet for the methods which exists only in the class versionA
-
-<return: IdentityDictionary>
-"  
-    ^ changeSet
-!
-
-changeSet:something
-"sets a identity dictionary containing the different changes.
-key:            value:
-#changed        OrderedCollection of arrays containing ChangeSets for methods 
-                which are changed and exists in the class versionA and versionB
-#onlyInArg      ChangeSet for the methods which exists only in the class versionB
-#onlyInReceiver ChangeSet for the methods which exists only in the class versionA
-
-<return: self>
-"  
-
-    changeSet := something.
-!
-
 classBeingCompared
 "returns the value of the class which is compared
 
@@ -1426,6 +1577,33 @@
     classBeingCompared := something.
 !
 
+diffSet
+"returns a identity dictionary containing the different changes.
+key:            value:
+#changed        OrderedCollection of arrays containing ChangeSets for methods 
+                which are changed and exists in the class versionA and versionB
+#onlyInArg      ChangeSet for the methods which exists only in the class versionB
+#onlyInReceiver ChangeSet for the methods which exists only in the class versionA
+
+<return: IdentityDictionary>
+"  
+    ^ diffSet
+!
+
+diffSet:something
+"sets a identity dictionary containing the different changes.
+key:            value:
+#changed        OrderedCollection of arrays containing ChangeSets for methods 
+                which are changed and exists in the class versionA and versionB
+#onlyInArg      ChangeSet for the methods which exists only in the class versionB
+#onlyInReceiver ChangeSet for the methods which exists only in the class versionA
+
+<return: self>
+"  
+
+    diffSet := something.
+!
+
 labelA
 "returns the label for the class versionA
 
@@ -1465,7 +1643,7 @@
 
 <return: OrderedCollection>
 "
-    ^ self changeSet at:#changed
+    ^ self diffSet at:#changed
 !
 
 methodsOnlyInA
@@ -1474,7 +1652,7 @@
 <return: ChangeSet>
 "  
 
-    ^ self changeSet at:#onlyInReceiver
+    ^ self diffSet at:#onlyInReceiver
 !
 
 methodsOnlyInB
@@ -1483,11 +1661,11 @@
 <return: ChangeSet>
 "  
 
-    ^ self changeSet at:#onlyInArg
+    ^ self diffSet at:#onlyInArg
 ! !
 
 !VersionDiffBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.23 2000-08-10 09:50:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.24 2000-08-11 17:35:06 cg Exp $'
 ! !