MultiSelectionInList.st
author Claus Gittinger <cg@exept.de>
Tue, 16 Apr 1996 12:15:42 +0200
changeset 536 fd1b723e69b6
parent 526 8203430fbadd
child 537 21fc632b22fe
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
174
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     1
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     3
	      All Rights Reserved
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     4
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     5
 This software is furnished under a license and may be used
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     6
 only in accordance with the terms of that license and with the
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
     9
 other person.  No title to or ownership of the software is
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    10
 hereby transferred.
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    11
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    12
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
    13
SelectionInList subclass:#MultiSelectionInList
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    14
	instanceVariableNames:''
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    15
	classVariableNames:''
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    16
	poolDictionaries:''
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    17
	category:'Interface-Support-Models'
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
    18
!
5d736ee65276 Initial revision
claus
parents:
diff changeset
    19
174
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    20
!MultiSelectionInList class methodsFor:'documentation'!
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    21
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    22
copyright
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    23
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    25
	      All Rights Reserved
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    26
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    27
 This software is furnished under a license and may be used
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    28
 only in accordance with the terms of that license and with the
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    30
 be provided or otherwise made available to, or used by, any
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    31
 other person.  No title to or ownership of the software is
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    32
 hereby transferred.
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    33
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    34
!
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    35
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    36
documentation
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    37
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    38
    Like a selectionInList, but allows for multiple selected items.
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    39
    For use as a model for SelectionInListViews, with multipleSelectOk set to true.
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    40
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    41
! !
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    42
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    43
!MultiSelectionInList methodsFor:'accessing-values'!
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    44
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    45
selection
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    46
    "return the selections value (i.e. the entry in the list"
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    47
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    48
    |l|
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    49
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    50
    l := self list.
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    51
    ^ selectionIndexHolder value collect:[:index |
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    52
	l at:index
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    53
      ]
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    54
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    55
    "Created: 26.10.1995 / 16:52:27 / cg"
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    56
!
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    57
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    58
selection:anObjectList 
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    59
    "set the selection to be anObjectList."
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    60
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    61
    |l indizes|
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    62
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    63
    l := self list.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    64
    indizes := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    65
    anObjectList do:[:o |
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    66
	|idx|
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    67
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    68
	idx := l indexOf:o ifAbsent:0.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    69
	idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    70
	    indizes add:idx
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    71
	].
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    72
    ].
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    73
    ^ self selectionIndex:indizes
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    74
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    75
    "Created: 26.10.1995 / 16:40:24 / cg"
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    76
! !
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    77
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    78
!MultiSelectionInList methodsFor:'initialization'!
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    79
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    80
initialize
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    81
    self listHolder:(nil asValue).      "/ could also use an empty collection here
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    82
    self selectionIndexHolder:(Array new asValue).
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    83
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    84
    "Created: 26.10.1995 / 16:30:22 / cg"
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    85
! !
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    86
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    87
!MultiSelectionInList methodsFor:'private'!
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    88
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    89
clearSelection
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    90
    selectionIndexHolder setValue:(Array new).
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    91
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
    92
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    93
! !
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    94
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
    95
!MultiSelectionInList methodsFor:'selections'!
5d736ee65276 Initial revision
claus
parents:
diff changeset
    96
5d736ee65276 Initial revision
claus
parents:
diff changeset
    97
selections
5d736ee65276 Initial revision
claus
parents:
diff changeset
    98
    |selectionIndices|
5d736ee65276 Initial revision
claus
parents:
diff changeset
    99
293
ab897211c99c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
    selectionIndices := selectionIndexHolder value.
536
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   101
    (selectionIndices isNil
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   102
     or:[selectionIndices == 0
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   103
     or:[selectionIndices isEmpty]]) ifFalse:[
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   104
        ^ selectionIndices collect:[:index | listHolder value at:index]
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
   105
    ].
360
c057423ecdd0 literal array overwrite fixed
Claus Gittinger <cg@exept.de>
parents: 293
diff changeset
   106
    ^ Array new
536
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   107
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   108
    "Modified: 16.4.1996 / 12:15:34 / cg"
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
   109
! !
5d736ee65276 Initial revision
claus
parents:
diff changeset
   110
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
   111
!MultiSelectionInList class methodsFor:'documentation'!
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
   112
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
   113
version
536
fd1b723e69b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   114
    ^ '$Header: /cvs/stx/stx/libwidg/MultiSelectionInList.st,v 1.8 1996-04-16 10:15:42 cg Exp $'
526
8203430fbadd oops - clearing selection was wrong in MultiSelectionInList
ca
parents: 360
diff changeset
   115
! !