# HG changeset patch # User ps # Date 945963079 -3600 # Node ID e4a8d9c98640dbda404912c3def2a22f43ef20d1 # Parent f4ddf19a910ba0ff73ea095315aa1c29a4e00cc8 initial checkin diff -r f4ddf19a910b -r e4a8d9c98640 HierarchicalVersionDiffBrowser.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HierarchicalVersionDiffBrowser.st Thu Dec 23 16:31:19 1999 +0100 @@ -0,0 +1,553 @@ +ApplicationModel subclass:#HierarchicalVersionDiffBrowser + instanceVariableNames:'versionDiffBrowser' + classVariableNames:'' + poolDictionaries:'' + category:'Interface-Browsers' +! + +HierarchicalItem subclass:#AbstractVersionDiffBrowserItem + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + privateIn:HierarchicalVersionDiffBrowser +! + +HierarchicalVersionDiffBrowser::AbstractVersionDiffBrowserItem subclass:#ClassItemRoot + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + privateIn:HierarchicalVersionDiffBrowser +! + +HierarchicalVersionDiffBrowser::AbstractVersionDiffBrowserItem subclass:#ClassItem + instanceVariableNames:'myClass' + classVariableNames:'' + poolDictionaries:'' + privateIn:HierarchicalVersionDiffBrowser +! + +HierarchicalVersionDiffBrowser::AbstractVersionDiffBrowserItem subclass:#RevisionItem + instanceVariableNames:'revision' + classVariableNames:'' + poolDictionaries:'' + privateIn:HierarchicalVersionDiffBrowser +! + + +!HierarchicalVersionDiffBrowser class methodsFor:'interface specs'! + +contentsSpecVersionDiffBrowser + "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." + + " + UIPainter new openOnClass:HierarchicalVersionDiffBrowser andSelector:#contentsSpecVersionDiffBrowser + HierarchicalVersionDiffBrowser new openInterface:#contentsSpecVersionDiffBrowser + " + + + + ^ + #(#FullSpec + #name: #contentsSpecVersionDiffBrowser + #window: + #(#WindowSpec + #label: 'Hierarchical Version DiffBrowser' + #name: 'Hierarchical Version DiffBrowser' + #min: #(#Point 10 10) + #max: #(#Point 9999 9999) + #bounds: #(#Rectangle 12 22 877 551) + ) + #component: + #(#SpecCollection + #collection: #( + #(#SubCanvasSpec + #name: 'VersionDiffBrowser' + #layout: #(#LayoutFrame 0 0.0 30 0.0 0 1.0 0 1.0) + #hasHorizontalScrollBar: false + #hasVerticalScrollBar: false + #majorKey: #VersionDiffBrowser + #minorKey: #windowSpec + #clientKey: #versionDiffBrowser + ) + #(#LabelSpec + #name: 'Label1' + #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 20 0) + #visibilityChannel: #'' + #translateLabel: true + #labelChannel: #versionDiffModel + #resizeForLabel: false + #adjust: #left + ) + ) + + ) + ) +! + +windowSpec + "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." + + " + UIPainter new openOnClass:HierarchicalVersionDiffBrowser andSelector:#windowSpec + HierarchicalVersionDiffBrowser new openInterface:#windowSpec + HierarchicalVersionDiffBrowser open + " + + + + ^ + #(#FullSpec + #name: #windowSpec + #window: + #(#WindowSpec + #label: 'Hierarchical Version DiffBrowser' + #name: 'Hierarchical Version DiffBrowser' + #min: #(#Point 10 10) + #max: #(#Point 9999 9999) + #bounds: #(#Rectangle 12 22 877 551) + ) + #component: + #(#SpecCollection + #collection: #( + #(#MenuPanelSpec + #name: 'menuPanel' + #layout: #(#LayoutFrame 0 0 0 0 0 1.0 24 0) + #level: 1 + #tabable: true + #style: + #(#Font + 'helvetica' 'bold' + 'oblique' 10 + ) + ) + #(#VariableHorizontalPanelSpec + #name: 'VariableHorizontalPanel1' + #layout: #(#LayoutFrame 0 0.0 21 0.0 0 1.0 0 1.0) + #level: 0 + #component: + #(#SpecCollection + #collection: #( + #(#HierarchicalListViewSpec + #name: 'HierarchicalItemListView' + #model: #hierarchicalItemSelectionAspect + #menu: #selectHierarchicalItemMenu + #hasHorizontalScrollBar: true + #hasVerticalScrollBar: true + #listModel: #hierarchicalItemListModel + #multipleSelectOk: true + #highlightMode: #label + #doubleClickSelector: #doubleClick: + #indicatorSelector: #doubleClick: + ) + #(#UISubSpecification + #name: 'SubSpecification1' + #majorKey: #HierarchicalVersionDiffBrowser + #minorKey: #contentsSpecVersionDiffBrowser + ) + ) + + ) + #handles: #(#Any 0.289017 1.0) + ) + ) + + ) + ) +! ! + +!HierarchicalVersionDiffBrowser class methodsFor:'menu specs'! + +resourceItemMenu + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:HierarchicalVersionDiffBrowser andSelector:#resourceItemMenu + (Menu new fromLiteralArrayEncoding:(HierarchicalVersionDiffBrowser resourceItemMenu)) startUp + " + + + + ^ + #(#Menu + #( + #(#MenuItem + #label: 'Compare Changes' + #translateLabel: true + #value: #menuActionCompareChanges + ) + ) + nil + nil + ) +! ! + +!HierarchicalVersionDiffBrowser class methodsFor:'startup'! + +openOnClasses:aClassColl + |theBrowser theClassItemColl| + + theBrowser := self new. + theBrowser allButOpen. + theClassItemColl := aClassColl collect:[:eachClass | + |theClassItem theClass| + theClassItem := ClassItem new. + theClass := Smalltalk resolveName:eachClass inClass:self. + theClassItem myClass:theClass. + theClassItem]. + theBrowser hierarchicalItemList addAll: theClassItemColl. + theBrowser hierarchicalListSelectionIndexColl:(Array with:1). + theBrowser openWindow. + + +" +HierarchicalVersionDiffBrowser openOnClasses:#(VersionDiffBrowser FileBrowser Array) +HierarchicalVersionDiffBrowser openOnClasses:(Smalltalk allClasses asOrderedCollection sort:[:x : y|x name < y name]) +" + + + +! ! + +!HierarchicalVersionDiffBrowser methodsFor:'accessing'! + +hierarchicalListItemForSelectionIndex: anIndex + + ^self hierarchicalItemListModel at:anIndex ifAbsent:nil +! + +hierarchicalListSelectionIndexColl + + ^self hierarchicalItemSelectionAspect value +! + +hierarchicalListSelectionIndexColl:anArray + + ^self hierarchicalItemSelectionAspect value:anArray +! ! + +!HierarchicalVersionDiffBrowser methodsFor:'actions'! + +doubleClick: anIndex + "automatically generated by UIPainter ..." + + "*** the code below performs no action" + "*** (except for some feedback on the Transcript)" + "*** Please change as required and accept in the browser." + + "action to be added ..." + + (self hierarchicalItemListModel at: anIndex) toggleExpand +! + +menuActionCompareChanges + + |theSelectionIndexColl theFirstRevisionItem theSecondRevisionString theClass theFirstRevisionString| + + theSelectionIndexColl := self hierarchicalListSelectionIndexColl. + theFirstRevisionItem := (self hierarchicalListItemForSelectionIndex:theSelectionIndexColl first). + theClass := theFirstRevisionItem parent myClass. + theFirstRevisionString := theFirstRevisionItem revision. + theSecondRevisionString := (self hierarchicalListItemForSelectionIndex:theSelectionIndexColl last) revision. + self updateVersionDiffLabelForClass:theClass andVersionA:theFirstRevisionString andVersionB:theSecondRevisionString. + self withWaitCursorDo:[ + self versionDiffBrowser setupForClass:theClass versionA:theFirstRevisionString versionB:theSecondRevisionString. + ]. +! + +selectHierarchicalItemMenu +" + +" + + ^[|menu| + self checkIfTwoResourceItemsSelected + ifFalse:[menu := nil] + ifTrue: [menu := Menu new fromLiteralArrayEncoding:(self class resourceItemMenu). + menu receiver:self]. + menu + ] +! + +versionDiffBrowser + versionDiffBrowser isNil ifTrue:[ + versionDiffBrowser := VersionDiffBrowser new. +"/ versionDiffBrowser hasMenu:false. + versionDiffBrowser masterApplication:self. + ]. + ^ versionDiffBrowser +! ! + +!HierarchicalVersionDiffBrowser methodsFor:'aspects'! + +hierarchicalItemList + "automatically generated by UIPainter ..." + + "*** the code below creates a default model when invoked." + "*** (which may not be the one you wanted)" + "*** Please change as required and accept it in the browser." + + ^ self hierarchicalItemListModel root + + + + + +! + +hierarchicalItemListModel + "automatically generated by UIPainter ..." + + "*** the code below creates a default model when invoked." + "*** (which may not be the one you wanted)" + "*** Please change as required and accept it in the browser." + + |holder| + + (holder := builder bindingAt:#hierarchicalItemListModel) isNil ifTrue:[ + holder := HierarchicalList new. + holder root:(ClassItemRoot new). + holder showRoot:false. + builder aspectAt:#hierarchicalItemListModel put:holder. + holder application:self. + ]. + + ^ holder. + +! + +hierarchicalItemSelectionAspect + "automatically generated by UIPainter ..." + + "*** the code below creates a default model when invoked." + "*** (which may not be the one you wanted)" + "*** Please change as required and accept it in the browser." + + |holder| + + (holder := builder bindingAt:#hierarchicalItemSelectionAspect) isNil ifTrue:[ + holder := ValueHolder new. + builder aspectAt:#hierarchicalItemSelectionAspect put:holder. + holder addDependent: self. + ]. + ^ holder. + +! + +versionDiffModel + "automatically generated by UIPainter ..." + + "*** the code below creates a default model when invoked." + "*** (which may not be the one you wanted)" + "*** Please change as required and accept it in the browser." + + |holder| + + (holder := builder bindingAt:#versionDiffModel) isNil ifTrue:[ + holder := String new asValue. + builder aspectAt:#versionDiffModel put:holder. + ]. + ^ holder. +! ! + +!HierarchicalVersionDiffBrowser methodsFor:'interface opening'! + +postOpenWith: aBuilder + + + super postOpenWith: aBuilder. + self hierarchicalItemList expand. +! ! + +!HierarchicalVersionDiffBrowser methodsFor:'testing'! + +checkIfTwoResourceItemsSelected + + |theSelectionIndexColl| + + ((theSelectionIndexColl := self hierarchicalListSelectionIndexColl) isNil or: + [theSelectionIndexColl size ~~ 2]) + ifTrue:[^false]. + ^((self hierarchicalListItemForSelectionIndex:theSelectionIndexColl first) isRevisionItem + and:[(self hierarchicalListItemForSelectionIndex:theSelectionIndexColl last) isRevisionItem]) +! ! + +!HierarchicalVersionDiffBrowser methodsFor:'update'! + +updateVersionDiffLabelForClass:aClass andVersionA:aVersionA andVersionB:aVersionB + + + |theStream| + + theStream := WriteStream on:#String. + theStream nextPutAll:'Compare '. + theStream nextPutAll: aClass name. + theStream nextPutAll:' revision '''. + theStream nextPutAll: aVersionA. + theStream nextPutAll: ''' with revision '''. + theStream nextPutAll: aVersionB. + theStream nextPutAll: '''.'. + self versionDiffModel value:theStream contents +! ! + +!HierarchicalVersionDiffBrowser::AbstractVersionDiffBrowserItem methodsFor:'protocol'! + +children + "returns list of children + *** to optimize:redefine by subClass + " + children isNil ifTrue:[ + children := #() + ]. + ^ children + + + + + + +! + +icon + ^ nil + + +! + +label + ^ nil + +! + +middleButtonMenu + "returns the middleButtonMenu or nil if no menu is defined + " + ^ nil + +! ! + +!HierarchicalVersionDiffBrowser::AbstractVersionDiffBrowserItem methodsFor:'testing'! + +isClassItem + + ^false +! + +isRevisionItem + + ^false +! ! + +!HierarchicalVersionDiffBrowser::ClassItemRoot methodsFor:'initialization'! + +initialize + super initialize. + + children := OrderedCollection new. + isExpanded := true. + + +! ! + +!HierarchicalVersionDiffBrowser::ClassItem methodsFor:'accessing'! + +myClass + "return the value of the instance variable 'myClass' (automatically generated)" + + ^ myClass! + +myClass:something + "set the value of the instance variable 'myClass' (automatically generated)" + + myClass := something.! ! + +!HierarchicalVersionDiffBrowser::ClassItem methodsFor:'protocol'! + +children +"returns list of children. The revision for the class myClass +are computed via the sourcecode manager. Only when the childrens +are needed, they are calculated. + + +" + + children ifNil:[ + self application withWaitCursorDo:[ + |theRevisionItemColl| + theRevisionItemColl := (myClass sourceCodeManager revisionsOf:myClass) collect:[:eachRevision| + |theRevisionItem| + theRevisionItem := HierarchicalVersionDiffBrowser::RevisionItem new. + theRevisionItem revision:eachRevision. + theRevisionItem]. + children:=theRevisionItemColl. + children do:[:aChild| aChild parent:self]]]. + ^children +! + +hasChildren + children ifNil:[^ true]. + ^ children size ~~ 0 +! + +label + + ^myClass name + + +! ! + +!HierarchicalVersionDiffBrowser::ClassItem methodsFor:'testing'! + +isClassItem + + ^true + + +! ! + +!HierarchicalVersionDiffBrowser::RevisionItem methodsFor:'accessing'! + +revision + "return the value of the instance variable 'revision' (automatically generated)" + + ^ revision! + +revision:something + "set the value of the instance variable 'revision' (automatically generated)" + + revision := something.! ! + +!HierarchicalVersionDiffBrowser::RevisionItem methodsFor:'protocol'! + +label + + + ^revision + + +! ! + +!HierarchicalVersionDiffBrowser::RevisionItem methodsFor:'testing'! + +isRevisionItem + + ^true + +! ! + +!HierarchicalVersionDiffBrowser class methodsFor:'documentation'! + +version + ^ '$Header: /cvs/stx/stx/libtool/HierarchicalVersionDiffBrowser.st,v 1.1 1999-12-23 15:31:19 ps Exp $' +! !