PerforceSourceCodeManagementSettingsAppl.st
author Claus Gittinger <cg@exept.de>
Wed, 21 Dec 2011 13:06:12 +0100
changeset 10983 b8ef5eab439e
parent 10980 b626963597f1
child 11009 763eae9a867b
permissions -rw-r--r--
changed: #defaultIcon1

"
 COPYRIGHT (c) 2011 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:#PerforceSourceCodeManagementSettingsAppl
	instanceVariableNames:'sourceCacheDir listOfModules removeEnabled acceptChannel
		selectedPerModuleRoot verboseSourceCodeAccess
		perforceExecutableHolder listOfPerforceModules
		defaultSettingsHolder tableColumns defaultSettingsPrototypeList'
	classVariableNames:'RecentlyUsedCVSRoots RecentlyUsedStoreHosts
		RecentlyUsedSmallTeamHosts LastStoreHost LastStoreUser
		LastStorePassword'
	poolDictionaries:''
	category:'System-SourceCodeManagement'
!

ApplicationModel subclass:#ManagerPerModuleApp
	instanceVariableNames:'moduleHolder acceptChannel settingsHolder
		sourceCodeManagementSettingsApp acceptEnableChannel canceled
		defaultSettingsPrototypeList'
	classVariableNames:''
	poolDictionaries:''
	privateIn:PerforceSourceCodeManagementSettingsAppl
!

Object subclass:#ModuleManager
	instanceVariableNames:'manager module settings app'
	classVariableNames:''
	poolDictionaries:''
	privateIn:PerforceSourceCodeManagementSettingsAppl
!

!PerforceSourceCodeManagementSettingsAppl class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2011 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.
"
! !

!PerforceSourceCodeManagementSettingsAppl class methodsFor:'image specs'!

defaultIcon
    ^ self defaultIcon1

    "Created: / 21-12-2011 / 12:35:05 / cg"
!

defaultIcon1
    "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 defaultIcon1 inspect
     ImageEditor openOnClass:self andSelector:#defaultIcon1
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'PerforceSourceCodeManagementSettingsAppl class defaultIcon1'
        ifAbsentPut:[(Depth8Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@PHA@PHA@0D@@@D@@@@@@@@@@@@@@ TFA XFA \B@@@C@ HB@ @@@@@@
@@HIB (IBP(IA@LB@ $JBPH@@@@@@@@BBP(LCPXJB $N@!!@JB!!@B@@@@@@@@@!!@PCP@@D!!@PA (PBP(P@ @@@@@@@@HPDAH@@ALPDA@PD@(PD@H@@@@@@@@B
EQ@VB (WDA@PEQLMEP(B@@@@@@@@@!!TWEQ$ZE1\WEQ@@F1$S@ @@@@@@@@HZEQ@SF1TUEQT\@AXZA H@@@@@@@@BF!!4S@@4ZF!!4Q@@@^G00B@@@@@@@@@!!8^
D2@^F!!(G@@@QH"L$IPH@@@@@@@H''G!!TUG" )AR(EJ2L,KR4B@@@@@@@B@!!D/LBL"H#D1LRH2H3L4@ @@@@@@@@@BJ3L6KB0,KB0#H2L#H0H@@@@@@@@@@ HB
@ HB@ HBH#(-@ HB@@@@@@@@@@@@@@@@@@@@@#(4KPH@@@@@@@@@@@@@@@@@@@@@@@H=O H@@@@@@@@@@@@@@@@@@@@@@@@B@ HB@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[240 240 240 224 232 250 208 232 250 224 240 250 160 192 210 128 176 200 144 176 200 160 192 220 144 176 210 112 160 180 128 160 180 160 200 220 128 168 200 160 184 210 208 224 240 176 208 220 112 152 180 176 200 220 144 184 210 144 168 200 192 216 240 112 144 170 128 152 180 112 144 180 128 168 180 96 136 170 112 136 170 144 168 180 192 216 220 96 136 160 96 128 160 48 112 140 176 192 220 144 184 220 16 96 130 32 96 130 144 200 220 192 232 250 176 216 250 96 120 140 80 120 140 80 128 160 112 168 200 80 136 170 32 104 140 96 152 180 128 184 210 96 144 170 48 104 140 16 88 120 32 104 130 16 88 130 0 80 100 176 224 250 32 96 140 144 192 220 160 208 240 160 208 220 16 80 120 80 144 170 80 144 180 0 64 100 0 72 100]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@G?H@G?O G?? G?? G''? G''? G?? G?7 G?7 G/'' G?O0G??0G??0A??0A??0@@_@@@^@@@^@@@@@@@@@') ; yourself); yourself]
!

defaultIcon2
    "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 defaultIcon2 inspect
     ImageEditor openOnClass:self andSelector:#defaultIcon2
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'PerforceSourceCodeManagementSettingsAppl class defaultIcon2'
        ifAbsentPut:[(Depth4Image new) width: 24; height: 24; photometric:(#palette); bitsPerSample:(#[4]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@AH@@@@@@@@@@@@@QUUV@@@@@@@@@@A%UUUUUX@@@@@@BUUUUUUUUUTP@@@HUUUUUUUUUUUU$@@@@@UUUU
UUUU$@@@@@@@@FUUUUT@@@@@@@@@@@AUUZ@@)B@@@@@@H@@BL@BUUV @@@BEUU @@HUUZP@@@@YUUUUQ!!%UY@@@@@@@$UUUUUUVP@@@@@@@@@BUUUU@@QUP@
@@@@@@@AU@B%UP@@@@@@A0@@@@EUP@@@@@@@UUU@@DUY@@@@@@@UUUUUUUV@@@@@@@JH$VUUUU @@@@@@@@@@@@HYY@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[255 248 248 240 200 104 255 216 160 255 248 240 240 192 64 240 168 24 240 176 48 255 240 224 255 224 176 255 208 136 255 232 208]; mask:((Depth1Image new) width: 24; height: 24; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@A @@G8@@_?@C??0O??<@?? @O<@@C88@!!#<C<O0G??@C?>@@O8<@A30@PG @>O@C?>@G?<@@A8@@@@@@@@@@@@@') ; yourself); yourself]
! !

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

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Source Code Manager Settings'
          name: 'Source Code Manager Settings'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 726 653)
        )
        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: (
                       (FramedBoxSpec
                          label: 'Perforce (P4) Sourcecode Manager Settings'
                          name: 'FramedBox3'
                          labelPosition: topLeft
                          translateLabel: true
                          component: 
                         (SpecCollection
                            collection: (
                             (ViewSpec
                                name: 'Box3'
                                layout: (LayoutFrame 0 0 0 0 0 1 0 1)
                                component: 
                               (SpecCollection
                                  collection: (
                                   (LabelSpec
                                      label: 'Default Perforce Root'
                                      name: ''
                                      layout: (LayoutFrame 0 0.0 1 0 60 0.25 23 0)
                                      level: 0
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (LabelSpec
                                      label: 'client:user:pass@host:port '
                                      name: 'Label18'
                                      layout: (LayoutFrame 4 0.0 19 0 64 0.25 34 0)
                                      style: (FontDescription helvetica medium roman 10)
                                      level: 0
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (ComboBoxSpec
                                      name: 'cvsRootComboBox'
                                      layout: (LayoutFrame 66 0.25 7 0 -5 1 29 0)
                                      tabable: true
                                      model: defaultSettingsHolder
                                      immediateAccept: true
                                      acceptOnLeave: true
                                      acceptOnReturn: true
                                      acceptOnTab: true
                                      acceptOnLostFocus: true
                                      acceptChannel: acceptChannel
                                      acceptOnPointerLeave: true
                                      comboList: defaultSettingsPrototypeList
                                    )
                                   (LabelSpec
                                      label: 'Perforce Command or Path:'
                                      name: 'Label22'
                                      layout: (LayoutFrame 0 0.0 38 0 60 0.25 60 0)
                                      level: 0
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (InputFieldSpec
                                      name: 'EntryField8'
                                      layout: (LayoutFrame 66 0.25 38 0 -5 1 60 0)
                                      tabable: true
                                      model: perforceExecutableHolder
                                      immediateAccept: false
                                      acceptOnLostFocus: true
                                      acceptChannel: acceptChannel
                                      acceptOnPointerLeave: true
                                    )
                                   )
                                 
                                )
                              )
                             )
                           
                          )
                          extent: (Point 726 95)
                        )
                       (ViewSpec
                          name: 'ManagerSetupBoxx'
                          component: 
                         (SpecCollection
                            collection: (
                             (FramedBoxSpec
                                label: 'Per Module Manager Setup'
                                name: 'PerModuleManagerSetup'
                                layout: (LayoutFrame 0 0 -1 0 0 1 -3 1)
                                labelPosition: topLeft
                                translateLabel: true
                                component: 
                               (SpecCollection
                                  collection: (
                                   (DataSetSpec
                                      name: 'Table1'
                                      layout: (LayoutFrame 5 0 5 0 0 1 180 0)
                                      model: selectedPerModuleRoot
                                      hasHorizontalScrollBar: true
                                      hasVerticalScrollBar: true
                                      dataList: listOfModules
                                      useIndex: false
                                      columnHolder: tableColumns
                                      beDependentOfRows: true
                                    )
                                   (HorizontalPanelViewSpec
                                      name: 'HorizontalPanel11'
                                      layout: (LayoutFrame 5 0 -25 1 -1 1 0 1)
                                      horizontalLayout: fitSpace
                                      verticalLayout: center
                                      horizontalSpace: 3
                                      verticalSpace: 3
                                      component: 
                                     (SpecCollection
                                        collection: (
                                         (ActionButtonSpec
                                            label: 'Add/Apply'
                                            name: 'Button2'
                                            translateLabel: true
                                            tabable: true
                                            model: addPerModuleRoot
                                            extent: (Point 338 22)
                                          )
                                         (ActionButtonSpec
                                            label: 'Remove'
                                            name: 'Button3'
                                            translateLabel: true
                                            tabable: true
                                            model: removePerModuleRoot
                                            enableChannel: removeEnabled
                                            extent: (Point 339 22)
                                          )
                                         )
                                       
                                      )
                                    )
                                   )
                                 
                                )
                              )
                             )
                           
                          )
                          extent: (Point 726 250)
                        )
                       (FramedBoxSpec
                          label: 'Source Cache'
                          name: 'FramedBox2'
                          labelPosition: topLeft
                          translateLabel: true
                          component: 
                         (SpecCollection
                            collection: (
                             (ViewSpec
                                name: 'Box4'
                                layout: (LayoutFrame 0 0 0 0 0 1 30 0)
                                component: 
                               (SpecCollection
                                  collection: (
                                   (LabelSpec
                                      label: 'Source Cache Dir:'
                                      name: 'Label23'
                                      layout: (LayoutFrame 0 0.0 0 0 60 0.25 22 0)
                                      translateLabel: true
                                      adjust: right
                                    )
                                   (InputFieldSpec
                                      name: 'EntryField9'
                                      layout: (LayoutFrame 64 0.25 0 0 0 1 22 0)
                                      model: sourceCacheDir
                                      immediateAccept: false
                                      acceptOnReturn: true
                                      acceptOnTab: true
                                      acceptOnLostFocus: true
                                      acceptOnPointerLeave: true
                                    )
                                   )
                                 
                                )
                              )
                             (HorizontalPanelViewSpec
                                name: 'HorizontalPanel12'
                                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: 'Button4'
                                      translateLabel: true
                                      tabable: true
                                      model: flushSourceCache
                                      extent: (Point 233 22)
                                    )
                                   (ActionButtonSpec
                                      label: 'Condense Cache now'
                                      name: 'Button5'
                                      translateLabel: true
                                      tabable: true
                                      model: condenseSourceCache
                                      extent: (Point 233 22)
                                    )
                                   )
                                 
                                )
                              )
                             )
                           
                          )
                          extent: (Point 726 95)
                        )
                       (ViewSpec
                          name: 'VerboseBox'
                          component: 
                         (SpecCollection
                            collection: (
                             (CheckBoxSpec
                                label: 'Verbose (Trace Access on Transcript)'
                                name: 'CheckBox6'
                                layout: (LayoutFrame 30 0 5 0 -5 1 27 0)
                                model: verboseSourceCodeAccess
                                translateLabel: true
                              )
                             )
                           
                          )
                          extent: (Point 726 25)
                        )
                       )
                     
                    )
                    extent: (Point 726 768)
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!PerforceSourceCodeManagementSettingsAppl class methodsFor:'queries'!

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

    ^ PerforceSourceCodeManager

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

!PerforceSourceCodeManagementSettingsAppl class methodsFor:'tableColumns specs'!

tableColumns
    "This resource specification was automatically generated
     by the DataSetBuilder of ST/X."

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

    "
     DataSetBuilder new openOnClass:P4SourceCodeManagementSettingsAppl andSelector:#tableColumns
    "

    <resource: #tableColumns>

    ^#(
      (DataSetColumnSpec
         label: 'Module'
         labelButtonType: Button
         usePreferredWidth: true
         model: module
       )
      (DataSetColumnSpec
         label: 'Settings'
         labelButtonType: Button
         editorType: InputField
         model: settings
         isResizeable: false
       )
      )

! !

!PerforceSourceCodeManagementSettingsAppl methodsFor:'actions'!

addModule:aModuleManager

    |detectedManager|

    detectedManager := self listOfModules detect:[:eachModuleManager| eachModuleManager module = aModuleManager module] ifNone:nil.
    detectedManager isNil ifTrue:[
        self listOfModules add:aModuleManager; sort.
        self updateModifiedChannel.
    ] ifFalse:[
        Dialog information:'Manager for Module ', aModuleManager module, ' already exists'.
    ].


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

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

    self updateModifiedChannel.

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

addPerModuleRoot

    |app moduleManager|

    app := ManagerPerModuleApp openFromSourceCodeManagementSettingsApp:self.
    app canceled ifFalse:[
        moduleManager := ModuleManager newForApplication:self.
        app moduleHolder value isEmptyOrNil ifTrue:[
            self information:'Adding without module name not allowed'.
            ^ self.
        ].
        moduleManager module:app moduleHolder value.
        moduleManager settings:app settingsHolder value.
        moduleManager settings:app settingsHolder value.
        self listOfModules add:moduleManager.
        self updateModifiedChannel.
    ].
    "Modified: / 08-11-2006 / 19:27:39 / cg"
!

basicReadSettings
    |moduleManager moduleAndSettings|

    self initialize.

    self defaultSettingsHolder value:PerforceSourceCodeManager getPerforceDefaultSettingsString.
    self listOfModules removeAll.
    moduleAndSettings := PerforceSourceCodeManager repositoryInfoPerModule copy.
    moduleAndSettings notEmptyOrNil ifTrue:[
        moduleAndSettings keysAndValuesDo:[:module :settings|
            moduleManager := ModuleManager newForApplication:self.
            moduleManager module:module.
            moduleManager settings:settings.
            self listOfModules add:moduleManager.
        ].
    ].
    self listOfModules sort.

    self hasManager ifTrue:[
        self sourceCacheDir value:(PerforceSourceCodeManager cacheDirectoryName).
    ].

    self perforceExecutableHolder value:PerforceSourceCodeManager perforceExecutable.
    self verboseSourceCodeAccess value:PerforceSourceCodeManager verboseSourceCodeAccess.

"/    self selectedPerModuleRootChanged.

    "Modified: / 19-04-2011 / 10:53:15 / cg"
!

basicSaveSettings
    |client settings repositoryInfoPerModule|

    self hasManager ifTrue:[
        | nm fn|

        nm := self sourceCacheDir value.
        nm notEmptyOrNil ifTrue:[
            (fn := nm asFilename) exists ifFalse:[
                (self confirm:('Perforce cache directory ''' , nm , ''' does not exist\create ?' withCRs)) ifTrue:[
                    fn makeDirectory;
                       makeReadableForAll;
                       makeWritableForAll;
                       makeExecutableForAll.
                ]
            ].
            (fn isDirectory
            and:[fn isReadable
            and:[fn isWritable]]) ifTrue:[
                PerforceSourceCodeManager cacheDirectoryName:nm.
            ] ifFalse:[
                self warn:'Invalid sourceCache directory.'
            ]
        ].
        repositoryInfoPerModule := Dictionary new.
        self listOfModules do:[:aModuleManager|
            repositoryInfoPerModule at:aModuleManager module put:aModuleManager settings.
        ].

        PerforceSourceCodeManager repositoryInfoPerModule:repositoryInfoPerModule.
        PerforceSourceCodeManager perforceExecutable:((self perforceExecutableHolder value ? '') withoutSeparators).
        client := self defaultSettingsHolder value.
        client notNil ifTrue:[
            settings := PerforceSourceCodeManager getPerforceSettingsFromString:client.
            PerforceSourceCodeManager perforceClient:(settings at:#client ifAbsent:nil).
            PerforceSourceCodeManager perforceUser:(settings at:#user ifAbsent:nil).
            PerforceSourceCodeManager perforcePort:(settings at:#port ifAbsent:nil).
            PerforceSourceCodeManager perforcePassword:(settings at:#password ifAbsent:nil).
        ].
        PerforceSourceCodeManager verboseSourceCodeAccess:self verboseSourceCodeAccess value.
    ].

    self acceptChannel value.

    "Modified: / 19-04-2011 / 10:53:46 / cg"
!

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

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

flushSourceCache
    self withWaitCursorDo:[ AbstractSourceCodeManager flushSourceCache ].

    "Modified: / 30-09-2011 / 13:33:51 / cg"
!

removePerModuleRoot

    |module|

    acceptChannel value:true.
    module := self selectedPerModuleRoot value.
    self listOfModules remove:module ifAbsent:nil.
    self updateModifiedChannel.
! !

!PerforceSourceCodeManagementSettingsAppl methodsFor:'aspects'!

acceptChannel

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

defaultSettingsHolder

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

defaultSettingsPrototypeList

    defaultSettingsPrototypeList isNil ifTrue:[
        defaultSettingsPrototypeList := self perforcePrototypeList.
    ].
    ^ defaultSettingsPrototypeList.
!

listOfModules

    listOfModules isNil ifTrue:[
        listOfModules := List new.
        listOfModules addDependent:self.
    ].
    ^ listOfModules.
!

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

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

perforcePrototypeList

    |first client|

    client := PerforceSourceCodeManager perforceClient.
    client isEmptyOrNil ifTrue:[
        client := 'workspace'.
    ].
    first := (client ,':', PerforceSourceCodeManager perforceUser, ':',
                           (PerforceSourceCodeManager perforcePassword ? 'pass'), '@',
                           PerforceSourceCodeManager perforcePort).
    ^ Array with:first.
!

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.
!

tableColumns
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    tableColumns isNil ifTrue:[
        tableColumns := self class tableColumns asValue.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       tableColumns addDependent:self.
"/       tableColumns onChangeSend:#tableColumnsChanged to:self.
    ].
    ^ tableColumns.
!

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

!PerforceSourceCodeManagementSettingsAppl methodsFor:'change & update'!

selectedPerModuleRootChanged

    self removeEnabled value:self selectedPerModuleRoot value notNil.
!

sourceDirChanged
    | nm fn|

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

    (fn := nm asFilename) exists ifFalse:[
        (self confirm:('SourceCache directory ''' , nm , ''' does not exist.\Create ?' withCRs)) ifTrue:[
            fn makeDirectory;
               makeReadableForAll;
               makeWritableForAll;
               makeExecutableForAll.
        ] ifFalse:[
            self sourceCacheDir value:(AbstractSourceCodeManager cacheDirectoryName).
            ^ self.
        ].
    ].
    (fn isDirectory
    and:[fn isReadable
    and:[fn isWritable]]) ifTrue:[
        AbstractSourceCodeManager cacheDirectoryName:nm.
    ] ifFalse:[
        self warn:'Invalid sourceCache directory.'.
        self sourceCacheDir value:(AbstractSourceCodeManager cacheDirectoryName).
    ].
!

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

    changedObject == selectedPerModuleRoot ifTrue:[
        self selectedPerModuleRootChanged.
        ^ self
    ].

    changedObject == self listOfModules ifTrue:[
        self updateModifiedChannel.
    ].

    changedObject == defaultSettingsHolder ifTrue:[
        self updateModifiedChannel.
    ].


    super update:something with:aParameter from:changedObject

    "Modified: / 09-11-2006 / 14:41:10 / cg"
! !

!PerforceSourceCodeManagementSettingsAppl methodsFor:'help'!

helpFilename
    ^ 'Launcher/perforceSetup.html'

    "Modified: / 05-08-2011 / 09:10:03 / cg"
! !

!PerforceSourceCodeManagementSettingsAppl methodsFor:'initialization & release'!

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

    sourceCacheDir := nil asValue.
    sourceCacheDir addDependent:self.

    super initialize.

    "Modified: / 08-11-2006 / 19:20:32 / cg"
! !

!PerforceSourceCodeManagementSettingsAppl methodsFor:'queries'!

hasManager
    "true if ANY source code management class is available"

    ^ PerforceSourceCodeManager notNil and:[PerforceSourceCodeManager isLoaded]
!

hasUnsavedChanges

    |repositoryInfoPerModule client settings|

    client := self defaultSettingsHolder value.
    client notNil ifTrue:[
        settings := PerforceSourceCodeManager getPerforceSettingsFromString:client.
        PerforceSourceCodeManager perforceClient ~= (settings at:#client ifAbsent:nil) ifTrue:[
            ^ true
        ].
        PerforceSourceCodeManager perforceUser ~= (settings at:#user ifAbsent:nil) ifTrue:[
            ^ true
        ].
        PerforceSourceCodeManager perforcePort ~= (settings at:#port ifAbsent:nil) ifTrue:[
            ^ true
        ].
        PerforceSourceCodeManager perforcePassword ~= (settings at:#password ifAbsent:nil) ifTrue:[
            ^ true
        ].
    ].

    repositoryInfoPerModule := Dictionary new.
    self listOfModules do:[:aModuleManager|
        repositoryInfoPerModule at:aModuleManager module put:aModuleManager settings.
    ].
    PerforceSourceCodeManager verboseSourceCodeAccess ~= self verboseSourceCodeAccess value ifTrue:[
        ^true
    ].

    PerforceSourceCodeManager repositoryInfoPerModule keysAndValuesDo:[:module :info |
        ((repositoryInfoPerModule includesKey:module) and:[info = (repositoryInfoPerModule at:module)])
        ifFalse:[^ true].
    ].
    repositoryInfoPerModule keysAndValuesDo:[:module :info|
        ((PerforceSourceCodeManager repositoryInfoPerModule includesKey:module) and:[(PerforceSourceCodeManager repositoryInfoPerModule at:module) = info])
        ifFalse:[^ true].
    ].
    self perforceExecutableHolder value ~= PerforceSourceCodeManager perforceExecutable ifTrue:[
        ^true
    ].
    ^ false

    "Modified: / 19-04-2011 / 10:54:31 / cg"
!

repositoryInfoPerModuleFor:sourceCodeManager

    |repositoryInfoPerModule|

    repositoryInfoPerModule := Dictionary new.
    self listOfModules do:[:aModuleManager|
        repositoryInfoPerModule at:aModuleManager module put:aModuleManager settings.
    ].
    ^ repositoryInfoPerModule
! !

!PerforceSourceCodeManagementSettingsAppl::ManagerPerModuleApp class methodsFor:'instance creation'!

openFromSourceCodeManagementSettingsApp:something

    |inst|

    inst := self new.
    inst sourceCodeManagementSettingsApp:something.
    inst openModal.
    ^ inst
! !

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

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Manager per Module'
          name: 'Manager per Module'
          min: (Point 10 10)
          max: (Point 1024 768)
          bounds: (Rectangle 0 0 653 100)
        )
        component: 
       (SpecCollection
          collection: (
           (VerticalPanelViewSpec
              name: 'VerticalPanel1'
              layout: (LayoutFrame 0 0 0 0 -5 1 -30 1)
              horizontalLayout: fit
              verticalLayout: topSpace
              horizontalSpace: 3
              verticalSpace: 3
              component: 
             (SpecCollection
                collection: (
                 (HorizontalPanelViewSpec
                    name: 'HorizontalPanel1'
                    horizontalLayout: leftFit
                    verticalLayout: center
                    horizontalSpace: 3
                    verticalSpace: 3
                    component: 
                   (SpecCollection
                      collection: (
                       (LabelSpec
                          label: 'Module:'
                          name: 'Label16'
                          translateLabel: true
                          adjust: right
                          extent: (Point 180 17)
                        )
                       (InputFieldSpec
                          name: 'EntryField7'
                          tabable: true
                          model: moduleHolder
                          acceptChannel: acceptChannel
                          acceptOnPointerLeave: true
                          extent: (Point 465 22)
                        )
                       )
                     
                    )
                    extent: (Point 648 23)
                  )
                 (HorizontalPanelViewSpec
                    name: 'HorizontalPanel4'
                    horizontalLayout: leftFit
                    verticalLayout: topSpace
                    horizontalSpace: 3
                    verticalSpace: 3
                    component: 
                   (SpecCollection
                      collection: (
                       (ViewSpec
                          name: 'Box1'
                          component: 
                         (SpecCollection
                            collection: (
                             (LabelSpec
                                label: 'Manager Info'
                                name: 'Label18'
                                layout: (LayoutFrame 0 0 0 0 149 0 16 0)
                                translateLabel: true
                                adjust: right
                              )
                             (LabelSpec
                                label: 'client:user:pass@host:port '
                                name: 'Label19'
                                layout: (LayoutFrame 0 0 14 0 180 0 29 0)
                                style: (FontDescription helvetica medium roman 10)
                                level: 0
                                translateLabel: true
                                adjust: right
                              )
                             )
                           
                          )
                          extent: (Point 180 35)
                        )
                       (ComboBoxSpec
                          name: 'ComboBox1'
                          model: settingsHolder
                          acceptOnPointerLeave: false
                          comboList: defaultSettingsPrototypeList
                          extent: (Point 465 20)
                        )
                       )
                     
                    )
                    extent: (Point 648 35)
                  )
                 )
               
              )
            )
           (HorizontalPanelViewSpec
              name: 'HorizontalPanel2'
              layout: (LayoutFrame 0 0 -30 1 0 1 0 1)
              horizontalLayout: fitSpace
              verticalLayout: center
              horizontalSpace: 3
              verticalSpace: 3
              component: 
             (SpecCollection
                collection: (
                 (ActionButtonSpec
                    label: 'Add'
                    name: 'Button1'
                    translateLabel: true
                    model: doAccept
                    enableChannel: acceptEnableChannel
                    extent: (Point 322 22)
                  )
                 (ActionButtonSpec
                    label: 'Cancel'
                    name: 'Button2'
                    translateLabel: true
                    model: doCancel
                    extent: (Point 322 22)
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!PerforceSourceCodeManagementSettingsAppl::ManagerPerModuleApp methodsFor:'accessing'!

canceled
    ^ canceled
!

defaultSettingsPrototypeList

    defaultSettingsPrototypeList isNil ifTrue:[
        defaultSettingsPrototypeList := sourceCodeManagementSettingsApp perforcePrototypeList.
    ].
    ^ defaultSettingsPrototypeList.
!

sourceCodeManagementSettingsApp
    ^ sourceCodeManagementSettingsApp
!

sourceCodeManagementSettingsApp:something
    sourceCodeManagementSettingsApp := something.
! !

!PerforceSourceCodeManagementSettingsAppl::ManagerPerModuleApp methodsFor:'aspects'!

acceptChannel
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

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

acceptEnableChannel
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    acceptEnableChannel isNil ifTrue:[
        acceptEnableChannel := true asValue.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       acceptEnableChannel addDependent:self.
"/       acceptEnableChannel onChangeSend:#acceptEnableChannelChanged to:self.
    ].
    ^ acceptEnableChannel.
!

moduleHolder
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    moduleHolder isNil ifTrue:[
        moduleHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
        moduleHolder addDependent:self.
"/       moduleHolder onChangeSend:#moduleHolderChanged to:self.
    ].
    ^ moduleHolder.
!

settingsHolder
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    settingsHolder isNil ifTrue:[
        settingsHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       settingsHolder addDependent:self.
"/       settingsHolder onChangeSend:#settingsHolderChanged to:self.
    ].
    ^ settingsHolder.
! !

!PerforceSourceCodeManagementSettingsAppl::ManagerPerModuleApp methodsFor:'initialization & release'!

doCancel

    canceled := true.
    ^ super doCancel
!

postBuildWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked during the initialization of your app/dialog,
     after all of the visual components have been built,
     but BEFORE the top window is made visible.
     Add any app-specific actions here (reading files, setting up values etc.)
     See also #postOpenWith:, which is invoked after opening."

    "/ add any code here ...

    canceled := false.
    ^ super postBuildWith:aBuilder
!

postOpenWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked right after the applications window has been opened.
     Add any app-specific actions here (starting background processes etc.).
     See also #postBuildWith:, which is invoked before opening."

    "/ add any code here ...

    ^ super postOpenWith:aBuilder
! !

!PerforceSourceCodeManagementSettingsAppl::ModuleManager class methodsFor:'instance creation'!

newForApplication:anApplication
    |instance|

    instance := self new.
    instance app:anApplication.
    ^instance
! !

!PerforceSourceCodeManagementSettingsAppl::ModuleManager methodsFor:'accessing'!

app
    ^ app
!

app:something
    app := something.
!

manager
    ^ manager
!

manager:something
    manager := something.
!

module
    ^ module
!

module:something
    module := something.
!

settings
    ^ settings
!

settings:something
    settings := something.
    app notNil ifTrue:[
        app listOfModules changed.
    ].
! !

!PerforceSourceCodeManagementSettingsAppl::ModuleManager methodsFor:'comparing'!

< aModuleManager

    ^ self module < aModuleManager module
! !

!PerforceSourceCodeManagementSettingsAppl::ModuleManager methodsFor:'queries'!

availableManagerTypeNames
    ^ AbstractSourceCodeManager availableManagers collect:[:cls | cls managerTypeName].
!

managerClass

    ^ AbstractSourceCodeManager availableManagers detect:[:cls | cls managerTypeName = manager] ifNone:[nil].
! !

!PerforceSourceCodeManagementSettingsAppl class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/PerforceSourceCodeManagementSettingsAppl.st,v 1.11 2011-12-21 12:06:12 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/PerforceSourceCodeManagementSettingsAppl.st,v 1.11 2011-12-21 12:06:12 cg Exp $'
!

version_SVN
    ^ '§Id§'
! !