OrderedCollectionInspectorView.st
author claus
Sun, 26 Mar 1995 19:35:57 +0200
changeset 88 a38a2e87687b
parent 73 e332d9c71624
child 110 570a38362ae1
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.
"
!

version
"
$Header: /cvs/stx/stx/libtool/OrderedCollectionInspectorView.st,v 1.8 1995-03-26 17:35:34 claus Exp $
"
! !

!OrderedCollectionInspectorView methodsFor:'private'!

fieldMenu
    |labels selectors|

    hasMore ifTrue:[
	labels := #(
		      'inspect'
		      'basicInspect'
		      '-'
		      'remove'
		      '-'
		      'show more'
		   ).

	selectors := #(
		      doInspect 
		      doBasicInspect 
		      nil 
		      removeIndex
		      nil 
		      showMore
		      ).
    ] ifFalse:[
	labels := #(
		      'inspect'
		      'basicInspect'
		      '-'
		      'remove'
"/                      '-'
"/                      'owners'
		   ).

	selectors := #(
		      doInspect 
		      doBasicInspect 
		      nil 
		      removeIndex
"/                      nil
"/                      inspectOwners
		      ).
    ].

    ^ PopUpMenu
	  labels:(resources array:labels)
	  selectors:selectors
!

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

!OrderedCollectionInspectorView methodsFor:'user interaction'!

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

!

doInspect
    "user selected inspect-menu entry"

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

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
	]
    ].
! !