ChangesBrowser.st
changeset 89 43ca5e534f5e
parent 81 b3b4d34c5ada
child 90 60d0bb749a1c
--- a/ChangesBrowser.st	Sun Mar 26 19:35:57 1995 +0200
+++ b/ChangesBrowser.st	Sun Mar 26 22:18:34 1995 +0200
@@ -15,7 +15,7 @@
 StandardSystemView subclass:#ChangesBrowser
 	 instanceVariableNames:'changeListView codeView changeFileName changeChunks
 		changePositions changeClassNames changeHeaderLines anyChanges
-		changeNrShown changeNrProcessed skipSignal'
+		changeNrShown changeNrProcessed skipSignal compareChanges compareCheckBox'
 	 classVariableNames:'CompressSnapshotInfo'
 	 poolDictionaries:''
 	 category:'Interface-Browsers'
@@ -25,7 +25,7 @@
 COPYRIGHT (c) 1990 by Claus Gittinger
 	    All Rights Reserved
 
-$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.28 1995-03-18 05:18:14 claus Exp $
+$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.29 1995-03-26 20:18:01 claus Exp $
 '!
 
 !ChangesBrowser class methodsFor:'documentation'!
@@ -46,7 +46,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.28 1995-03-18 05:18:14 claus Exp $
+$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.29 1995-03-26 20:18:01 claus Exp $
 "
 !
 
@@ -199,7 +199,7 @@
      Starting with 2.10.3, the entries are multi-col entries;
      the cols are:
 	1   class/selector
-	2   delta 
+	2   delta (only if comparing)
 		'+' -> new method (w.r.t. current state)
 		'-' -> removed method (w.r.t. current state)
 		'?' -> class does not exist currently
@@ -208,6 +208,9 @@
 		doit
 		method
 		category change
+
+     since comparing slows down startup time, it is now disabled by
+     default and can be enabled via a toggle.
      "
 
     |aStream maxLen|
@@ -318,11 +321,14 @@
 				    changeClass := (Smalltalk classNamed:cls)
 				].
 				sel := (p args at:1) evaluate.
-				(changeClass isNil or:[changeClass isLoaded not]) ifTrue:[
-				    changeDelta := '?'
-				] ifFalse:[
-				    (changeClass implements:sel asSymbol) ifTrue:[
-					changeDelta := '-'.
+
+				compareChanges ifTrue:[
+				    (changeClass isNil or:[changeClass isLoaded not]) ifTrue:[
+					changeDelta := '?'
+				    ] ifFalse:[
+					(changeClass implements:sel asSymbol) ifTrue:[
+					    changeDelta := '-'.
+					]
 				    ]
 				].
 				changeType := '(remove)'.
@@ -423,19 +429,22 @@
 				    ] ifFalse:[
 					headerLine := cls , ' ' , sel , ' ' , '(change category: ''' , category , ''')'.
 				    ].
-				    (changeClass isNil or:[changeClass isLoaded not]) ifTrue:[
-					changeDelta := '?'
-				    ] ifFalse:[
-					(changeClass implements:sel asSymbol) ifFalse:[
-					    changeDelta := '+'.
-					] ifTrue:[
-					    |m currentText|
 
-					    m := changeClass compiledMethodAt:sel asSymbol.
-					    currentText := m source.
-					    currentText notNil ifTrue:[
-						text asString = currentText asString ifTrue:[
-						    changeDelta := '='
+				    compareChanges ifTrue:[    
+					(changeClass isNil or:[changeClass isLoaded not]) ifTrue:[
+					    changeDelta := '?'
+					] ifFalse:[
+					    (changeClass implements:sel asSymbol) ifFalse:[
+						changeDelta := '+'.
+					    ] ifTrue:[
+						|m currentText|
+
+						m := changeClass compiledMethodAt:sel asSymbol.
+						currentText := m source.
+						currentText notNil ifTrue:[
+						    text asString = currentText asString ifTrue:[
+							changeDelta := '='
+						    ]
 						]
 					    ]
 					]
@@ -691,17 +700,21 @@
 			    (oldSource = newSource) ifTrue:[
 				outcome := 'same source'
 			    ] ifFalse:[
-				"/
-				"/ compare for tabulator <-> space changes
-				"/ before showing diff ...
-				"/
-				t1 := oldSource asString withTabsExpanded.
-				t2 := newSource asString withTabsExpanded.
-				t1 = t2 ifTrue:[
-				    outcome := 'same source (tabs <-> spaces)'
+				oldSource isNil ifTrue:[
+				    outcome := 'no source for compare.'
 				] ifFalse:[
-				    outcome := 'source changed.'.
-				    showDiff := true
+				    "/
+				    "/ compare for tabulator <-> space changes
+				    "/ before showing diff ...
+				    "/
+				    t1 := oldSource asString withTabsExpanded.
+				    t2 := newSource asString withTabsExpanded.
+				    t1 = t2 ifTrue:[
+					outcome := 'same source (tabs <-> spaces)'
+				    ] ifFalse:[
+					outcome := 'source changed.'.
+					showDiff := true
+				    ]
 				]
 			    ]
 			] ifFalse:[
@@ -724,8 +737,11 @@
 	    outcome := 'not comparable.'
 	]
     ].
-    Transcript showCr:outcome.
     aStream close.
+    showDiff ifFalse:[
+	self information:outcome.
+"/        Transcript showCr:outcome.
+    ].
 !
 
 writeBackChanges
@@ -1399,24 +1415,36 @@
 !ChangesBrowser methodsFor:'initialize / release'!
 
 initialize
-    |frame v|
+    |panel v upperFrame buttonPanel|
 
     super initialize.
 
     changeFileName := 'changes'.
+    compareChanges := false.
 
-    frame := VariableVerticalPanel origin:(0.0 @ 0.0)
+    panel := VariableVerticalPanel origin:(0.0 @ 0.0)
 				   corner:(1.0 @ 1.0)
 			      borderWidth:0
 				       in:self.
 
-    v := ScrollableView for:SelectionInListView in:frame.
-    v origin:(0.0 @ 0.0) corner:(1.0 @ 0.3).
+    upperFrame := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.3) in:panel.
+
+    v := ScrollableView for:SelectionInListView in:upperFrame.
+    v origin:(0.0 @ 0.0) corner:(0.8 @ 1.0).
     changeListView := v scrolledView.
     changeListView delegate:self.
     changeListView model:self; menu:#changeListMenu.
 
-    v := HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:frame.
+    buttonPanel := VerticalPanelView in:upperFrame.
+    buttonPanel origin:(0.8 @ 0.0) corner:(1.0 @ 1.0).
+    buttonPanel layout:#topSpace.
+
+    compareCheckBox := CheckBox new.
+    compareCheckBox label:(resources string:'compare').
+    compareCheckBox model:self; change:#compare:.
+    buttonPanel addSubView:compareCheckBox.
+
+    v := HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:panel.
     v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
     codeView := v scrolledView.
     codeView readOnly.
@@ -1465,6 +1493,17 @@
     super update:what
 !
 
+compare:aBoolean
+    "sent from the compare-toggle"
+
+    aBoolean ~~ compareChanges ifTrue:[
+	compareChanges := aBoolean.
+	compareChanges ifTrue:[
+	    self doUpdate
+	]
+    ]
+!
+
 changeListMenu
     |labels selectors m|
 
@@ -1600,6 +1639,21 @@
     self destroy
 ! !
 
+!ChangesBrowser methodsFor:'help '!
+
+helpTextFor:aComponent
+    aComponent == codeView ifTrue:[
+	^ resources string:'HELP_CODEVIEW'
+    ].
+    aComponent == changeListView ifTrue:[
+	^ resources string:'HELP_CHANGELIST'
+    ].
+    aComponent == compareCheckBox ifTrue:[
+	^ resources string:'HELP_CHECK_COMPARE'
+    ].
+    ^ nil
+! !
+
 !ChangesBrowser methodsFor:'error handling'!
 
 correctableError:aString position:relPos to:relEndPos