SelectionInListModelView.st
changeset 5729 2bbfe888300a
parent 5684 bba053081b4e
child 5733 7b192c9c2a99
--- a/SelectionInListModelView.st	Tue Mar 27 09:51:06 2018 +0200
+++ b/SelectionInListModelView.st	Tue Mar 27 12:47:11 2018 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1999 by eXept Software AG
 	      All Rights Reserved
@@ -2568,6 +2566,26 @@
     "Created: / 06-10-2011 / 13:32:28 / cg"
 !
 
+selectElements:aCollectionOfElement
+    "select the elements. 
+     Scroll to make the new selection visible.
+     Model and/or actionBlock notification IS done.
+    "
+    self selectElements:aCollectionOfElement ifAnyAbsent:[]
+!
+
+selectElements:aCollectionOfElements ifAnyAbsent:exceptionalValue
+    |indices|
+
+    indices := aCollectionOfElements collect:[:each |
+                    self identityIndexOf:each.
+               ].
+    (indices includes:0) ifTrue:[
+        ^ exceptionalValue value
+    ].
+    self selection:indices
+!
+
 selectFirst
     "select the first selectable element.
      Model and/or actionBlock notification IS done."
@@ -2661,15 +2679,15 @@
 !
 
 selectedIndex
-    "returns the index of the selected line or 0. If more
-     lines are selected, 0 is returned
+    "returns the index of the selected line or 0. 
+     If multiple lines are selected, 0 is returned
     "
     selection notNil ifTrue:[
-	multipleSelectOk ifFalse:[ ^ selection ].
-
-	selection size == 1 ifTrue:[
-	    ^ selection at:1
-	]
+        multipleSelectOk ifFalse:[ ^ selection ].
+
+        selection size == 1 ifTrue:[
+            ^ selection at:1
+        ]
     ].
     ^ 0
 !
@@ -2684,6 +2702,8 @@
 
 selection:something
     "select something or deselect if the argument is nil;
+     something is either an individual index 
+     or (if multiSelect is enabled) a collection of indices.
      scroll to make the selected line visible.
      The model and/or actionBlock IS notified."
 
@@ -2806,7 +2826,10 @@
 !
 
 selectWithoutScroll:something redraw:doRedraw
-    "change selection to something; returns true if selection changed
+    "change selection to something; 
+     something is either an individual index 
+     or (if multiSelect is enabled) a collection of indices.
+     returns true if selection changed
     "
     |oldSelect size|