SettingsDialog.st
branchjv
changeset 15566 184cea584be5
parent 13609 8b400fde34ef
parent 15523 429b7e780d5a
child 15609 9e16a127f90a
--- a/SettingsDialog.st	Sun Jan 12 23:30:25 2014 +0000
+++ b/SettingsDialog.st	Wed Apr 01 10:38:01 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2002 by eXept Software AG
               All Rights Reserved
@@ -11,6 +13,8 @@
 "
 "{ Package: 'stx:libtool' }"
 
+"{ NameSpace: Smalltalk }"
+
 ApplicationModel subclass:#SettingsDialog
 	instanceVariableNames:'requestor subCanvasApplicationHolder help doReload doSave
 		enableReload enableHelp enableOK selectedItem applicationList
@@ -35,7 +39,7 @@
 !
 
 AbstractSettingsApplication subclass:#SettingsFilenameAppl
-	instanceVariableNames:''
+	instanceVariableNames:'settingsFilenameHolder infoLabelHolder'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:SettingsDialog
@@ -191,52 +195,54 @@
 !
 
 defaultSettingsApplicationList
-    ^ #(          
-        #('Language'                            #'AbstractSettingsApplication::LanguageSettingsAppl'            )
-        #('Keyboard Mappings'                   #'AbstractSettingsApplication::KbdMappingSettingsAppl'          )
-        #('ViewStyle'                           #'AbstractSettingsApplication::MiscDisplaySettingsAppl'         )
-        #('ViewStyle/Style'                     #'AbstractSettingsApplication::StyleSettingsAppl'               )
-        #('ViewStyle/Other'                     #'AbstractSettingsApplication::MiscDisplay2SettingsAppl'        )
-        #('ViewStyle/Fonts'                     #'AbstractSettingsApplication::FontSettingsAppl'                )
-        #('System Messages'                     #'AbstractSettingsApplication::SystemMessageSettingsAppl'       )
-        #('Memory'                              #'AbstractSettingsApplication::MemorySettingsAppl'              )
-        #('Processor & Scheduler'               #'AbstractSettingsApplication::ProcessorSchedulerSettingsAppl'  )
-        #('Tools'                               #'AbstractSettingsApplication::ToolsSettingsAppl'               )
-        #('Tools/Toolbox'                       #'AbstractSettingsApplication::ToolboxSettingsAppl'             )
-        #('Tools/Editor'                        #'AbstractSettingsApplication::EditSettingsAppl'                )
-        #('Tools/Editor/Code Editor 2'          #'Tools::CodeView2SettingsAppl'                                 )
-        #('Tools/Editor/Syntax Color'           #'AbstractSettingsApplication::SyntaxColorSettingsAppl'         )
-        #('Tools/Editor/Code Format'            #'AbstractSettingsApplication::SourceCodeFormatSettingsAppl'    )
-        #('Tools/System Browser'                #'AbstractSettingsApplication::SystemBrowserSettingsAppl'       )
-        #('Tools/System Browser/Code Generator' #'AbstractSettingsApplication::CodeGeneratorSettingsAppl'       )
-        #('Tools/Changes'                       #'AbstractSettingsApplication::ChangeFileSettingsAppl'          )
-        #('Tools/Debugger'                      #'AbstractSettingsApplication::DebuggerSettingsAppl'            )
-        #('Tools/Compiler'                      #'AbstractSettingsApplication::GeneralCompilerSettingsAppl'     )
-        #('Tools/Compiler/ByteCode'             #'AbstractSettingsApplication::ByteCodeCompilerSettingsAppl'    )
-        #('Tools/Compiler/STC'                  #'AbstractSettingsApplication::STCCompilerSettingsAppl'         )
-        #('Tools/Compiler/Build'                #'AbstractSettingsApplication::BuildSettingsAppl'         )
-        #('Source Code Management'              #'AbstractSettingsApplication::SourceCodeManagementSettingsAppl')
-        "/ see initializeSettingsList for how the following is expanded...
-        #('Source Code Management/[% managerTypeName]'     
-                                                '[ AbstractSourceCodeManager availableManagers 
-                                                     collect:[:each | each settingsApplicationClass] ]'    
-                                                                                                            '[% defaultIcon]' )
-"/        #('Source Code Management/CVS'          #'CVSSourceCodeManagementSettingsAppl')
-"/        #('Source Code Management/PerForce'     #'P4SourceCodeManagementSettingsAppl')
-"/        #('Source Code Management/SVN'          #'SVN::SettingsApp' )
-"/        #('Source Code Management/Store'        #'StoreSourceCodeManagementSettingsAppl')
-"/        #('Source Code Management/SmallTeam'    #'SmallTeamSourceCodeManagementSettingsAppl')
-        #('Printer'                             #'AbstractSettingsApplication::PrinterSettingsAppl'             )
-        #('Display'                             #'AbstractSettingsApplication::DisplaySettingsAppl'             )
-        #('Communication'                       nil                                                         #communicationIcon)
+    ^ OrderedCollection new
+        addAll:#(          
+                #('Language'                            #'AbstractSettingsApplication::LanguageSettingsAppl'            )
+                #('Keyboard Mappings'                   #'AbstractSettingsApplication::KbdMappingSettingsAppl'          )
+                #('ViewStyle'                           #'AbstractSettingsApplication::MiscDisplaySettingsAppl'         )
+                #('ViewStyle/Style'                     #'AbstractSettingsApplication::StyleSettingsAppl'               )
+                #('ViewStyle/Other'                     #'AbstractSettingsApplication::MiscDisplay2SettingsAppl'        )
+                #('ViewStyle/Fonts'                     #'Tools::FontSettingsApplication'                               )
+                #('System Messages'                     #'AbstractSettingsApplication::SystemMessageSettingsAppl'       )
+                #('Memory'                              #'AbstractSettingsApplication::MemorySettingsAppl'              )
+                #('Processor & Scheduler'               #'AbstractSettingsApplication::ProcessorSchedulerSettingsAppl'  )
+                #('Tools'                               #'AbstractSettingsApplication::ToolsSettingsAppl'               )
+                #('Tools/Toolbox'                       #'AbstractSettingsApplication::ToolboxSettingsAppl'             )
+                #('Tools/Editor'                        #'AbstractSettingsApplication::EditSettingsAppl'                )
+                #('Tools/Editor/Code Editor 2'          #'Tools::CodeView2SettingsAppl'                                 )
+                #('Tools/Editor/Syntax Color'           #'AbstractSettingsApplication::SyntaxColorSettingsAppl'         )
+                #('Tools/Editor/Code Format'            #'AbstractSettingsApplication::SourceCodeFormatSettingsAppl'    )
+                #('Tools/System Browser'                #'AbstractSettingsApplication::SystemBrowserSettingsAppl'       )
+                #('Tools/System Browser/Code Generator' #'AbstractSettingsApplication::CodeGeneratorSettingsAppl'       )
+                #('Tools/Changes'                       #'AbstractSettingsApplication::ChangeFileSettingsAppl'          )
+                #('Tools/Debugger'                      #'AbstractSettingsApplication::DebuggerSettingsAppl'            )
+                #('Tools/Terminal'                      #'AbstractSettingsApplication::TerminalViewSettingsAppl'        )
+                #('Tools/Compiler'                      #'AbstractSettingsApplication::GeneralCompilerSettingsAppl'     )
+                #('Tools/Compiler/ByteCode'             #'AbstractSettingsApplication::ByteCodeCompilerSettingsAppl'    )
+                #('Tools/Compiler/STC'                  #'AbstractSettingsApplication::STCCompilerSettingsAppl'         )
+                #('Tools/Compiler/Build'                #'AbstractSettingsApplication::BuildSettingsAppl'               )
+                #('Source Code Management'              #'AbstractSettingsApplication::SourceCodeManagementSettingsAppl')
+            );
+        add:
+            "/ see initializeSettingsList for how the following is expanded...
+            { 'Source Code Management/[% managerTypeName]' .     
+                                                 [ AbstractSourceCodeManager availableManagers 
+                                                     collect:[:each | each settingsApplicationClass] ] .    
+                                                                                              '[% defaultIcon]' };
+        addAll: 
+            #(
+                #('Printer'                             #'AbstractSettingsApplication::PrinterSettingsAppl'             )
+                #('Display'                             #'AbstractSettingsApplication::DisplaySettingsAppl'             )
+                #('Communication'                       nil                                           #communicationIcon)
 
-        #('Communication/Logging'               #'AbstractSettingsApplication::CommunicationLoggingSettingsAppl')
-        #('Communication/RDoIt'                 #'AbstractSettingsApplication::RDoItServerSettingsAppl'         )
-        #('Communication/OSI Protocol'          #'AbstractSettingsApplication::OsiSettingsAppl'                 )
-        #('Communication/Misc'                  #'AbstractSettingsApplication::MiscCommunicationSettingsAppl'   )
-        #('Communication/SQLServer'             #'AbstractSettingsApplication::SQLServerSettingsAppl'           )
-        #('Communication/HTTPServer'            #'AbstractSettingsApplication::HTTPStartServerSettingsApplication'   )
-    ) asOrderedCollection
+                #('Communication/Logging'               #'AbstractSettingsApplication::CommunicationLoggingSettingsAppl')
+                #('Communication/RDoIt'                 #'AbstractSettingsApplication::RDoItServerSettingsAppl'         )
+                #('Communication/OSI Protocol'          #'AbstractSettingsApplication::OsiSettingsAppl'                 )
+                #('Communication/Misc'                  #'AbstractSettingsApplication::MiscCommunicationSettingsAppl'   )
+                #('Communication/SQLServer'             #'AbstractSettingsApplication::SQLServerSettingsAppl'           )
+                #('Communication/HTTPServer'            #'AbstractSettingsApplication::HTTPStartServerSettingsApplication'   )
+            );
+        yourself
 
     "Modified: / 16-12-2002 / 18:12:28 / penk"
     "Modified: / 25-11-2011 / 15:28:42 / cg"
@@ -300,173 +306,176 @@
     <resource: #canvas>
 
     ^ 
-     #(FullSpec
-        name: windowSpec
-        window: 
-       (WindowSpec
-          label: 'Settings Dialog'
-          name: 'Settings Dialog'
-          min: (Point 10 10)
-          bounds: (Rectangle 0 0 789 642)
-          menu: mainMenu
-          icon: defaultIcon
-        )
-        component: 
-       (SpecCollection
-          collection: (
-           (VariableHorizontalPanelSpec
-              name: 'VariableHorizontalPanel1'
-              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
-              showHandle: true
-              snapMode: both
-              component: 
-             (SpecCollection
-                collection: (
-                 (ViewSpec
-                    name: 'Box1'
-                    component: 
-                   (SpecCollection
-                      collection: (
-                       (HierarchicalListViewSpec
-                          name: 'HierarchicalListView1'
-                          layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
-                          model: selectedItem
-                          hasHorizontalScrollBar: true
-                          hasVerticalScrollBar: true
-                          listModel: applicationList
-                          useIndex: false
-                          highlightMode: label
-                          showLeftIndicators: false
-                          indicatorSelector: doIndicatorClick:
-                        )
-                       (HorizontalPanelViewSpec
-                          name: 'HorizontalPanel2'
-                          layout: (LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
-                          visibilityChannel: loadAndSaveSettingsItemVisible
-                          horizontalLayout: fitSpace
-                          verticalLayout: center
-                          horizontalSpace: 3
-                          verticalSpace: 3
-                          component: 
-                         (SpecCollection
-                            collection: (
-                             (ActionButtonSpec
-                                label: 'Save'
-                                name: 'Button3'
-                                activeHelpKey: saveSettingsToFile
-                                translateLabel: true
-                                tabable: true
-                                model: saveSettingsWithoutAskingForFile
-                                extent: (Point 126 22)
-                              )
-                             (ActionButtonSpec
-                                label: 'Load From...'
-                                name: 'Button2'
-                                activeHelpKey: loadSettingsFromFile
-                                translateLabel: true
-                                tabable: true
-                                model: loadSettingsFromFile
-                                extent: (Point 126 22)
-                              )
+    #(FullSpec
+       name: windowSpec
+       window: 
+      (WindowSpec
+         label: 'Settings Dialog'
+         name: 'Settings Dialog'
+         min: (Point 10 10)
+         bounds: (Rectangle 0 0 789 642)
+         menu: mainMenu
+         icon: defaultIcon
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (VariableHorizontalPanelSpec
+             name: 'VariableHorizontalPanel1'
+             layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+             showHandle: true
+             snapMode: both
+             component: 
+            (SpecCollection
+               collection: (
+                (ViewSpec
+                   name: 'Box1'
+                   component: 
+                  (SpecCollection
+                     collection: (
+                      (HierarchicalListViewSpec
+                         name: 'HierarchicalListView1'
+                         layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
+                         model: selectedItem
+                         hasHorizontalScrollBar: true
+                         hasVerticalScrollBar: true
+                         listModel: applicationList
+                         useIndex: false
+                         highlightMode: label
+                         showLeftIndicators: false
+                         indicatorSelector: doIndicatorClick:
+                       )
+                      (HorizontalPanelViewSpec
+                         name: 'HorizontalPanel2'
+                         layout: (LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
+                         visibilityChannel: loadAndSaveSettingsItemVisible
+                         horizontalLayout: fitSpace
+                         verticalLayout: center
+                         horizontalSpace: 3
+                         verticalSpace: 3
+                         component: 
+                        (SpecCollection
+                           collection: (
+                            (ActionButtonSpec
+                               label: 'Save'
+                               name: 'Button3'
+                               activeHelpKey: saveSettingsToFile
+                               translateLabel: true
+                               tabable: true
+                               model: saveSettingsWithoutAskingForFile
+                               extent: (Point 126 22)
                              )
-                           
-                          )
-                        )
+                            (ActionButtonSpec
+                               label: 'Load From...'
+                               name: 'Button2'
+                               activeHelpKey: loadSettingsFromFile
+                               translateLabel: true
+                               tabable: true
+                               model: loadSettingsFromFile
+                               extent: (Point 126 22)
+                             )
+                            )
+                          
+                         )
                        )
-                     
-                    )
-                  )
-                 (ViewSpec
-                    name: 'Box2'
-                    component: 
-                   (SpecCollection
-                      collection: (
-                       (ViewSpec
-                          name: 'DisabledSettingsBox'
-                          layout: (LayoutFrame 0 0 0 0 0 1 0 1)
-                          initiallyInvisible: true
-                          component: 
-                         (SpecCollection
-                            collection: (
-                             (LabelSpec
-                                label: 'whyDisabledLabel'
-                                name: 'whyDisabledLabel'
-                                layout: (LayoutFrame 0 0 0 0 0 1 0 1)
-                                translateLabel: true
-                                labelChannel: whyDisabledInfoHolder
-                              )
+                      )
+                    
+                   )
+                 )
+                (ViewSpec
+                   name: 'Box2'
+                   component: 
+                  (SpecCollection
+                     collection: (
+                      (ViewSpec
+                         name: 'DisabledSettingsBox'
+                         layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+                         initiallyInvisible: true
+                         component: 
+                        (SpecCollection
+                           collection: (
+                            (LabelSpec
+                               label: 'whyDisabledLabel'
+                               name: 'whyDisabledLabel'
+                               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+                               translateLabel: true
+                               labelChannel: whyDisabledInfoHolder
                              )
-                           
-                          )
-                        )
-                       (SubCanvasSpec
-                          name: 'SubCanvas'
-                          layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
-                          level: -1
-                          hasHorizontalScrollBar: false
-                          hasVerticalScrollBar: false
-                          clientHolder: subCanvasApplicationHolder
-                          createNewBuilder: false
-                          postBuildCallback: postBuildSubCanvas:
-                        )
-                       (HorizontalPanelViewSpec
-                          name: 'HorizontalPanel1'
-                          layout: (LayoutFrame 0 0.0 -34 1 0 1.0 0 1)
-                          horizontalLayout: fitSpace
-                          verticalLayout: center
-                          horizontalSpace: 3
-                          verticalSpace: 3
-                          component: 
-                         (SpecCollection
-                            collection: (
-                             (ActionButtonSpec
-                                label: 'Apply'
-                                name: 'Apply'
-                                activeHelpKey: acceptChangedSettings
-                                translateLabel: true
-                                tabable: true
-                                model: doSave
-                                enableChannel: enableOK
-                                extent: (Point 168 22)
-                              )
-                             (ActionButtonSpec
-                                label: 'Discard'
-                                name: 'Reload'
-                                activeHelpKey: discardChangedSettings
-                                translateLabel: true
-                                tabable: true
-                                model: doReload
-                                enableChannel: enableReload
-                                extent: (Point 169 22)
-                              )
-                             (ActionButtonSpec
-                                label: 'Help'
-                                name: 'Help'
-                                activeHelpKey: helpOnSettings
-                                translateLabel: true
-                                tabable: true
-                                model: help
-                                enableChannel: enableHelp
-                                extent: (Point 169 22)
-                              )
+                            )
+                          
+                         )
+                       )
+                      (SubCanvasSpec
+                         name: 'SubCanvas'
+                         layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
+                         level: -1
+                         hasHorizontalScrollBar: true
+                         hasVerticalScrollBar: true
+                         miniScrollerHorizontal: false
+                         miniScrollerVertical: false
+                         clientHolder: subCanvasApplicationHolder
+                         createNewBuilder: false
+                         postBuildCallback: postBuildSubCanvas:
+                       )
+                      (HorizontalPanelViewSpec
+                         name: 'HorizontalPanel1'
+                         layout: (LayoutFrame 0 0.0 -34 1 -16 1.0 0 1)
+                         horizontalLayout: fitSpace
+                         verticalLayout: center
+                         horizontalSpace: 3
+                         verticalSpace: 3
+                         reverseOrderIfOKAtLeft: true
+                         component: 
+                        (SpecCollection
+                           collection: (
+                            (ActionButtonSpec
+                               label: 'Help'
+                               name: 'Help'
+                               activeHelpKey: helpOnSettings
+                               translateLabel: true
+                               tabable: true
+                               model: help
+                               enableChannel: enableHelp
+                               extent: (Point 163 22)
                              )
-                           
-                          )
-                          keepSpaceForOSXResizeHandleH: true
-                        )
+                            (ActionButtonSpec
+                               label: 'Discard'
+                               name: 'Reload'
+                               activeHelpKey: discardChangedSettings
+                               translateLabel: true
+                               tabable: true
+                               model: doReload
+                               enableChannel: enableReload
+                               extent: (Point 163 22)
+                             )
+                            (ActionButtonSpec
+                               label: 'Apply'
+                               name: 'Apply'
+                               activeHelpKey: acceptChangedSettings
+                               translateLabel: true
+                               tabable: true
+                               model: doSave
+                               enableChannel: enableOK
+                               extent: (Point 164 22)
+                             )
+                            )
+                          
+                         )
+                         keepSpaceForOSXResizeHandleH: true
                        )
-                     
-                    )
-                  )
+                      )
+                    
+                   )
                  )
-               
-              )
-              handles: (Any 0.3375 1.0)
-            )
+                )
+              
+             )
+             handles: (Any 0.33750000000000002 1.0)
            )
-         
-        )
-      )
+          )
+        
+       )
+     )
 ! !
 
 !SettingsDialog class methodsFor:'menu actions'!
@@ -492,7 +501,7 @@
     "Modified: / 27-10-2010 / 11:24:54 / cg"
 !
 
-saveSettingsAsDefaultSettings
+currentSettingsFilename
     | file |
 
     "JV@2012-02-07: Changed to save preferences back to file from which
@@ -503,7 +512,11 @@
     file isNil ifTrue:[
         file := UserPreferences defaultUserSettingsFile.
     ].
-    self saveSettingsTo:file.
+    ^ file.
+!
+
+saveSettingsAsDefaultSettings
+    self saveSettingsTo:(self currentSettingsFilename).
 
     "Modified: / 07-02-2012 / 00:45:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
@@ -532,6 +545,7 @@
     "Do not manually edit this!! If it is corrupted,
      the MenuEditor may not be able to read the specification."
 
+
     "
      MenuEditor new openOnClass:SettingsDialog andSelector:#mainMenu
      (Menu new fromLiteralArrayEncoding:(SettingsDialog mainMenu)) startUp
@@ -544,14 +558,12 @@
         (
          (MenuItem
             label: '&File'
-            translateLabel: true
             submenu: 
            (Menu
               (
                (MenuItem
                   label: '&Load From...'
                   itemValue: loadSettingsFromFile
-                  translateLabel: true
                   isVisible: loadAndSaveSettingsItemVisible
                 )
                (MenuItem
@@ -561,13 +573,11 @@
                (MenuItem
                   label: 'Save'
                   itemValue: saveSettingsWithoutAskingForFile
-                  translateLabel: true
                   isVisible: loadAndSaveSettingsItemVisible
                 )
                (MenuItem
                   label: '&Save As...'
                   itemValue: askForFileAndSaveSettings
-                  translateLabel: true
                   isVisible: loadAndSaveSettingsItemVisible
                 )
                (MenuItem
@@ -577,7 +587,24 @@
                (MenuItem
                   label: 'E&xit'
                   itemValue: closeRequest
-                  translateLabel: true
+                )
+               )
+              nil
+              nil
+            )
+          )
+         (MenuItem
+            label: 'View'
+            submenu: 
+           (Menu
+              (
+               (MenuItem
+                  label: 'Expand All'
+                  itemValue: menuExpandAll
+                )
+               (MenuItem
+                  label: 'Collapse All'
+                  itemValue: menuCollapseAll
                 )
                )
               nil
@@ -590,6 +617,33 @@
       )
 ! !
 
+!SettingsDialog class methodsFor:'startup'!
+
+openWithList:settingsList label:label
+    ^ self 
+        openWithList:settingsList 
+        label:label 
+        initialSettingsClass:nil
+!
+
+openWithList:settingsList label:label initialSettingsClass:settingsClassToSelectOrNil
+    "given a list of page-label/class pairs,
+     open a settings dialog showing that set of items."
+
+    |settingsApp|
+
+    settingsApp := SettingsDialog new.
+    settingsApp installSettingsEntries:settingsList.
+    settingsApp allButOpen.
+    settingsApp showRoot: false.
+    settingsApp window label:label.
+    settingsClassToSelectOrNil notNil ifTrue:[
+        settingsApp selectItemWithClass: settingsClassToSelectOrNil.
+    ].
+    settingsApp openWindow.
+    ^ settingsApp
+! !
+
 !SettingsDialog methodsFor:'accessing'!
 
 requestor
@@ -637,6 +691,10 @@
     ]
 
     "Modified: / 15-10-2011 / 12:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+subCanvasApplication
+    ^ self subCanvasApplicationHolder value
 ! !
 
 !SettingsDialog methodsFor:'actions'!
@@ -652,15 +710,7 @@
 !
 
 destroyAll
-    self applicationList do:[:applItem |
-        |application|
-
-        applItem isCategory ifFalse:[
-            (application := applItem application) notNil ifTrue:[
-                application close.
-            ].
-        ].
-    ].
+    self realApplicationsDo:[:app | app close ].
 !
 
 doIndicatorClick:index 
@@ -707,59 +757,82 @@
 !
 
 reopenLauncher
-    self requestor notNil ifTrue:[
-        self requestor reopenLauncher.
+    "force the launcher to reopen an instance of itself.
+     Done whenever relevant look&feel settings are changed
+     (actually a workaround - a much better solution would be to teach
+     all smalltalk applications/views to dynamically update their style)."
+
+    |app|
+
+    (app := self requestor) notNil ifTrue:[
+        app reopenLauncher.
     ] ifFalse:[
         NewLauncher current reopenLauncher.
     ].
 !
 
 sendLoadRequestToAll
-    self applicationList do:[:applItem | 
-        (applItem isCategory not and:[applItem application notNil]) ifTrue:[
-            applItem application readSettings.
-        ]
+    "ask all subApps to reload their idea of the current settings.
+     Do this, after userPrefs have been loaded from a file,
+     while a settingsDialog is open"
+
+    self realApplicationsDo:[:app |
+        app readSettings.
+        app clearDidModifySettings.
     ].
 
     "Modified: / 24-08-2010 / 18:41:36 / sr"
 !
 
 sendSaveRequestToAll
-    self applicationList do:[ : applItem |
-        (applItem isCategory not and:[applItem application notNil]) ifTrue:[
-            applItem application saveRequest ifFalse:[
-                ^ false
-            ].
+    "give all subapps a chance to apply any changes.
+     No longer needed, as we do this at the time the subApp
+     is changed; so only the current app needs this chance again,
+     when about to close (seesendSaveRequestToCurrent) "
+
+    self realApplicationsDo:[ :app |
+        app saveRequest ifFalse:[
+            ^ false
         ].
     ].
     ^ true
 !
 
 sendSaveRequestToCurrent
-    | item |
+    "when about to close the dialog, give the current
+     subapp a chance to apply any changes"
+
+    | item currentApp |
 
     item := self selectedItem value.
-    (item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ true].
+    (item isNil 
+        or:[item isCategory 
+        or:[(currentApp := item application) isNil]]
+    ) ifTrue:[ ^ true].
+
     self withWaitCursorDo:[
-        ^ item application saveRequest.
+        ^ currentApp saveRequest.
     ].
     ^ true
 ! !
 
 !SettingsDialog methodsFor:'application list access'!
 
-addApplClass:aClass forApplication:anApplication label:aLabel expand:aBoolean
+addApplClass:aClassName forApplication:anApplication label:aLabel expand:aBoolean
     "add an application to the settingsTree, take the icon from the application classes defaultIcon method"
 
     | class |
 
-    class := Smalltalk classNamed:aClass.
+    class := Smalltalk classNamed:aClassName.
     class isNil ifTrue:[
-        ('SettingsDialog [warning]: can''t find ', aClass asString, ' to register') infoPrintCR.
+        ('SettingsDialog [warning]: can''t find ', aClassName asString, ' to register') infoPrintCR.
+        aClassName isString ifFalse:[
+            thisContext fullPrintAll.
+        ].
         ^ nil
     ].
     class autoload.
-    ^ self createItemForApplication:anApplication class:aClass label:aLabel icon:class defaultIcon expandParent:aBoolean replaceExisting:false
+    ^ self createItemForApplication:anApplication class:aClassName label:aLabel icon:class defaultIcon expandParent:aBoolean replaceExisting:false
 
     "Modified: / 14-02-2011 / 20:10:11 / cg"
 !
@@ -780,23 +853,26 @@
     ^ self addApplClass:aClass withName:aName icon:icon expand:false
 !
 
-addApplClass:aClass withName:aName icon:icon expand:doExpand
+addApplClass:aClassName withName:aName icon:icon expand:doExpand
     |applicationLabel locIcon locClass|
 
 "/    (self applicationNames includes:aName) ifTrue:[
 "/        ^ self getItemForName:aName.
 "/    ].
     
-    aClass isNil ifTrue:[ 
+    aClassName isNil ifTrue:[ 
         self addIcon:icon forCategory:aName.
         ^ self 
     ].
     self addCategoriesFor:aName.
 
     locIcon := icon.
-    locClass := Smalltalk classNamed:aClass.
+    locClass := Smalltalk classNamed:aClassName.
     locClass isNil ifTrue:[
-        ('SettingsDialog [warning]: can''t find ', aClass asString, ' to register') infoPrintCR.
+        ('SettingsDialog [warning]: can''t find ', aClassName asString, ' to register') infoPrintCR.
+        aClassName isString ifFalse:[
+            thisContext fullPrintAll.
+        ].
         ^ nil
     ].
     locClass autoload.
@@ -1213,6 +1289,22 @@
     "Modified: / 03-11-2007 / 14:23:28 / cg"
 !
 
+realApplications
+    "return a collection of all real (non-folder) applications.
+     A helper to avoid code duplication"
+
+    ^ self applicationList 
+        select:[:appItem | appItem isCategory not and:[ appItem application notNil]]
+        thenCollect:[:appItem | appItem application].
+!
+
+realApplicationsDo:aBlock
+    "evaluate aBlock for all real (non-folder) applications.
+     A helper to avoid code duplication"
+
+    self realApplications do:aBlock.
+!
+
 removeItem:anItem 
     "remove an application from the settingsTree"
 
@@ -1317,35 +1409,11 @@
 !SettingsDialog methodsFor:'change & update'!
 
 modifiedChanged
-    |changedObject|
-
-    changedObject := self subCanvasApplicationHolder value modifiedChannel.
-    self enableOK value:(changedObject value).
-    self enableReload value:(changedObject value).
-!
-
-selectItemWithClass:aClass
-    |entry|
+    |modified|
 
-    entry := applicationList root
-                recursiveDetect:[:entry | entry applicationClass = aClass].
-    entry notNil ifTrue:[
-        entry makeVisible.
-        self selectedItem value:entry
-    ].
-
-    "Created: / 29-10-2010 / 11:54:13 / cg"
-!
-
-selectItemWithName:aPathString
-    |entry|
-
-    entry := applicationList root
-                recursiveDetect:[:entry | entry nameString = aPathString].
-    entry notNil ifTrue:[
-        entry makeVisible.
-        self selectedItem value:entry
-    ].
+    modified := self subCanvasApplication modifiedChannel value.
+    self enableOK value:modified.
+    self enableReload value:modified.
 !
 
 selectionChanged
@@ -1353,7 +1421,7 @@
 
     self selectedItem value == lastSelection  ifTrue:[ ^ self].
 
-    oldAppl := self subCanvasApplicationHolder value.
+    oldAppl := self subCanvasApplication.
     oldAppl notNil ifTrue:[
         oldAppl saveRequest ifFalse:[
             lastSelection notNil ifTrue:[
@@ -1381,7 +1449,8 @@
     window notNil ifTrue:[
         lbl := self rootItemLabel ? 'Settings Dialog'.
         item notNil ifTrue:[
-            itemLabel := (item label copyReplaceAll:(Character cr) with:(Character space)).
+            itemLabel := item label.
+            itemLabel := itemLabel copyReplaceAll:(Character cr) with:(Character space) ifNone:itemLabel.
             itemLabel ~= lbl ifTrue:[
                 lbl := lbl , ' [', itemLabel, ']'.
             ]
@@ -1442,7 +1511,7 @@
         self selectionChanged.
         ^ self.
     ].
-    subCanvasApplication := self subCanvasApplicationHolder value.
+    subCanvasApplication := self subCanvasApplication.
     (subCanvasApplication notNil 
     and:[changedObject == subCanvasApplication modifiedChannel]) ifTrue:[
         self modifiedChanged.
@@ -1453,14 +1522,28 @@
 !SettingsDialog methodsFor:'initialization & release'!
 
 closeRequest
-    "This is a hook method generated by the Browser.
-     It will be invoked when your app/dialog-window is about to be
-     closed (this method has a chance to suppress the close).
+    "This is a hook method.
+     It will be invoked when your app/dialog-window is about to be closed.
+     This method has a chance to suppress the close by returning false.
      See also #closeDownViews, which is invoked when the close is really done."
 
     | req |
 
     (self sendSaveRequestToCurrent == false) ifTrue:[^ self].
+
+    "/ if any of my subApps has made a change, ask user if he wants
+    "/ to write the settings file
+    (self realApplications contains:[:app | app didModifySettings]) ifTrue:[
+        "D121136 - Filename doesnot understand allBold"
+        (Dialog 
+            confirm:(resources 
+                        stringWithCRs:'Save your changed settings in the settings file?\(which is: "%1"\\If not saved, these changes only apply to your current session.'
+                        with:self class currentSettingsFilename asString allBold))
+        ifTrue:[
+            self saveSettingsWithoutAskingForFile.
+        ].
+    ].
+
     self destroyAll.
 
     req := self requestor.
@@ -1502,10 +1585,12 @@
 !
 
 postOpenWith:aBuilder
+    |items|
+
     self rootItem expand.
     super postOpenWith:aBuilder.
-    self rootItem children size == 1 ifTrue:[
-        self selectedItem value: self rootItem children anyOne.
+    (items := self rootItem children) size == 1 ifTrue:[
+        self selectedItem value: items anyOne.
     ]
 
     "Modified: / 03-11-2007 / 14:23:25 / cg"
@@ -1516,6 +1601,7 @@
 
 askForFileAndSaveSettings
     self class askForFileAndSaveSettings.
+    self realApplicationsDo:[:app | app clearDidModifySettings].
 !
 
 loadSettingsFromFile
@@ -1524,7 +1610,11 @@
     "a temporary kludge - we need a central systemSettings object for this,
      which can be saved/restored with a single store/read."
 
-    |fileName transcript launcher|
+    |oldFile dir fileName transcript launcher|
+
+    (oldFile := UserPreferences current at:#settingsFilename) notNil ifTrue:[
+        dir := oldFile asFilename directory.
+    ].
 
     fileName := Dialog 
         requestFileName:(resources string:'Load Settings from File') 
@@ -1532,7 +1622,7 @@
         ok:(resources string:'Load') 
         abort:(resources string:'Cancel') 
         pattern:'*.stx'
-        fromDirectory:nil.
+        fromDirectory:dir.
 
     (fileName size == 0) ifTrue:[
         "/ canceled
@@ -1557,8 +1647,48 @@
     "Modified: / 08-09-2006 / 19:23:15 / cg"
 !
 
+menuCollapseAll
+    applicationList root children do:[:each | each collapse].
+!
+
+menuExpandAll
+    applicationList root children do:[:each | each recursiveExpand].
+!
+
 saveSettingsWithoutAskingForFile
     self class saveSettingsWithoutAskingForFile.
+    self realApplicationsDo:[:app | app clearDidModifySettings].
+! !
+
+!SettingsDialog methodsFor:'selection'!
+
+selectItemWithClass:aClass
+    "select an item based on the sub-settings application class"
+
+    |entry|
+
+    entry := applicationList root
+                recursiveDetect:[:entry | entry applicationClass = aClass].
+    entry notNil ifTrue:[
+        entry makeVisible.
+        self selectedItem value:entry
+    ].
+
+    "Created: / 29-10-2010 / 11:54:13 / cg"
+!
+
+selectItemWithName:aPathString
+    "select an item based on the sub-settings page name.
+     See standardRawSettingsList for a list of names"
+
+    |entry|
+
+    entry := applicationList root
+                recursiveDetect:[:entry | entry nameString = aPathString].
+    entry notNil ifTrue:[
+        entry makeVisible.
+        self selectedItem value:entry
+    ].
 ! !
 
 !SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'accessing'!
@@ -1646,7 +1776,9 @@
 
 canCollapse
     "the rootItem is cannot be collapsed"
-    ^ self isRootItem not
+
+    "/ first check if we are expanded, if not answer false
+    ^ (isExpanded and:[self isRootItem not])
 !
 
 isCategory
@@ -1654,6 +1786,25 @@
     ^ self applicationClass isNil
 ! !
 
+!SettingsDialog::SettingsFilenameAppl class methodsFor:'help specs'!
+
+flyByHelpSpec
+    <resource: #help>
+
+    ^ super flyByHelpSpec addPairsFrom:#(
+
+#openSettingsFile
+'Click to open a file browser on the settings file'
+
+#reloadSettingsFile
+'Reload the settings from the file'
+
+#saveAsPrivateSettingsFile
+'Save the settings into your private settings file'
+
+)
+! !
+
 !SettingsDialog::SettingsFilenameAppl class methodsFor:'interface specs'!
 
 windowSpec
@@ -1672,101 +1823,142 @@
     <resource: #canvas>
 
     ^ 
-     #(FullSpec
-        name: windowSpec
-        window: 
-       (WindowSpec
-          label: 'Settings File'
-          name: 'Settings File'
-          min: (Point 10 10)
-          bounds: (Rectangle 0 0 300 300)
-        )
-        component: 
-       (SpecCollection
-          collection: (
-           (LabelSpec
-              label: 'Preferences are stored in file:'
-              name: 'Label1'
-              layout: (LayoutFrame 0 0 -30 0.5 0 1 0 0.5)
-              translateLabel: true
-            )
-           (LinkButtonSpec
-              label: 'LinkButton'
-              name: 'EditPreferences'
-              layout: (LayoutFrame 0 0 0 0.5 0 1 30 0.5)
-              foregroundColor: (Color 0.0 0.0 100.0)
-              translateLabel: true
-              labelChannel: settingsFilenameAspect
-              model: openSettingsFile
-            )
-           (ActionButtonSpec
-              label: 'Edit'
-              name: 'Button1'
-              layout: (LayoutFrame -120 1 60 0.5 -20 1 85 0.5)
-              translateLabel: true
-              model: openSettingsFile
-            )
-           (ActionButtonSpec
-              label: 'Reload'
-              name: 'Button2'
-              layout: (LayoutFrame -230 1 60 0.5 -130 1 85 0.5)
-              translateLabel: true
-              model: reloadSettingsFile
-            )
+    #(FullSpec
+       name: windowSpec
+       window: 
+      (WindowSpec
+         label: 'Settings File'
+         name: 'Settings File'
+         min: (Point 10 10)
+         bounds: (Rectangle 0 0 426 359)
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (LabelSpec
+             name: 'InfoLabel'
+             layout: (LayoutFrame 0 0 -169 0.5 0 1 -45 0.5)
+             translateLabel: true
+             labelChannel: infoLabelHolder
+           )
+          (LabelSpec
+             label: 'Preferences are stored in file:'
+             name: 'Label1'
+             layout: (LayoutFrame 0 0 -30 0.5 0 1 0 0.5)
+             translateLabel: true
+           )
+          (LinkButtonSpec
+             label: 'LinkButton'
+             name: 'EditPreferences'
+             layout: (LayoutFrame 0 0 0 0.5 0 1 30 0.5)
+             activeHelpKey: openSettingsFile
+             foregroundColor: (Color 0.0 0.0 100.0)
+             translateLabel: true
+             labelChannel: settingsFilenameHolder
+             model: openSettingsFile
            )
-         
-        )
-      )
+          (HorizontalPanelViewSpec
+             name: 'HorizontalPanel1'
+             layout: (LayoutFrame 0 0 53 0.5 0 1 101 0.5)
+             horizontalLayout: centerMax
+             verticalLayout: center
+             horizontalSpace: 3
+             verticalSpace: 3
+             component: 
+            (SpecCollection
+               collection: (
+                (ActionButtonSpec
+                   label: 'Reload'
+                   name: 'Button2'
+                   activeHelpKey: reloadSettingsFile
+                   translateLabel: true
+                   model: reloadSettingsFile
+                   useDefaultExtent: true
+                 )
+                (ActionButtonSpec
+                   label: 'Save as Private'
+                   name: 'Button3'
+                   activeHelpKey: saveAsPrivateSettingsFile
+                   translateLabel: true
+                   model: saveAsPrivateSettingsFile
+                   useDefaultExtent: true
+                 )
+                (ActionButtonSpec
+                   label: 'File Browser'
+                   name: 'Button1'
+                   activeHelpKey: openSettingsFile
+                   translateLabel: true
+                   model: openSettingsFile
+                   useDefaultExtent: true
+                 )
+                )
+              
+             )
+           )
+          )
+        
+       )
+     )
+! !
+
+!SettingsDialog::SettingsFilenameAppl methodsFor:'actions'!
+
+openSettingsFile
+    self openSettingsFile: (self settingsFile)
+
+    "Created: / 07-02-2012 / 11:15:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+reloadSettingsFile
+    self reloadSettingsFile: (self settingsFile)
+
+    "Created: / 17-02-2012 / 10:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+saveAsPrivateSettingsFile
+    |fn|
+
+    fn := UserPreferences defaultUserSettingsFile pathName.
+    SettingsDialog saveSettingsTo:fn.
+    UserPreferences current at:#settingsFilename put:fn.
+    settingsFilenameHolder value:fn.
 ! !
 
 !SettingsDialog::SettingsFilenameAppl methodsFor:'aspects'!
 
-settingsFilenameAspect
-
-    | filename |
+infoLabelHolder
+    infoLabelHolder isNil ifTrue:[
+        infoLabelHolder := nil asValue.
+        infoLabelHolder value:
+                     (resources 
+                        stringWithCRs:(
+                            'Unless saved via the "Save"-Button,'
+                            , '\changes affect the current session only.')).
 
-    filename := UserPreferences current 
-                    at:#settingsFilename      
-                    ifAbsent:[UserPreferences defaultUserSettingsFile pathName].
-    ^filename asText
-"/        colorizeAllWith: Color blue;
-"/        actionForAll:[ self openSettingsFile: filename ].
+    ].
+    ^ infoLabelHolder
+!
+
+settingsFilenameHolder
+    settingsFilenameHolder isNil ifTrue:[
+        settingsFilenameHolder := nil asValue.
+        self basicReadSettings.
+    ].
+    ^ settingsFilenameHolder
 
     "Created: / 07-02-2012 / 01:08:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SettingsDialog::SettingsFilenameAppl methodsFor:'private'!
 
-openSettingsFile
-    | filename |
-
-    filename := UserPreferences current 
-                    at:#settingsFilename      
-                    ifAbsent:[UserPreferences defaultUserSettingsFile pathName].
-    self openSettingsFile: filename
-
-    "Created: / 07-02-2012 / 11:15:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 openSettingsFile: filename 
 
-    UserPreferences current fileBrowserClass
+    UserPreferences fileBrowserClass
         openOnFileNamed:filename editing:true
 
     "Created: / 07-02-2012 / 01:08:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-reloadSettingsFile
-    | filename |
-
-    filename := UserPreferences current 
-                    at:#settingsFilename      
-                    ifAbsent:[UserPreferences defaultUserSettingsFile pathName].
-    self reloadSettingsFile: filename
-
-    "Created: / 17-02-2012 / 10:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 reloadSettingsFile: filename 
 
     filename asFilename fileIn.
@@ -1778,15 +1970,33 @@
 !SettingsDialog::SettingsFilenameAppl methodsFor:'protocol'!
 
 basicReadSettings
-    ^self
+    |filename|
 
-    "Modified: / 07-02-2012 / 01:02:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    filename := self settingsFile.
+"/      filename := filename asText
+"/        colorizeAllWith: Color blue;
+"/        actionForAll:[ self openSettingsFile: filename ].
+    self settingsFilenameHolder value:filename.
 !
 
 basicSaveSettings
     ^self
 
     "Modified: / 07-02-2012 / 01:03:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+editorHelpRelativeWikiURL
+    "the relative URL of the dialog-description in the Wiki"
+
+    ^ 'Settings'
+!
+
+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.
 ! !
 
 !SettingsDialog::SettingsFilenameAppl methodsFor:'queries'!
@@ -1795,25 +2005,20 @@
     ^false
 
     "Modified: / 07-02-2012 / 01:03:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+settingsFile
+    ^ SettingsDialog currentSettingsFilename
 ! !
 
 !SettingsDialog class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.109 2013-09-11 11:51:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.128 2015-03-11 05:56:44 ca Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.109 2013-09-11 11:51:33 cg Exp $'
-!
-
-version_HG
-
-    ^ '$Changeset: <not expanded> $'
-!
-
-version_SVN
-    ^ '$Id: SettingsDialog.st,v 1.102 2013-05-21 20:32:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.128 2015-03-11 05:56:44 ca Exp $'
 ! !