MCCommitDialog.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 23 Aug 2011 15:46:54 +0200
changeset 440 da9c1bbb1a61
parent 360 49f34323f6c6
child 529 d0d668b95c4c
permissions -rw-r--r--
Fixes

"{ Package: 'stx:goodies/monticello' }"

MCDialog subclass:#MCCommitDialog
	instanceVariableNames:'workingCopyHolder repositoryHolder versionNameHolder
		messageHolder messageView'
	classVariableNames:''
	poolDictionaries:''
	category:'Monticello-St/X UI'
!


!MCCommitDialog class methodsFor:'interface specs'!

contentSpec
    "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:MCCommitDialog andSelector:#contentSpec
     MCCommitDialog new openInterface:#contentSpec
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: contentSpec
        window: 
       (WindowSpec
          label: 'Commit Dialog'
          name: 'Commit Dialog'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 300 300)
        )
        component: 
       (SpecCollection
          collection: (
           (ComboListSpec
              name: 'RepositoryList'
              layout: (LayoutFrame 0 0 0 0 0 1 25 0)
              model: repositoryHolder
              comboList: repositoryList
              useIndex: false
            )
           (InputFieldSpec
              name: 'VersionName'
              layout: (LayoutFrame 0 0 30 0 0 1 55 0)
              model: versionNameHolder
              immediateAccept: true
              acceptOnReturn: true
              acceptOnTab: true
              acceptOnPointerLeave: true
            )
           (TextEditorSpec
              name: 'CommitMessage'
              layout: (LayoutFrame 0 0 60 0 0 1 0 1)
              model: messageHolder
              hasHorizontalScrollBar: true
              hasVerticalScrollBar: true
              hasKeyboardFocusInitially: false
              postBuildCallback: postBuildMessageView:
            )
           )
         
        )
      )
! !

!MCCommitDialog methodsFor:'accessing'!

workingCopy: aMCWorkingCopy

    ^self workingCopyHolder value: aMCWorkingCopy

    "Created: / 14-09-2010 / 23:43:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCCommitDialog methodsFor:'accessing - defaults'!

defaultTitle
    "superclass MCDialog says that I am responsible to implement this method"

    ^ 'Commit'

    "Modified: / 14-09-2010 / 23:00:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCCommitDialog methodsFor:'actions'!

doAccept

    | workingCopy version repository |

    self acceptEnabled ifFalse:[^self].
    workingCopy := self workingCopyHolder value.
    [version := workingCopy newVersion]
                on: MCVersionNameAndMessageRequest
                do: [:n | 
                    n resume: 
                        (Array  with: self versionNameHolder value 
                                with: messageView contents asText string)].
    repository := self repositoryHolder value.
    repository storeVersion: version.
    super doAccept.

    "Created: / 15-09-2010 / 14:07:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCCommitDialog methodsFor:'aspects'!

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

    messageHolder isNil ifTrue:[
        messageHolder := ValueHolder with: ('Commit message' asText colorizeAllWith: Color gray).
        messageHolder addDependent:self.
    ].
    ^ messageHolder

    "Modified: / 15-09-2010 / 13:58:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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

    |oldValue newValue|

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

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

    repositoryHolder isNil ifTrue:[
        repositoryHolder := ValueHolder new.
        repositoryHolder addDependent:self.
    ].
    ^ repositoryHolder
!

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

    |oldValue newValue|

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

repositoryList

    ^[MCRepositoryGroup default repositories]

    "Created: / 14-09-2010 / 23:16:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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

    versionNameHolder isNil ifTrue:[
        versionNameHolder := ValueHolder new.
        versionNameHolder addDependent:self.
    ].
    ^ versionNameHolder
!

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

    |oldValue newValue|

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

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

    workingCopyHolder isNil ifTrue:[
        workingCopyHolder := ValueHolder new.
        workingCopyHolder addDependent:self.
    ].
    ^ workingCopyHolder
!

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

    |oldValue newValue|

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

!MCCommitDialog methodsFor:'change & update'!

messageChanged

    self halt

    "Created: / 15-09-2010 / 10:04:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

repositoryChanged

    self updateAcceptEnabled

    "Created: / 15-09-2010 / 14:02:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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 == workingCopyHolder ifTrue:[
         self workingCopyChanged.
         ^ self.
    ].

    changedObject == messageHolder ifTrue:[
         self messageChanged.
         ^ self.
    ].
    changedObject == repositoryHolder ifTrue:[
         self repositoryChanged.
         ^ self.
    ].

    super update:something with:aParameter from:changedObject

    "Modified: / 15-09-2010 / 14:02:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateAcceptEnabled

    | enabled |
    enabled := true.
    enabled := enabled and:[self workingCopyHolder value notNil].
    enabled := enabled and:[self repositoryHolder value notNil].
    self acceptEnabledHolder value: enabled.

    "Created: / 15-09-2010 / 14:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

workingCopyChanged

    | wc |
    wc := self workingCopyHolder value.
    wc ifNil:[^self].
    self subtitle: wc package name.
    self versionNameHolder value: wc uniqueVersionName.
    self updateAcceptEnabled

    "Created: / 15-09-2010 / 09:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 15-09-2010 / 14:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCCommitDialog methodsFor:'hooks'!

postBuildMessageView: aView

    messageView := aView scrolledView

    "Created: / 15-09-2010 / 13:56:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCCommitDialog class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCCommitDialog.st,v 1.2 2011-08-23 13:46:54 vrany Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCCommitDialog.st,v 1.2 2011-08-23 13:46:54 vrany Exp $'
!

version_SVN
    ^ '§Id: MCCommitDialog.st 12 2010-09-15 13:13:22Z vranyj1 §'
! !