*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Thu, 11 May 2006 19:53:47 +0200
changeset 6780 31249d86422b
parent 6779 3e95d8048f6f
child 6781 facbb533a366
*** empty log message ***
AbstractSettingsApplication.st
--- a/AbstractSettingsApplication.st	Thu May 11 19:05:55 2006 +0200
+++ b/AbstractSettingsApplication.st	Thu May 11 19:53:47 2006 +0200
@@ -383,6 +383,44 @@
     ^ modifiedChannel
 ! !
 
+!AbstractSettingsApplication methodsFor:'helpers'!
+
+readAspects:aListOfAspects from:anAspectProvider
+    "this code-sharing helper reads a bunch of aspect values from some object.
+     The object is typically the current userPreferences object, or a flag-holder, such
+     as ParserFlags.
+     Using this, and a list of aspect selectors replaces code like:
+        self aspect1 value:(someone aspect1).
+        self aspect2 value:(someone aspect2).
+        ...
+        self aspectN value:(someone aspectN).
+     Prerequisite:
+        local aspects must be named like corresponding aspect methods in the flag-provider.
+    "
+
+    aListOfAspects do:[:eachAspectSymbol |
+        (self perform:eachAspectSymbol) value:(anAspectProvider perform:eachAspectSymbol)
+    ].
+!
+
+writeAspects:aListOfAspects to:anAspectProvider
+    "this code-sharing helper writes a bunch of aspect values into some object.
+     The object is typically the current userPreferences object, or a flag-holder, such
+     as ParserFlags.
+     Using this, and a list of aspect selectors replaces code like:
+        someone aspect1:(self aspect1 value).
+        someone aspect2:(self aspect2 value).
+        ...
+        someone aspectN:(self aspectN value).
+     Prerequisite:
+        local aspects must be named like corresponding aspect methods in the flag-provider.
+    "
+
+    aListOfAspects do:[:eachAspectSymbol |
+        anAspectProvider perform:(eachAspectSymbol,':')asSymbol with:(self perform:eachAspectSymbol) value
+    ].
+! !
+
 !AbstractSettingsApplication methodsFor:'initialization'!
 
 initialize
@@ -906,33 +944,33 @@
 !AbstractSettingsApplication::ByteCodeCompilerSettingsAppl methodsFor:'actions'!
 
 basicReadSettings
-    #( 
-        allowDollarInIdentifier
-        allowDolphinExtensions
-        allowOldStyleAssignment
-        allowQualifiedNames
-        allowReservedWordsAsSelectors
-        allowSqueakExtensions
-        allowUnderscoreInIdentifier
-        allowVisualAgeESSymbolLiterals
-        allowFixedPointLiterals
-        arraysAreImmutable
-        warnings
-        warnCommonMistakes
-        warnPossibleIncompatibilities
-        warnDollarInIdentifier
-        warnOldStyleAssignment
-        warnSTXSpecials
-        warnUnderscoreInIdentifier
-        warnUnusedVars
-        warnAboutWrongVariableNames
-        warnAboutBadComments
-        warnInconsistentReturnValues
-        warnAboutLowercaseLocalVariableNames
-    )
-    do:[:aspect |
-        (self perform:aspect) value:(ParserFlags perform:aspect)
-    ].
+    self 
+        readAspects:
+            #( 
+                allowDollarInIdentifier
+                allowDolphinExtensions
+                allowOldStyleAssignment
+                allowQualifiedNames
+                allowReservedWordsAsSelectors
+                allowSqueakExtensions
+                allowUnderscoreInIdentifier
+                allowVisualAgeESSymbolLiterals
+                allowFixedPointLiterals
+                arraysAreImmutable
+                warnings
+                warnCommonMistakes
+                warnPossibleIncompatibilities
+                warnDollarInIdentifier
+                warnOldStyleAssignment
+                warnSTXSpecials
+                warnUnderscoreInIdentifier
+                warnUnusedVars
+                warnAboutWrongVariableNames
+                warnAboutBadComments
+                warnInconsistentReturnValues
+                warnAboutLowercaseLocalVariableNames
+            )
+        from:ParserFlags.
 
     self constantFoldingSelection 
         value:(self class constantFoldingOptions indexOf:Compiler foldConstants ifAbsent:3).
@@ -949,35 +987,33 @@
 !
 
 basicSaveSettings
-    "/ todo: move all compiler interface to ParserFlags
-
-    #( 
-        warnings
-        warnSTXSpecials
-        warnOldStyleAssignment
-        warnUnderscoreInIdentifier
-        warnDollarInIdentifier
-        warnCommonMistakes
-        warnPossibleIncompatibilities
-        warnUnusedVars
-        warnAboutWrongVariableNames
-        warnAboutBadComments
-        warnInconsistentReturnValues
-        warnAboutLowercaseLocalVariableNames
-        allowUnderscoreInIdentifier
-        allowDollarInIdentifier
-        allowSqueakExtensions
-        allowDolphinExtensions
-        allowQualifiedNames
-        allowOldStyleAssignment
-        allowReservedWordsAsSelectors
-        allowVisualAgeESSymbolLiterals
-        allowFixedPointLiterals
-        arraysAreImmutable
-    )
-    do:[:aspect |
-        ParserFlags perform:(aspect,':')asSymbol with:(self perform:aspect) value
-    ].
+    self 
+        writeAspects:
+            #( 
+                warnings
+                warnSTXSpecials
+                warnOldStyleAssignment
+                warnUnderscoreInIdentifier
+                warnDollarInIdentifier
+                warnCommonMistakes
+                warnPossibleIncompatibilities
+                warnUnusedVars
+                warnAboutWrongVariableNames
+                warnAboutBadComments
+                warnInconsistentReturnValues
+                warnAboutLowercaseLocalVariableNames
+                allowUnderscoreInIdentifier
+                allowDollarInIdentifier
+                allowSqueakExtensions
+                allowDolphinExtensions
+                allowQualifiedNames
+                allowOldStyleAssignment
+                allowReservedWordsAsSelectors
+                allowVisualAgeESSymbolLiterals
+                allowFixedPointLiterals
+                arraysAreImmutable
+            )
+        to:ParserFlags.
 
     self fullDebugSupport value ifTrue:[
         Compiler lineNumberInfo:#full.
@@ -2221,23 +2257,29 @@
 !AbstractSettingsApplication::EditSettingsAppl methodsFor:'actions'!
 
 basicReadSettings
-    |prefs|
-
-    prefs := UserPreferences current.
-
-    self st80EditingMode value:prefs st80EditMode.
+    self 
+        readAspects:
+            #( 
+                searchDialogIsModal
+                startTextDragWithControl
+            )
+        from:currentUserPrefs.
+
+    self st80EditingMode value:currentUserPrefs st80EditMode.
     self st80DoubleClickSelectMode value:TextView st80SelectMode.
     self tabsIs4 value:(ListView userDefaultTabPositions = ListView tab4Positions).
-    self searchDialogIsModal value:prefs searchDialogIsModal.
-    self startTextDragWithControl value:prefs startTextDragWithControl.
 !
 
 basicSaveSettings
-    |prefs|
-
-    prefs := UserPreferences current.
-
-    prefs st80EditMode:(self st80EditingMode value).
+    self 
+        writeAspects:
+            #( 
+                searchDialogIsModal
+                startTextDragWithControl
+            )
+        to:currentUserPrefs.
+
+    currentUserPrefs st80EditMode:(self st80EditingMode value).
     TextView st80SelectMode:(self st80DoubleClickSelectMode value).
     tabsIs4 value ~~ (ListView userDefaultTabPositions = ListView tab4Positions) ifTrue:[
         ListView userDefaultTabPositions:(self tabsIs4 value ifTrue:[ListView tab4Positions] ifFalse:[ListView tab8Positions]).
@@ -2245,8 +2287,6 @@
             self tabsIs4 value ifTrue:[eachKindOfListView setTab4] ifFalse:[eachKindOfListView setTab8]
         ].
     ].
-    prefs searchDialogIsModal:self searchDialogIsModal value.
-    prefs startTextDragWithControl:self startTextDragWithControl value.
 !
 
 helpFilename
@@ -3527,6 +3567,7 @@
 !
 
 basicSaveSettings
+    "nothing done here"
 
     ^ self
 !
@@ -3896,6 +3937,7 @@
 !
 
 basicSaveSettings
+    "nothing done here"
 !
 
 helpFilename
@@ -5088,12 +5130,13 @@
 !AbstractSettingsApplication::MemorySettingsAppl methodsFor:'actions'!
 
 basicReadSettings
-    #(
-        newSpaceSize
-        maxOldSpace
-    ) do:[:aspect |
-        (self perform:aspect) value:(ObjectMemory perform:aspect).
-    ].
+    self 
+        readAspects:
+            #( 
+                newSpaceSize
+                maxOldSpace
+            )
+        from:ObjectMemory.
 
     self igcLimit value:ObjectMemory incrementalGCLimit.
     self igcFreeLimit value:ObjectMemory freeSpaceGCLimit.
@@ -5108,12 +5151,13 @@
 !
 
 basicSaveSettings
-    #(
-        newSpaceSize
-        maxOldSpace
-    ) do:[:aspect |
-        ObjectMemory perform:(aspect,':')asSymbol with:(self perform:aspect) value.
-    ].
+    self 
+        writeAspects:
+            #(
+                newSpaceSize
+                maxOldSpace
+            )
+        to:ObjectMemory.
 
     ObjectMemory freeSpaceGCAmount:self igcFreeAmount value.
     ObjectMemory freeSpaceGCLimit:self igcFreeLimit value.
@@ -5826,22 +5870,30 @@
 !AbstractSettingsApplication::MiscDisplaySettingsAppl methodsFor:'actions'!
 
 basicReadSettings
+    self 
+        readAspects:
+            #( 
+                nativeWidgets
+                nativeDialogs
+            )
+        from:Screen current.
+
+    self 
+        readAspects:
+            #( 
+                beepEnabled
+            )
+        from:currentUserPrefs.
+
     self shadows value:PopUpView shadows.
-    self nativeWidgets value:Screen current nativeWidgets.
-    self nativeDialogs value:Screen current nativeDialogs.
-    self beepEnabled value:currentUserPrefs beepEnabled.
     self newWindowLabelFormat value:StandardSystemView windowLabelFormat.
-    self hostNameInLabelHolder 
-        value:StandardSystemView includeHostNameInLabel.
-    self returnFocus 
-        value:StandardSystemView returnFocusWhenClosingModalBoxes.
+    self hostNameInLabelHolder value:StandardSystemView includeHostNameInLabel.
+    self returnFocus value:StandardSystemView returnFocusWhenClosingModalBoxes.
     self takeFocus value:StandardSystemView takeFocusWhenMapped.
     self focusFollowsMouse value:(currentUserPrefs focusFollowsMouse ? true).
     self activateOnClick value:(Display activateOnClick:nil).
-    self opaqueVariablePanelResize 
-        value:currentUserPrefs opaqueVariablePanelResizing.
-    self opaqueTableColumnResize 
-        value:currentUserPrefs opaqueTableColumnResizing.
+    self opaqueVariablePanelResize value:currentUserPrefs opaqueVariablePanelResizing.
+    self opaqueTableColumnResize value:currentUserPrefs opaqueTableColumnResizing.
     self showAccelerators value:MenuView showAcceleratorKeys.
 !
 
@@ -5885,11 +5937,16 @@
     currentUserPrefs opaqueVariablePanelResizing:self opaqueVariablePanelResize value.
     currentUserPrefs opaqueTableColumnResizing:self opaqueTableColumnResize value.
 
-    currentUserPrefs beepEnabled:self beepEnabled value.
+    self 
+        writeAspects:
+            #(
+                beepEnabled
+                focusFollowsMouse
+            )
+        to:currentUserPrefs.
 
     StandardSystemView returnFocusWhenClosingModalBoxes:self returnFocus value.
     StandardSystemView takeFocusWhenMapped:self takeFocus value.
-    currentUserPrefs focusFollowsMouse:self focusFollowsMouse value.
     currentScreen activateOnClick:self activateOnClick value.
 
     MenuView showAcceleratorKeys:self showAccelerators value.
@@ -6820,25 +6877,29 @@
 !AbstractSettingsApplication::PrinterSettingsAppl methodsFor:'actions'!
 
 basicReadSettings
-    self bottomMargin value:Printer bottomMargin.
-    self landscape value:Printer landscape.
-    self leftMargin value:Printer leftMargin.
-    self rightMargin value:Printer rightMargin.
-    self topMargin value:Printer topMargin.
-    self printCommand value:Printer printCommand.
-    self printFilename value:Printer printFilename.
-    self printerTypeSelection 
-        value:(self possiblePrinters identityIndexOf:Printer).
-    self supportsColor value:Printer supportsColor.
-    self pageFormatList notEmpty ifTrue:[
-        self pageFormat value:Printer pageFormat
-    ].
+    self 
+        readAspects:
+            #( 
+                topMargin
+                bottomMargin
+                leftMargin
+                rightMargin
+                landscape
+                printCommand
+                printFilename
+                supportsColor
+            )
+        from:Printer.
+
+    self printerTypeSelection value:(self possiblePrinters identityIndexOf:Printer).
+    self pageFormatList notEmpty ifTrue:[ self pageFormat value:Printer pageFormat ].
     self printerTypeSelectionOrUnitListChanged.
 !
 
 basicSaveSettings
 
     Printer := self possiblePrinters at:(self printerTypeSelection value).
+
     Printer printCommand:self printCommand value.
     Printer printFilename:(printFilename value isEmptyOrNil ifTrue:[nil] ifFalse:[printFilename value]).
 
@@ -9098,20 +9159,24 @@
 
 basicReadSettings
     reformatLocked := true.
+
+    self 
+        readAspects:
+            #( 
+                tabIndent
+                spaceAroundTemporaries
+                emptyLineAfterTemporaries
+                spaceAfterReturnToken
+                spaceAfterKeywordSelector
+                spaceAfterBlockStart
+                spaceBeforeBlockEnd
+                cStyleBlocks
+                blockArgumentsOnNewLine
+                maxLengthForSingleLineBlocks
+            )
+        from:RBFormatter.
+
     self autoFormat value:currentUserPrefs autoFormatting.
-    self tabIndent value:RBFormatter tabIndent.
-    self spaceAroundTemporaries value:RBFormatter spaceAroundTemporaries.
-    self emptyLineAfterTemporaries 
-            value:RBFormatter emptyLineAfterTemporaries.
-    self spaceAfterReturnToken value:RBFormatter spaceAfterReturnToken.
-    self spaceAfterKeywordSelector 
-            value:RBFormatter spaceAfterKeywordSelector.
-    self spaceAfterBlockStart value:RBFormatter spaceAfterBlockStart.
-    self spaceBeforeBlockEnd value:RBFormatter spaceBeforeBlockEnd.
-    self cStyleBlocks value:RBFormatter cStyleBlocks.
-    self blockArgumentsOnNewLine value:RBFormatter blockArgumentsOnNewLine.
-    self maxLengthForSingleLineBlocks 
-            value:RBFormatter maxLengthForSingleLineBlocks.
     self updateModifiedChannel.
     reformatLocked := false.
     self reformat.
@@ -11488,6 +11553,15 @@
 !AbstractSettingsApplication::SystemMessageSettingsAppl methodsFor:'actions'!
 
 basicReadSettings
+    self 
+        readAspects:
+            #( 
+                beepForInfoDialog
+                beepForWarningDialog
+                beepForErrorDialog
+            )
+        from:UserPreferences current.
+
     self vmInfo value:ObjectMemory infoPrinting.
     self vmErrors value:ObjectMemory debugPrinting.
     self classInfos value:Object infoPrinting.
@@ -11495,9 +11569,6 @@
     self changeFileName value:ObjectMemory nameForChanges.
     self logDoits value:Smalltalk logDoits.
     self updChanges value:Class updatingChanges.
-    self beepForInfoDialog value:UserPreferences current beepForInfoDialog.
-    self beepForWarningDialog value:UserPreferences current beepForWarningDialog.
-    self beepForErrorDialog value:UserPreferences current beepForErrorDialog.
     self flyByHelp value:UserPreferences current flyByHelpActive.
 !
 
@@ -11511,10 +11582,15 @@
     Smalltalk logDoits:self logDoits value.
     Class updateChanges:self updChanges value.
 
-    UserPreferences current beepForInfoDialog:self beepForInfoDialog value.
-    UserPreferences current beepForWarningDialog:self beepForWarningDialog value.
-    UserPreferences current beepForErrorDialog:self beepForErrorDialog value.
-    UserPreferences current flyByHelpActive:self flyByHelp value.
+    self 
+        writeAspects:
+            #( 
+                beepForInfoDialog
+                beepForWarningDialog
+                beepForErrorDialog
+                flyByHelpActive
+            )
+        to:currentUserPrefs.
 !
 
 helpFilename
@@ -11824,23 +11900,21 @@
 !AbstractSettingsApplication::ToolsSettingsAppl methodsFor:'actions'!
 
 basicReadSettings
-    currentUserPrefs := UserPreferences current.
-
-    #( 
-        useNewInspector
-        useNewChangesBrowser
-        useNewSystemBrowser
-        useNewVersionDiffBrowser
-        useNewFileBrowser
-        useNewFileDialog
-        useNewSettingsApplication
-        useProcessMonitorV2
-        useSmalltalkDocumentViewer
-        showClockInLauncher
-    )
-    do:[:aspect |
-        (self perform:aspect) value:(currentUserPrefs perform:aspect).
-    ].
+    self 
+        readAspects:
+            #( 
+                useNewInspector
+                useNewChangesBrowser
+                useNewSystemBrowser
+                useNewVersionDiffBrowser
+                useNewFileBrowser
+                useNewFileDialog
+                useNewSettingsApplication
+                useProcessMonitorV2
+                useSmalltalkDocumentViewer
+                showClockInLauncher
+            )
+        from:currentUserPrefs.
 
     Transcript current isExternalStream ifFalse:[
         self transcriptBufferSize value:Transcript current lineLimit.
@@ -11848,17 +11922,21 @@
 !
 
 basicSaveSettings
-    | showClock launcher reopenLauncher newSystemBrowserClass transcript|
+    |showClock launcher reopenLauncher newSystemBrowserClass transcript|
 
     newSystemBrowserClass := Tools::NewSystemBrowser ? NewSystemBrowser.
 
-    currentUserPrefs := UserPreferences current.
-    currentUserPrefs useNewInspector:self useNewInspector value.
-    currentUserPrefs useNewChangesBrowser:self useNewChangesBrowser value.
-    currentUserPrefs useNewVersionDiffBrowser:self useNewVersionDiffBrowser value.
-    currentUserPrefs useNewFileDialog:self useNewFileDialog value.
-    currentUserPrefs useProcessMonitorV2:self useProcessMonitorV2 value.
-    currentUserPrefs useSmalltalkDocumentViewer:self useSmalltalkDocumentViewer value.
+    self 
+        writeAspects:
+            #( 
+                useNewInspector
+                useNewChangesBrowser
+                useNewVersionDiffBrowser
+                useNewFileDialog
+                useProcessMonitorV2
+                useSmalltalkDocumentViewer
+            )
+        to:currentUserPrefs.
 
     currentUserPrefs useNewSettingsApplication ~= self useNewSettingsApplication value ifTrue:[
         currentUserPrefs useNewSettingsApplication:self useNewSettingsApplication value.
@@ -12038,5 +12116,5 @@
 !AbstractSettingsApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.224 2006-05-11 17:05:55 cg Exp $'
-! !
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.225 2006-05-11 17:53:47 cg Exp $'
+! !