OrderedCollectionInspectorView.st
author Claus Gittinger <cg@exept.de>
Fri, 12 Apr 1996 18:41:35 +0200
changeset 473 5435d56402db
parent 200 01ce3d3636d5
child 510 6543e55fb227
permissions -rw-r--r--
added monitor stuff to menu; items reordered

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

! !

!OrderedCollectionInspectorView methodsFor:'private'!

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.
    aList add:'self'.
    1 to:n do:[:index |
	aList add:(index printString)
    ].
    ^ aList
!

fieldMenu
    |labels selectors m|

    hasMore ifTrue:[
        labels := #(
                      'inspect'
                      'basicInspect'
                      '-'
                      'browse'
                      'browse class hierarchy'
                      'browse full class protocol'
                      '-'
                      'remove'
                      '-'
                      'show more'
                   ).

        selectors := #(
                      doInspect 
                      doBasicInspect 
                      nil 
                      browse
                      browseClassHierarchy
                      browseFullClassProtocol
                      nil 
                      removeIndex
                      nil 
                      showMore
                      ).
    ] ifFalse:[
        labels := #(
                      'inspect'
                      'basicInspect'
                      '-'
                      'browse'
                      'browse class hierarchy'
                      'browse full class protocol'
                      '-'
                      'remove'
"/                      '-'
"/                      'owners'
                   ).

        selectors := #(
                      doInspect 
                      doBasicInspect 
                      nil 
                      browse
                      browseClassHierarchy
                      browseFullClassProtocol
                      nil 
                      removeIndex
"/                      nil
"/                      inspectOwners
                      ).

    ].

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

    m := PopUpMenu
          labels:(resources array:labels)
          selectors:selectors.

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

    ^ m

    "Modified: 12.4.1996 / 14:04:40 / 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|

    lineNr == 1 ifTrue:[
	^ inspectedObject
    ].
    index := lineNr - 1.   "/ skip self
    ^ inspectedObject at:index

! !

!OrderedCollectionInspectorView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/OrderedCollectionInspectorView.st,v 1.13 1996-04-12 16:41:35 cg Exp $'
! !