SelectionInListModelView.st
changeset 4273 d56dfb04df83
parent 4258 d6ea83906c4e
child 4318 ee2c154ee065
equal deleted inserted replaced
4272:7372fb880713 4273:d56dfb04df83
   846     "update selection from the model
   846     "update selection from the model
   847     "
   847     "
   848     |value newSelection|
   848     |value newSelection|
   849 
   849 
   850     model isNil ifTrue:[
   850     model isNil ifTrue:[
   851 	^ self
   851         ^ self
   852     ].
   852     ].
   853 
   853 
   854     buttonMotionAction notNil ifTrue:[
   854     buttonMotionAction notNil ifTrue:[
   855 	"running in button motion; discard change notification
   855         "running in button motion; discard change notification
   856 	"
   856         "
   857 	^ self
   857         ^ self
   858     ].
   858     ].
   859 
   859 
   860     value := model value.
   860     value := model value.
   861 
   861 
   862     (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
   862     (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
   863 	multipleSelectOk ifFalse:[
   863         multipleSelectOk ifFalse:[
   864 	    newSelection := self identityIndexOf:value
   864             newSelection := self identityIndexOf:value
   865 	] ifTrue:[
   865         ] ifTrue:[
   866 	    value size == 0 ifTrue:[
   866             value size == 0 ifTrue:[
   867 		newSelection := nil
   867                 newSelection := nil
   868 	    ] ifFalse:[
   868             ] ifFalse:[
   869 		newSelection := OrderedCollection new.
   869                 newSelection := OrderedCollection new.
   870 
   870 
   871 		value do:[:e||index|
   871                 value do:[:e||index|
   872 		    index := self identityIndexOf:e.
   872                     index := self identityIndexOf:e.
   873 		    index ~~ 0 ifTrue:[ newSelection add:index ].
   873                     index ~~ 0 ifTrue:[ newSelection add:index ].
   874 		].
   874                 ].
   875 
   875                 newSelection := newSelection asNilIfEmpty.
   876 		newSelection isEmpty ifTrue:[
   876             ]
   877 		    newSelection := nil
   877         ].
   878 		].
       
   879 	    ]
       
   880 	].
       
   881     ] ifTrue:[
   878     ] ifTrue:[
   882 	newSelection := value copy
   879         newSelection := value copy
   883     ].
   880     ].
   884     self setSelection:newSelection.
   881     self setSelection:newSelection.
   885 ! !
   882 ! !
   886 
   883 
   887 !SelectionInListModelView methodsFor:'drag & drop'!
   884 !SelectionInListModelView methodsFor:'drag & drop'!
  2697 ! !
  2694 ! !
  2698 
  2695 
  2699 !SelectionInListModelView class methodsFor:'documentation'!
  2696 !SelectionInListModelView class methodsFor:'documentation'!
  2700 
  2697 
  2701 version_CVS
  2698 version_CVS
  2702     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.160 2013-06-27 14:02:41 cg Exp $'
  2699     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.161 2013-07-13 20:31:53 cg Exp $'
  2703 ! !
  2700 ! !
  2704 
  2701