OrderedCollectionInspectorView.st
author Claus Gittinger <cg@exept.de>
Wed, 23 Jun 1999 18:39:52 +0200
changeset 2193 3d7b1044e8c8
parent 2085 ec4daf11d3b6
child 2236 257f587ad7dc
permissions -rw-r--r--
fixed access to namedInstvars

"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

InspectorView subclass:#OrderedCollectionInspectorView
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Inspector'
!

!OrderedCollectionInspectorView class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    a modified Inspector for orderedCollections

    [author:]
        Claus Gittinger
"

! !

!OrderedCollectionInspectorView methodsFor:'private'!

baseInspectedObjectClass
    ^ OrderedCollection

!

defaultLabel
    ^ 'contents'

    "
     (OrderedCollection with:1 with:2 with:3) inspect
    "

    "Modified: 28.6.1996 / 16:06:24 / cg"
!

fieldList 
    "return a list of names for the selectionlist. Leave hasMore as
     true, if a '...' entry should be added."

    |aList n|

    n := inspectedObject size.
    (n > nShown) ifTrue:[
        n := nShown.
        hasMore := true.
    ].
    aList := OrderedCollection new:n+1.
    hideReceiver ifFalse:[aList add:'self'].
    1 to:n do:[:index |
        aList add:(index printString)
    ].
    ^ aList

    "Modified: 28.6.1996 / 15:09:24 / cg"
!

fieldMenu
    "return the menu for the field-list"

    <resource: #programMenu>

    |items m|

    hasMore ifTrue:[
        items := #(                                  
                      ('inspect'                     doInspect              )
                      ('basicInspect'                doBasicInspect         )
                      ('inspect hierarchical'        doNewInspect           )
                      ('-')
                      ('ref chains'                  showReferences         )
                      ('-')
                      ('browse'                      browse                 )
                      ('browse class hierarchy'      browseClassHierarchy   )
                      ('browse full class protocol'  browseFullClassProtocol)
                      ('-')
                      ('remove'                      removeIndex            )
                      ('-')
                      ('show more'                   showMore               )
                   ).
    ] ifFalse:[
        items := #(
                      ('inspect'                     doInspect              )
                      ('basicInspect'                doBasicInspect         )
                      ('inspect hierarchical'        doNewInspect           )
                      ('-')
                      ('ref chains'                  showReferences         )
                      ('-')
                      ('browse'                      browse                 )
                      ('browse class hierarchy'      browseClassHierarchy   )
                      ('browse full class protocol'  browseFullClassProtocol)
                      ('-')
                      ('remove'                      removeIndex            )
                   ).
    ].

    monitorProcess isNil ifTrue:[
        items := items , #( ('-') ('start monitor' doStartMonitor)).
    ] ifFalse:[
        items := items , #( ('-') ('stop monitor' doStopMonitor)).
    ].

    m := PopUpMenu
          itemList:items
          resources:resources.

    selectedLine isNil ifTrue:[
        m disableAll:#(doInspect doBasicInspect 
                       browse browseClassHierarchy browseFullClassProtocol
                       doStartMonitor removeIndex)
    ] ifFalse:[
        (self keyIndexForLine:selectedLine) isNil ifTrue:[
            m disable:#removeIndex
        ].
    ].

    ^ m

    "Modified: / 21.5.1998 / 13:32:09 / cg"
! !

!OrderedCollectionInspectorView methodsFor:'user interaction'!

doAccept:theText
    |value idx|

    value := Compiler evaluate:theText
                      receiver:inspectedObject 
                     notifying:workspace.

    idx := self keyIndexForLine:selectedLine.
    idx notNil ifTrue:[
        inspectedObject at:idx put:value.
    ] ifFalse:[
        idx := self instVarIndexForLine:selectedLine.
        idx notNil ifTrue:[
            inspectedObject instVarAt:idx put:value.
        ] ifFalse:[
            ^ self "/ self selected
        ]
    ].
!

removeIndex
    "remove selected item from the collection"

    |idx|

    idx := self keyIndexForLine:selectedLine.
    idx notNil ifTrue:[
        inspectedObject removeIndex:idx.
        selectedLine := nil.
        inspectedObject changed.
        self reinspect.
    ]
!

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

    |key idx|

    idx := self keyIndexForLine:lineNr.
    idx notNil ifTrue:[
        ^ inspectedObject at:idx ifAbsent:nil.
    ].
    idx := self instVarIndexForLine:lineNr.
    idx notNil ifTrue:[
        ^ inspectedObject instVarAt:idx.
    ].

    hideReceiver ifFalse:[
        (lineNr == 1 or:[lineNr isNil]) ifTrue:[
            ^ inspectedObject
        ].
    ].

    ^ nil

! !

!OrderedCollectionInspectorView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/OrderedCollectionInspectorView.st,v 1.25 1999-06-23 16:39:50 cg Exp $'
! !