MCSettingsApp.st
changeset 320 638d89d7ff93
child 461 1d0c79f1ca04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCSettingsApp.st	Sat Aug 20 14:26:34 2011 +0200
@@ -0,0 +1,444 @@
+"{ 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
+                                      hasHorizontalScrollBar: true
+                                      hasVerticalScrollBar: true
+                                      listModel: mcRepositories
+                                      useIndex: false
+                                      highlightMode: line
+                                    )
+                                   )
+                                 
+                                )
+                                extent: (Point 659 457)
+                              )
+                             (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 328 25)
+                                    )
+                                   (ActionButtonSpec
+                                      label: 'Remove repository'
+                                      name: 'RemoveConfigurationAction'
+                                      translateLabel: true
+                                      model: removeRepositoryAction
+                                      enableChannel: mcEnabled
+                                      extent: (Point 328 25)
+                                    )
+                                   )
+                                 
+                                )
+                                extent: (Point 659 30)
+                              )
+                             )
+                           
+                          )
+                        )
+                       )
+                     
+                    )
+                    extent: (Point 695 525)
+                  )
+                 )
+               
+              )
+            )
+           )
+         
+        )
+      )
+! !
+
+!MCSettingsApp methodsFor:'accessing'!
+
+repositoryConfiguration
+
+    ^self repositoryConfigurationAspect value
+
+    "Created: / 26-05-2008 / 12:04:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+repositoryConfiguration: anObject
+
+    self repositoryConfigurationAspect value: anObject
+
+    "Created: / 26-05-2008 / 12:12:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+repositoryConfigurationList
+
+    ^self repositoryConfigurationListAspect value
+
+    "Created: / 26-05-2008 / 12:05:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+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:'Fill in data' lines:10 columns:40 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>"
+!
+
+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>"
+! !
+
+!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.1 2011-08-20 12:26:34 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCSettingsApp.st,v 1.1 2011-08-20 12:26:34 cg Exp $'
+!
+
+version_SVN
+    ^ '§Id: MCSettingsApp.st 33 2011-07-21 11:26:12Z vranyj1 §'
+! !