#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Mon, 06 Aug 2018 16:23:45 +0200
changeset 18322 5ac30199fb23
parent 18321 b69522bd7a39
child 18323 81be140cef5a
#UI_ENHANCEMENT by cg class: SettingsDialog added: #selectItem: changed: #postOpenWith: #selectItemWithClass: #selectItemWithName: #selectionChanged
SettingsDialog.st
--- a/SettingsDialog.st	Mon Aug 06 15:18:15 2018 +0200
+++ b/SettingsDialog.st	Mon Aug 06 16:23:45 2018 +0200
@@ -1617,18 +1617,26 @@
 !
 
 selectionChanged
+    "settings selection has changed;
+     first send the previous application a saveRequest;
+     then construct the new selected application (if not yet done before),
+     and set it in the right subcanvas"
+     
     |item oldAppl noApp lbl window app itemLabel|
 
-    self selectedItem value == lastSelection  ifTrue:[ ^ self].
+    item := self selectedItem value.
+    item == lastSelection  ifTrue:[ ^ self].
 
     oldAppl := self subCanvasApplication.
     oldAppl notNil ifTrue:[
         oldAppl saveRequest ifFalse:[
             lastSelection notNil ifTrue:[
-            self
-                enqueueMessage:#value 
-                for:[ self selectedItem value:lastSelection ]
-                arguments:#().
+                self
+                    enqueueMessage:#value 
+                    for:[ 
+                        self selectedItem value:lastSelection 
+                    ]
+                    arguments:#().
             ].
             ^ self
         ].
@@ -1636,7 +1644,6 @@
         self unhighlightWidgets.
     ].
 
-    item := self selectedItem value.
 
     item isNil ifTrue:[ item := applicationList root ].
 
@@ -1707,9 +1714,10 @@
     false ifTrue:[
         self highlightWidgetsWithChangedSettings.
     ].
-    
+
     "Modified: / 29-10-2010 / 11:51:13 / cg"
     "Modified: / 17-02-2012 / 10:24:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 06-08-2018 / 16:13:42 / Claus Gittinger"
 !
 
 update:something with:aParameter from:changedObject
@@ -1885,17 +1893,27 @@
 !
 
 postOpenWith:aBuilder
-    |items|
+    |items searchItem|
 
     self rootItem expand.
     super postOpenWith:aBuilder.
-    (items := self rootItem children) size == 1 ifTrue:[
-        self selectedItem value: items anElement.
+
+    lastSelection isNil ifTrue:[
+        "/ if there is only one child, select it initially
+        "/ may also be inside a one-child-only parent.
+        searchItem := self rootItem.
+        (items := searchItem children) size == 1 ifTrue:[
+            searchItem := items anElement     
+        ].
+        searchItem notNil ifTrue:[
+            self selectedItem value:searchItem.
+        ]
     ]
 
     "Modified: / 03-11-2007 / 14:23:25 / cg"
     "Modified: / 03-10-2011 / 16:27:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 09-10-2017 / 17:20:04 / stefan"
+    "Modified (format): / 06-08-2018 / 16:23:33 / Claus Gittinger"
 ! !
 
 !SettingsDialog methodsFor:'menu actions'!
@@ -2290,6 +2308,15 @@
 
 !SettingsDialog methodsFor:'selection'!
 
+selectItem:anEntryInTheSettingsList
+    anEntryInTheSettingsList notNil ifTrue:[
+        anEntryInTheSettingsList makeVisible.
+        self selectedItem value:anEntryInTheSettingsList
+    ].
+
+    "Created: / 06-08-2018 / 16:03:35 / Claus Gittinger"
+!
+
 selectItemWithClass:aClass
     "select an item based on the sub-settings application class"
 
@@ -2297,12 +2324,10 @@
 
     entry := applicationList root
                 recursiveDetect:[:entry | entry applicationClass = aClass].
-    entry notNil ifTrue:[
-        entry makeVisible.
-        self selectedItem value:entry
-    ].
+    self selectItem:entry.
 
     "Created: / 29-10-2010 / 11:54:13 / cg"
+    "Modified: / 06-08-2018 / 16:03:44 / Claus Gittinger"
 !
 
 selectItemWithName:aPathString
@@ -2313,10 +2338,9 @@
 
     entry := applicationList root
                 recursiveDetect:[:entry | entry nameString = aPathString].
-    entry notNil ifTrue:[
-        entry makeVisible.
-        self selectedItem value:entry
-    ].
+    self selectItem:entry.
+
+    "Modified: / 06-08-2018 / 16:03:50 / Claus Gittinger"
 ! !
 
 !SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'accessing'!