author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:44:20 +0200 | |
changeset 583 | 2ec13b7ceba5 |
parent 579 | a9188bedbfb9 |
child 1228 | e30336972355 |
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 |
|
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
51 |
|l| |
166 | 52 |
|
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
53 |
l := self list. |
563 | 54 |
l isNil ifTrue:[^ self zeroIndex]. "/ mhmh - no list; what should we do here ? |
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
55 |
|
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
56 |
^ selectionIndexHolder value |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
57 |
collect:[:index | |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
58 |
l at:index |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
59 |
] |
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 |
||
68 |
|l indizes| |
|
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 |
"/ |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
74 |
(anObjectList isNil or:[anObjectList == 0]) ifTrue:[ |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
75 |
^ self selectionIndex:#() |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
76 |
]. |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
77 |
|
166 | 78 |
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
|
79 |
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
|
80 |
|
166 | 81 |
indizes := OrderedCollection new. |
82 |
anObjectList do:[:o | |
|
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
83 |
|idx| |
166 | 84 |
|
537
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
85 |
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
|
86 |
idx ~~ 0 ifTrue:[ |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
87 |
indizes add:idx |
21fc632b22fe
dont err when selection is set, but there is no list
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
88 |
]. |
166 | 89 |
]. |
90 |
^ self selectionIndex:indizes |
|
91 |
||
92 |
"Created: 26.10.1995 / 16:40:24 / cg" |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
93 |
"Modified: 25.4.1996 / 09:07:44 / cg" |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
94 |
! ! |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
95 |
|
563 | 96 |
!MultiSelectionInList methodsFor:'queries'! |
166 | 97 |
|
563 | 98 |
zeroIndex |
99 |
"return the selectionIndex returned when nothing is selected. |
|
100 |
Here, an empty collection is returned." |
|
166 | 101 |
|
563 | 102 |
^ Array new |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
103 |
|
563 | 104 |
"Modified: 20.4.1996 / 13:12:58 / cg" |
166 | 105 |
! ! |
106 |
||
114 | 107 |
!MultiSelectionInList methodsFor:'selections'! |
108 |
||
109 |
selections |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
110 |
"obsolete - almost the same as selection" |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
111 |
|
114 | 112 |
|selectionIndices| |
113 |
||
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
114 |
self obsoleteMethodWarning. |
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
115 |
|
293 | 116 |
selectionIndices := selectionIndexHolder value. |
536 | 117 |
(selectionIndices isNil |
563 | 118 |
or:[selectionIndices == 0 |
536 | 119 |
or:[selectionIndices isEmpty]]) ifFalse:[ |
120 |
^ selectionIndices collect:[:index | listHolder value at:index] |
|
114 | 121 |
]. |
360
c057423ecdd0
literal array overwrite fixed
Claus Gittinger <cg@exept.de>
parents:
293
diff
changeset
|
122 |
^ Array new |
536 | 123 |
|
579
a9188bedbfb9
commentary & backward compatibility fix
Claus Gittinger <cg@exept.de>
parents:
563
diff
changeset
|
124 |
"Modified: 25.4.1996 / 09:09:45 / cg" |
114 | 125 |
! ! |
126 |
||
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
127 |
!MultiSelectionInList class methodsFor:'documentation'! |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
128 |
|
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
129 |
version |
583 | 130 |
^ '$Header: /cvs/stx/stx/libwidg/MultiSelectionInList.st,v 1.12 1996-04-25 16:43:12 cg Exp $' |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
360
diff
changeset
|
131 |
! ! |