VersionDiffBrowser.st
changeset 2507 f5f8a26b7003
parent 2501 e86fae15642d
child 2510 58974b8db9fd
equal deleted inserted replaced
2506:ed2a31e2ecd0 2507:f5f8a26b7003
   401 ! !
   401 ! !
   402 
   402 
   403 !VersionDiffBrowser class methodsFor:'startup'!
   403 !VersionDiffBrowser class methodsFor:'startup'!
   404 
   404 
   405 openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB 
   405 openOnClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB 
       
   406 "
       
   407 create an VersionDiffBrowser instance and set the class change set of the
       
   408 broswer. The class change set is genertated from two source files.
       
   409 
       
   410 <return: VersionDiffBrowser>
       
   411 "
       
   412 
   406     |theBrowser|
   413     |theBrowser|
   407 
   414 
   408     theBrowser := self new.
   415     theBrowser := self new.
   409     theBrowser allButOpen.
   416     theBrowser allButOpen.
   410     theBrowser classChangeSet:(ClassChangeSet newForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB).
   417     theBrowser classChangeSet:(ClassChangeSet newForClass:aClass labelA:aLabelA sourceA:aSourceA labelB:aLabelB sourceB:aSourceB).
   411     theBrowser openWindow.
   418     theBrowser openWindow.
   412     ^ theBrowser.
   419     ^ theBrowser.
   413 
   420 
   414     "
       
   415      self openOnClass:Array versionA:'1.116' versionB:'1.113'
       
   416     "
       
   417 !
   421 !
   418 
   422 
   419 openOnClass:aClass versionA:aVersionA versionB:aVersionB
   423 openOnClass:aClass versionA:aVersionA versionB:aVersionB
       
   424 "
       
   425 create an VersionDiffBrowser instance and set the class change set of the
       
   426 broswer. The class change set is generated from two class versions via
       
   427 the source code manager .
       
   428 
       
   429 <return: VersionDiffBrowser>
       
   430 "
   420     |theBrowser|
   431     |theBrowser|
   421 
   432 
   422     theBrowser := self new.
   433     theBrowser := self new.
   423     theBrowser allButOpen.
   434     theBrowser allButOpen.
   424     theBrowser classChangeSet:(ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB).
   435     theBrowser classChangeSet:(ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB).
   453 
   464 
   454     ^ self classChangeSet methodsOnlyInB
   465     ^ self classChangeSet methodsOnlyInB
   455 !
   466 !
   456 
   467 
   457 classBeingCompared
   468 classBeingCompared
   458 
   469 "
       
   470 gets the class from the change set which is compared.
       
   471 
       
   472 <return: Class>
       
   473 " 
   459     ^ self classChangeSet classBeingCompared
   474     ^ self classChangeSet classBeingCompared
   460 !
   475 !
   461 
   476 
   462 classChangeSet
   477 classChangeSet
   463     "return the value of the instance variable 'classChangeSet' (automatically generated)"
   478 "
   464 
   479 returns the class change set which is the model of the version diff browser.
   465     ^ classChangeSet!
   480 
   466 
   481 <return: ClassChangeSet> 
   467 classChangeSet:something
       
   468 "
       
   469 
       
   470 " 
   482 " 
   471     classChangeSet := something.
   483     ^ classChangeSet
       
   484 !
       
   485 
       
   486 classChangeSet:aClassChangeSet
       
   487 "
       
   488 sets the class change set which is the model of the version diff browser.
       
   489 The labels, the lists, the visibility and the selection of the lists must be reseted
       
   490 when a new change set is given.
       
   491 
       
   492 <return: self>
       
   493 " 
       
   494     classChangeSet := aClassChangeSet.
   472     self updateLabels.
   495     self updateLabels.
   473     self updateLists.
   496     self updateLists.
   474     self resetSelectionHolders.
   497     self resetSelectionHolders.
   475 !
   498 !
   476 
   499 
       
   500 selectedChangeInA
       
   501 "
       
   502 gets the selected method change for the 'method only in version A'.
       
   503 
       
   504 <return: MethodChange | nil>
       
   505 "
       
   506     |sel change|
       
   507 
       
   508     sel := self methodsOnlyInASelection value.
       
   509     sel notNil ifTrue:[
       
   510         change := (self changeSetA at:sel).
       
   511     ].
       
   512     ^ nil
       
   513 !
       
   514 
       
   515 selectedChangeInB
       
   516 "
       
   517 gets the selected method change for the 'method only in version B'.
       
   518 
       
   519 <return: MethodChange | nil>
       
   520 "
       
   521     |sel change|
       
   522 
       
   523     sel := self methodsOnlyInBSelection value.
       
   524     sel notNil ifTrue:[
       
   525         change := (self changeSetB at:sel).
       
   526     ].
       
   527     ^ nil
       
   528 !
       
   529 
       
   530 selectedChangesInM
       
   531 "
       
   532 get the two method changes for the selected 'changed method'.
       
   533 
       
   534 <return: <Array with:MethodChange with:MethodChange | nil>>
       
   535 "
       
   536     |sel changeA changeB|
       
   537 
       
   538     sel := self methodsChangedSelection value.
       
   539     sel notNil ifTrue:[
       
   540         changeA := (self classChangeSet methodsChanged at:sel) first.
       
   541         changeB := (self classChangeSet methodsChanged at:sel) second.
       
   542         ^ Array with:changeA 
       
   543                 with:changeB 
       
   544     ].
       
   545     ^ nil
       
   546 !
       
   547 
   477 versionA
   548 versionA
   478     "return the value of the instance variable 'versionA' (automatically generated)"
   549 "
   479 
   550 gets the first class version to be compared
       
   551 
       
   552 <return: String>
       
   553 "
   480     ^ self classChangeSet labelA
   554     ^ self classChangeSet labelA
   481 
   555 
   482 !
   556 !
   483 
   557 
   484 versionB
   558 versionB
   485     "return the value of the instance variable 'versionB' (automatically generated)"
   559 "
   486 
   560 gets the second class version to be compared
       
   561 
       
   562 <return: String>
       
   563 "
   487     ^ self classChangeSet labelB
   564     ^ self classChangeSet labelB
   488 
   565 
   489 ! !
   566 ! !
   490 
   567 
   491 !VersionDiffBrowser methodsFor:'actions'!
   568 !VersionDiffBrowser methodsFor:'actions'!
   492 
   569 
   493 methodsChangedSelectionChanged
   570 methodsChangedSelectionChanged
       
   571 "
       
   572 the selection in the list of the 'changed methods' changed.
       
   573 Reset the selection of the two other lists and calc the method change.
       
   574 
       
   575 <return: self>
       
   576 "
   494     |sel idxA idxB changeA changeB|
   577     |sel idxA idxB changeA changeB|
   495 
   578 
   496     sel := self methodsChangedSelection value.
   579     sel := self methodsChangedSelection value.
   497     sel notNil ifTrue:[
   580     sel notNil ifTrue:[
   498         self methodsOnlyInASelection value:nil.
   581         self methodsOnlyInASelection value:nil.
   502         self withReadCursorDo:[
   585         self withReadCursorDo:[
   503             self diffTextView text1:changeA source text2:changeB source.
   586             self diffTextView text1:changeA source text2:changeB source.
   504             self diffTextView moveToNextChanged
   587             self diffTextView moveToNextChanged
   505         ].
   588         ].
   506         self showDiffTextView.
   589         self showDiffTextView.
   507     ] ifFalse:[
       
   508         self diffTextView text1:'' text2:''.
       
   509     ]
   590     ]
   510 
   591 
   511     "Modified: / 3.9.1999 / 15:01:30 / ps"
   592     "Modified: / 3.9.1999 / 15:01:30 / ps"
   512 !
   593 !
   513 
   594 
   514 methodsOnlyInASelectionChanged
   595 methodsOnlyInASelectionChanged
       
   596 "
       
   597 the selection in the list of the 'method only in version A' changed.
       
   598 Reset the selection of the two other lists and show the method in
       
   599 the text view.
       
   600 
       
   601 <return: self>
       
   602 "
   515     |change sel|
   603     |change sel|
   516 
   604 
   517     sel := self methodsOnlyInASelection value.
   605     sel := self methodsOnlyInASelection value.
   518     sel notNil ifTrue:[
   606     sel notNil ifTrue:[
   519         self methodsOnlyInBSelection value:nil.
   607         self methodsOnlyInBSelection value:nil.
   520         self methodsChangedSelection value:nil.
   608         self methodsChangedSelection value:nil.
   521 
       
   522         change := self changeSetA at:sel.
   609         change := self changeSetA at:sel.
   523         self methodText value:(change source).    
   610         self methodText value:(change source).    
   524         self showSingleTextView.
   611         self showSingleTextView.
   525     ] ifFalse:[
       
   526         self methodText value:''.
       
   527     ]
   612     ]
   528 !
   613 !
   529 
   614 
   530 methodsOnlyInBSelectionChanged
   615 methodsOnlyInBSelectionChanged
       
   616 "
       
   617 the selection in the list of the 'method only in version B' changed.
       
   618 Reset the selection of the two other lists and show the method in
       
   619 the text view.
       
   620 
       
   621 <return: self>
       
   622 "
   531     |change sel|
   623     |change sel|
   532 
   624 
   533     sel := self methodsOnlyInBSelection value.
   625     sel := self methodsOnlyInBSelection value.
   534     sel notNil ifTrue:[
   626     sel notNil ifTrue:[
   535         self methodsOnlyInASelection value:nil.
   627         self methodsOnlyInASelection value:nil.
   536         self methodsChangedSelection value:nil.
   628         self methodsChangedSelection value:nil.
   537 
       
   538         change := self changeSetB at:sel.
   629         change := self changeSetB at:sel.
   539         self methodText value:(change source).    
   630         self methodText value:(change source).    
   540         self showSingleTextView.
   631         self showSingleTextView.
   541     ] ifFalse:[
       
   542         self methodText value:''.
       
   543     ]
   632     ]
   544 ! !
   633 ! !
   545 
   634 
   546 !VersionDiffBrowser methodsFor:'aspects'!
   635 !VersionDiffBrowser methodsFor:'aspects'!
   547 
   636 
   548 changedLabelHolder
   637 changedLabelHolder
   549     "automatically generated by UIPainter ..."
   638 "
   550 
   639 aspect for the label of the changed method box.
   551     "*** the code below creates a default model when invoked."
   640 
   552     "*** (which may not be the one you wanted)"
   641 <return: ValueHolder on: nil>
   553     "*** Please change as required and accept in the browser."
   642 "
   554 
       
   555     |holder|
   643     |holder|
   556 
   644 
   557     (holder := builder bindingAt:#changedLabelHolder) isNil ifTrue:[
   645     (holder := builder bindingAt:#changedLabelHolder) isNil ifTrue:[
   558         builder aspectAt:#changedLabelHolder put:(holder :=  ValueHolder new).
   646         builder aspectAt:#changedLabelHolder put:(holder :=  ValueHolder new).
   559     ].
   647     ].
   560     ^ holder.
   648     ^ holder.
   561 !
   649 !
   562 
   650 
   563 diffTextLabelA
   651 diffTextLabelA
   564     "automatically generated by UIPainter ..."
   652 "
   565 
   653 aspect for the label for version A.
   566     "*** the code below creates a default model when invoked."
   654 
   567     "*** (which may not be the one you wanted)"
   655 <return: ValueHolder on: nil>
   568     "*** Please change as required and accept in the browser."
   656 "
   569 
   657 
   570     |holder|
   658     |holder|
   571 
   659 
   572     (holder := builder bindingAt:#diffTextLabelA) isNil ifTrue:[
   660     (holder := builder bindingAt:#diffTextLabelA) isNil ifTrue:[
   573         builder aspectAt:#diffTextLabelA put:(holder :=  ValueHolder new).
   661         builder aspectAt:#diffTextLabelA put:(holder :=  ValueHolder new).
   574     ].
   662     ].
   575     ^ holder.
   663     ^ holder.
   576 !
   664 !
   577 
   665 
   578 diffTextLabelB
   666 diffTextLabelB
   579     "automatically generated by UIPainter ..."
   667 "
   580 
   668 aspect for the label for version B.
   581     "*** the code below creates a default model when invoked."
   669 
   582     "*** (which may not be the one you wanted)"
   670 <return: ValueHolder on: nil>
   583     "*** Please change as required and accept in the browser."
   671 "
   584 
   672 
   585     |holder|
   673     |holder|
   586 
   674 
   587     (holder := builder bindingAt:#diffTextLabelB) isNil ifTrue:[
   675     (holder := builder bindingAt:#diffTextLabelB) isNil ifTrue:[
   588         builder aspectAt:#diffTextLabelB put:(holder :=  ValueHolder new).
   676         builder aspectAt:#diffTextLabelB put:(holder :=  ValueHolder new).
   589     ].
   677     ].
   590     ^ holder.
   678     ^ holder.
   591 !
   679 !
   592 
   680 
   593 diffTextView
   681 diffTextView
   594     "automatically generated by UIPainter ..."
   682 "
   595 
   683 return the component for the diff text view.
       
   684 
       
   685 <return: HVScrollableView>
       
   686 "
   596     diffTextView isNil ifTrue:[
   687     diffTextView isNil ifTrue:[
   597         diffTextView := HVScrollableView
   688         diffTextView := HVScrollableView
   598                            for:DiffTextView
   689                            for:DiffTextView
   599                            miniScrollerH:true miniScrollerV:false.
   690                            miniScrollerH:true miniScrollerV:false.
   600         diffTextView addNextPreviousButtons.
   691         diffTextView addNextPreviousButtons.
   601     ].
   692     ].
   602     ^ diffTextView
   693     ^ diffTextView
   603 !
   694 !
   604 
   695 
   605 methodText
   696 methodText
   606     "automatically generated by UIPainter ..."
   697 "
   607 
   698 aspect for the text in the method text view.
   608     "*** the code below creates a default model when invoked."
   699 
   609     "*** (which may not be the one you wanted)"
   700 <return: ValueHolder on: nil>
   610     "*** Please change as required and accept in the browser."
   701 "
   611 
       
   612     |holder|
   702     |holder|
   613 
   703 
   614     (holder := builder bindingAt:#methodText) isNil ifTrue:[
   704     (holder := builder bindingAt:#methodText) isNil ifTrue:[
   615         builder aspectAt:#methodText put:(holder :=  ValueHolder new).
   705         builder aspectAt:#methodText put:(holder :=  ValueHolder new).
   616     ].
   706     ].
   617     ^ holder.
   707     ^ holder.
   618 !
   708 !
   619 
   709 
   620 methodsChanged
   710 methodsChanged
   621     "automatically generated by UIPainter ..."
   711 "
   622 
   712 aspect for the 'changed method' list.
   623     "*** the code below creates a default model when invoked."
   713 
   624     "*** (which may not be the one you wanted)"
   714 <return: List>
   625     "*** Please change as required and accept in the browser."
   715 "
   626 
   716 
   627     |holder|
   717     |holder|
   628 
   718 
   629     (holder := builder bindingAt:#methodsChanged) isNil ifTrue:[
   719     (holder := builder bindingAt:#methodsChanged) isNil ifTrue:[
   630         builder aspectAt:#methodsChanged put:(holder :=  List new).
   720         builder aspectAt:#methodsChanged put:(holder :=  List new).
   631     ].
   721     ].
   632     ^ holder.
   722     ^ holder.
   633 !
   723 !
   634 
   724 
   635 methodsChangedSelection
   725 methodsChangedSelection
   636     "automatically generated by UIPainter ..."
   726 "
   637 
   727 aspect for the selection holder of 'changed method'-list.
   638     "*** the code below creates a default model when invoked."
   728 
   639     "*** (which may not be the one you wanted)"
   729 <return: ValueHolder on: nil>
   640     "*** Please change as required and accept in the browser."
   730 "
   641 
   731 
   642     |holder|
   732     |holder|
   643 
   733 
   644     (holder := builder bindingAt:#methodsChangedSelection) isNil ifTrue:[
   734     (holder := builder bindingAt:#methodsChangedSelection) isNil ifTrue:[
   645         builder aspectAt:#methodsChangedSelection put:(holder :=  ValueHolder new).
   735         builder aspectAt:#methodsChangedSelection put:(holder :=  ValueHolder new).
   646     ].
   736     ].
   647     ^ holder.
   737     ^ holder.
   648 !
   738 !
   649 
   739 
   650 methodsOnlyInA
   740 methodsOnlyInA
   651     "automatically generated by UIPainter ..."
   741 "
   652 
   742 aspect for the 'method only in version A' list.
   653     "*** the code below creates a default model when invoked."
   743 
   654     "*** (which may not be the one you wanted)"
   744 <return: List>
   655     "*** Please change as required and accept in the browser."
   745 "
   656 
   746 
   657     |holder|
   747     |holder|
   658 
   748 
   659     (holder := builder bindingAt:#methodsOnlyInA) isNil ifTrue:[
   749     (holder := builder bindingAt:#methodsOnlyInA) isNil ifTrue:[
   660         builder aspectAt:#methodsOnlyInA put:(holder :=  List new).
   750         builder aspectAt:#methodsOnlyInA put:(holder :=  List new).
   661     ].
   751     ].
   662     ^ holder.
   752     ^ holder.
   663 !
   753 !
   664 
   754 
   665 methodsOnlyInASelection
   755 methodsOnlyInASelection
   666     "automatically generated by UIPainter ..."
   756 "
   667 
   757 aspect for the selection holder of 'method only in version A'-list.
   668     "*** the code below creates a default model when invoked."
   758 
   669     "*** (which may not be the one you wanted)"
   759 <return: ValueHolder on: nil>
   670     "*** Please change as required and accept in the browser."
   760 "
   671 
   761 
   672     |holder|
   762     |holder|
   673 
   763 
   674     (holder := builder bindingAt:#methodsOnlyInASelection) isNil ifTrue:[
   764     (holder := builder bindingAt:#methodsOnlyInASelection) isNil ifTrue:[
   675         builder aspectAt:#methodsOnlyInASelection put:(holder :=  ValueHolder new).
   765         builder aspectAt:#methodsOnlyInASelection put:(holder :=  ValueHolder new).
   676     ].
   766     ].
   677     ^ holder.
   767     ^ holder.
   678 !
   768 !
   679 
   769 
   680 methodsOnlyInB
   770 methodsOnlyInB
   681     "automatically generated by UIPainter ..."
   771 "
   682 
   772 aspect for the 'method only in version B' list.
   683     "*** the code below creates a default model when invoked."
   773 
   684     "*** (which may not be the one you wanted)"
   774 <return: List>
   685     "*** Please change as required and accept in the browser."
   775 "
   686 
   776 
   687     |holder|
   777     |holder|
   688 
   778 
   689     (holder := builder bindingAt:#methodsOnlyInB) isNil ifTrue:[
   779     (holder := builder bindingAt:#methodsOnlyInB) isNil ifTrue:[
   690         builder aspectAt:#methodsOnlyInB put:(holder :=  List new).
   780         builder aspectAt:#methodsOnlyInB put:(holder :=  List new).
   691     ].
   781     ].
   692     ^ holder.
   782     ^ holder.
   693 !
   783 !
   694 
   784 
   695 methodsOnlyInBSelection
   785 methodsOnlyInBSelection
   696     "automatically generated by UIPainter ..."
   786 "
   697 
   787 aspect for the selection holder of 'method only in version B'-list.
   698     "*** the code below creates a default model when invoked."
   788 
   699     "*** (which may not be the one you wanted)"
   789 <return: ValueHolder on: nil>
   700     "*** Please change as required and accept in the browser."
   790 "
   701 
   791 
   702     |holder|
   792     |holder|
   703 
   793 
   704     (holder := builder bindingAt:#methodsOnlyInBSelection) isNil ifTrue:[
   794     (holder := builder bindingAt:#methodsOnlyInBSelection) isNil ifTrue:[
   705         builder aspectAt:#methodsOnlyInBSelection put:(holder :=  ValueHolder new).
   795         builder aspectAt:#methodsOnlyInBSelection put:(holder :=  ValueHolder new).
   706     ].
   796     ].
   707     ^ holder.
   797     ^ holder.
   708 !
   798 !
   709 
   799 
   710 onlyInALabelHolder
   800 onlyInALabelHolder
   711     "automatically generated by UIPainter ..."
   801 "
   712 
   802 aspect for the label for 'method only in version A'.
   713     "*** the code below creates a default model when invoked."
   803 
   714     "*** (which may not be the one you wanted)"
   804 <return: ValueHolder on: nil>
   715     "*** Please change as required and accept in the browser."
   805 "
   716 
   806 
   717     |holder|
   807     |holder|
   718 
   808 
   719     (holder := builder bindingAt:#onlyInALabelHolder) isNil ifTrue:[
   809     (holder := builder bindingAt:#onlyInALabelHolder) isNil ifTrue:[
   720         builder aspectAt:#onlyInALabelHolder put:(holder :=  ValueHolder new).
   810         builder aspectAt:#onlyInALabelHolder put:(holder :=  ValueHolder new).
   721     ].
   811     ].
   722     ^ holder.
   812     ^ holder.
   723 !
   813 !
   724 
   814 
   725 onlyInBLabelHolder
   815 onlyInBLabelHolder
   726     "automatically generated by UIPainter ..."
   816 "
   727 
   817 aspect for the label for 'method only in version B'.
   728     "*** the code below creates a default model when invoked."
   818 
   729     "*** (which may not be the one you wanted)"
   819 <return: ValueHolder on: nil>
   730     "*** Please change as required and accept in the browser."
   820 "
   731 
   821 
   732     |holder|
   822     |holder|
   733 
   823 
   734     (holder := builder bindingAt:#onlyInBLabelHolder) isNil ifTrue:[
   824     (holder := builder bindingAt:#onlyInBLabelHolder) isNil ifTrue:[
   735         builder aspectAt:#onlyInBLabelHolder put:(holder :=  ValueHolder new).
   825         builder aspectAt:#onlyInBLabelHolder put:(holder :=  ValueHolder new).
   738 ! !
   828 ! !
   739 
   829 
   740 !VersionDiffBrowser methodsFor:'initialization & release'!
   830 !VersionDiffBrowser methodsFor:'initialization & release'!
   741 
   831 
   742 postBuildWith:aBuilder
   832 postBuildWith:aBuilder
   743     "This is a hook method generated by the Browser.
   833 "
   744      It will be invoked during the initialization of your app/dialog,
   834 components which are invisible should be ignored by the panel.
   745      after all of the visual components have been built, 
   835 Cannot be set via the interface builder.
   746      but BEFORE the top window is made visible.
   836 
   747      Add any app-specific actions here (reading files, setting up
   837 <return: self>
   748      values etc.)"
   838 "
   749 
       
   750     "/ add any code here ...
       
   751 
       
   752     (aBuilder componentAt:#TopHorizontalPanel) ignoreInvisibleComponents:true.
   839     (aBuilder componentAt:#TopHorizontalPanel) ignoreInvisibleComponents:true.
   753     ^ super postBuildWith:aBuilder
   840     ^ super postBuildWith:aBuilder
   754 ! !
   841 ! !
   755 
   842 
   756 !VersionDiffBrowser methodsFor:'menu action'!
   843 !VersionDiffBrowser methodsFor:'menu action'!
   757 
   844 
   758 browseChange:aChange
   845 browseChange:aChange
       
   846 "
       
   847 browse the change in aChange 
       
   848 
       
   849 <return: self>
       
   850 "
   759     SystemBrowser 
   851     SystemBrowser 
   760         openInClass:aChange changeClass
   852         openInClass:aChange changeClass
   761         selector:aChange changeSelector.
   853         selector:aChange changeSelector.
   762 !
   854 !
   763 
   855 
   764 browseClassInA
   856 browseClassInA
       
   857 "
       
   858 browse the selected method.
       
   859 
       
   860 <return: self>
       
   861 "
   765     self browseChange:(self selectedChangeInA).
   862     self browseChange:(self selectedChangeInA).
   766 !
   863 !
   767 
   864 
   768 browseClassInB
   865 browseClassInB
       
   866 "
       
   867 browse the selected method.
       
   868 
       
   869 <return: self>
       
   870 "
   769     self browseChange:(self selectedChangeInB).
   871     self browseChange:(self selectedChangeInB).
   770 !
   872 !
   771 
   873 
   772 browseClassInM
   874 browseClassInM
       
   875 "
       
   876 browse the selected method.
       
   877 
       
   878 <return: self>
       
   879 "
   773     self browseChange:(self selectedChangesInM first).
   880     self browseChange:(self selectedChangesInM first).
   774 !
   881 !
   775 
   882 
   776 createPatchFile
   883 createPatchFile
   777     "create a pacthFile, to patch the old version (versionB) into
   884     "create a pacthFile, to patch the old version (versionB) into
   778      the new version (versionA)"
   885      the new version (versionA)"
   779 
   886 
   780     |oldVersion newVersion vsnMthdA vsnMthdB vsnA vsnB info|
   887     |oldVersion newVersion vsnMthdA vsnMthdB vsnA vsnB info|
   781 
   888     self halt.
   782     vsnMthdA := self changeSetA 
   889     vsnMthdA := self changeSetA 
   783                 detect:[:ch | ch isMethodChange
   890                 detect:[:ch | ch isMethodChange
   784                               and:[ch changeClass isMeta
   891                               and:[ch changeClass isMeta
   785                               and:[ch changeSelector = #version]]]
   892                               and:[ch changeSelector = #version]]]
   786                 ifNone:nil.
   893                 ifNone:nil.
   813                 vsnB := nil.
   920                 vsnB := nil.
   814             ].
   921             ].
   815         ].
   922         ].
   816     ].
   923     ].
   817 
   924 
   818     (vsnA isNil 
   925     (vsnA isNil or:[vsnB isNil or:[vsnA = vsnB]]) ifTrue:[
   819     or:[vsnB isNil
       
   820     or:[vsnA = vsnB]]) ifTrue:[
       
   821         self warn:'The generated patch file will not be able to validate/update the class version'.
   926         self warn:'The generated patch file will not be able to validate/update the class version'.
   822     ].
   927     ].
   823 
   928 
   824 self halt.
   929 self halt.
   825 
   930 
   826 !
   931 !
   827 
   932 
   828 inspectSelectedChangeInA
   933 inspectSelectedChangeInA
       
   934 "
       
   935 inspect the selected method change for the 'method only in version A'.
       
   936 
       
   937 <return: self>
       
   938 "
   829     self selectedChangeInA inspect.
   939     self selectedChangeInA inspect.
   830 !
   940 !
   831 
   941 
   832 inspectSelectedChangeInB
   942 inspectSelectedChangeInB
       
   943 "
       
   944 inspect the selected method change for the 'method only in version B'.
       
   945 
       
   946 <return: self>
       
   947 "
   833     self selectedChangeInB inspect.
   948     self selectedChangeInB inspect.
   834 !
   949 !
   835 
   950 
   836 inspectSelectedChangeInM
   951 inspectSelectedChangeInM
       
   952 "
       
   953 inspect the two method changes for the selected 'changed method'.
       
   954 
       
   955 <return: self>
       
   956 "
   837     |changes|
   957     |changes|
   838 
   958 
   839     changes := self selectedChangesInM.
   959     changes := self selectedChangesInM.
   840     changes do:[:change |
   960     changes do:[:change |
   841         change inspect
   961         change inspect
   842     ].
   962     ].
   843 !
   963 !
   844 
   964 
   845 mainMenu
   965 mainMenu
       
   966 "
       
   967 if this application runs as an subapplication,
       
   968 the menu bar should not be used.
       
   969 
       
   970 <return: self>
       
   971 "
   846     self masterApplication isNil ifTrue:[
   972     self masterApplication isNil ifTrue:[
   847         ^ self class mainMenu
   973         ^ self class mainMenu
   848     ].
   974     ].
   849     ^ nil
   975     ^ nil
   850 !
       
   851 
       
   852 selectedChangeInA
       
   853     |sel change|
       
   854 
       
   855     sel := self methodsOnlyInASelection value.
       
   856     sel notNil ifTrue:[
       
   857         change := (self changeSetA at:sel).
       
   858     ].
       
   859     ^ change
       
   860 !
       
   861 
       
   862 selectedChangeInB
       
   863     |sel change|
       
   864 
       
   865     sel := self methodsOnlyInBSelection value.
       
   866     sel notNil ifTrue:[
       
   867         change := (self changeSetB at:sel).
       
   868     ].
       
   869     ^ change
       
   870 !
       
   871 
       
   872 selectedChangesInM
       
   873     |sel idxA idxB|
       
   874 
       
   875     sel := self methodsChangedSelection value.
       
   876     sel notNil ifTrue:[
       
   877         idxA := self indexFromChangedToA at:sel ifAbsent:nil.
       
   878         idxB := self indexFromChangedToB at:sel ifAbsent:nil.
       
   879 
       
   880         ^ Array with:(self changeSetA at:idxA) 
       
   881                 with:(self changeSetB at:idxB) 
       
   882     ].
       
   883     ^ nil
       
   884 ! !
   976 ! !
   885 
   977 
   886 !VersionDiffBrowser methodsFor:'private'!
   978 !VersionDiffBrowser methodsFor:'private'!
   887 
   979 
   888 generator
   980 generator
   889 
   981 "
   890     ^[:c |
   982 generate a print string for a change.
       
   983 
       
   984 <return: Block>
       
   985 "
       
   986     ^[:aChange |
   891         |result mPkg cPkg cls m|
   987         |result mPkg cPkg cls m|
   892 
   988         aChange isClassDefinitionChange ifTrue:[
   893         c isClassDefinitionChange ifTrue:[
   989             result := aChange printStringWithoutClass
   894             result := c printStringWithoutClass
       
   895         ] ifFalse:[
   990         ] ifFalse:[
   896             c isDoIt ifTrue:[
   991             aChange isDoIt ifTrue:[
   897                 result := c source , ' (doIt)'
   992                 result := aChange source , ' (doIt)'
   898             ] ifFalse:[
   993             ] ifFalse:[
   899                 c className = self classBeingCompared name ifTrue:[
   994                 aChange className = self classBeingCompared name ifTrue:[
   900                     result := c printStringWithoutClass.
   995                     result := aChange printStringWithoutClass.
   901                     c isMethodChange ifTrue:[
   996                     aChange isMethodChange ifTrue:[
   902                         cls := c changeClass.
   997                         cls := aChange changeClass.
   903                         cls notNil ifTrue:[
   998                         cls notNil ifTrue:[
   904                             m := cls compiledMethodAt:c selector.
   999                             m := cls compiledMethodAt:aChange selector.
   905                             (m notNil 
  1000                             (m notNil 
   906                             and:[m package ~= cls package]) ifTrue:[
  1001                             and:[m package ~= cls package]) ifTrue:[
   907                                 result := c printStringWithoutClass , ' [' , m package , ']'.
  1002                                 result := aChange printStringWithoutClass , ' [' , m package , ']'.
   908                             ].
  1003                             ].
   909                         ].
  1004                         ].
   910                     ]
  1005                     ]
   911                 ] ifFalse:[
  1006                 ] ifFalse:[
   912                     "/ include name in private class changes
  1007                     "/ include name in private class changes
   913                     (c className startsWith:(self classBeingCompared name , '::')) ifTrue:[
  1008                     (aChange className startsWith:(self classBeingCompared name , '::')) ifTrue:[
   914                         result := (c className copyFrom:(self classBeingCompared name size + 3)) , ' ' ,  c printStringWithoutClass
  1009                         result := (aChange className copyFrom:(self classBeingCompared name size + 3)) , ' ' ,  aChange printStringWithoutClass
   915                     ] ifFalse:[
  1010                     ] ifFalse:[
   916                         result := c printString
  1011                         result := aChange printString
   917                     ]
  1012                     ]
   918                 ]
  1013                 ]
   919             ]
  1014             ]
   920         ].
  1015         ].
   921         result
  1016         result
   922     ].
  1017     ].
   923 
  1018 
   924 !
  1019 !
   925 
  1020 
   926 resetSelectionHolders
  1021 resetSelectionHolders
       
  1022 "
       
  1023 reset all selection holders when a new change set is given.
       
  1024 First set the selection to nil. 
       
  1025 
       
  1026 <return: self>
       
  1027 "
   927 
  1028 
   928     self methodsChangedSelection value:nil.
  1029     self methodsChangedSelection value:nil.
   929     self methodsOnlyInASelection value:nil.
  1030     self methodsOnlyInASelection value:nil.
   930     self methodsOnlyInBSelection value:nil.
  1031     self methodsOnlyInBSelection value:nil.
   931     self methodsChangedSelectionChanged.
  1032     self diffTextView text1:'' text2:''.
   932     self methodsOnlyInASelectionChanged.
  1033     self methodText value:''.
   933     self methodsOnlyInBSelectionChanged.
  1034 
       
  1035 "/    self methodsChangedSelectionChanged.
       
  1036 "/    self methodsOnlyInASelectionChanged.
       
  1037 "/    self methodsOnlyInBSelectionChanged.
   934 
  1038 
   935 !
  1039 !
   936 
  1040 
   937 showDiffTextView
  1041 showDiffTextView
       
  1042 "
       
  1043 if a method change is selected, then show the diff text view.
       
  1044 Add an accept entry to the popup menu.
       
  1045 
       
  1046 <return: self>
       
  1047 "
   938     (self builder componentAt:#diffTextViewBox) raise; beVisible.
  1048     (self builder componentAt:#diffTextViewBox) raise; beVisible.
   939     (self builder componentAt:#singleTextView) beInvisible.
  1049     (self builder componentAt:#singleTextView) beInvisible.
   940     (self builder componentAt:#diffTextView) realizeAllSubViews.
  1050     (self builder componentAt:#diffTextView) realizeAllSubViews.
   941     self addAcceptToTextViewMenus.
  1051     self addAcceptToTextViewMenus.
   942 !
  1052 !
   943 
  1053 
   944 showSingleTextView
  1054 showSingleTextView
       
  1055 "
       
  1056 if a method  is selected which is only in version A or B of the class,
       
  1057 then show the text view.
       
  1058 Add an accept entry to the popup menu.
       
  1059 
       
  1060 <return: self>
       
  1061 "
       
  1062 
   945     (self builder componentAt:#singleTextView) raise; beVisible.
  1063     (self builder componentAt:#singleTextView) raise; beVisible.
   946     (self builder componentAt:#diffTextViewBox) beInvisible.
  1064     (self builder componentAt:#diffTextViewBox) beInvisible.
   947     self addAcceptToTextViewMenus.
  1065     self addAcceptToTextViewMenus.
   948 
  1066 
   949 !
  1067 !
   950 
  1068 
   951 updateLabels
  1069 updateLabels
   952 
  1070 "
       
  1071 update the labels of the diff text view. Show the version numbers
       
  1072 of the class.
       
  1073 
       
  1074 <return: self>
       
  1075 "
   953 
  1076 
   954     |theVersionA theVersionB|
  1077     |theVersionA theVersionB|
   955 
  1078 
   956     (theVersionA := self versionA) notNil ifTrue:[
  1079     (theVersionA := self versionA) notNil ifTrue:[
   957         self diffTextLabelA value:theVersionA.
  1080         self diffTextLabelA value:theVersionA.
   964         (self builder componentAt:#OnlyInBLabel) backgroundColor:Color red darkened.
  1087         (self builder componentAt:#OnlyInBLabel) backgroundColor:Color red darkened.
   965     ].
  1088     ].
   966 !
  1089 !
   967 
  1090 
   968 updateLists
  1091 updateLists
   969     "walk over the two changeSets and add change to one of the tree lists"
  1092 "walk over the two changeSets and add change to one of the tree lists.
       
  1093 Methods which belong to the version A of the class or version B go
       
  1094 to the list methodsOnlyInA or methodsOnlyInB.
       
  1095 Methods which are changed from version A to B go to the list methodsChanged.
       
  1096 
       
  1097 <return: self>
       
  1098 "
   970 
  1099 
   971     self methodsOnlyInA removeAll.
  1100     self methodsOnlyInA removeAll.
   972     self methodsOnlyInA addAll: (self classChangeSet methodsOnlyInA collect:self generator).
  1101     self methodsOnlyInA addAll: (self classChangeSet methodsOnlyInA collect:self generator).
   973     self methodsOnlyInB removeAll.
  1102     self methodsOnlyInB removeAll.
   974     self methodsOnlyInB addAll: (self classChangeSet methodsOnlyInB collect:self generator).
  1103     self methodsOnlyInB addAll: (self classChangeSet methodsOnlyInB collect:self generator).
   975     self methodsChanged removeAll.
  1104     self methodsChanged removeAll.
   976     self methodsChanged addAll: (self classChangeSet methodsChanged collect:[:arr| self generator value:(arr first)]).
  1105     self methodsChanged addAll: (self classChangeSet methodsChanged collect:[:arr| self generator value:(arr first)]).
   977 
  1106 
   978     self methodsOnlyInA value isEmpty ifTrue:[
  1107     self methodsOnlyInA value isEmpty
   979         (self builder componentAt:#BoxA) beInvisible.
  1108         ifTrue: [(self builder componentAt:#BoxA) beInvisible]
   980     ] ifFalse:[
  1109         ifFalse:[(self builder componentAt:#BoxA) beVisible].
   981         (self builder componentAt:#BoxA) beVisible.
  1110 
   982     ].
  1111     self methodsOnlyInB value isEmpty
   983 
  1112          ifTrue: [(self builder componentAt:#BoxB) beInvisible]
   984     self methodsOnlyInB value isEmpty ifTrue:[
  1113          ifFalse:[(self builder componentAt:#BoxB) beVisible].
   985         (self builder componentAt:#BoxB) beInvisible.
  1114 
   986     ] ifFalse:[
  1115     self methodsChanged value isEmpty 
   987         (self builder componentAt:#BoxB) beVisible.
  1116         ifTrue: [(self methodsOnlyInA value notEmpty or:[self methodsOnlyInB value notEmpty])
   988     ].
  1117                      ifTrue:[(self builder componentAt:#BoxM) beInvisible]]
   989 
  1118         ifFalse:[(self builder componentAt:#BoxM) beVisible]
   990     self methodsChanged value isEmpty ifTrue:[
       
   991         (self methodsOnlyInA value notEmpty or:[self methodsOnlyInB value notEmpty]) ifTrue:[
       
   992             (self builder componentAt:#BoxM) beInvisible.
       
   993         ]
       
   994     ] ifFalse:[
       
   995         (self builder componentAt:#BoxM) beVisible.
       
   996     ]
       
   997 ! !
  1119 ! !
   998 
  1120 
   999 !VersionDiffBrowser methodsFor:'setup'!
  1121 !VersionDiffBrowser methodsFor:'setup'!
  1000 
  1122 
  1001 setupForClass:aClass versionA:aVersionA versionB:aVersionB
  1123 setupForClass:aClass versionA:aVersionA versionB:aVersionB
  1002 
  1124 "
       
  1125 compute the class change set for the class aClass and the versions A and B.
       
  1126 When setting the class change set, the labels, list etc. of the receiver
       
  1127 are updated.
       
  1128 
       
  1129 <return: self>
       
  1130 "
  1003     self classChangeSet:(ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB)
  1131     self classChangeSet:(ClassChangeSet newForClass:aClass versionA:aVersionA versionB:aVersionB)
  1004 ! !
  1132 ! !
  1005 
  1133 
  1006 !VersionDiffBrowser methodsFor:'values'!
  1134 !VersionDiffBrowser methodsFor:'values'!
  1007 
  1135 
  1008 addAcceptToTextViewMenus
  1136 addAcceptToTextViewMenus
       
  1137 "
       
  1138 add to the standard diff text view or single text views menu an accept entry.
       
  1139 
       
  1140 <return: self>
       
  1141 "
       
  1142 
  1009     |m v|
  1143     |m v|
  1010 
  1144 
  1011     (Array 
  1145     (Array 
  1012         with:self diffTextView leftTextView
  1146         with:self diffTextView leftTextView
  1013         with:self diffTextView rightTextView
  1147         with:self diffTextView rightTextView
  1234 ! !
  1368 ! !
  1235 
  1369 
  1236 !VersionDiffBrowser class methodsFor:'documentation'!
  1370 !VersionDiffBrowser class methodsFor:'documentation'!
  1237 
  1371 
  1238 version
  1372 version
  1239     ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.15 1999-12-23 16:10:33 ps Exp $'
  1373     ^ '$Header: /cvs/stx/stx/libtool/VersionDiffBrowser.st,v 1.16 1999-12-27 14:16:34 ps Exp $'
  1240 ! !
  1374 ! !