OCInspView.st
author claus
Thu, 10 Aug 1995 15:14:54 +0200
changeset 110 570a38362ae1
parent 88 a38a2e87687b
child 111 b4ef3e799345
permissions -rw-r--r--
.

"
 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/Attic/OCInspView.st,v 1.9 1995-08-10 13:14:42 claus Exp $
$Revision: 1.9 $
"
! !

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