AbstractSettingsApplication.st
changeset 18174 2bb8e22801bc
parent 18143 016a788c0ec3
child 18176 96c61c107803
--- a/AbstractSettingsApplication.st	Thu May 31 12:16:45 2018 +0200
+++ b/AbstractSettingsApplication.st	Thu May 31 16:05:19 2018 +0200
@@ -749,6 +749,11 @@
     |result holder notAgainText|
 
     self hasUnsavedChanges ifTrue:[
+        "/ debugging
+        "/ self whichUnsavedChangesInto:[:aspect |
+        "/     Transcript show:'different: '; showCR:aspect.
+        "/ ].
+        
         askForChangeOnRelease ifTrue:[
             notAgainText := resources string:'Do not ask this again (always save changes when closing)'.
 
@@ -794,6 +799,7 @@
 
     "Modified: / 20-09-2006 / 23:56:25 / cg"
     "Modified (comment): / 10-04-2018 / 16:55:30 / sr"
+    "Modified: / 31-05-2018 / 16:04:57 / Claus Gittinger"
 !
 
 saveSettings
@@ -904,6 +910,40 @@
     "Modified: / 08-02-2011 / 09:11:03 / cg"
 !
 
+whichChangedAspectIn:aListOfAspects asComparedTo:anAspectProvider
+    "this code-sharing helper compares a bunch of aspect value against some object,
+     and returns a list of changed aspect names (for info only, in a confirmer).    
+     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) ifTrue:[^ true].
+        someone aspect2 ~= (self aspect2 value) ifTrue:[^ true].
+        ...
+        someone aspectN ~= (self aspectN value) ifTrue:[^ true].
+        ^ false
+     Prerequisite:
+        local aspects must be named like corresponding aspect methods in the flag-provider.
+    "
+
+    ^ aListOfAspects select:[:eachAspectSymbol |
+        (self myAspectHolderFor:eachAspectSymbol) value ~= (anAspectProvider perform:eachAspectSymbol)
+    ]
+
+    "Created: / 31-05-2018 / 12:53:05 / Claus Gittinger"
+!
+
+whichChangedAspectIn:aListOfAspects asComparedTo:anAspectProvider into:aBlock
+    "this code-sharing helper compares a bunch of aspect value against some object,
+     and returns a list of changed aspect names through aBlock(for info only, in a confirmer)"
+
+    ^ aListOfAspects select:[:eachAspectSymbol |
+        (self myAspectHolderFor:eachAspectSymbol) value ~= (anAspectProvider perform:eachAspectSymbol)
+        ifTrue:[ aBlock value:eachAspectSymbol ]
+    ]
+
+    "Created: / 31-05-2018 / 12:57:19 / Claus Gittinger"
+!
+
 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
@@ -1061,6 +1101,24 @@
     ^ nil.
 !
 
+whichUnsavedChangesInto:aBlock
+    "utility to return a list of changed aspects through aBlock.
+     (for info only, in a confirmer)"
+
+    |aspects|
+    
+    (aspects := self aspects) notNil ifTrue:[
+        self
+            whichChangedAspectIn:(self aspects)
+            asComparedTo:currentUserPrefs
+            into:aBlock.
+        ^ self    
+    ].
+    ^ self subclassResponsibility
+
+    "Created: / 31-05-2018 / 12:56:53 / Claus Gittinger"
+!
+
 widgetsWithChangedSettingsDo:aBlock
     "/ to be redefined in subclasses...