SVN__Wizard.st
author fm
Wed, 23 Sep 2009 18:46:07 +0200
changeset 35 3d1baf19d9b9
child 208 2e3839dd856e
permissions -rw-r--r--
initial checkin

"{ Package: 'cvut:stx/goodies/libsvn' }"

"{ NameSpace: SVN }"

Dialog subclass:#Wizard
	instanceVariableNames:'paneHolder goNextEnabledHolder goPrevEnabledHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'SVN-UI-Dialogs'
!

ApplicationModel subclass:#Pane
	instanceVariableNames:'prev next'
	classVariableNames:''
	poolDictionaries:''
	privateIn:Wizard
!

!Wizard class methodsFor:'documentation'!

version_SVN
    ^'$Id$'
! !

!Wizard class methodsFor:'interface specs'!

buttonsSpec
    "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:SVN::Wizard andSelector:#buttonsSpec
     SVN::Wizard new openInterface:#buttonsSpec
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: buttonsSpec
        window: 
       (WindowSpec
          label: 'Buttons'
          name: 'Buttons'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 400 30)
        )
        component: 
       (SpecCollection
          collection: (
           (HorizontalPanelViewSpec
              name: 'ButtonPanel'
              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
              horizontalLayout: rightSpace
              verticalLayout: center
              horizontalSpace: 3
              verticalSpace: 3
              component: 
             (SpecCollection
                collection: (
                 (ActionButtonSpec
                    label: 'Prev'
                    name: 'PrevButton'
                    translateLabel: true
                    model: goPrev
                    enableChannel: goPrevEnabledHolder
                    extent: (Point 125 22)
                  )
                 (ActionButtonSpec
                    label: 'Next'
                    name: 'NextButton'
                    translateLabel: true
                    model: goNext
                    enableChannel: goNextEnabledHolder
                    extent: (Point 125 22)
                  )
                 (ActionButtonSpec
                    label: 'OK'
                    name: 'AcceptButton'
                    translateLabel: true
                    labelChannel: acceptButtonTitleAspect
                    model: doAccept
                    enableChannel: canDoAcceptAspect
                    extent: (Point 125 22)
                  )
                 (ActionButtonSpec
                    label: 'Cancel'
                    name: 'CancelButton'
                    translateLabel: true
                    model: doCancel
                    extent: (Point 125 22)
                  )
                 )
               
              )
            )
           )
         
        )
      )

    "Modified: / 24-03-2009 / 19:52:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

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

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: contentSpec
        window: 
       (WindowSpec
          label: 'Content'
          name: 'Content'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 300 300)
        )
        component: 
       (SpecCollection
          collection: (
           (SubCanvasSpec
              name: 'WizardPane'
              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
              hasHorizontalScrollBar: false
              hasVerticalScrollBar: false
              miniScrollerHorizontal: false
              clientHolder: paneHolder
              createNewBuilder: false
            )
           )
         
        )
      )
! !

!Wizard methodsFor:'accessing'!

answerValueSelector
    "Superclass SVN::Dialog says that I am responsible to implement this method"

    ^#yourself

    "Created: / 20-04-2008 / 20:39:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

defaultSubtitle
    ^ 'Package: ' , self model package asText allItalic

    "Created: / 28-10-2008 / 09:14:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

firstPane
    "
        Answers the very first pane to show
    "

    ^self subclassResponsibility

    "Created: / 20-03-2009 / 13:46:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

pane

    ^self paneHolder value

    "Created: / 08-04-2009 / 20:17:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

pane:aWizardPane 
    self pane leave.
    self paneHolder subjectChannel:aWizardPane.
    self paneHolder changed.
    aWizardPane masterApplication: self.
    self updateButtons.
    self pane enter.

    "Created: / 21-03-2009 / 10:55:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 09-04-2009 / 08:53:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

task

    ^self model

    "Created: / 23-03-2009 / 11:49:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

task: aTask

    ^self model: aTask

    "Created: / 23-03-2009 / 11:49:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard methodsFor:'accessing - buttons'!

doAcceptEnabled: aBoolean

    self canDoAcceptAspect value: aBoolean

    "Created: / 24-03-2009 / 19:56:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goNextEnabled: aBoolean

    self goNextEnabledHolder value: aBoolean

    "Created: / 24-03-2009 / 19:56:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goPrevEnabled: aBoolean

    self goPrevEnabledHolder value: aBoolean

    "Created: / 24-03-2009 / 19:56:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard methodsFor:'actions'!

goNext

    self showContent.
    ^self pane value goNext

    "Created: / 24-03-2009 / 14:38:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 09-04-2009 / 08:30:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goPrev

    self showContent.
    ^self pane value goPrev

    "Created: / 24-03-2009 / 14:38:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 09-04-2009 / 08:31:03 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard methodsFor:'aspects'!

goNextEnabledHolder

    goNextEnabledHolder ifNil:
        [goNextEnabledHolder := false asValue].
    ^goNextEnabledHolder

    "Created: / 24-03-2009 / 19:51:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goPrevEnabledHolder

    goPrevEnabledHolder ifNil:
        [goPrevEnabledHolder := false asValue].
    ^goPrevEnabledHolder

    "Created: / 24-03-2009 / 19:51:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

paneHolder
    paneHolder 
        ifNil:[
            paneHolder := (AspectAdaptor subjectChannel:self firstPane
                        sendsUpdates:true) forAspect:#value.
        ].
    ^ paneHolder

    "Created: / 20-03-2009 / 13:45:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 24-03-2009 / 20:09:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard methodsFor:'change & update'!

contentSpecChanged: specSymbol

    self updateButtons

    "Created: / 24-03-2009 / 20:15:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

updateButtons

    self pane value updateButtons

    "Created: / 24-03-2009 / 19:54:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard methodsFor:'hooks'!

postOpenWith: anUIBuilder

    ^self pane value enter

    "Created: / 02-04-2009 / 17:10:14 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."

    "/ please change as required (and remove this comment)
    "/ pane := nil.

    super initialize.
! !

!Wizard::Pane methodsFor:'accessing'!

doAcceptEnabled: aBoolean

    ^self wizard doAcceptEnabled: aBoolean

    "Created: / 24-03-2009 / 19:55:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goNextEnabled: aBoolean

    ^self wizard goNextEnabled: aBoolean

    "Created: / 24-03-2009 / 19:55:19 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goPrevEnabled: aBoolean

    ^self wizard goPrevEnabled: aBoolean

    "Created: / 24-03-2009 / 19:55:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

next
    next ifNil:[ next := self createNext. next prev: self.].
    ^ next

    "Modified: / 02-04-2009 / 17:13:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

next:aWizardPane
    next := aWizardPane.
!

prev
    ^ prev
!

prev:aWizardPane
    prev := aWizardPane.
!

task

    ^self wizard task

    "Created: / 24-03-2009 / 19:29:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

wizard

    ^self masterApplication

    "Created: / 24-03-2009 / 14:37:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard::Pane methodsFor:'actions'!

enter

    "This method is called whenever a a pane is shown"

    "Created: / 02-04-2009 / 17:07:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goNext

    self wizard pane: self next

    "Created: / 20-03-2009 / 14:12:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 24-03-2009 / 14:38:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

goPrev

    self wizard pane: self prev

    "Created: / 20-03-2009 / 14:12:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 24-03-2009 / 14:38:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

leave

    "This method is called whenever a a pane is left (via pressing next/prev/accept)"

    "Created: / 02-04-2009 / 17:08:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard::Pane methodsFor:'change & update'!

updateButtons

    self 
        goPrevEnabled: self canGoPrev;
        goNextEnabled: self canGoNext;
        doAcceptEnabled: self canDoAccept.

    "Created: / 24-03-2009 / 19:54:49 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 02-04-2009 / 16:27:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard::Pane methodsFor:'private'!

createNext
    ^ self subclassResponsibility

    "Created: / 21-03-2009 / 10:56:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

showMessage: aString

    ^self wizard showMessage: aString

    "Created: / 09-04-2009 / 08:19:03 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

showProgressWhile: aBlock

    ^self wizard showProgressWhile: aBlock

    "Created: / 24-03-2009 / 14:58:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard::Pane methodsFor:'queries'!

canDoAccept

    ^false

    "Created: / 21-03-2009 / 12:22:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 02-04-2009 / 16:29:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

canGoNext

    ^true

    "Created: / 20-03-2009 / 12:41:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 02-04-2009 / 16:44:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

canGoPrev

    ^prev notNil

    "Created: / 20-03-2009 / 12:42:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Wizard class methodsFor:'documentation'!

version
    ^ '$Header$'
! !