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