Tools__TextDiffTool.st
changeset 10332 1aac52034cda
parent 10196 3942434287fe
child 10344 956791655804
equal deleted inserted replaced
10331:395bdb2d4575 10332:1aac52034cda
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libbasic3' }"
    12 "{ Package: 'stx:libtool' }"
    13 
    13 
    14 "{ NameSpace: Tools }"
    14 "{ NameSpace: Tools }"
    15 
    15 
    16 ApplicationModel subclass:#TextDiffTool
    16 ApplicationModel subclass:#TextDiffTool
    17 	instanceVariableNames:'labelAHolder textAHolder labelBHolder textBHolder diffSpecHolder
    17 	instanceVariableNames:'labelAHolder textAHolder labelBHolder textBHolder classHolder
    18 		showDiffHolder diffView numChangedTexts'
    18 		languageHolder showDiffHolder diffSpecHolder diffView
       
    19 		numChangedTexts codeView'
    19 	classVariableNames:''
    20 	classVariableNames:''
    20 	poolDictionaries:''
    21 	poolDictionaries:''
    21 	category:'Interface-Diff'
    22 	category:'Interface-Diff'
    22 !
    23 !
    23 
    24 
   123          
   124          
   124         )
   125         )
   125       )
   126       )
   126 !
   127 !
   127 
   128 
       
   129 textViewSpec
       
   130     "This resource specification was automatically generated
       
   131      by the UIPainter of ST/X."
       
   132 
       
   133     "Do not manually edit this!! If it is corrupted,
       
   134      the UIPainter may not be able to read the specification."
       
   135 
       
   136     "
       
   137      UIPainter new openOnClass:Tools::TextDiffTool andSelector:#textViewSpec
       
   138      Tools::TextDiffTool new openInterface:#textViewSpec
       
   139     "
       
   140 
       
   141     <resource: #canvas>
       
   142 
       
   143     ^ 
       
   144      #(FullSpec
       
   145         name: 'textViewSpec'
       
   146         window: 
       
   147        (WindowSpec
       
   148           label: 'Text Only'
       
   149           name: 'Text Only'
       
   150           min: (Point 10 10)
       
   151           bounds: (Rectangle 0 0 782 506)
       
   152         )
       
   153         component: 
       
   154        (SpecCollection
       
   155           collection: (
       
   156            (ArbitraryComponentSpec
       
   157               name: 'CodeView'
       
   158               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
       
   159               model: textAHolder
       
   160               hasHorizontalScrollBar: false
       
   161               hasVerticalScrollBar: false
       
   162               autoHideScrollBars: false
       
   163               hasBorder: false
       
   164               component: #'Tools::CodeView2'
       
   165               postBuildCallback: postBuildCodeView:
       
   166             )
       
   167            )
       
   168          
       
   169         )
       
   170       )
       
   171 !
       
   172 
       
   173 versionAOnlySpec
       
   174     "This resource specification was automatically generated
       
   175      by the UIPainter of ST/X."
       
   176 
       
   177     "Do not manually edit this!! If it is corrupted,
       
   178      the UIPainter may not be able to read the specification."
       
   179 
       
   180     "
       
   181      UIPainter new openOnClass:Tools::TextDiffTool andSelector:#versionAOnlySpec
       
   182      Tools::TextDiffTool new openInterface:#versionAOnlySpec
       
   183     "
       
   184 
       
   185     <resource: #canvas>
       
   186 
       
   187     ^ 
       
   188      #(FullSpec
       
   189         name: versionAOnlySpec
       
   190         window: 
       
   191        (WindowSpec
       
   192           label: 'Version A Only'
       
   193           name: 'Version A Only'
       
   194           min: (Point 10 10)
       
   195           bounds: (Rectangle 0 0 782 506)
       
   196         )
       
   197         component: 
       
   198        (SpecCollection
       
   199           collection: (
       
   200            (UISubSpecification
       
   201               name: 'VersionA'
       
   202               layout: (LayoutFrame 0 0 0 0 0 1 30 0)
       
   203               minorKey: versionALabelSpec
       
   204             )
       
   205            (UISubSpecification
       
   206               name: 'Text'
       
   207               layout: (LayoutFrame 0 0 30 0 0 1 0 1)
       
   208               minorKey: textViewSpec
       
   209             )
       
   210            )
       
   211          
       
   212         )
       
   213       )
       
   214 !
       
   215 
       
   216 versionBOnlySpec
       
   217     "This resource specification was automatically generated
       
   218      by the UIPainter of ST/X."
       
   219 
       
   220     "Do not manually edit this!! If it is corrupted,
       
   221      the UIPainter may not be able to read the specification."
       
   222 
       
   223     "
       
   224      UIPainter new openOnClass:Tools::TextDiffTool andSelector:#versionBOnlySpec
       
   225      Tools::TextDiffTool new openInterface:#versionBOnlySpec
       
   226     "
       
   227 
       
   228     <resource: #canvas>
       
   229 
       
   230     ^ 
       
   231      #(FullSpec
       
   232         name: 'versionBOnlySpec'
       
   233         window: 
       
   234        (WindowSpec
       
   235           label: 'Version B Only'
       
   236           name: 'Version B Only'
       
   237           min: (Point 10 10)
       
   238           bounds: (Rectangle 0 0 782 506)
       
   239         )
       
   240         component: 
       
   241        (SpecCollection
       
   242           collection: (
       
   243            (UISubSpecification
       
   244               name: 'VersionB'
       
   245               layout: (LayoutFrame 0 0 0 0 0 1 30 0)
       
   246               minorKey: versionBLabelSpec
       
   247             )
       
   248           (UISubSpecification
       
   249               name: 'Text'
       
   250               layout: (LayoutFrame 0 0 30 0 0 1 0 1)
       
   251               minorKey: textViewSpec
       
   252             )
       
   253            )
       
   254          
       
   255         )
       
   256       )
       
   257 
       
   258     "Created: / 19-07-2011 / 10:06:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   259 !
       
   260 
   128 windowSpec
   261 windowSpec
   129     "This resource specification was automatically generated
   262     "This resource specification was automatically generated
   130      by the UIPainter of ST/X."
   263      by the UIPainter of ST/X."
   131 
   264 
   132     "Do not manually edit this!! If it is corrupted,
   265     "Do not manually edit this!! If it is corrupted,
   380      (if this app is embedded in a subCanvas)."
   513      (if this app is embedded in a subCanvas)."
   381 
   514 
   382     ^ #(
   515     ^ #(
   383         #labelAHolder
   516         #labelAHolder
   384         #labelBHolder
   517         #labelBHolder
       
   518 
   385         #textAHolder
   519         #textAHolder
   386         #textBHolder
   520         #textBHolder
       
   521 
       
   522         #showDiffHolder
       
   523 
       
   524         #classHolder
       
   525         #languageHolder
   387       ).
   526       ).
   388 
   527 
       
   528     "Modified: / 19-07-2011 / 13:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   389 ! !
   529 ! !
   390 
   530 
   391 !TextDiffTool methodsFor:'aspects'!
   531 !TextDiffTool methodsFor:'aspects'!
       
   532 
       
   533 classHolder
       
   534     "return/create the 'classHolder' value holder (automatically generated)"
       
   535 
       
   536     classHolder isNil ifTrue:[
       
   537         classHolder := ValueHolder new.
       
   538     ].
       
   539     ^ classHolder
       
   540 !
       
   541 
       
   542 classHolder: aValueHolder
       
   543 
       
   544     classHolder := aValueHolder.
       
   545     codeView notNil ifTrue:[codeView classHolder: aValueHolder].
       
   546     diffView notNil ifTrue:[diffView classHolder: aValueHolder].
       
   547 
       
   548     "Modified: / 19-07-2011 / 12:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   549 !
   392 
   550 
   393 diffSpecHolder
   551 diffSpecHolder
   394     "return/create the 'diffSpecHolder' value holder (automatically generated)"
   552     "return/create the 'diffSpecHolder' value holder (automatically generated)"
   395 
   553 
   396     diffSpecHolder isNil ifTrue:[
   554     diffSpecHolder isNil ifTrue:[
   423 
   581 
   424 labelAHolder
   582 labelAHolder
   425     "return/create the 'labelAHolder' value holder (automatically generated)"
   583     "return/create the 'labelAHolder' value holder (automatically generated)"
   426 
   584 
   427     labelAHolder isNil ifTrue:[
   585     labelAHolder isNil ifTrue:[
   428         labelAHolder := ValueHolder new.
   586         labelAHolder := ValueHolder with:'Version A'.
   429         labelAHolder addDependent:self.
   587         labelAHolder addDependent:self.
   430     ].
   588     ].
   431     ^ labelAHolder
   589     ^ labelAHolder
       
   590 
       
   591     "Modified: / 19-07-2011 / 11:41:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   432 !
   592 !
   433 
   593 
   434 labelAHolder:something
   594 labelAHolder:something
   435     "set the 'labelAHolder' value holder (automatically generated)"
   595     "set the 'labelAHolder' value holder (automatically generated)"
   436 
   596 
   452 
   612 
   453 labelBHolder
   613 labelBHolder
   454     "return/create the 'labelBHolder' value holder (automatically generated)"
   614     "return/create the 'labelBHolder' value holder (automatically generated)"
   455 
   615 
   456     labelBHolder isNil ifTrue:[
   616     labelBHolder isNil ifTrue:[
   457         labelBHolder := ValueHolder new.
   617         labelBHolder := ValueHolder with:'Version B'.
   458         labelBHolder addDependent:self.
   618         labelBHolder addDependent:self.
   459     ].
   619     ].
   460     ^ labelBHolder
   620     ^ labelBHolder
       
   621 
       
   622     "Modified: / 19-07-2011 / 11:42:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   461 !
   623 !
   462 
   624 
   463 labelBHolder:something
   625 labelBHolder:something
   464     "set the 'labelBHolder' value holder (automatically generated)"
   626     "set the 'labelBHolder' value holder (automatically generated)"
   465 
   627 
   477     oldValue ~~ newValue ifTrue:[
   639     oldValue ~~ newValue ifTrue:[
   478         self update:#value with:newValue from:labelBHolder.
   640         self update:#value with:newValue from:labelBHolder.
   479     ].
   641     ].
   480 !
   642 !
   481 
   643 
       
   644 languageHolder
       
   645     "return/create the 'languageHolder' value holder (automatically generated)"
       
   646 
       
   647     languageHolder isNil ifTrue:[
       
   648         languageHolder := ValueHolder new.
       
   649     ].
       
   650     ^ languageHolder
       
   651 !
       
   652 
       
   653 languageHolder:aValueHolder
       
   654 
       
   655     languageHolder := aValueHolder.
       
   656     codeView notNil ifTrue:[codeView languageHolder: aValueHolder].
       
   657     diffView notNil ifTrue:[diffView languageHolder: aValueHolder].
       
   658 
       
   659     "Modified: / 19-07-2011 / 12:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   660 !
       
   661 
   482 showDiffHolder
   662 showDiffHolder
   483     "return/create the 'showDiffHolder' value holder (automatically generated)"
   663     "return/create the 'showDiffHolder' value holder (automatically generated)"
   484 
   664 
   485     showDiffHolder isNil ifTrue:[
   665     showDiffHolder isNil ifTrue:[
   486         showDiffHolder := ValueHolder with: true.
   666         showDiffHolder := ValueHolder with: true.
   573 update:something with:aParameter from:changedObject
   753 update:something with:aParameter from:changedObject
   574     "Invoked when an object that I depend upon sends a change notification."
   754     "Invoked when an object that I depend upon sends a change notification."
   575 
   755 
   576 
   756 
   577     (changedObject == textAHolder or:[changedObject == textBHolder]) ifTrue:[
   757     (changedObject == textAHolder or:[changedObject == textBHolder]) ifTrue:[
   578          self updateAfterAorBChanged.
   758         self updateAfterAorBChanged.
   579          ^ self.
   759         ^ self.
   580      ].
   760     ].
       
   761     (changedObject == showDiffHolder) ifTrue:[
       
   762         self updateViews.            
       
   763         ^self.
       
   764     ].
   581     super update:something with:aParameter from:changedObject
   765     super update:something with:aParameter from:changedObject
   582 
   766 
   583     "Modified: / 06-07-2011 / 12:46:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   767     "Modified: / 19-07-2011 / 11:30:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   584 !
   768 !
   585 
   769 
   586 updateAfterAorBChanged
   770 updateAfterAorBChanged
   587 
   771 
   588     numChangedTexts := numChangedTexts + 1.
   772     numChangedTexts := numChangedTexts + 1.
   589     numChangedTexts >= 2 ifFalse:[^self].
   773     numChangedTexts >= 2 ifFalse:[^self].
   590     numChangedTexts := 0.
   774     numChangedTexts := 0.
   591 
   775 
       
   776     self updateViews
       
   777 
       
   778     "Created: / 06-07-2011 / 12:12:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   779 !
       
   780 
       
   781 updateViews
       
   782 
       
   783     | a b |
       
   784     a := self textAHolder value.
       
   785     b := self textBHolder value.
       
   786 
       
   787     self showDiffHolder value ifFalse:[
       
   788         self showTextOnly.
       
   789         ^ self
       
   790     ].
       
   791 
       
   792     (a notNil and:[b notNil]) ifTrue:[
       
   793         self showDiff.
       
   794         ^self
       
   795     ].
       
   796     a notNil ifTrue:[
       
   797         self showVersionA.
       
   798         ^self
       
   799     ].
       
   800     b notNil ifTrue:[
       
   801         self showVersionB.
       
   802         ^self
       
   803     ].
       
   804 
       
   805     self breakPoint: #jv.
       
   806 
       
   807     "Created: / 19-07-2011 / 11:29:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   808 ! !
       
   809 
       
   810 !TextDiffTool methodsFor:'hooks'!
       
   811 
       
   812 postBuildCodeView:aScrollableView
       
   813 
       
   814     codeView := aScrollableView
       
   815 
       
   816     "Created: / 19-07-2011 / 10:17:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   817 !
       
   818 
       
   819 postBuildDiffView:aScrollableView
       
   820 
       
   821     diffView := aScrollableView
       
   822 
       
   823     "Created: / 30-06-2011 / 20:55:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   824 ! !
       
   825 
       
   826 !TextDiffTool methodsFor:'initialization'!
       
   827 
       
   828 initialize
       
   829 
       
   830     super initialize.
       
   831     numChangedTexts := 0.
       
   832 
       
   833     "Modified: / 06-07-2011 / 12:15:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   834 ! !
       
   835 
       
   836 !TextDiffTool methodsFor:'private'!
       
   837 
       
   838 showDiff
       
   839 
       
   840     self diffSpecHolder value: #diffSpec.
       
   841     
   592     diffView ifNil:[^self].
   842     diffView ifNil:[^self].
   593     diffView scrolledView ifNil:[^self].
   843     diffView scrolledView ifNil:[^self].
   594     diffView scrolledView
   844     diffView scrolledView
   595         text1: self textAHolder value
   845         text1: self textAHolder value
   596         text2: self textBHolder value
   846         text2: self textBHolder value
   597 
   847 
   598     "Created: / 06-07-2011 / 12:12:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   848     "Created: / 19-07-2011 / 10:22:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   599 ! !
   849 !
   600 
   850 
   601 !TextDiffTool methodsFor:'hooks'!
   851 showTextOnly
   602 
   852 
   603 postBuildDiffView:aScrollableView
   853     self diffSpecHolder value: #textViewSpec
   604 
   854 
   605     diffView := aScrollableView
   855     "Created: / 19-07-2011 / 11:39:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   606 
   856 !
   607     "Created: / 30-06-2011 / 20:55:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   857 
   608 ! !
   858 showVersionA
   609 
   859 
   610 !TextDiffTool methodsFor:'initialization'!
   860     self diffSpecHolder value: #versionAOnlySpec
   611 
   861 
   612 initialize
   862     "Created: / 19-07-2011 / 10:22:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   613 
   863 !
   614     super initialize.
   864 
   615     numChangedTexts := 0.
   865 showVersionB
   616 
   866 
   617     "Modified: / 06-07-2011 / 12:15:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   867     self diffSpecHolder value: #versionBOnlySpec
       
   868 
       
   869     "Created: / 19-07-2011 / 10:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   618 ! !
   870 ! !
   619 
   871 
   620 !TextDiffTool class methodsFor:'documentation'!
   872 !TextDiffTool class methodsFor:'documentation'!
   621 
   873 
   622 version_CVS
   874 version_CVS
   623     ^ '$Header: /cvs/stx/stx/libtool/Tools__TextDiffTool.st,v 1.1 2011-07-06 12:03:36 vrany Exp $'
   875     ^ '$Header: /cvs/stx/stx/libtool/Tools__TextDiffTool.st,v 1.2 2011-07-19 12:32:56 vrany Exp $'
   624 !
   876 !
   625 
   877 
   626 version_SVN
   878 version_SVN
   627     ^ '§Id§'
   879     ^ '§Id§'
   628 ! !
   880 ! !