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