Tools_BrowserList.st
changeset 10430 de5471e4fa33
parent 10419 9d417ea98d0f
child 10835 9bb85dddf432
--- a/Tools_BrowserList.st	Tue Aug 02 09:39:19 2011 +0200
+++ b/Tools_BrowserList.st	Tue Aug 02 10:24:50 2011 +0200
@@ -27,7 +27,8 @@
 !
 
 Object subclass:#SearchHandler
-	instanceVariableNames:'listView listHolder searchField searchWindow searchHolder'
+	instanceVariableNames:'listView listHolder listSelectionHolder searchField searchWindow
+		searchHolder'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:BrowserList
@@ -1616,24 +1617,20 @@
 
 restoreList
 
-    | sel |
-    sel := listView selection.
-    sel notNil ifTrue:[
-        sel isInteger ifTrue:[
-            sel := listHolder identityIndexOf: (listView list at: sel)
-        ] ifFalse:[
-            sel := sel collect:[:each|listHolder value identityIndexOf: (listView list at: each)]
-        ].
+    self updateSelection.
+    listView listHolder: listHolder.
+    listSelectionHolder notNil ifTrue:[
+        listView model: listSelectionHolder.    
     ].
-    listView listHolder: listHolder.
-    listView selection: sel.
+    listSelectionHolder changed: #value
 
     "Created: / 27-07-2011 / 22:14:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 saveList
 
-    listHolder := listView listHolder.
+    listHolder := listView listHolder.  
+    listSelectionHolder := listView model.
 
     "Created: / 27-07-2011 / 22:14:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
@@ -1688,15 +1685,51 @@
     ] ifFalse:[
         listView listHolder value: filteredList.
     ].
+    listView model == listSelectionHolder ifTrue:[
+        listView model: ValueHolder new.
+        listView model onChangeSend: #updateSelection to: self.
+    ].
     filteredList size == 1 ifTrue:[
         listView selection: 1
     ]
 
     "Created: / 27-07-2011 / 22:18:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateSelection
+
+    | sel |
+
+    listSelectionHolder isNil ifTrue:[^self].
+
+    sel := listView selection.
+    sel notNil ifTrue:[
+        sel isInteger ifTrue:[
+            sel := listHolder identityIndexOf: (listView list at: sel)
+        ] ifFalse:[
+            sel := sel collect:[:each|listHolder value identityIndexOf: (listView list at: each)]
+        ].
+    ] ifFalse:[
+        listView multipleSelectOk ifTrue:[
+            sel := #()
+        ]
+    ].
+    listView useIndex ifFalse:[
+        sel isInteger ifTrue:[
+            sel := listHolder value at: sel
+        ] ifFalse:[
+            sel := sel collect:[:each|listHolder value at: each].
+        ]
+    ].
+
+
+    listSelectionHolder value: sel.
+
+    "Created: / 02-08-2011 / 09:08:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BrowserList class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools_BrowserList.st,v 1.35 2011-07-28 15:04:26 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools_BrowserList.st,v 1.36 2011-08-02 08:24:50 vrany Exp $'
 ! !