author | Claus Gittinger <cg@exept.de> |
Wed, 23 Jun 1999 18:04:06 +0200 | |
changeset 2192 | c7bce869223c |
parent 2191 | 06957119a0ac |
child 2193 | 3d7b1044e8c8 |
permissions | -rw-r--r-- |
370 | 1 |
InspectorView subclass:#SetInspectorView |
2 |
instanceVariableNames:'keys' |
|
3 |
classVariableNames:'' |
|
4 |
poolDictionaries:'' |
|
5 |
category:'Interface-Inspector' |
|
6 |
! |
|
7 |
||
794 | 8 |
!SetInspectorView class methodsFor:'documentation'! |
370 | 9 |
|
10 |
documentation |
|
11 |
" |
|
12 |
A modified inspector for Sets |
|
510 | 13 |
|
14 |
[author:] |
|
15 |
Stefan Vogel |
|
370 | 16 |
" |
17 |
! |
|
18 |
||
19 |
examples |
|
20 |
" |
|
21 |
#(a b c d e) asSet inspect |
|
22 |
" |
|
23 |
! ! |
|
24 |
||
25 |
!SetInspectorView methodsFor:'initialization'! |
|
26 |
||
27 |
fieldMenu |
|
1361 | 28 |
<resource: #programMenu > |
29 |
||
370 | 30 |
|menu| |
31 |
||
32 |
menu := super fieldMenu. |
|
33 |
menu addLabels:#( |
|
34 |
'-' |
|
35 |
'remove element' |
|
36 |
) |
|
37 |
selectors:#( |
|
38 |
nil |
|
39 |
doRemoveKey |
|
40 |
). |
|
41 |
||
42 |
^ menu |
|
1361 | 43 |
|
44 |
"Modified: / 29.10.1997 / 03:41:47 / cg" |
|
370 | 45 |
! ! |
46 |
||
47 |
!SetInspectorView methodsFor:'private'! |
|
48 |
||
647 | 49 |
defaultLabel |
50 |
^ 'contents' |
|
51 |
||
52 |
" |
|
53 |
(Set with:1 with:2 with:3) inspect |
|
54 |
" |
|
55 |
||
56 |
"Modified: 28.6.1996 / 16:05:42 / cg" |
|
57 |
! |
|
58 |
||
370 | 59 |
fieldList |
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
60 |
"return a list of names for the selectionlist." |
370 | 61 |
|
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
62 |
|aList l| |
370 | 63 |
|
64 |
inspectedObject isNil ifTrue:[^ #()]. |
|
65 |
||
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
66 |
self topView withWaitCursorDo:[ |
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
67 |
aList := inspectedObject class allInstVarNames asOrderedCollection. |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
68 |
"/ hide Set stuff |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
69 |
aList := aList copyFrom:(Set instSize + 1). |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
70 |
hideReceiver ifFalse:[aList addFirst:'self']. |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
71 |
|
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
72 |
keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString]. |
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
73 |
l := keys collect:[:k | k isSymbol ifTrue:[ |
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
74 |
k printString |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
75 |
] ifFalse:[ |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
76 |
k displayString |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
77 |
] |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
78 |
]. |
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
79 |
aList addAll:l. |
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
80 |
]. |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
81 |
|
370 | 82 |
^ aList |
83 |
||
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
84 |
|
370 | 85 |
! |
86 |
||
87 |
release |
|
88 |
"release inspected object" |
|
89 |
||
90 |
keys := nil. |
|
91 |
super release |
|
92 |
||
93 |
"Created: 9.2.1996 / 12:04:30 / stefan" |
|
94 |
! ! |
|
95 |
||
96 |
!SetInspectorView methodsFor:'user interaction'! |
|
97 |
||
98 |
doAccept:theText |
|
99 |
"accept value for selected item" |
|
100 |
||
101 |
|value| |
|
102 |
||
103 |
value := Compiler evaluate:theText receiver:inspectedObject notifying:workspace. |
|
104 |
||
105 |
inspectedObject add:value. |
|
106 |
inspectedObject changed. |
|
107 |
self inspect:inspectedObject |
|
108 |
||
109 |
||
110 |
! |
|
111 |
||
112 |
doRemoveKey |
|
113 |
"remove selected item from keys" |
|
114 |
||
2192 | 115 |
|key idx| |
370 | 116 |
|
2192 | 117 |
idx := selectedLine. |
118 |
(idx notNil and:[idx ~~ 1]) ifTrue:[ |
|
119 |
idx := idx + Set instSize. |
|
120 |
idx <= inspectedObject class instSize ifTrue:[ |
|
121 |
^ self |
|
122 |
]. |
|
123 |
idx := idx - inspectedObject class instSize. |
|
124 |
||
125 |
key := keys at:idx. |
|
370 | 126 |
(inspectedObject includes:key) ifTrue:[ |
127 |
listView cursor:(Cursor wait). |
|
128 |
inspectedObject remove:key. |
|
129 |
keys := nil. |
|
130 |
selectedLine := nil. |
|
131 |
inspectedObject changed. |
|
132 |
listView cursor:(Cursor hand). |
|
133 |
self inspect:inspectedObject. "force list update" |
|
134 |
]. |
|
135 |
] |
|
136 |
||
137 |
||
138 |
! |
|
139 |
||
140 |
valueAtLine:lineNr |
|
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
141 |
"helper - return the value of the selected entry; |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
142 |
Here, the key itself is the value." |
370 | 143 |
|
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
144 |
|key idx| |
370 | 145 |
|
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
146 |
idx := lineNr. |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
147 |
hideReceiver ifFalse:[ |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
148 |
(lineNr == 1 or:[lineNr isNil]) ifTrue:[ |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
149 |
^ inspectedObject |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
150 |
]. |
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
151 |
idx := idx - 1. |
370 | 152 |
]. |
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
153 |
|
2192 | 154 |
idx := idx + Set instSize. |
155 |
idx <= inspectedObject class instSize ifTrue:[ |
|
156 |
^ inspectedObject instVarAt:idx |
|
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
157 |
]. |
2192 | 158 |
idx := idx - inspectedObject class instSize. |
2191
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
159 |
|
06957119a0ac
show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
160 |
key := keys at:idx. |
370 | 161 |
^ key. |
162 |
||
163 |
! ! |
|
164 |
||
794 | 165 |
!SetInspectorView class methodsFor:'documentation'! |
370 | 166 |
|
167 |
version |
|
2192 | 168 |
^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.10 1999-06-23 16:04:06 cg Exp $' |
370 | 169 |
! ! |