OrderedCollectionInspectorView.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Jul 1998 23:29:51 +0200
changeset 1742 982fa0fdf9e3
parent 1739 d98fa6eea4fc
child 1743 88f86bfde4a4
permissions -rw-r--r--
*** empty log message ***

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

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           )
                      ('-'                           nil                    )
                      ('owners'                      showReferences         )
                      ('-'                           nil                    )
                      ('browse'                      browse                 )
                      ('browse class hierarchy'      browseClassHierarchy   )
                      ('browse full class protocol'  browseFullClassProtocol)
                      ('-'                           nil                    )
                      ('remove'                      removeIndex            )
                      ('-'                           nil                    )
                      ('show more'                   showMore               )
                   ).
    ] ifFalse:[
        items := #(
                      ('inspect'                     doInspect              )
                      ('basicInspect'                doBasicInspect         )
                      ('inspect hierarchical'        doNewInspect           )
                      ('-'                           nil                    )
                      ('owners'                      showReferences         )
                      ('-'                           nil                    )
                      ('browse'                      browse                 )
                      ('browse class hierarchy'      browseClassHierarchy   )
                      ('browse full class protocol'  browseFullClassProtocol)
                      ('-'                             nil                  )
                      ('remove'                        removeIndex        )
                   ).
    ].

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

    m := PopUpMenu
          itemList:items
          resources:resources.

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

    ^ m

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

!OrderedCollectionInspectorView methodsFor:'user interaction'!

doAccept:theText
    |value|

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

    selectedLine notNil ifTrue:[
	selectedLine == 1 ifFalse:[
	    inspectedObject at:selectedLine - 1 put:value.
	    inspectedObject changed
	]
    ].
!

doInspect
    "user selected inspect-menu entry"

    selectedLine notNil ifTrue:[
	(selectedLine == 1) ifTrue:[
	    inspectedObject inspect
	] ifFalse:[
	    (inspectedObject at:selectedLine - 1) inspect
	].
    ]
!

removeIndex
    "remove selected item from the collection"

    selectedLine == 1 ifFalse:[
	inspectedObject removeIndex:selectedLine -1.
	selectedLine := nil.
	inspectedObject changed.
	self inspect:inspectedObject. "force list update"
    ]
!

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

    |index|

    hideReceiver ifFalse:[
        (lineNr isNil or:[lineNr == 1]) ifTrue:[
            ^ inspectedObject
        ].
        index := lineNr - 1.   "/ skip self
    ] ifTrue:[
        index := lineNr
    ].
    ^ inspectedObject at:index

    "Modified: 28.6.1996 / 15:53:56 / cg"
! !

!OrderedCollectionInspectorView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/OrderedCollectionInspectorView.st,v 1.22 1998-07-23 21:29:46 cg Exp $'
! !