author | ca |
Wed, 14 Jan 1998 16:17:01 +0100 | |
changeset 1413 | e00159f1414d |
parent 1410 | 80332bbccffc |
child 2724 | 23f4e16dc4f4 |
permissions | -rw-r--r-- |
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 | 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 | 18 |
! |
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. |
583 | 40 |
|
41 |
[author:] |
|
42 |
Claus Gittinger |
|
174
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 |
! ! |
d80a6cc3f9b2
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
166
diff
changeset
|
45 |
|
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
46 |
!MultiSelectionInList methodsFor:'accessing-values'! |
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 |
selection |
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
49 |
"return the selections value (i.e. the entry numbers in the list)" |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
50 |
|
1413 | 51 |
|l s| |
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
52 |
|
1413 | 53 |
( (l := self list) isNil "/ mhmh - no list; what should we do here ? |
54 |
or:[(s := selectionIndexHolder value) size == 0] "/ mhmh - can be nil ? |
|
55 |
) ifTrue:[ |
|
56 |
^ self zeroIndex |
|
57 |
]. |
|
58 |
||
59 |
^ s collect:[:index | l at:index ] |
|
166 | 60 |
|
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
61 |
"Created: 26.10.1995 / 16:52:27 / cg" |
563 | 62 |
"Modified: 20.4.1996 / 13:14:29 / cg" |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
63 |
! |
166 | 64 |
|
65 |
selection:anObjectList |
|
66 |
"set the selection to be anObjectList." |
|
67 |
||
1228 | 68 |
|l indizes objList| |
166 | 69 |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
70 |
"/ |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
71 |
"/ for your convenience: allow 0 and nil as empty |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
72 |
"/ selections |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
73 |
"/ |
1228 | 74 |
anObjectList size == 0 ifTrue:[ |
75 |
(anObjectList isCollection or:[anObjectList isNil]) ifTrue:[ |
|
76 |
^ self selectionIndex:#() |
|
77 |
]. |
|
78 |
objList := Array with:anObjectList |
|
79 |
] ifFalse:[ |
|
80 |
objList := anObjectList |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
81 |
]. |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
82 |
|
166 | 83 |
l := self list. |
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
84 |
l isNil ifTrue:[^ self]. "/ mhmh - no list; what should we do here ? |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
85 |
|
166 | 86 |
indizes := OrderedCollection new. |
1228 | 87 |
objList do:[:o | |
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
88 |
|idx| |
166 | 89 |
|
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
90 |
idx := l indexOf:o ifAbsent:0. |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
91 |
idx ~~ 0 ifTrue:[ |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
92 |
indizes add:idx |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
93 |
]. |
166 | 94 |
]. |
95 |
^ self selectionIndex:indizes |
|
96 |
||
97 |
"Created: 26.10.1995 / 16:40:24 / cg" |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
98 |
"Modified: 25.4.1996 / 09:07:44 / cg" |
1228 | 99 |
! |
100 |
||
101 |
selectionIndex:indexes |
|
102 |
"set list of indexes |
|
103 |
" |
|
104 |
indexes size ~~ 0 ifTrue:[ |
|
105 |
^ super selectionIndex:indexes |
|
106 |
]. |
|
107 |
||
108 |
(indexes isCollection or:[indexes isNil]) ifTrue:[ |
|
109 |
^ super selectionIndex:#() |
|
110 |
]. |
|
111 |
^ super selectionIndex:(OrderedCollection with:indexes) |
|
112 |
! |
|
113 |
||
114 |
selectionIndexes |
|
115 |
"added for ST-80 compatibility |
|
116 |
" |
|
117 |
^ self selectionIndex value |
|
118 |
! |
|
119 |
||
120 |
selectionIndexes:indizes |
|
121 |
"added for ST-80 compatibility |
|
122 |
" |
|
123 |
^ self selectionIndex:indizes |
|
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
124 |
! ! |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
125 |
|
563 | 126 |
!MultiSelectionInList methodsFor:'queries'! |
166 | 127 |
|
1413 | 128 |
numberOfSelections |
129 |
"return the number of selected entries |
|
130 |
" |
|
131 |
^ selectionIndexHolder value size |
|
132 |
||
133 |
! |
|
134 |
||
563 | 135 |
zeroIndex |
136 |
"return the selectionIndex returned when nothing is selected. |
|
137 |
Here, an empty collection is returned." |
|
166 | 138 |
|
563 | 139 |
^ Array new |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
140 |
|
563 | 141 |
"Modified: 20.4.1996 / 13:12:58 / cg" |
166 | 142 |
! ! |
143 |
||
114 | 144 |
!MultiSelectionInList methodsFor:'selections'! |
145 |
||
1410 | 146 |
clearAll |
147 |
"ST80 compatibility" |
|
148 |
||
149 |
self selection:nil. |
|
150 |
! |
|
151 |
||
152 |
selectAll |
|
153 |
"ST80 compatibility" |
|
154 |
||
155 |
|indizes size| |
|
156 |
||
157 |
(size := listHolder value size) == 0 ifTrue:[ |
|
158 |
^ self clearAll |
|
159 |
]. |
|
160 |
||
161 |
indizes := Array new:size. |
|
162 |
1 to:size do:[:i| indizes at:i put:i]. |
|
163 |
self selectionIndex:indizes. |
|
164 |
! |
|
165 |
||
114 | 166 |
selections |
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
167 |
"obsolete - almost the same as selection" |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
168 |
|
114 | 169 |
|selectionIndices| |
170 |
||
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
171 |
self obsoleteMethodWarning. |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
172 |
|
293 | 173 |
selectionIndices := selectionIndexHolder value. |
536 | 174 |
(selectionIndices isNil |
563 | 175 |
or:[selectionIndices == 0 |
536 | 176 |
or:[selectionIndices isEmpty]]) ifFalse:[ |
177 |
^ selectionIndices collect:[:index | listHolder value at:index] |
|
114 | 178 |
]. |
360
c057423ecdd0
literal array overwrite fixed
Claus Gittinger <cg@exept.de>
parents:
293
diff
changeset
|
179 |
^ Array new |
536 | 180 |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
181 |
"Modified: 25.4.1996 / 09:09:45 / cg" |
1397
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
182 |
! |
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
183 |
|
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
184 |
selections:aCollection |
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
185 |
"ST80 compatibility" |
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
186 |
|
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
187 |
^ self selection:aCollection |
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
188 |
|
d52f3f02882d
added #selections: (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
189 |
"Created: / 8.11.1997 / 12:55:23 / cg" |
114 | 190 |
! ! |
191 |
||
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
192 |
!MultiSelectionInList class methodsFor:'documentation'! |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
193 |
|
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
194 |
version |
1413 | 195 |
^ '$Header: /cvs/stx/stx/libwidg/MultiSelectionInList.st,v 1.16 1998-01-14 15:17:01 ca Exp $' |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
196 |
! ! |