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