CVSSourceCodeManagementSettingsAppl.st
author Claus Gittinger <cg@exept.de>
Tue, 19 Apr 2011 12:58:09 +0200
changeset 9858 2376163ad093
parent 9845 bfb845fd9ff2
child 9872 22f0e9324999
permissions -rw-r--r--
added: #managerClass

"
 COPYRIGHT (c) 2002 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' }"

AbstractSourceCodeManagementSettingsAppl subclass:#CVSSourceCodeManagementSettingsAppl
	instanceVariableNames:'sourceCacheDir useManager availableManagers condenseSourceCache
		setupSourceCodeManager checkClassesWhenCheckingIn
		formattingConfiguration flushSourceCache localSourceFirst
		repositoryHolder manager repository listOfModules
		cvsRootPrototypeList addPerModuleRoot removeEnabled
		perModuleRootModule acceptChannel removePerModuleRoot
		perModuleRoot cvsRootHolder selectedPerModuleRoot
		cvsBinDirectoryHolder cvsExecutableHolder rootsPerModule
		cvsLoginInModuleEnabled cvsLoginEnabled
		selectedManagerTypeIndexHolder managerIsCVSSourceCodeManager
		managerIsStoreSourceCodeManager storeLoginEnabled
		storeHostPrototypeList storeHostnameHolder storeUsernameHolder
		storePasswordHolder perStoreModuleHostnameHolder
		perStoreModuleUsernameHolder perStoreModulePasswordHolder
		perStoreModuleRoot perStoreModuleRootModule
		selectedPerStoreModuleRoot storeConnectEnabled
		storeConnectInModuleEnabled perModuleFieldsEnableHolder
		managerIsSmallTeamSourceCodeManager
		selectedPerSmallTeamModuleRoot
		perSmallTeamModuleFieldsEnableHolder perSmallTeamModuleRoot
		perSmallTeamModuleRootModule perSmallTeamModuleHostnameHolder
		smallTeamHostnameHolder verboseSourceCodeAccess keepMethodSource'
	classVariableNames:'RecentlyUsedCVSRoots RecentlyUsedStoreHosts
		RecentlyUsedSmallTeamHosts LastStoreHost LastStoreUser
		LastStorePassword'
	poolDictionaries:''
	category:'System-SourceCodeManagement'
!

!CVSSourceCodeManagementSettingsAppl class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2002 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
"
    CVS part of the source code settings;   
    extrated for pluggability from SourceCodeManagerSettings in the AbstractSettingsApplication.
"
! !

!CVSSourceCodeManagementSettingsAppl class methodsFor:'defaults'!

defaultRepositoryName

    ^ '/cvs/stx'

    "Created: / 19-04-2011 / 11:00:11 / cg"
! !

!CVSSourceCodeManagementSettingsAppl class methodsFor:'image specs'!

defaultIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self defaultIcon inspect
     ImageEditor openOnClass:self andSelector:#defaultIcon
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:#'AbstractSettingsApplication::SourceCodeManagementSettingsAppl class defaultIcon'
        ifAbsentPut:[(Depth8Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(8 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@A@PHB@0P@@@@@@@@@@@@@@@@@@@HEA \HA $JB0HD@@@@@@@@@@@@@@HLA04NC0HD@@L@@ P@@@@@@@@@@@@ED@ NDP@@@@@@@@@D@@@@@@@@
@@@BA \FAPP@@@@@@@@@@@P@@@@@@@@@AQ@RC0@@@@@@@@@@@@@@@@@@@@@@@@TGA!!DD@@@@@@@@@@@@@@@@@@@D@PDIA08OA@@@@@@@@@@@@@@@@@@@AP S
A0XIBPXGC0P@@@@@@@@@@@@@@@@ECAPLBPXOAP@@@@@@EQX@@@@@@@@@@@TIE@XOAP@@@@@@EQ\XE @@@@@@@@@@AP$OAP@@@@@@FQ\ZE!! V@@@@@@@@@@@E
F0@@@@@@EQ\ZF!!(VFAX@@@@@@@@@@@@@@@@ZEQ\VE!!(ZF!!XWF @@@@@@@@@@@@@@@@@@@A\ZE!!(@@@@@@@@@@@@@@@@@@@@@@@@XE!!XZ@@@@@@@@@@@@@@@@
@@@@@@@@EQ(V@@@@@@@@@@@@@@@@@@@@@@@@EQ\VE @@@@@@@@@@@@@@@@@@@@@@EQ VE @@@@@@@@@@@@@@F @@@@@WEQ VE!!(@@@@@@@@@@@@@@@@@E!!\W
EQXVE @@@@@@@@@@@@@@@@@@@@@@@A(Z@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 32 64 0 0 64 0 32 32 0 0 32 0 32 96 32 96 192 128 192 224 192 160 224 160 32 128 64 64 96 64 64 96 32 32 160 64 160 224 192 64 160 96 32 128 32 224 224 224 64 128 64 160 192 160 224 224 192 32 160 96 160 160 160 64 64 64 96 96 96 128 128 128 192 192 192 32 32 32 32 64 32]; mask:((ImageMask new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@O8@@?>@A??@A?C C<@0C8@PC8@@??@@??F@_>O@O<_ G8?0C1?8A#?<@C?<@@_@H@_@L@?@GC>@C?>@A?<@@_0@') ; yourself); yourself]
! !

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

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'CVS Settings'
          name: 'CVS Settings'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 659 580)
        )
        component: 
       (SpecCollection
          collection: (
           (VerticalPanelViewSpec
              name: 'VerticalPanel2'
              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              horizontalLayout: fit
              verticalLayout: topSpace
              horizontalSpace: 3
              verticalSpace: 20
              component: 
             (SpecCollection
                collection: (
                 (VerticalPanelViewSpec
                    name: 'VerticalPanel3'
                    horizontalLayout: fit
                    verticalLayout: top
                    horizontalSpace: 3
                    verticalSpace: 4
                    component: 
                   (SpecCollection
                      collection: (
                       (ViewSpec
                          name: 'ManagerSetupBoxx'
                          component: 
                         (SpecCollection
                            collection: (
                             (FramedBoxSpec
                                label: 'CVS Sourcecode Manager Setup'
                                name: 'CVSSetupBox'
                                layout: (LayoutFrame 0 0 0 0 0 1 0 1)
                                labelPosition: topLeft
                                translateLabel: true
                                component: 
                               (SpecCollection
                                  collection: (
                                   (ViewSpec
                                      name: 'Box1'
                                      layout: (LayoutFrame 0 0 0 0 0 1 25 0)
                                      component: 
                                     (SpecCollection
                                        collection: (
                                         (LabelSpec
                                            label: 'CVS Command or Path:'
                                            name: 'Label1'
                                            layout: (LayoutFrame 0 0.0 0 0 60 0.25 22 0)
                                            level: 0
                                            translateLabel: true
                                            adjust: right
                                          )
                                         (InputFieldSpec
                                            name: 'CVSExecutableField'
                                            layout: (LayoutFrame 64 0.25 0 0 0 1 22 0)
                                            enableChannel: useManager
                                            tabable: true
                                            model: cvsExecutableHolder
                                            acceptChannel: acceptChannel
                                            acceptOnPointerLeave: true
                                          )
                                         )
                                       
                                      )
                                    )
                                   (ViewSpec
                                      name: 'Box7'
                                      layout: (LayoutFrame 0 0.0 27 0 0 1 52 0)
                                      component: 
                                     (SpecCollection
                                        collection: (
                                         (LabelSpec
                                            label: 'CVSRoot default:'
                                            name: 'defaultCvsRootLabel'
                                            layout: (LayoutFrame 0 0.0 0 0 60 0.25 22 0)
                                            level: 0
                                            translateLabel: true
                                            adjust: right
                                          )
                                         (ComboBoxSpec
                                            name: 'cvsRootComboBox'
                                            layout: (LayoutFrame 64 0.25 0 0 0 1 22 0)
                                            tabable: true
                                            model: cvsRootHolder
                                            immediateAccept: true
                                            acceptOnLeave: true
                                            acceptOnReturn: true
                                            acceptOnTab: true
                                            acceptOnLostFocus: true
                                            acceptChannel: acceptChannel
                                            acceptOnPointerLeave: true
                                            comboList: cvsRootPrototypeList
                                          )
                                         )
                                       
                                      )
                                    )
                                   (HorizontalPanelViewSpec
                                      name: 'HorizontalPanel3'
                                      layout: (LayoutFrame 44 0.25 51 0 -1 1 82 0)
                                      horizontalLayout: fitSpace
                                      verticalLayout: center
                                      horizontalSpace: 3
                                      verticalSpace: 3
                                      component: 
                                     (SpecCollection
                                        collection: (
                                         (ViewSpec
                                            name: 'Box8'
                                            extent: (Point 102 10)
                                          )
                                         (ViewSpec
                                            name: 'Box9'
                                            extent: (Point 102 10)
                                          )
                                         (ViewSpec
                                            name: 'Box10'
                                            extent: (Point 102 10)
                                          )
                                         (ActionButtonSpec
                                            label: 'CVS-Login'
                                            name: 'loginButton1'
                                            translateLabel: true
                                            tabable: true
                                            model: loginCVSRoot
                                            enableChannel: cvsLoginEnabled
                                            extent: (Point 103 22)
                                          )
                                         )
                                       
                                      )
                                    )
                                   (LabelSpec
                                      label: 'CVSRoot per Module:'
                                      name: 'knownModulesLabel'
                                      layout: (LayoutFrame 0 0.0 82 0 60 0.25 104 0)
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (SequenceViewSpec
                                      name: 'List1'
                                      layout: (LayoutFrame 64 0.25 82 0 0 1 201 0)
                                      tabable: true
                                      model: selectedPerModuleRoot
                                      hasHorizontalScrollBar: true
                                      hasVerticalScrollBar: true
                                      miniScrollerHorizontal: true
                                      useIndex: false
                                      sequenceList: listOfModules
                                    )
                                   (LabelSpec
                                      label: 'Module:'
                                      name: 'moduleLabel'
                                      layout: (LayoutFrame 0 0.0 211 0 60 0.25 228 0)
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (InputFieldSpec
                                      name: 'perModuleRootModuleEntryField'
                                      layout: (LayoutFrame 64 0.25 207 0 0 1 229 0)
                                      tabable: true
                                      model: perModuleRootModule
                                      acceptChannel: acceptChannel
                                      acceptOnPointerLeave: true
                                    )
                                   (LabelSpec
                                      label: 'CVSRoot:'
                                      name: 'cvsRootLabel'
                                      layout: (LayoutFrame 0 0.0 236 0 60 0.25 253 0)
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (ComboBoxSpec
                                      name: 'perModuleRootComboBox'
                                      layout: (LayoutFrame 64 0.25 232 0 0 1.0 254 0)
                                      tabable: true
                                      model: perModuleRoot
                                      immediateAccept: true
                                      acceptOnLeave: true
                                      acceptOnReturn: true
                                      acceptOnTab: true
                                      acceptOnLostFocus: true
                                      acceptChannel: acceptChannel
                                      acceptOnPointerLeave: true
                                      comboList: cvsRootPrototypeList
                                    )
                                   (HorizontalPanelViewSpec
                                      name: 'HorizontalPanel2'
                                      layout: (LayoutFrame 64 0.25 -25 1 -1 1 0 1)
                                      horizontalLayout: fitSpace
                                      verticalLayout: center
                                      horizontalSpace: 3
                                      verticalSpace: 3
                                      component: 
                                     (SpecCollection
                                        collection: (
                                         (ActionButtonSpec
                                            label: 'Add/Apply'
                                            name: 'addButton'
                                            translateLabel: true
                                            tabable: true
                                            model: addPerModuleRoot
                                            extent: (Point 97 22)
                                          )
                                         (ActionButtonSpec
                                            label: 'Remove'
                                            name: 'removeButton'
                                            translateLabel: true
                                            tabable: true
                                            model: removePerModuleRoot
                                            enableChannel: removeEnabled
                                            extent: (Point 97 22)
                                          )
                                         (ViewSpec
                                            name: 'Box11'
                                            extent: (Point 97 10)
                                          )
                                         (ActionButtonSpec
                                            label: 'CVS-Login'
                                            name: 'loginButton2'
                                            translateLabel: true
                                            tabable: true
                                            model: loginPerModuleRoot
                                            enableChannel: cvsLoginInModuleEnabled
                                            extent: (Point 98 22)
                                          )
                                         )
                                       
                                      )
                                    )
                                   )
                                 
                                )
                              )
                             )
                           
                          )
                          extent: (Point 659 327)
                        )
                       (FramedBoxSpec
                          label: 'Source Cache'
                          name: 'FramedBox1'
                          labelPosition: topLeft
                          translateLabel: true
                          component: 
                         (SpecCollection
                            collection: (
                             (ViewSpec
                                name: 'SourceCacheDirBox'
                                layout: (LayoutFrame 0 0 0 0 0 1 30 0)
                                component: 
                               (SpecCollection
                                  collection: (
                                   (LabelSpec
                                      label: 'Source Cache Dir:'
                                      name: 'SourceCacheDirLabel'
                                      layout: (LayoutFrame 0 0.0 0 0 60 0.25 22 0)
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (InputFieldSpec
                                      name: 'SourceCacheDirEntryField'
                                      layout: (LayoutFrame 64 0.25 0 0 0 1 22 0)
                                      enableChannel: useManager
                                      model: sourceCacheDir
                                      immediateAccept: false
                                      acceptOnReturn: true
                                      acceptOnTab: true
                                      acceptOnLostFocus: true
                                      acceptOnPointerLeave: true
                                    )
                                   )
                                 
                                )
                              )
                             (HorizontalPanelViewSpec
                                name: 'CacheActionsHorizontalPanel'
                                layout: (LayoutFrame 44 0.25 33 0 0 1 67 0)
                                horizontalLayout: fitSpace
                                verticalLayout: center
                                horizontalSpace: 3
                                verticalSpace: 3
                                component: 
                               (SpecCollection
                                  collection: (
                                   (ActionButtonSpec
                                      label: 'Flush Cache now'
                                      name: 'FlushCacheNowButton'
                                      translateLabel: true
                                      tabable: true
                                      model: flushSourceCache
                                      enableChannel: useManager
                                      extent: (Point 208 22)
                                    )
                                   (ActionButtonSpec
                                      label: 'Condense Cache now'
                                      name: 'CondenseCacheNowButton'
                                      translateLabel: true
                                      tabable: true
                                      model: condenseSourceCache
                                      enableChannel: useManager
                                      extent: (Point 208 22)
                                    )
                                   )
                                 
                                )
                              )
                             )
                           
                          )
                          extent: (Point 659 95)
                        )
                       )
                     
                    )
                    extent: (Point 659 768)
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!CVSSourceCodeManagementSettingsAppl class methodsFor:'queries'!

managerClass
    "backlink to my manager class (needed by the settings app)"

    ^ CVSSourceCodeManager

    "Created: / 19-04-2011 / 12:46:52 / cg"
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'actions'!

addModule:module withData:data
    (self listOfModules includes:module) ifFalse:[
        self listOfModules add:module; sort.
    ].
    rootsPerModule at:module put:data.

    self updateModifiedChannel.

    "Created: / 08-11-2006 / 19:25:21 / cg"
!

basicReadSettings
    self initialize.

    self sourceCacheDir value:(CVSSourceCodeManager cacheDirectoryName).

    CVSSourceCodeManager forgetDisabledModules.
    repository := CVSSourceCodeManager repositoryName.
    repositoryHolder := (repository ? '') asValue.

    (Array with:CVSSourceCodeManager) "self availableManagers" do:[:eachManager |
        |infoPerModule|

        infoPerModule := eachManager repositoryInfoPerModule.
        infoPerModule keysAndValuesDo:[:module :info | 
            rootsPerModule at:module put:(Array with:eachManager with:info).
        ].
    ].

    self cvsRootHolder value:CVSSourceCodeManager repositoryName ? self class defaultRepositoryName.
    self cvsExecutableHolder value:CVSSourceCodeManager cvsExecutable.
    self verboseSourceCodeAccess value:CVSSourceCodeManager verboseSourceCodeAccess. 

    rootsPerModule notNil ifTrue:[
        self listOfModules removeAll.
        listOfModules addAll:rootsPerModule keys asList.
    ].
"/    self selectedPerModuleRootChanged.

    "Modified: / 19-04-2011 / 11:00:48 / cg"
!

basicSaveSettings
    |modules nm fn|

    nm := self sourceCacheDir value.
    nm notEmptyOrNil ifTrue:[
        (fn := nm asFilename) exists ifFalse:[
            (self confirm:('CVS cache directory ''' , nm , ''' does not exist\create ?' withCRs)) ifTrue:[
                fn recursiveMakeDirectory; 
                   makeReadableForAll;
                   makeWritableForAll;
                   makeExecutableForAll.
            ]
        ].
        (fn isDirectory
        and:[fn isReadable
        and:[fn isWritable]]) ifTrue:[
            CVSSourceCodeManager cacheDirectoryName:nm.
        ] ifFalse:[
            self warn:'Invalid sourceCache directory.'
        ]
    ].

    (Array with:CVSSourceCodeManager) "self availableManagers" do:[:eachManager |
        |infoPerModule|
        modules := rootsPerModule select:[:entry | entry first == eachManager].
        infoPerModule := Dictionary new.
        modules keysAndValuesDo:[:module :entry | 
            entry first == eachManager ifTrue:[
                infoPerModule at:module put:(entry second).
            ].
        ].
        eachManager repositoryInfoPerModule:infoPerModule.
    ].

    self basicSaveCVSSettings.

    self sourceCacheDir value:(AbstractSourceCodeManager cacheDirectoryName).

    DebugView newDebugger. "/ ???

    self acceptChannel value.

    "Modified: / 18-04-2011 / 18:26:57 / cg"
!

condenseSourceCache
    self withWaitCursorDo:[ AbstractSourceCodeManager condenseSourceCache ].
    Method flushSourceStreamCache.

    "Modified: / 28-11-2006 / 12:21:33 / cg"
!

flushSourceCache
    self withWaitCursorDo:[ AbstractSourceCodeManager flushSourceCache ].
    Method flushSourceStreamCache.

    "Modified: / 28-11-2006 / 12:21:21 / cg"
!

removePerModuleRoot

    |module|

    acceptChannel value:true.    
    module := self perModuleRootModule value.
    self listOfModules remove:module ifAbsent:nil.
    rootsPerModule removeKey:module ifAbsent:nil.
    self perModuleRootModule value:nil.
    self perModuleRoot value:nil.
    self updateModifiedChannel.
!

setupSourceCodeManager

   AbstractLauncherApplication::LauncherDialogs cvsConfigurationDialog.
   manager := (Smalltalk at:#SourceCodeManager).
   manager notNil ifTrue:[
        repositoryHolder value: manager repositoryName.
        sourceCacheDir value:(AbstractSourceCodeManager cacheDirectoryName).
   ].

    "Modified: / 16-08-2006 / 11:07:51 / cg"
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'actions - cvs'!

addPerModuleRoot
    |module cvsRoot|

    acceptChannel value:true.    

    module := self perModuleRootModule value.
    cvsRoot := self perModuleRoot value.

    cvsRoot size > 0 ifTrue:[
        self addModule:module withData:(Array with:CVSSourceCodeManager with:cvsRoot).
    ].

    "Modified: / 08-11-2006 / 19:27:39 / cg"
!

basicSaveCVSSettings
    |cvsRoot|

    repositoryHolder notNil ifTrue:[
        repositoryHolder value size > 0 ifTrue:[
            manager notNil ifTrue:[
                manager initializeForRepository:repositoryHolder value.
            ]
        ].
    ].
    CVSSourceCodeManager cvsExecutable:((self cvsExecutableHolder value ? '') withoutSeparators).
    CVSSourceCodeManager initializeForRepository:(cvsRoot := self cvsRootHolder value).
    CVSSourceCodeManager verboseSourceCodeAccess: verboseSourceCodeAccess value. 

    RecentlyUsedCVSRoots isNil ifTrue:[
        RecentlyUsedCVSRoots := OrderedCollection new.
    ].
    (RecentlyUsedCVSRoots includes:cvsRoot) ifFalse:[
        RecentlyUsedCVSRoots addFirst:cvsRoot.
        RecentlyUsedCVSRoots size > 20 ifTrue:[
            RecentlyUsedCVSRoots removeLast.
        ].
    ].

    "Modified: / 29-09-2006 / 12:28:50 / cg"
!

cvsLogin:cvsRoot
    |cmd term|

    VT100TerminalView isNil ifTrue:[
        self warn:'Function not available'.
        ^ self.
    ].

    cmd := 'cvs -d ' , cvsRoot , ' login ; exit'.
    term := VT100TerminalView open.
    term topView 
        label:'CVS Login for ' , cvsRoot;
        waitUntilVisible.
    term shellTerminateAction:[
        "/ term topView destroy
    ].

    term showCR:(('Please enter the CVS-password then close this terminal window.') allBold colorizeAllWith:Color red).
    term showCR:''.
    term endEntry.
    Delay waitForSeconds:1.
    term sendLine:cmd.

    "
     self basicNew cvsLogin:':pserver:stx@exept.eu.org:/stx'
    "

    "Modified: / 25-08-2010 / 23:03:19 / cg"
!

loginCVSRoot
    self cvsLogin:cvsRootHolder value.
!

loginPerModuleRoot
    self cvsLogin:perModuleRoot value.
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'aspects'!

acceptChannel

    acceptChannel isNil ifTrue:[
        acceptChannel := TriggerValue new.
    ].
    ^ acceptChannel.
!

checkClassesWhenCheckingIn

    checkClassesWhenCheckingIn isNil ifTrue:[
        checkClassesWhenCheckingIn := (currentUserPrefs at:#checkClassesWhenCheckingIn ifAbsent:true) asValue.
        checkClassesWhenCheckingIn onChangeSend:#updateModifiedChannel to:self
    ].
    ^ checkClassesWhenCheckingIn.
!

cvsExecutableHolder
    cvsExecutableHolder isNil ifTrue:[
        cvsExecutableHolder := ValueHolder new.
        cvsExecutableHolder onChangeSend:#updateModifiedChannel to:self
    ].
    ^ cvsExecutableHolder.

    "Created: / 21-09-2006 / 15:37:06 / cg"
!

cvsLoginEnabled
    cvsLoginEnabled isNil ifTrue:[
        cvsLoginEnabled := false asValue.
    ].
    ^ cvsLoginEnabled.
!

cvsLoginInModuleEnabled
    cvsLoginInModuleEnabled isNil ifTrue:[
        cvsLoginInModuleEnabled := false asValue.
    ].
    ^ cvsLoginInModuleEnabled.
!

cvsRootHolder

    cvsRootHolder isNil ifTrue:[
        cvsRootHolder := self cvsRootFromCVSRootFileOrNil asValue.
        cvsRootHolder addDependent:self.
    ].
    ^ cvsRootHolder.
!

cvsRootPrototypeList
    |cvsRoot prototypeList|

    cvsRootPrototypeList isNil ifTrue:[
        prototypeList := OrderedSet new.

        cvsRoot := self cvsRootFromCVSRootFileOrNil.
        cvsRoot notNil ifTrue:[
            prototypeList add:cvsRoot    
        ].

        prototypeList add:(':pserver:cvs@cvs.smalltalk-x.de:/cvs/stx').

        OperatingSystem getDomainName = 'bh.exept.de' ifTrue:[
            prototypeList add:(':pserver:' , OperatingSystem getLoginName , '@cvs.bh.exept.de:/cvs/stx')
        ] ifFalse:[
            prototypeList add:(':pserver:' , OperatingSystem getLoginName , '@CVSHOST:/cvs/stx').
        ].

        OperatingSystem isUNIXlike ifTrue:[
            prototypeList add:'/cvs/stx'.
        ] ifFalse:[
            OperatingSystem isMSDOSlike ifTrue:[
                prototypeList addFirst:':local:c:\cvs\stx'.
            ] ifFalse:[
                "there might be more here in the future"
            ]
        ].

        cvsRootPrototypeList := prototypeList asOrderedCollection.
    ].
    ^ cvsRootPrototypeList.
!

keepMethodSource

    keepMethodSource isNil ifTrue:[
        keepMethodSource := ValueHolder new.
        keepMethodSource onChangeSend:#updateModifiedChannel to:self
    ].
    ^ keepMethodSource.
!

listOfModules

    listOfModules isNil ifTrue:[
        rootsPerModule notNil ifTrue:[
            listOfModules := rootsPerModule keys asList.
        ].
        listOfModules sort.
        listOfModules onChangeSend:#updateModifiedChannel to:self
    ].
    ^ listOfModules.
!

localSourceFirst

    localSourceFirst isNil ifTrue:[
        localSourceFirst := ValueHolder new.
        localSourceFirst onChangeSend:#updateModifiedChannel to:self
    ].
    ^ localSourceFirst.
!

perModuleFieldsEnableHolder

    perModuleFieldsEnableHolder isNil ifTrue:[
        perModuleFieldsEnableHolder := true asValue.
        perModuleFieldsEnableHolder addDependent:self.
    ].
    ^ perModuleFieldsEnableHolder.
!

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

perModuleRootModule
    perModuleRootModule isNil ifTrue:[
        perModuleRootModule := ValueHolder new.
    ].
    ^ perModuleRootModule.
!

removeEnabled

    removeEnabled isNil ifTrue:[
        removeEnabled := false asValue.
    ].
    ^ removeEnabled.
!

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

sourceCacheDir
    sourceCacheDir isNil ifTrue:[
        sourceCacheDir := ValueHolder new.
        sourceCacheDir onChangeSend:#updateModifiedChannel to:self
    ].
    ^ sourceCacheDir.
!

useManager
    useManager isNil ifTrue:[
        useManager := ValueHolder new.
        useManager onChangeSend:#updateModifiedChannel to:self
    ].
    ^ useManager.
!

verboseSourceCodeAccess
    verboseSourceCodeAccess isNil ifTrue:[
        verboseSourceCodeAccess := false asValue.
        verboseSourceCodeAccess onChangeSend:#updateModifiedChannel to:self
    ].
    ^ verboseSourceCodeAccess.
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'change & update'!

selectedPerModuleRootChanged
    |module entry|

    self acceptChannel value:true.    
    module := self selectedPerModuleRoot value.
    module isNil ifTrue:[ 
        self removeEnabled value:false.
        self perModuleRootModule value:' '.
        self perModuleRoot value:''.
        ^ self
    ].

    entry := rootsPerModule at:module ifAbsent:#().    
    (entry first = CVSSourceCodeManager) ifTrue:[
        self removeEnabled value:true.
        self perModuleRootModule value:module.
        self perModuleRoot value:(entry at:2).
    ] ifFalse:[
        self removeEnabled value:false.
        self perModuleRootModule value:module , ' ',('<<use ',entry first managerTypeName,'>>') allBold.
        self perModuleRoot value:''.
    ].
!

sourceDirChanged
    |nm fn previousDir|

    manager isNil ifTrue:[^ self].

    previousDir := AbstractSourceCodeManager cacheDirectoryName.

    nm := self sourceCacheDir value.
    nm isEmptyOrNil ifTrue:[^ self].

    (fn := nm asFilename) exists ifFalse:[
        (self confirm:(resources 
                            stringWithCRs:'SourceCache directory "%1" does not exist.\Create ?'
                            with:nm)
        ) ifFalse:[
            self sourceCacheDir value:previousDir.
            ^ self.
        ].
        fn 
            recursiveMakeDirectory; 
            makeReadableForAll;
            makeWritableForAll;
            makeExecutableForAll.
        ^ self.
    ].

    (fn isDirectory) ifFalse:[
        self warn:(resources 
                            stringWithCRs:'Not a directory: "%1"'
                            with:nm).
        self sourceCacheDir value:previousDir.
        ^ self.
    ].

    (fn isReadable and:[fn isWritable]) ifFalse:[
        (self confirm:(resources 
                            stringWithCRs:'SourceCache directory "%1" is not both readable and writable.\Change ?'
                            with:nm)
        ) ifFalse:[
            self sourceCacheDir value:previousDir.
            ^ self.
        ].
        fn
            makeReadableForAll;
            makeWritableForAll;
            makeExecutableForAll.
    ].
"/    (fn isReadableForAll and:[fn isWritableForAll]) ifFalse:[
"/        (self confirm:(resources 
"/                            stringWithCRs:'SourceCache directory "%1" is not both readable and writable for other users.\Change ?'
"/                            with:nm)
"/        ) ifTrue:[
"/            fn
"/                makeReadableForAll;
"/                makeWritableForAll;
"/                makeExecutableForAll.
"/        ]
"/    ].
!

update:something with:aParameter from:changedObject 
    "/ common    
    changedObject == sourceCacheDir ifTrue:[
        self sourceDirChanged.
        self updateModifiedChannel.
        ^ self
    ].

    "/ cvs
    changedObject == cvsRootHolder ifTrue:[
        self updateModifiedChannel.
        self updateLoginEnableHolders.
        ^ self
    ].
    changedObject == perModuleRoot ifTrue:[
        self updateLoginEnableHolders.
        ^ self
    ].
    changedObject == selectedPerModuleRoot ifTrue:[
        self selectedPerModuleRootChanged.
        ^ self
    ].

    super update:something with:aParameter from:changedObject

    "Modified: / 18-04-2011 / 18:18:04 / cg"
!

updateLoginEnableHolders
    self cvsLoginEnabled value:((cvsRootHolder value ? '') startsWith:':pserver:').
    self cvsLoginInModuleEnabled value:((perModuleRoot value ? '') startsWith:':pserver:').
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'help'!

helpFilename
    ^ 'Launcher/cvsSetup.html'
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'initialization & release'!

initialize
    (AbstractSourceCodeManager notNil) ifTrue:[ AbstractSourceCodeManager autoload ].

    useManager := false asValue.
    useManager onChangeSend:#updateModifiedChannel to:self.

    sourceCacheDir := nil asValue.
    sourceCacheDir addDependent:self.

    repositoryHolder := '' asValue.
    rootsPerModule := Dictionary new.

    (Array with:CVSSourceCodeManager) "self availableManagers" do:[:eachManager |
        eachManager repositoryInfoPerModule 
            keysAndValuesDo:[:module :info |
                module withoutSeparators ~= module ifTrue:[
                    self halt:'should not happen any longer'
                ].
                rootsPerModule at:module put:(Array with:eachManager with:info)
            ].
    ].

    super initialize.

    "Modified: / 18-04-2011 / 18:28:00 / cg"
! !

!CVSSourceCodeManagementSettingsAppl methodsFor:'queries'!

cvsRootFromCVSRootFileOrNil
    |cvsDir cvsRootFile cvsRoot|

    cvsDir := 'CVS' asFilename.
    cvsDir isDirectory ifTrue:[
        cvsRootFile := cvsDir construct:'Root'.
        cvsRootFile isReadable ifTrue:[
            cvsRoot := cvsRootFile contents firstIfEmpty:nil.
        ].
    ].
    ^ cvsRoot
!

hasUnsavedChanges
    ((CVSSourceCodeManager cacheDirectoryName ? '') ~= (self sourceCacheDir value ? '')) ifTrue:[^ true].

    (Array with:CVSSourceCodeManager) "self availableManagers" do:[:mgr |
        |modules|

        modules := rootsPerModule select:[:entry | entry first == mgr].

        mgr repositoryInfoPerModule keysAndValuesDo:[:module :info |
            ((modules includesKey:module) and:[info = (modules at:module) second])
            ifFalse:[^ true].
        ].
        modules keysAndValuesDo:[:module :info|
            ((mgr repositoryInfoPerModule includesKey:module) and:[(mgr repositoryInfoPerModule at:module) = info second])
            ifFalse:[^ true].
        ].
    ].

    ((CVSSourceCodeManager cvsExecutable ? '') ~= (self cvsExecutableHolder value ? '') withoutSeparators)  
        ifTrue:[^ true].

    (CVSSourceCodeManager repositoryName ? self class defaultRepositoryName ~= self cvsRootHolder value)    
        ifTrue:[^ true].

    (CVSSourceCodeManager verboseSourceCodeAccess ~= self verboseSourceCodeAccess value) 
        ifTrue:[^ true].

    ^ false

    "Modified: / 19-04-2011 / 11:00:32 / cg"
! !

!CVSSourceCodeManagementSettingsAppl class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/CVSSourceCodeManagementSettingsAppl.st,v 1.3 2011-04-19 10:58:09 cg Exp $'
! !