author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 18:26:58 +0100 | |
changeset 956 | afea28c682be |
parent 794 | b4b902784e00 |
child 1361 | 20c353524524 |
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 |
|
28 |
|menu| |
|
29 |
||
30 |
menu := super fieldMenu. |
|
31 |
menu addLabels:#( |
|
32 |
'-' |
|
33 |
'remove element' |
|
34 |
) |
|
35 |
selectors:#( |
|
36 |
nil |
|
37 |
doRemoveKey |
|
38 |
). |
|
39 |
||
40 |
^ menu |
|
41 |
! ! |
|
42 |
||
43 |
!SetInspectorView methodsFor:'private'! |
|
44 |
||
647 | 45 |
defaultLabel |
46 |
^ 'contents' |
|
47 |
||
48 |
" |
|
49 |
(Set with:1 with:2 with:3) inspect |
|
50 |
" |
|
51 |
||
52 |
"Modified: 28.6.1996 / 16:05:42 / cg" |
|
53 |
! |
|
54 |
||
370 | 55 |
fieldList |
56 |
"return a list of names for the selectionlist. Leave hasMore as |
|
57 |
true, if a '...' entry should be added." |
|
58 |
||
59 |
|aList| |
|
60 |
||
61 |
inspectedObject isNil ifTrue:[^ #()]. |
|
62 |
||
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
63 |
self topView withWaitCursorDo:[ |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
64 |
keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString]. |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
65 |
aList := keys collect:[:k | k isSymbol ifTrue:[ |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
66 |
k printString |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
67 |
] ifFalse:[ |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
68 |
k displayString |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
69 |
] |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
70 |
]. |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
71 |
aList := aList asOrderedCollection. |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
72 |
hideReceiver ifFalse:[aList addFirst:'self']. |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
73 |
]. |
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
74 |
|
370 | 75 |
^ aList |
76 |
||
532
12050a9af056
Sort keys by dosplayString, not printString.
Stefan Vogel <sv@exept.de>
parents:
510
diff
changeset
|
77 |
"Modified: 8.5.1996 / 14:29:45 / stefan" |
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
78 |
"Modified: 14.2.1997 / 18:26:04 / cg" |
370 | 79 |
! |
80 |
||
81 |
release |
|
82 |
"release inspected object" |
|
83 |
||
84 |
keys := nil. |
|
85 |
super release |
|
86 |
||
87 |
"Created: 9.2.1996 / 12:04:30 / stefan" |
|
88 |
! ! |
|
89 |
||
90 |
!SetInspectorView methodsFor:'user interaction'! |
|
91 |
||
92 |
doAccept:theText |
|
93 |
"accept value for selected item" |
|
94 |
||
95 |
|value| |
|
96 |
||
97 |
value := Compiler evaluate:theText receiver:inspectedObject notifying:workspace. |
|
98 |
||
99 |
inspectedObject add:value. |
|
100 |
inspectedObject changed. |
|
101 |
self inspect:inspectedObject |
|
102 |
||
103 |
||
104 |
! |
|
105 |
||
106 |
doRemoveKey |
|
107 |
"remove selected item from keys" |
|
108 |
||
109 |
|key| |
|
110 |
||
111 |
selectedLine == 1 ifFalse:[ |
|
112 |
key := (keys at:selectedLine - 1). |
|
113 |
(inspectedObject includes:key) ifTrue:[ |
|
114 |
listView cursor:(Cursor wait). |
|
115 |
inspectedObject remove:key. |
|
116 |
keys := nil. |
|
117 |
selectedLine := nil. |
|
118 |
inspectedObject changed. |
|
119 |
listView cursor:(Cursor hand). |
|
120 |
self inspect:inspectedObject. "force list update" |
|
121 |
]. |
|
122 |
] |
|
123 |
||
124 |
||
125 |
! |
|
126 |
||
127 |
valueAtLine:lineNr |
|
128 |
"helper - return the value of the selected entry" |
|
129 |
||
130 |
|key| |
|
131 |
||
132 |
lineNr == 1 ifTrue:[ |
|
133 |
^ inspectedObject |
|
134 |
]. |
|
135 |
key := (keys at:lineNr - 1). |
|
136 |
^ key. |
|
137 |
||
138 |
"Created: 9.2.1996 / 12:03:29 / stefan" |
|
139 |
! ! |
|
140 |
||
794 | 141 |
!SetInspectorView class methodsFor:'documentation'! |
370 | 142 |
|
143 |
version |
|
956
afea28c682be
show a waitCursor, while collecitng keys
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
144 |
^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.7 1997-01-14 17:26:58 cg Exp $' |
370 | 145 |
! ! |