Tools__TextDiff3Tool.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 16 Mar 2012 22:44:50 +0000
branchjv
changeset 12190 2a77dea2eceb
parent 12179 47f98e7d6de1
child 12193 c0bdf75cfde5
permissions -rw-r--r--
Improvements in Diff3CodeiView2 - now it highlights differences

"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libtool' }"

"{ NameSpace: Tools }"

TextDiffTool subclass:#TextDiff3Tool
	instanceVariableNames:'mergeHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Diff'
!

!TextDiff3Tool class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    documentation to be added.

    [author:]
        Jan Vrany <jan.vrany@fit.cvut.cz>

    [instance variables:]

    [class variables:]

    [see also:]

"
!

examples
"
  Starting the application:
                                                                [exBegin]
    Tools::TextDiff3Tool open

                                                                [exEnd]

  more examples to be added:
                                                                [exBegin]
    ... add code fragment for 
    ... executable example here ...
                                                                [exEnd]
"
! !

!TextDiff3Tool class methodsFor:'interface specs'!

diff3Spec
    "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:Tools::TextDiff3Tool andSelector:#diff3Spec
     Tools::TextDiff3Tool new openInterface:#diff3Spec
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: diff3Spec
        window: 
       (WindowSpec
          label: 'Text Diff Tool (for embedding)'
          name: 'Text Diff Tool (for embedding)'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 782 506)
        )
        component: 
       (SpecCollection
          collection: (
           (ViewSpec
              name: '3Labels'
              layout: (LayoutFrame 0 0 0 0 -16 1 30 0)
              component: 
             (SpecCollection
                collection: (
                 (UISubSpecification
                    name: 'VersionC'
                    layout: (LayoutFrame 0 0 0 0 0 0.33333 30 0)
                    minorKey: versionCLabelSpec
                  )
                 (UISubSpecification
                    name: 'VersionA'
                    layout: (LayoutFrame 5 0.3333 0 0 0 0.67 30 0)
                    minorKey: versionALabelSpec
                  )
                 (UISubSpecification
                    name: 'VersionB'
                    layout: (LayoutFrame 5 0.67 0 0 0 1 30 0)
                    minorKey: versionBLabelSpec
                  )
                 )
               
              )
            )
           (ArbitraryComponentSpec
              name: 'Diff3TextView'
              layout: (LayoutFrame 0 0 30 0 0 1 0 1)
              hasHorizontalScrollBar: false
              hasVerticalScrollBar: false
              autoHideScrollBars: false
              hasBorder: false
              component: #'Tools::Diff3CodeView2'
              postBuildCallback: postBuildDiffView:
            )
           )
         
        )
      )
! !

!TextDiff3Tool 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)."

    ^ #(
        #codeAspectHolder
        #labelAHolder
        #labelBHolde
        #labelCHolder
        #labelHolder
        #languageHolder
        #textAHolder
        #textBHolder
        #textCHolder
      ).

! !

!TextDiff3Tool methodsFor:'aspects'!

mergeHolder
    "return/create the 'mergeHolder' value holder (automatically generated)"

    mergeHolder isNil ifTrue:[
        mergeHolder := ValueHolder with: false.
        mergeHolder addDependent:self.
    ].
    ^ mergeHolder

    "Modified: / 16-03-2012 / 13:24:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

mergeHolder:something
    "set the 'mergeHolder' value holder (automatically generated)"

    |oldValue newValue|

    mergeHolder notNil ifTrue:[
        oldValue := mergeHolder value.
        mergeHolder removeDependent:self.
    ].
    mergeHolder := something.
    mergeHolder notNil ifTrue:[
        mergeHolder addDependent:self.
    ].
    newValue := mergeHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:mergeHolder.
    ].
! !

!TextDiff3Tool methodsFor:'change & update'!

update:something with:aParameter from:changedObject
    "Invoked when an object that I depend upon sends a change notification."

    "stub code automatically generated - please change as required"

    changedObject == mergeHolder ifTrue:[
        self updateViews.
         ^ self.
    ].
    super update:something with:aParameter from:changedObject

    "Modified (format): / 16-03-2012 / 13:24:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateAfterAorBorCChanged

    (textAChanged & textBChanged & textCChanged) ifTrue:[
        textAChanged := textBChanged := textCChanged := false.
        self updateViews
    ].

    "Created: / 16-03-2012 / 15:26:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateViews

    self mergeHolder value ifTrue:[
        self contentSpecHolder value: #mergeSpec
    ] ifFalse:[
        self contentSpecHolder value: #diff3Spec
    ].

    diffView notNil ifTrue:[
        diffView
            text1: self textCHolder value
            text2: self textAHolder value
            text3: self textBHolder value
    ]

    "Created: / 16-03-2012 / 13:24:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TextDiff3Tool methodsFor:'hooks'!

commonPostBuild
    self updateViews

    "Created: / 16-03-2012 / 13:25:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

postBuildDiffView:aScrollableView

    super postBuildDiffView:aScrollableView.
    diffView notNil ifTrue:[
       (self textAHolder value notNil and:[self textBHolder value notNil and:[self textCHolder value notNil]]) ifTrue:[
            diffView scrolledView
                text1: self textCHolder value
                text2: self textAHolder value
                text3: self textBHolder value

        ]
    ].

    "Created: / 16-03-2012 / 13:31:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TextDiff3Tool methodsFor:'testing'!

isDiff3
    ^true

    "Created: / 16-03-2012 / 15:21:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TextDiff3Tool class methodsFor:'documentation'!

version_SVN
    ^ '$Id: Tools__TextDiff3Tool.st 7936 2012-03-16 22:44:50Z vranyj1 $'
! !