MCSettingsApp.st
author Claus Gittinger <cg@exept.de>
Tue, 27 Sep 2011 12:05:41 +0200
changeset 504 9cd65fe6164f
parent 461 1d0c79f1ca04
child 517 6201502d98fb
permissions -rw-r--r--
added: #selectedRepositoryHolder changed:5 methods

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

AbstractSettingsApplication subclass:#MCSettingsApp
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Monticello-St/X UI'
!


!MCSettingsApp class methodsFor:'* As yet uncategorized *'!

managerTypeName

    ^ 'Monticello'

    "Created: / 21-07-2011 / 11:47:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSettingsApp class methodsFor:'help specs'!

flyByHelpSpec

    <resource: #help>
    
    ^self helpSpec

    "Created: / 26-05-2008 / 14:25:31 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

helpSpec
    "This resource specification was automatically generated
     by the UIHelpTool of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIHelpTool may not be able to read the specification."

    "
     UIHelpTool openOnClass:SVN::SettingsApp    
    "

    <resource: #help>

    ^ super helpSpec addPairsFrom:#(

#Package
''

)

    "Modified: / 26-05-2008 / 14:24:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!MCSettingsApp class methodsFor:'image specs'!

defaultIcon

    "^SVN::IconLibrary svn_wizban2 magnifiedTo: 24@24"
    ^nil

    "Created: / 26-05-2008 / 14:55:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 16-09-2010 / 14:02:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

svnIcon
    "^ IconLibrary svn_wizban"
    ^nil

    "Created: / 24-05-2008 / 01:44:19 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 16-09-2010 / 14:02:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSettingsApp class methodsFor:'interface opening'!

open    

    | settingsApp |

    settingsApp := SettingsDialog new.
    settingsApp addApplClass:self fullName
                withName:'Subversion'.
    settingsApp showRoot: false.
    settingsApp selectedItem value:
        (settingsApp applicationList root children anyOne).
    settingsApp open.

    "Created: / 26-05-2008 / 12:17:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 27-02-2010 / 17:07:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSettingsApp class methodsFor:'interface specs'!

windowSpec
    "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:MCSettingsApp andSelector:#windowSpec
     MCSettingsApp new openInterface:#windowSpec
     MCSettingsApp open
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Monticello Settings'
          name: 'Monticello Settings'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 695 627)
        )
        component: 
       (SpecCollection
          collection: (
           (LabelSpec
              label: ' Monticello Settings'
              name: 'Title'
              layout: (LayoutFrame 0 0 0 0 0 1 66 0)
              style: (FontDescription helvetica medium roman 18 #'iso10646-1')
              backgroundColor: (Color 100.0 100.0 100.0)
              translateLabel: true
              adjust: left
            )
           (LabelSpec
              label: 'Icon'
              name: 'Icon'
              layout: (LayoutFrame -75 1 0 0 0 1 66 0)
              initiallyInvisible: true
              hasCharacterOrientedLabel: false
              backgroundColor: (Color 100.0 100.0 100.0)
              translateLabel: true
            )
           (VerticalPanelViewSpec
              name: 'Controls'
              layout: (LayoutFrame 0 0 70 0 0 1 0 1)
              horizontalLayout: fit
              verticalLayout: topFit
              horizontalSpace: 3
              verticalSpace: 3
              component: 
             (SpecCollection
                collection: (
                 (HorizontalPanelViewSpec
                    name: 'EnabledAndResetPanel'
                    horizontalLayout: rightSpaceFit
                    verticalLayout: fit
                    horizontalSpace: 0
                    verticalSpace: 3
                    component: 
                   (SpecCollection
                      collection: (
                       (CheckBoxSpec
                          label: 'Enable Monticello Manager'
                          name: 'Enabled'
                          model: mcEnabled
                          translateLabel: true
                          useDefaultExtent: true
                        )
                       (ActionButtonSpec
                          label: 'Flush caches'
                          name: 'ResetCachedRepositoriesButton'
                          translateLabel: true
                          model: flushCaches
                          enableChannel: mcEnabled
                          useDefaultExtent: true
                        )
                       )
                     
                    )
                    useDefaultExtent: true
                  )
                 (FramedBoxSpec
                    label: 'Repositories'
                    name: 'Repositories'
                    labelPosition: topLeft
                    translateLabel: true
                    component: 
                   (SpecCollection
                      collection: (
                       (VerticalPanelViewSpec
                          name: 'RepositoryConfigurations'
                          layout: (LayoutFrame 0 0 0 0 0 1 0 1)
                          horizontalLayout: fit
                          verticalLayout: bottomFit
                          horizontalSpace: 3
                          verticalSpace: 3
                          component: 
                         (SpecCollection
                            collection: (
                             (ViewSpec
                                name: 'RepositoryConfigurationListBox'
                                model: mcRepositories
                                component: 
                               (SpecCollection
                                  collection: (
                                   (SelectionInListModelViewSpec
                                      name: 'RepositoryList'
                                      layout: (LayoutFrame 0 0 0 0 0 1 0 1)
                                      enableChannel: mcEnabled
                                      model: selectedRepositoryHolder
                                      hasHorizontalScrollBar: true
                                      hasVerticalScrollBar: true
                                      listModel: mcRepositories
                                      useIndex: false
                                      highlightMode: line
                                    )
                                   )
                                 
                                )
                                extent: (Point 661 464)
                              )
                             (HorizontalPanelViewSpec
                                name: 'AddRemovePanel'
                                horizontalLayout: fit
                                verticalLayout: center
                                horizontalSpace: 3
                                verticalSpace: 3
                                component: 
                               (SpecCollection
                                  collection: (
                                   (ActionButtonSpec
                                      label: 'Add Repository...'
                                      name: 'AddConfigurationAction'
                                      translateLabel: true
                                      model: addRepositoryAction
                                      enableChannel: mcEnabled
                                      extent: (Point 329 25)
                                    )
                                   (ActionButtonSpec
                                      label: 'Remove Repository...'
                                      name: 'RemoveConfigurationAction'
                                      translateLabel: true
                                      model: removeRepositoryAction
                                      enableChannel: mcEnabled
                                      extent: (Point 329 25)
                                    )
                                   )
                                 
                                )
                                extent: (Point 661 30)
                              )
                             )
                           
                          )
                        )
                       )
                     
                    )
                    extent: (Point 695 530)
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!MCSettingsApp methodsFor:'accessing'!

repositoryConfiguration

    ^self selectedRepositoryHolder value

    "Created: / 26-05-2008 / 12:04:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 27-09-2011 / 11:55:22 / cg"
!

repositoryConfiguration: anObject

    self selectedRepositoryHolder value: anObject

    "Created: / 26-05-2008 / 12:12:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 27-09-2011 / 11:55:24 / cg"
!

repositoryConfigurationList

    ^self mcRepositories value

    "Created: / 26-05-2008 / 12:05:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 27-09-2011 / 11:50:53 / cg"
!

repositoryManager

    ^RepositoryManager current

    "Created: / 26-05-2008 / 10:46:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

workingCopyBase

    ^self workingCopyBaseAspect value

    "Created: / 26-05-2008 / 13:15:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!MCSettingsApp methodsFor:'actions'!

addRepositoryAction

    | dialog class codeHolder repo |
    class := Dialog 
            choose:'Select repository type' 
            fromList:#('HTTP repository' 'Local repository')
            values:(Array with: MCHttpRepository with: MCDirectoryRepository)
            lines:5 cancel:[^self].

    codeHolder := ValueHolder new.
    dialog := Dialog forRequestText:'Please Fill in Data' lines:10 columns:60 initialAnswer: class creationTemplate  model:codeHolder.
    dialog open.
    dialog accepted ifFalse:[^self].
    repo := Compiler evaluate: codeHolder value.
    self mcRepositories value add: repo.
    self mcRepositories changed.

    "Created: / 26-05-2008 / 12:04:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 16-08-2009 / 17:24:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 16-09-2010 / 14:33:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 27-09-2011 / 11:49:42 / cg"
!

flushCaches
    <resource: #uiCallback>

    "automatically generated by UIPainter..."

    "*** the code below performs no action"
    "*** (except for some feedback on the Transcript)"
    "*** Please change as required and accept in the browser."
    "*** (and replace this comment by something more useful ;-)"

    "action to be defined here..."

    Transcript showCR:self class name, ': action for flushCaches ...'.
!

removeRepositoryAction
    self repositoryConfiguration ifNotNil: 
            [ self repositoryConfigurationList remove: self repositoryConfiguration ].

    "Created: / 26-05-2008 / 12:04:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!MCSettingsApp methodsFor:'aspects'!

mcEnabled

    ^self settingsAspectFor: #mcEnabled

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

mcRepositories

    ^self settingsAspectFor: #mcRepositories

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

selectedRepositoryHolder

    ^self settingsAspectFor: #selectedRepositoryHolder

    "Created: / 16-09-2010 / 14:14:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Created: / 27-09-2011 / 11:55:01 / cg"
! !

!MCSettingsApp methodsFor:'helpers'!

settingsAspectFor: settingName

    |holder|

    self createBuilder.

    (holder := builder bindingAt:settingName) ifNil:
            [holder := (currentUserPrefs perform: settingName asSymbol)
                            asValue.
            holder onChangeSend:#updateModifiedChannel to:self.
            builder aspectAt:settingName put:holder
    ].
    ^ holder.

    "Created: / 25-05-2009 / 18:43:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!MCSettingsApp methodsFor:'protocol'!

basicReadSettings

    self
        readAspects: #(mcEnabled mcRepositories)
        from:currentUserPrefs.

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

basicSaveSettings

    self
        writeAspects: #(mcEnabled mcRepositories)
        to:currentUserPrefs.

    "Created: / 19-04-2008 / 09:42:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 25-05-2009 / 19:06:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 16-09-2010 / 14:35:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

helpFilename
    "subclasses must return the relative name of a helpFile
     in the doc/online/<language>/help directory.
     Or nil, if no help is available."

    ^nil

    "Created: / 19-04-2008 / 09:42:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 26-05-2008 / 13:12:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!MCSettingsApp methodsFor:'queries'!

hasUnsavedChanges

    (self
        hasChangedAspectIn: #(mcEnabled mcRepositories)
        asComparedTo:currentUserPrefs) 
            ifTrue:[^ true].
    ^false

    "Created: / 28-05-2008 / 07:33:26 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 19-08-2009 / 12:07:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 16-09-2010 / 14:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MCSettingsApp class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCSettingsApp.st,v 1.3 2011-09-27 10:05:41 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCSettingsApp.st,v 1.3 2011-09-27 10:05:41 cg Exp $'
!

version_SVN
    ^ '§Id: MCSettingsApp.st 33 2011-07-21 11:26:12Z vranyj1 §'
! !