SetInspectorView.st
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--
checkin from browser

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
"
!

history
    "Created: 13.2.1996 / 10:09:14 / stefan"
! !

!SetInspectorView methodsFor:'initialization'!

fieldMenu
    |menu|

    menu := super fieldMenu.
    menu addLabels:#(
                       '-'
                       'remove element'
                   )
         selectors:#(
                       nil 
                       doRemoveKey
                   ).

    ^ menu
! !

!SetInspectorView methodsFor:'private'!

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. Leave hasMore as
     true, if a '...' entry should be added."

    |aList|

    inspectedObject isNil ifTrue:[^ #()].

    keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString].
    aList := keys collect:[:k | k isSymbol ifTrue:[
                                                k printString
                                               ] ifFalse:[
                                                k displayString
                                               ]
                                         ].
    aList := aList asOrderedCollection.
    hideReceiver ifFalse:[aList addFirst:'self'].
    ^ aList

    "Modified: 8.5.1996 / 14:29:45 / stefan"
    "Modified: 28.6.1996 / 15:09:29 / cg"
!

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 inspect:inspectedObject


!

doRemoveKey
    "remove selected item from keys"

    |key|

    selectedLine == 1 ifFalse:[
        key := (keys at:selectedLine - 1).
        (inspectedObject includes:key) ifTrue:[
            listView cursor:(Cursor wait).
            inspectedObject remove:key.
            keys := nil.
            selectedLine := nil.
            inspectedObject changed.
            listView cursor:(Cursor hand).
            self inspect:inspectedObject. "force list update"
        ].
    ]


!

valueAtLine:lineNr
    "helper - return the value of the selected entry"

    |key|

    lineNr == 1 ifTrue:[
        ^ inspectedObject
    ].
    key := (keys at:lineNr - 1).
    ^ key.

    "Created: 9.2.1996 / 12:03:29 / stefan"
! !

!SetInspectorView  class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.5 1996-06-28 14:12:50 cg Exp $'
! !