author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jan 2018 19:07:03 +0100 | |
changeset 17944 | 58da3a446bc2 |
parent 15801 | 693e2bc2b0e1 |
child 15808 | e6815b0469a1 |
child 18811 | 8e00c5b70900 |
permissions | -rw-r--r-- |
15801 | 1 |
"{ Encoding: utf8 }" |
2 |
||
2627 | 3 |
" |
4 |
COPYRIGHT (c) 1996 by Claus Gittinger / eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2717 | 14 |
"{ Package: 'stx:libtool' }" |
15 |
||
15801 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
370 | 18 |
InspectorView subclass:#SetInspectorView |
19 |
instanceVariableNames:'keys' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Inspector' |
|
23 |
! |
|
24 |
||
794 | 25 |
!SetInspectorView class methodsFor:'documentation'! |
370 | 26 |
|
2627 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1996 by Claus Gittinger / eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
||
40 |
! |
|
41 |
||
370 | 42 |
documentation |
43 |
" |
|
44 |
A modified inspector for Sets |
|
510 | 45 |
|
46 |
[author:] |
|
47 |
Stefan Vogel |
|
370 | 48 |
" |
49 |
! |
|
50 |
||
51 |
examples |
|
52 |
" |
|
53 |
#(a b c d e) asSet inspect |
|
54 |
" |
|
55 |
! ! |
|
56 |
||
6491 | 57 |
!SetInspectorView methodsFor:'menu'! |
370 | 58 |
|
59 |
fieldMenu |
|
1361 | 60 |
<resource: #programMenu > |
61 |
||
370 | 62 |
|menu| |
63 |
||
64 |
menu := super fieldMenu. |
|
65 |
menu addLabels:#( |
|
66 |
'-' |
|
3200 | 67 |
'Remove element' |
370 | 68 |
) |
69 |
selectors:#( |
|
70 |
nil |
|
71 |
doRemoveKey |
|
72 |
). |
|
73 |
||
2236
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
74 |
(self keyIndexForLine:selectionIndex) isNil ifTrue:[ |
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
75 |
menu disableAll:#(doRemoveKey) |
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
76 |
]. |
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
77 |
|
370 | 78 |
^ menu |
1361 | 79 |
|
80 |
"Modified: / 29.10.1997 / 03:41:47 / cg" |
|
370 | 81 |
! ! |
82 |
||
83 |
!SetInspectorView methodsFor:'private'! |
|
84 |
||
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
85 |
baseInspectedObjectClass |
15801 | 86 |
(inspectedObject class inheritsFrom:Set) ifTrue:[ |
87 |
^ Set |
|
6324 | 88 |
]. |
15801 | 89 |
^ Object |
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
90 |
! |
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
91 |
|
647 | 92 |
defaultLabel |
4095
5bd36b14723d
labels; added suppressPseudoVars & dereferenceValueHolders
Claus Gittinger <cg@exept.de>
parents:
3884
diff
changeset
|
93 |
^ 'Contents' |
647 | 94 |
|
95 |
" |
|
96 |
(Set with:1 with:2 with:3) inspect |
|
97 |
" |
|
98 |
||
99 |
"Modified: 28.6.1996 / 16:05:42 / cg" |
|
100 |
! |
|
101 |
||
6943 | 102 |
derivedFields |
11894 | 103 |
^ super derivedFields |
104 |
"/ |
|
105 |
"/ size is already there |
|
106 |
"/ ^ Dictionary new |
|
107 |
"/ declareAllNewFrom:(super derivedFields ? #()); |
|
108 |
"/ add:('-size' -> [ object size ]); |
|
109 |
"/ yourself |
|
6943 | 110 |
|
7379 | 111 |
"Modified: / 09-10-2006 / 12:27:21 / cg" |
6943 | 112 |
! |
113 |
||
3875 | 114 |
indexList |
115 |
"return a list of indexes to show in the selectionList. |
|
116 |
Set hasMore to true, if a '...' entry should be added." |
|
117 |
||
8526
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
118 |
inspectedObject size > nShown ifTrue:[ |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
119 |
|coll| |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
120 |
|
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
121 |
coll := (SortedCollection new:nShown) sortBlock:[:a :b | a displayString < b displayString]. |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
122 |
inspectedObject do:[:el | |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
123 |
coll add:el. |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
124 |
coll size >= nShown ifTrue:[ |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
125 |
hasMore := true. |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
126 |
^ coll |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
127 |
]. |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
128 |
]. |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
129 |
]. |
5ecd6ffcfa6c
also show only the first nShown names;
Claus Gittinger <cg@exept.de>
parents:
7379
diff
changeset
|
130 |
|
3875 | 131 |
^ inspectedObject asSortedCollection:[:a :b | a displayString < b displayString]. |
132 |
! |
|
133 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
134 |
indexedFieldList |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
135 |
"return a list of indexed-variable names to show in the selectionList. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
136 |
Set hasMore to true, if a '...' entry should be added." |
370 | 137 |
|
3875 | 138 |
keys := self indexList. |
15801 | 139 |
^ keys collect:[:k | k displayString]. |
370 | 140 |
! |
141 |
||
12833 | 142 |
numIndexedFields |
143 |
^ inspectedObject size |
|
144 |
! |
|
145 |
||
370 | 146 |
release |
147 |
"release inspected object" |
|
148 |
||
149 |
keys := nil. |
|
150 |
super release |
|
151 |
||
152 |
"Created: 9.2.1996 / 12:04:30 / stefan" |
|
3884 | 153 |
! |
154 |
||
155 |
showAllIndexedVarsInFieldList |
|
15801 | 156 |
^ true |
157 |
! ! |
|
158 |
||
159 |
!SetInspectorView methodsFor:'queries'! |
|
160 |
||
161 |
isIndexShown |
|
3884 | 162 |
^ false |
370 | 163 |
! ! |
164 |
||
165 |
!SetInspectorView methodsFor:'user interaction'! |
|
166 |
||
167 |
doRemoveKey |
|
168 |
"remove selected item from keys" |
|
169 |
||
2192 | 170 |
|key idx| |
370 | 171 |
|
2236
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
172 |
idx := self keyIndexForLine:selectionIndex. |
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
173 |
idx notNil ifTrue:[ |
2192 | 174 |
key := keys at:idx. |
370 | 175 |
(inspectedObject includes:key) ifTrue:[ |
176 |
listView cursor:(Cursor wait). |
|
177 |
inspectedObject remove:key. |
|
178 |
keys := nil. |
|
2236
257f587ad7dc
migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
179 |
selectionIndex := selectedLine := nil. |
370 | 180 |
inspectedObject changed. |
181 |
listView cursor:(Cursor hand). |
|
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
182 |
self reinspect. |
370 | 183 |
]. |
184 |
] |
|
185 |
||
186 |
||
187 |
! |
|
188 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
189 |
indexedValueAtIndex:idx |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
190 |
^ keys at:idx |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
191 |
! |
370 | 192 |
|
3884 | 193 |
indexedValueAtKey:idx |
15801 | 194 |
^ idx |
3884 | 195 |
! |
196 |
||
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
197 |
valueAtLine:lineNr put:newValue |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
198 |
"store newValue; |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
199 |
For non-named instvars, we add the new value - ignoring the selection" |
370 | 200 |
|
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
201 |
|idx| |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
202 |
|
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
203 |
idx := self instVarIndexForLine:selectionIndex. |
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
204 |
idx notNil ifTrue:[ |
2271
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
205 |
inspectedObject instVarAt:idx put:newValue. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
206 |
] ifFalse:[ |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
207 |
inspectedObject add:newValue. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
208 |
|
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
209 |
"/ inspectedObject changed. |
0cf238543cb1
fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents:
2236
diff
changeset
|
210 |
self reinspect. |
2193
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
211 |
]. |
3d7b1044e8c8
fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
212 |
|
370 | 213 |
|
214 |
! ! |
|
215 |
||
794 | 216 |
!SetInspectorView class methodsFor:'documentation'! |
370 | 217 |
|
218 |
version |
|
15801 | 219 |
^ '$Header$' |
370 | 220 |
! ! |
12833 | 221 |