129
|
1 |
'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:01:39 pm'!
|
114
|
2 |
|
129
|
3 |
ValueHolder subclass:#SelectionInList
|
114
|
4 |
instanceVariableNames:'listHolder indexHolder'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
129
|
7 |
category:'Interface-Support-Models'
|
114
|
8 |
!
|
|
9 |
|
|
10 |
!SelectionInList class methodsFor:'instance creation'!
|
|
11 |
|
|
12 |
new
|
|
13 |
^ super new initialize
|
|
14 |
!
|
|
15 |
|
|
16 |
with:aList
|
|
17 |
^ self new listHolder:(ValueHolder with:aList)
|
|
18 |
! !
|
|
19 |
|
|
20 |
!SelectionInList methodsFor:'initialization'!
|
|
21 |
|
|
22 |
initialize
|
|
23 |
listHolder := ValueHolder new.
|
|
24 |
indexHolder := ValueHolder new.
|
|
25 |
! !
|
|
26 |
|
|
27 |
!SelectionInList methodsFor:'accessing'!
|
|
28 |
|
129
|
29 |
list
|
|
30 |
^ listHolder value
|
|
31 |
!
|
|
32 |
|
|
33 |
listHolder:aValueHolder
|
|
34 |
listHolder := aValueHolder
|
|
35 |
!
|
|
36 |
|
|
37 |
selectionIndex:newIndex
|
|
38 |
indexHolder isNil ifTrue:[
|
|
39 |
indexHolder := ValueHolder new.
|
|
40 |
].
|
|
41 |
indexHolder value:newIndex.
|
|
42 |
self notifyChange:#selectionIndex.
|
|
43 |
|
|
44 |
!
|
|
45 |
|
|
46 |
index
|
|
47 |
"OBSOLETE interface"
|
|
48 |
|
|
49 |
^ self selectionIndex
|
|
50 |
!
|
|
51 |
|
|
52 |
selectionIndex
|
|
53 |
^ indexHolder value
|
|
54 |
!
|
|
55 |
|
|
56 |
selection:anObject
|
|
57 |
^ self selectionIndex:(self list indexOf:anObject ifAbsent:0)
|
|
58 |
|
|
59 |
!
|
|
60 |
|
|
61 |
selection
|
|
62 |
|idx|
|
|
63 |
|
|
64 |
idx := self selectionIndex.
|
|
65 |
(idx isNil or:[idx == 0]) ifTrue:[^ nil].
|
|
66 |
^ self list at:idx
|
114
|
67 |
!
|
|
68 |
|
|
69 |
selectionIndexHolder
|
|
70 |
^ indexHolder
|
|
71 |
!
|
|
72 |
|
129
|
73 |
index:newIndex
|
|
74 |
"OBSOLETE interface"
|
|
75 |
|
|
76 |
^ self selectionIndex:newIndex
|
|
77 |
!
|
|
78 |
|
|
79 |
list:aCollection
|
|
80 |
listHolder isNil ifTrue:[
|
|
81 |
listHolder := ValueHolder new.
|
|
82 |
].
|
|
83 |
listHolder value:aCollection.
|
|
84 |
indexHolder isNil ifTrue:[
|
|
85 |
indexHolder := ValueHolder new.
|
|
86 |
].
|
|
87 |
indexHolder value:0.
|
|
88 |
self notifyChange:#list.
|
|
89 |
!
|
|
90 |
|
|
91 |
listHolder
|
|
92 |
^ listHolder
|
|
93 |
!
|
|
94 |
|
|
95 |
indexHolder
|
|
96 |
^ indexHolder
|
114
|
97 |
!
|
|
98 |
|
|
99 |
selectionIndexHolder:aValueHolder
|
|
100 |
indexHolder := aValueHolder
|
129
|
101 |
!
|
|
102 |
|
|
103 |
indexHolder:aValueHolder
|
|
104 |
indexHolder := aValueHolder
|
114
|
105 |
! !
|
|
106 |
|