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