36
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
52
|
3 |
All Rights Reserved
|
36
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
InspectorView subclass:#DictionaryInspectorView
|
52
|
14 |
instanceVariableNames:'keys'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Interface-Inspector'
|
36
|
18 |
!
|
|
19 |
|
52
|
20 |
DictionaryInspectorView comment:'
|
36
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
52
|
22 |
All Rights Reserved
|
36
|
23 |
|
110
|
24 |
$Header: /cvs/stx/stx/libtool/Attic/DictInspV.st,v 1.14 1995-08-10 13:14:00 claus Exp $
|
36
|
25 |
'!
|
|
26 |
|
|
27 |
!DictionaryInspectorView class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
52
|
32 |
All Rights Reserved
|
36
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
110
|
45 |
$Header: /cvs/stx/stx/libtool/Attic/DictInspV.st,v 1.14 1995-08-10 13:14:00 claus Exp $
|
|
46 |
$Revision: 1.14 $
|
36
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
documentation
|
|
51 |
"
|
|
52 |
a modified Inspector for Dictionaries
|
|
53 |
"
|
|
54 |
! !
|
|
55 |
|
|
56 |
!DictionaryInspectorView methodsFor:'user interaction'!
|
|
57 |
|
|
58 |
doAccept:theText
|
|
59 |
"accept value for selected item"
|
|
60 |
|
|
61 |
|value|
|
|
62 |
|
|
63 |
value := Compiler evaluate:theText receiver:inspectedObject notifying:workspace.
|
|
64 |
|
|
65 |
selectedLine notNil ifTrue:[
|
52
|
66 |
selectedLine == 1 ifFalse:[
|
|
67 |
inspectedObject at:(keys at:selectedLine - 1) put:value.
|
|
68 |
inspectedObject changed
|
|
69 |
].
|
36
|
70 |
]
|
|
71 |
!
|
|
72 |
|
56
|
73 |
valueAtLine:lineNr
|
|
74 |
"helper - return the value of the selected entry"
|
36
|
75 |
|
56
|
76 |
|key|
|
36
|
77 |
|
56
|
78 |
lineNr == 1 ifTrue:[
|
|
79 |
^ inspectedObject
|
|
80 |
].
|
|
81 |
key := (keys at:lineNr - 1).
|
|
82 |
^ inspectedObject at:key.
|
52
|
83 |
!
|
|
84 |
|
|
85 |
doInspectKey
|
|
86 |
"inspect selected items key"
|
|
87 |
|
|
88 |
selectedLine notNil ifTrue:[
|
|
89 |
selectedLine ~~ 1 ifTrue:[
|
|
90 |
(keys at:selectedLine - 1) inspect
|
|
91 |
].
|
36
|
92 |
]
|
|
93 |
!
|
|
94 |
|
|
95 |
doAddKey
|
|
96 |
"add a key"
|
|
97 |
|
|
98 |
|keyName key|
|
|
99 |
|
77
|
100 |
keyName := Dialog request:'key to add:' initialAnswer:''.
|
108
|
101 |
keyName notEmpty ifTrue:[
|
52
|
102 |
key := keyName asSymbol.
|
|
103 |
(inspectedObject includesKey:key) ifFalse:[
|
|
104 |
inspectedObject at:key put:nil.
|
|
105 |
selectedLine := nil.
|
|
106 |
inspectedObject changed.
|
|
107 |
self inspect:inspectedObject. "force list update"
|
|
108 |
]
|
36
|
109 |
]
|
|
110 |
!
|
|
111 |
|
|
112 |
doRemoveKey
|
|
113 |
"remove selected item from keys"
|
|
114 |
|
|
115 |
|key|
|
|
116 |
|
|
117 |
selectedLine == 1 ifFalse:[
|
52
|
118 |
key := (keys at:selectedLine - 1).
|
|
119 |
(inspectedObject includesKey:key) ifTrue:[
|
|
120 |
listView cursor:(Cursor wait).
|
|
121 |
inspectedObject removeKey:key.
|
|
122 |
keys := nil.
|
|
123 |
selectedLine := nil.
|
|
124 |
inspectedObject changed.
|
|
125 |
listView cursor:(Cursor hand).
|
|
126 |
self inspect:inspectedObject. "force list update"
|
|
127 |
].
|
36
|
128 |
]
|
45
|
129 |
!
|
|
130 |
|
|
131 |
doReferences
|
|
132 |
"show users of selected key (i.e. global)"
|
|
133 |
|
|
134 |
|k|
|
|
135 |
|
|
136 |
selectedLine notNil ifTrue:[
|
52
|
137 |
selectedLine == 1 ifFalse:[
|
|
138 |
k := (keys at:selectedLine - 1).
|
|
139 |
SystemBrowser browseReferendsOf:k asSymbol
|
|
140 |
].
|
45
|
141 |
]
|
36
|
142 |
! !
|
|
143 |
|
56
|
144 |
!DictionaryInspectorView methodsFor:'private'!
|
36
|
145 |
|
73
|
146 |
fieldList
|
56
|
147 |
"return a list of names for the selectionlist. Leave hasMore as
|
|
148 |
true, if a '...' entry should be added."
|
36
|
149 |
|
|
150 |
|aList|
|
|
151 |
|
57
|
152 |
keys := inspectedObject keys asSortedCollection:[:a :b | a printString < b printString].
|
|
153 |
aList := keys collect:[:k | k isSymbol ifTrue:[
|
|
154 |
k printString
|
|
155 |
] ifFalse:[
|
|
156 |
k displayString
|
|
157 |
]
|
|
158 |
].
|
|
159 |
aList := keys asOrderedCollection.
|
36
|
160 |
aList addFirst:'self'.
|
|
161 |
^ aList
|
|
162 |
!
|
|
163 |
|
|
164 |
release
|
|
165 |
"release inspected object"
|
|
166 |
|
|
167 |
keys := nil.
|
|
168 |
super release
|
|
169 |
! !
|
|
170 |
|
|
171 |
!DictionaryInspectorView methodsFor:'initialization'!
|
|
172 |
|
73
|
173 |
fieldMenu
|
45
|
174 |
|labels selectors|
|
36
|
175 |
|
45
|
176 |
inspectedObject == Smalltalk ifTrue:[
|
73
|
177 |
labels := #(
|
|
178 |
'inspect'
|
|
179 |
'inspect key'
|
|
180 |
'basicInspect'
|
|
181 |
'references'
|
|
182 |
'-'
|
|
183 |
'add key'
|
|
184 |
'remove key'
|
|
185 |
).
|
|
186 |
selectors := #(
|
|
187 |
doInspect
|
56
|
188 |
doInspectKey
|
|
189 |
doBasicInspect
|
|
190 |
doReferences
|
|
191 |
nil
|
|
192 |
doAddKey
|
73
|
193 |
doRemoveKey
|
|
194 |
).
|
45
|
195 |
] ifFalse:[
|
73
|
196 |
labels := #(
|
|
197 |
'inspect'
|
|
198 |
'inspect key'
|
|
199 |
'basicInspect'
|
|
200 |
'-'
|
|
201 |
'add key'
|
|
202 |
'remove key'
|
|
203 |
).
|
|
204 |
selectors := #(
|
|
205 |
doInspect
|
56
|
206 |
doInspectKey
|
|
207 |
doBasicInspect
|
|
208 |
nil
|
|
209 |
doAddKey
|
73
|
210 |
doRemoveKey
|
|
211 |
).
|
45
|
212 |
].
|
|
213 |
|
73
|
214 |
^ PopUpMenu
|
|
215 |
labels:(resources array:labels)
|
|
216 |
selectors:selectors
|
36
|
217 |
! !
|