InspectorView subclass:#SetInspectorView
instanceVariableNames:'keys'
classVariableNames:''
poolDictionaries:''
category:'Interface-Inspector'
!
!SetInspectorView class methodsFor:'documentation'!
documentation
"
A modified inspector for Sets
[author:]
Stefan Vogel
"
!
examples
"
#(a b c d e) asSet inspect
"
! !
!SetInspectorView methodsFor:'initialization'!
fieldMenu
<resource: #programMenu >
|menu|
menu := super fieldMenu.
menu addLabels:#(
'-'
'remove element'
)
selectors:#(
nil
doRemoveKey
).
(self keyIndexForLine:selectedLine) isNil ifTrue:[
menu disableAll:#(doRemoveKey)
].
^ menu
"Modified: / 29.10.1997 / 03:41:47 / cg"
! !
!SetInspectorView methodsFor:'private'!
baseInspectedObjectClass
^ Set
!
defaultLabel
^ 'contents'
"
(Set with:1 with:2 with:3) inspect
"
"Modified: 28.6.1996 / 16:05:42 / cg"
!
fieldList
"return a list of names for the selectionlist."
|aList l|
inspectedObject isNil ifTrue:[^ #()].
self topView withWaitCursorDo:[
aList := inspectedObject class allInstVarNames asOrderedCollection.
"/ hide Set stuff
aList := aList copyFrom:(Set instSize + 1).
hideReceiver ifFalse:[aList addFirst:'self'].
keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString].
l := keys collect:[:k | k isSymbol ifTrue:[
k printString
] ifFalse:[
k displayString
]
].
aList addAll:l.
].
^ aList
!
release
"release inspected object"
keys := nil.
super release
"Created: 9.2.1996 / 12:04:30 / stefan"
! !
!SetInspectorView methodsFor:'user interaction'!
doAccept:theText
"accept value for selected item"
|value|
value := Compiler evaluate:theText receiver:inspectedObject notifying:workspace.
inspectedObject add:value.
inspectedObject changed.
self reinspect.
!
doRemoveKey
"remove selected item from keys"
|key idx|
idx := self keyIndexForLine:selectedLine.
idx notNil ifTrue:[
key := keys at:idx.
(inspectedObject includes:key) ifTrue:[
listView cursor:(Cursor wait).
inspectedObject remove:key.
keys := nil.
selectedLine := nil.
inspectedObject changed.
listView cursor:(Cursor hand).
self reinspect.
].
]
!
valueAtLine:lineNr
"helper - return the value of the selected entry"
|key idx|
idx := self keyIndexForLine:lineNr.
idx notNil ifTrue:[
key := keys at:idx.
^ key.
].
idx := self instVarIndexForLine:lineNr.
idx notNil ifTrue:[
^ inspectedObject instVarAt:idx.
].
hideReceiver ifFalse:[
(lineNr == 1 or:[lineNr isNil]) ifTrue:[
^ inspectedObject
].
].
^ nil
! !
!SetInspectorView class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.11 1999-06-23 16:39:47 cg Exp $'
! !