SetInspectorView.st
author Claus Gittinger <cg@exept.de>
Fri, 16 Jul 1999 19:26:38 +0200
changeset 2271 0cf238543cb1
parent 2236 257f587ad7dc
child 2627 e633d9928ddd
permissions -rw-r--r--
fixed and improved fieldNameList generation & use. Enhanced DictionaryInspector to handle namespaces.

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:selectionIndex) 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"
!

indexedFieldList 
    "return a list of indexed-variable names to show in the selectionList.
     Set hasMore to true, if a '...' entry should be added."

    |aList n cls|

    keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString].
    ^ keys collect:[:k | k isSymbol ifTrue:[
                             k printString
                         ] ifFalse:[
                             k displayString
                         ]
                   ].


!

release 
    "release inspected object"

    keys := nil.
    super release

    "Created: 9.2.1996 / 12:04:30 / stefan"
! !

!SetInspectorView methodsFor:'user interaction'!

doRemoveKey
    "remove selected item from keys"

    |key idx|

    idx := self keyIndexForLine:selectionIndex.
    idx notNil ifTrue:[
        key := keys at:idx.
        (inspectedObject includes:key) ifTrue:[
            listView cursor:(Cursor wait).
            inspectedObject remove:key.
            keys := nil.
            selectionIndex := selectedLine := nil.
            inspectedObject changed.
            listView cursor:(Cursor hand).
            self reinspect.
        ].
    ]


!

indexedValueAtIndex:idx
    ^ keys at:idx

!

valueAtLine:lineNr put:newValue
    "store newValue;
     For non-named instvars, we add the new value - ignoring the selection"

    |idx|

    idx := self instVarIndexForLine:selectionIndex.
    idx notNil ifTrue:[
        inspectedObject instVarAt:idx put:newValue.
    ] ifFalse:[
        inspectedObject add:newValue.

"/        inspectedObject changed.
        self reinspect.
    ].


! !

!SetInspectorView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.13 1999-07-16 17:25:33 cg Exp $'
! !