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 |
|
52
|
24 |
$Header: /cvs/stx/stx/libtool/Attic/DictInspV.st,v 1.8 1994-11-17 14:46:44 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 |
"
|
52
|
45 |
$Header: /cvs/stx/stx/libtool/Attic/DictInspV.st,v 1.8 1994-11-17 14:46:44 claus Exp $
|
36
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
a modified Inspector for Dictionaries
|
|
52 |
"
|
|
53 |
! !
|
|
54 |
|
|
55 |
!DictionaryInspectorView methodsFor:'user interaction'!
|
|
56 |
|
|
57 |
doAccept:theText
|
|
58 |
"accept value for selected item"
|
|
59 |
|
|
60 |
|value|
|
|
61 |
|
|
62 |
value := Compiler evaluate:theText receiver:inspectedObject notifying:workspace.
|
|
63 |
|
|
64 |
selectedLine notNil ifTrue:[
|
52
|
65 |
selectedLine == 1 ifFalse:[
|
|
66 |
inspectedObject at:(keys at:selectedLine - 1) put:value.
|
|
67 |
inspectedObject changed
|
|
68 |
].
|
36
|
69 |
]
|
|
70 |
!
|
|
71 |
|
|
72 |
doInspect
|
|
73 |
"inspect selected item"
|
|
74 |
|
|
75 |
|k objectToInspect|
|
|
76 |
|
|
77 |
selectedLine notNil ifTrue:[
|
52
|
78 |
selectedLine == 1 ifTrue:[
|
|
79 |
objectToInspect := inspectedObject
|
|
80 |
] ifFalse:[
|
|
81 |
k := (keys at:selectedLine - 1).
|
|
82 |
objectToInspect := inspectedObject at:k.
|
|
83 |
].
|
|
84 |
objectToInspect inspect
|
|
85 |
]
|
|
86 |
!
|
|
87 |
|
|
88 |
doInspectKey
|
|
89 |
"inspect selected items key"
|
|
90 |
|
|
91 |
selectedLine notNil ifTrue:[
|
|
92 |
selectedLine ~~ 1 ifTrue:[
|
|
93 |
(keys at:selectedLine - 1) inspect
|
|
94 |
].
|
36
|
95 |
]
|
|
96 |
!
|
|
97 |
|
|
98 |
showSelection:lineNr
|
|
99 |
"user clicked on an instvar - show value in workspace"
|
|
100 |
|
|
101 |
|val string|
|
|
102 |
|
|
103 |
"
|
|
104 |
workspace contents:nil.
|
|
105 |
"
|
|
106 |
lineNr == 1 ifTrue:[
|
52
|
107 |
"selecting self also does a re-set, this allows updating the list"
|
|
108 |
self inspect:inspectedObject.
|
|
109 |
val := inspectedObject
|
36
|
110 |
] ifFalse:[
|
52
|
111 |
val := inspectedObject at:(keys at:lineNr - 1)
|
36
|
112 |
].
|
|
113 |
string := val displayString.
|
|
114 |
workspace replace:string.
|
|
115 |
selectedLine := lineNr
|
|
116 |
!
|
|
117 |
|
|
118 |
doAddKey
|
|
119 |
"add a key"
|
|
120 |
|
|
121 |
|keyName key|
|
|
122 |
|
|
123 |
keyName := DialogView request:'key to add:' initialAnswer:''.
|
|
124 |
keyName notNil ifTrue:[
|
52
|
125 |
key := keyName asSymbol.
|
|
126 |
(inspectedObject includesKey:key) ifFalse:[
|
|
127 |
inspectedObject at:key put:nil.
|
|
128 |
selectedLine := nil.
|
|
129 |
inspectedObject changed.
|
|
130 |
self inspect:inspectedObject. "force list update"
|
|
131 |
]
|
36
|
132 |
]
|
|
133 |
!
|
|
134 |
|
|
135 |
doRemoveKey
|
|
136 |
"remove selected item from keys"
|
|
137 |
|
|
138 |
|key|
|
|
139 |
|
|
140 |
selectedLine == 1 ifFalse:[
|
52
|
141 |
key := (keys at:selectedLine - 1).
|
|
142 |
(inspectedObject includesKey:key) ifTrue:[
|
|
143 |
listView cursor:(Cursor wait).
|
|
144 |
inspectedObject removeKey:key.
|
|
145 |
keys := nil.
|
|
146 |
selectedLine := nil.
|
|
147 |
inspectedObject changed.
|
|
148 |
listView cursor:(Cursor hand).
|
|
149 |
self inspect:inspectedObject. "force list update"
|
|
150 |
].
|
36
|
151 |
]
|
45
|
152 |
!
|
|
153 |
|
|
154 |
doReferences
|
|
155 |
"show users of selected key (i.e. global)"
|
|
156 |
|
|
157 |
|k|
|
|
158 |
|
|
159 |
selectedLine notNil ifTrue:[
|
52
|
160 |
selectedLine == 1 ifFalse:[
|
|
161 |
k := (keys at:selectedLine - 1).
|
|
162 |
SystemBrowser browseReferendsOf:k asSymbol
|
|
163 |
].
|
45
|
164 |
]
|
36
|
165 |
! !
|
|
166 |
|
|
167 |
!DictionaryInspectorView methodsFor:'accessing'!
|
|
168 |
|
|
169 |
listOfNames
|
|
170 |
"return a list of names for the selectionlist"
|
|
171 |
|
|
172 |
|aList|
|
|
173 |
|
|
174 |
aList := OrderedCollection new.
|
52
|
175 |
keys := inspectedObject keys asSortedCollection:[:a :b | a displayString < b displayString].
|
36
|
176 |
keys do:[:aKey |
|
52
|
177 |
aList add:(aKey displayString)
|
36
|
178 |
].
|
|
179 |
aList addFirst:'self'.
|
|
180 |
^ aList
|
|
181 |
!
|
|
182 |
|
|
183 |
release
|
|
184 |
"release inspected object"
|
|
185 |
|
|
186 |
keys := nil.
|
|
187 |
super release
|
|
188 |
! !
|
|
189 |
|
|
190 |
!DictionaryInspectorView methodsFor:'initialization'!
|
|
191 |
|
45
|
192 |
initializeListViewMiddleButtonMenus
|
|
193 |
|labels selectors|
|
36
|
194 |
|
45
|
195 |
inspectedObject == Smalltalk ifTrue:[
|
52
|
196 |
labels := resources array:#(
|
|
197 |
'inspect'
|
|
198 |
'inspect key'
|
|
199 |
'references'
|
|
200 |
'-'
|
|
201 |
'add key'
|
|
202 |
'remove key').
|
|
203 |
selectors := #(doInspect doInspectKey doReferences nil doAddKey doRemoveKey).
|
45
|
204 |
] ifFalse:[
|
52
|
205 |
labels := resources array:#(
|
|
206 |
'inspect'
|
|
207 |
'inspect key'
|
|
208 |
'-'
|
|
209 |
'add key'
|
|
210 |
'remove key').
|
|
211 |
selectors := #(doInspect doInspectKey nil doAddKey doRemoveKey).
|
45
|
212 |
].
|
|
213 |
|
|
214 |
menu1 := (PopUpMenu
|
52
|
215 |
labels:(resources array:labels)
|
|
216 |
selectors:selectors
|
|
217 |
receiver:self
|
|
218 |
for:listView).
|
|
219 |
|
36
|
220 |
! !
|