#REFACTORING
authorClaus Gittinger <cg@exept.de>
Thu, 19 Nov 2015 17:28:34 +0100
changeset 15956 786250fa05b8
parent 15955 2e5a87fdd779
child 15957 efc2024eefb8
#REFACTORING class: AbstractSettingsApplication allSettings preps
AbstractSettingsApplication.st
--- a/AbstractSettingsApplication.st	Thu Nov 19 17:26:14 2015 +0100
+++ b/AbstractSettingsApplication.st	Thu Nov 19 17:28:34 2015 +0100
@@ -22,7 +22,8 @@
 !
 
 AbstractSettingsApplication subclass:#AllSettingsAppl
-	instanceVariableNames:'buildDirectory localBuild selectedCompiler usedCompilerForBuild'
+	instanceVariableNames:'buildDirectory localBuild selectedCompiler usedCompilerForBuild
+		selectedSettingHolder settingsList'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:AbstractSettingsApplication
@@ -986,156 +987,56 @@
      the UIPainter may not be able to read the specification."
 
     "
-     UIPainter new openOnClass:AbstractSettingsApplication::BuildSettingsAppl andSelector:#windowSpec
-     AbstractSettingsApplication::BuildSettingsAppl new openInterface:#windowSpec
-     AbstractSettingsApplication::BuildSettingsAppl open
+     UIPainter new openOnClass:AbstractSettingsApplication::AllSettingsAppl andSelector:#windowSpec
+     AbstractSettingsApplication::AllSettingsAppl new openInterface:#windowSpec
+     AbstractSettingsApplication::AllSettingsAppl open
     "
 
     <resource: #canvas>
 
-    ^
-     #(FullSpec
-        name: windowSpec
-        window:
-       (WindowSpec
-          label: 'Build Settings'
-          name: 'Build Settings'
-          min: (Point 10 10)
-          bounds: (Rectangle 0 0 659 242)
-        )
-        component:
-       (SpecCollection
-          collection: (
-           (VerticalPanelViewSpec
-              name: 'VerticalPanel3'
-              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
-              horizontalLayout: fit
-              verticalLayout: top
-              horizontalSpace: 3
-              verticalSpace: 4
-              component:
-             (SpecCollection
-                collection: (
-                 (FramedBoxSpec
-                    label: 'Build Directory'
-                    name: 'FramedBox1'
-                    labelPosition: topLeft
-                    translateLabel: true
-                    component:
-                   (SpecCollection
-                      collection: (
-                       (ViewSpec
-                          name: 'LocalBuild'
-                          layout: (LayoutFrame 0 0.0 0 0 0 1.0 25 0)
-                          activeHelpKey: localBuild
-                          component:
-                         (SpecCollection
-                            collection: (
-                             (CheckBoxSpec
-                                label: 'Local Build (Do not use Repository)'
-                                name: 'CheckBox4'
-                                layout: (LayoutFrame 2 0 5 0 -5 1 27 0)
-                                enableChannel: hasSourceCodeManager
-                                activeHelpKey: localBuild
-                                model: localBuild
-                                translateLabel: true
-                              )
-                             )
-
-                          )
-                        )
-                       (ViewSpec
-                          name: 'Build Directory'
-                          layout: (LayoutFrame 0 0 40 0 0 1 70 0)
-                          component:
-                         (SpecCollection
-                            collection: (
-                             (LabelSpec
-                                label: 'Build Directory:'
-                                name: 'BuildDirDirLabel'
-                                layout: (LayoutFrame 0 0.0 0 0 60 0.25 22 0)
-                                translateLabel: true
-                                adjust: right
-                    activeHelpKey: buildDirectory
-                              )
-                             (FilenameInputFieldSpec
-                                name: 'FilenameEntryField1'
-                                layout: (LayoutFrame 221 0 0 0 0 1 22 0)
-                                enableChannel: localBuild
-                                model: buildDirectory
-                                acceptOnReturn: true
-                                acceptOnTab: true
-                                acceptOnLostFocus: true
-                                acceptOnPointerLeave: true
-                                viewClassName: FilenameWidgetWithHistory
-                                postBuildCallback: postBuildDirectoryField:
-                    activeHelpKey: buildDirectory
-                              )
-                             )
-
-                          )
-                        )
-                       (HorizontalPanelViewSpec
-                          name: 'ActionsHorizontalPanel'
-                          layout: (LayoutFrame 62 0.25 67 0 0 1 96 0)
-                          horizontalLayout: fitSpace
-                          verticalLayout: center
-                          horizontalSpace: 3
-                          verticalSpace: 3
-                          component:
-                         (SpecCollection
-                            collection: (
-                             (ActionButtonSpec
-                                label: 'Cleanup Build Directory'
-                                name: 'CleanupBuildDirectoryButton'
-                                translateLabel: true
-                                tabable: true
-                                model: cleanupBuildDirectory
-                                extent: (Point 401 22)
-                              )
-                             )
-
-                          )
-                        )
-                       )
-
-                    )
-                    extent: (Point 659 128)
-                  )
-                 (ViewSpec
-                    name: 'Box1'
-                    component:
-                   (SpecCollection
-                      collection: (
-                       (LabelSpec
-                          label: 'Compiler for Build:'
-                          name: 'Label1'
-                          layout: (LayoutFrame 0 0 0 0 150 0 22 0)
-                          translateLabel: true
-                          adjust: right
-                        )
-                       (ComboListSpec
-                          name: 'ComboList1'
-                          layout: (LayoutFrame 150 0 0 0 300 0 20 0)
-                          model: usedCompilerForBuild
-                          comboList: listOfPossibleCompilers
-                          useIndex: false
-                        )
-                       )
-
-                    )
-                    extent: (Point 659 25)
-                  )
-                 )
-
-              )
-            )
+    ^ 
+    #(FullSpec
+       name: windowSpec
+       window: 
+      (WindowSpec
+         label: 'All Settings'
+         name: 'All Settings'
+         min: (Point 10 10)
+         bounds: (Rectangle 0 0 659 242)
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (DataSetSpec
+             name: 'Table1'
+             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+             model: selectedSettingHolder
+             hasHorizontalScrollBar: true
+             hasVerticalScrollBar: true
+             dataList: settingsList
+             columns: 
+            (OrderedCollection
+               
+              (DataSetColumnSpec
+                 label: 'Name'
+                 labelButtonType: Button
+                 height: heightOfFirstRow
+                 model: key
+                 menuFromApplication: false
+               ) 
+              (DataSetColumnSpec
+                 label: 'Value'
+                 labelButtonType: Button
+                 height: heightOfFirstRow
+                 model: value
+                 menuFromApplication: false
+               )
+             )
            )
-
-        )
-      )
-
-    "Modified: / 22-01-2012 / 10:59:44 / cg"
+          )
+        
+       )
+     )
 ! !
 
 !AbstractSettingsApplication::AllSettingsAppl methodsFor:'actions'!
@@ -1204,6 +1105,32 @@
     ^ buildDirectory.
 !
 
+fetchSettingsList
+    |list|
+
+    list := List new.
+    UserPreferences selectorsAndMethodsDo:[:sel :mthd|
+        |setter getter getterMethod|
+        
+        sel numArgs == 1 ifTrue:[
+            (sel endsWith:$:) ifTrue:[
+                setter := sel.
+                getter := sel copyButLast asSymbolIfInterned.
+                getter notNil ifTrue:[
+                    (UserPreferences implements:getter) ifTrue:[
+                        getterMethod := UserPreferences compiledMethodAt:getter.
+                        getterMethod isObsolete ifFalse:[
+                            list add:(sel -> (UserPreferences current perform:getter)).
+                        ].    
+                    ].    
+                ].    
+            ].
+        ].
+    ].
+    list sortBySelector:#key.
+    ^ list
+!
+
 hasSourceCodeManager
     ^ SourceCodeManager notNil
 !
@@ -1222,6 +1149,42 @@
     ^ localBuild.
 !
 
+selectedSettingHolder
+    <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 ;-)"
+
+    selectedSettingHolder isNil ifTrue:[
+        selectedSettingHolder := ValueHolder new.
+"/ if your app needs to be notified of changes, uncomment one of the lines below:
+"/       selectedSettingHolder addDependent:self.
+"/       selectedSettingHolder onChangeSend:#selectedSettingHolderChanged to:self.
+    ].
+    ^ selectedSettingHolder.
+!
+
+settingsList
+    <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 ;-)"
+
+    settingsList isNil ifTrue:[
+        settingsList := self fetchSettingsList.
+        
+    ].
+    ^ settingsList.
+!
+
 usedCompilerForBuild
     usedCompilerForBuild isNil ifTrue:[
 	usedCompilerForBuild := nil asValue.