author | Claus Gittinger <cg@exept.de> |
Fri, 28 Jun 1996 16:12:50 +0200 | |
changeset 647 | 1791ceddf2ef |
parent 645 | 16a618dcbb43 |
child 794 | b4b902784e00 |
permissions | -rw-r--r-- |
370 | 1 |
InspectorView subclass:#SetInspectorView |
2 |
instanceVariableNames:'keys' |
|
3 |
classVariableNames:'' |
|
4 |
poolDictionaries:'' |
|
5 |
category:'Interface-Inspector' |
|
6 |
! |
|
7 |
||
645 | 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 |
history |
|
26 |
"Created: 13.2.1996 / 10:09:14 / stefan" |
|
27 |
! ! |
|
28 |
||
29 |
!SetInspectorView methodsFor:'initialization'! |
|
30 |
||
31 |
fieldMenu |
|
32 |
|menu| |
|
33 |
||
34 |
menu := super fieldMenu. |
|
35 |
menu addLabels:#( |
|
36 |
'-' |
|
37 |
'remove element' |
|
38 |
) |
|
39 |
selectors:#( |
|
40 |
nil |
|
41 |
doRemoveKey |
|
42 |
). |
|
43 |
||
44 |
^ menu |
|
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 |
60 |
"return a list of names for the selectionlist. Leave hasMore as |
|
61 |
true, if a '...' entry should be added." |
|
62 |
||
63 |
|aList| |
|
64 |
||
65 |
inspectedObject isNil ifTrue:[^ #()]. |
|
66 |
||
532
12050a9af056
Sort keys by dosplayString, not printString.
Stefan Vogel <sv@exept.de>
parents:
510
diff
changeset
|
67 |
keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString]. |
370 | 68 |
aList := keys collect:[:k | k isSymbol ifTrue:[ |
69 |
k printString |
|
70 |
] ifFalse:[ |
|
71 |
k displayString |
|
72 |
] |
|
73 |
]. |
|
74 |
aList := aList asOrderedCollection. |
|
645 | 75 |
hideReceiver ifFalse:[aList addFirst:'self']. |
370 | 76 |
^ aList |
77 |
||
532
12050a9af056
Sort keys by dosplayString, not printString.
Stefan Vogel <sv@exept.de>
parents:
510
diff
changeset
|
78 |
"Modified: 8.5.1996 / 14:29:45 / stefan" |
645 | 79 |
"Modified: 28.6.1996 / 15:09:29 / cg" |
370 | 80 |
! |
81 |
||
82 |
release |
|
83 |
"release inspected object" |
|
84 |
||
85 |
keys := nil. |
|
86 |
super release |
|
87 |
||
88 |
"Created: 9.2.1996 / 12:04:30 / stefan" |
|
89 |
! ! |
|
90 |
||
91 |
!SetInspectorView methodsFor:'user interaction'! |
|
92 |
||
93 |
doAccept:theText |
|
94 |
"accept value for selected item" |
|
95 |
||
96 |
|value| |
|
97 |
||
98 |
value := Compiler evaluate:theText receiver:inspectedObject notifying:workspace. |
|
99 |
||
100 |
inspectedObject add:value. |
|
101 |
inspectedObject changed. |
|
102 |
self inspect:inspectedObject |
|
103 |
||
104 |
||
105 |
! |
|
106 |
||
107 |
doRemoveKey |
|
108 |
"remove selected item from keys" |
|
109 |
||
110 |
|key| |
|
111 |
||
112 |
selectedLine == 1 ifFalse:[ |
|
113 |
key := (keys at:selectedLine - 1). |
|
114 |
(inspectedObject includes:key) ifTrue:[ |
|
115 |
listView cursor:(Cursor wait). |
|
116 |
inspectedObject remove:key. |
|
117 |
keys := nil. |
|
118 |
selectedLine := nil. |
|
119 |
inspectedObject changed. |
|
120 |
listView cursor:(Cursor hand). |
|
121 |
self inspect:inspectedObject. "force list update" |
|
122 |
]. |
|
123 |
] |
|
124 |
||
125 |
||
126 |
! |
|
127 |
||
128 |
valueAtLine:lineNr |
|
129 |
"helper - return the value of the selected entry" |
|
130 |
||
131 |
|key| |
|
132 |
||
133 |
lineNr == 1 ifTrue:[ |
|
134 |
^ inspectedObject |
|
135 |
]. |
|
136 |
key := (keys at:lineNr - 1). |
|
137 |
^ key. |
|
138 |
||
139 |
"Created: 9.2.1996 / 12:03:29 / stefan" |
|
140 |
! ! |
|
141 |
||
645 | 142 |
!SetInspectorView class methodsFor:'documentation'! |
370 | 143 |
|
144 |
version |
|
647 | 145 |
^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.5 1996-06-28 14:12:50 cg Exp $' |
370 | 146 |
! ! |