MSelList.st
author Claus Gittinger <cg@exept.de>
Thu, 18 Jan 1996 01:11:18 +0100
changeset 295 aa5887bff1b2
parent 293 ab897211c99c
child 360 c057423ecdd0
permissions -rw-r--r--
*** empty log message ***
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
'From Smalltalk/X, Version:2.10.5 on 25-mar-1995 at 12:12:09 pm'!
5d736ee65276 Initial revision
claus
parents:
diff changeset
    14
5d736ee65276 Initial revision
claus
parents:
diff changeset
    15
SelectionInList subclass:#MultiSelectionInList
5d736ee65276 Initial revision
claus
parents:
diff changeset
    16
	 instanceVariableNames:''
5d736ee65276 Initial revision
claus
parents:
diff changeset
    17
	 classVariableNames:''
5d736ee65276 Initial revision
claus
parents:
diff changeset
    18
	 poolDictionaries:''
129
claus
parents: 114
diff changeset
    19
	 category:'Interface-Support-Models'
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
    20
!
5d736ee65276 Initial revision
claus
parents:
diff changeset
    21
174
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    22
!MultiSelectionInList class methodsFor:'documentation'!
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
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    25
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    27
	      All Rights Reserved
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    28
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    29
 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
    30
 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
    31
 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
    32
 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
    33
 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
    34
 hereby transferred.
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
!
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
version
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    39
    ^ '$Header'
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
documentation
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    43
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    44
    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
    45
    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
    46
"
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    47
! !
d80a6cc3f9b2 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    48
166
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    49
!MultiSelectionInList methodsFor:'initialization'!
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    50
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    51
initialize
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    52
    self listHolder:(nil asValue).      "/ could also use an empty collection here
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    53
    self selectionIndexHolder:(#() asValue).
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    54
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    55
    "Created: 26.10.1995 / 16:30:22 / cg"
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    56
! !
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    57
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    58
!MultiSelectionInList methodsFor:'accessing-values'!
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    59
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    60
selection:anObjectList 
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    61
    "set the selection to be anObjectList."
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    62
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    63
    |l indizes|
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    64
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    65
    l := self list.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    66
    indizes := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    67
    anObjectList do:[:o |
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    68
	|idx|
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    69
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    70
	idx := l indexOf:o ifAbsent:0.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    71
	idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    72
	    indizes add:idx
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    73
	].
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    74
    ].
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    75
    ^ self selectionIndex:indizes
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    76
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    77
    "Created: 26.10.1995 / 16:40:24 / cg"
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    78
!
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    79
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    80
selection
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    81
    "return the selections value (i.e. the entry in the list"
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    82
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    83
    |l|
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    84
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    85
    l := self list.
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    86
    ^ selectionIndexHolder value collect:[:index |
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    87
	l at:index
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    88
      ]
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    89
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    90
    "Created: 26.10.1995 / 16:52:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    91
! !
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    92
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
    93
!MultiSelectionInList methodsFor:'selections'!
5d736ee65276 Initial revision
claus
parents:
diff changeset
    94
5d736ee65276 Initial revision
claus
parents:
diff changeset
    95
selections
5d736ee65276 Initial revision
claus
parents:
diff changeset
    96
    |selectionIndices|
5d736ee65276 Initial revision
claus
parents:
diff changeset
    97
293
ab897211c99c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
    selectionIndices := selectionIndexHolder value.
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
    99
    (selectionIndices isNil 
5d736ee65276 Initial revision
claus
parents:
diff changeset
   100
    or:[selectionIndices isEmpty]) ifFalse:[
129
claus
parents: 114
diff changeset
   101
	^ selectionIndices collect:[:index | listHolder value at:index]
114
5d736ee65276 Initial revision
claus
parents:
diff changeset
   102
    ].
5d736ee65276 Initial revision
claus
parents:
diff changeset
   103
    ^ #()
5d736ee65276 Initial revision
claus
parents:
diff changeset
   104
! !
5d736ee65276 Initial revision
claus
parents:
diff changeset
   105