OrderedCollectionInspectorView.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 21 Mar 2012 17:50:14 +0000
branchjv
changeset 12205 f210b6224ef0
parent 12128 a7ff7d66ee85
child 12262 d25ef6bb0ef3
permissions -rw-r--r--
Merged with /trunk

"
 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.
"
"{ Package: 'stx:libtool' }"

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:'menu'!

fieldMenu
    "return the menu for the field-list"

    <resource: #programMenu>

    |items m sel|

    items := #(
                  ('Inspect'                     doInspect              )
                  ('BasicInspect'                doBasicInspect         )
             ).
    NewInspector::NewInspectorView notNil ifTrue:[
        items := items , #(
                  ('Inspect Hierarchical'         #doNewInspect           )
             ).
    ].
    items := items , #(
                  ('-')
                  ('Owners'                      showOwners             )
                  ('Ref chains'                  showReferences         )
                  ('-')
                  ('Browse'                      browse                 )
"/                      ('Browse class hierarchy'      browseClassHierarchy   )
"/                      ('Browse full class protocol'  browseFullClassProtocol)
               ).

    sel := self selection.
    (sel isBlock or:[sel isContext]) ifTrue:[
        items := items , #(
                       ('Browse Blocks Home'           #browseHome)
              ).
    ].

    items := items , #(
                  ('-')
                  ('Remove'                      removeIndex            )
               ).

    (hasMore) ifTrue:[
        items := items , #(                                  
                      ('-')
                      ('Show more'                   showMore               )
                   ).
    ].

    monitorProcess isNil ifTrue:[
        items := items , #( ('-') ('Start monitor' doStartMonitor)).
    ] ifFalse:[
        items := items , #( ('-') ('Stop monitor' doStopMonitor)).
    ].
    items := items , (self numberBaseItems).

    m := PopUpMenu
          itemList:items
          resources:resources.

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

    ^ m

    "Modified: / 27-01-2011 / 11:49:59 / cg"
! !

!OrderedCollectionInspectorView methodsFor:'private'!

baseInspectedObjectClass
    (inspectedObject class inheritsFrom:OrderedCollection) ifFalse:[
        ^ Object
    ].
    ^ OrderedCollection
!

defaultLabel
    ^ 'Contents'

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

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

derivedFields
    "provide any derived (computed, virtual) fields"

    ^ Dictionary new
        declareAllNewFrom:(super derivedFields ? #());
        add:('-size' -> [ object size ]);
        yourself

    "Created: / 22-08-2006 / 11:55:29 / cg"
    "Modified: / 09-10-2006 / 12:27:32 / cg"
    "Modified (comment): / 09-03-2012 / 09:54:17 / cg"
!

indexList 
    "return a list of indexes to show in the selectionList.
     Set hasMore to true, if a '...' entry should be added."

    |n|

    n := inspectedObject size.
    (n > nShown) ifTrue:[
        n := nShown.
        hasMore := true.
    ].

    ^ (1 to:n)
! !

!OrderedCollectionInspectorView methodsFor:'user interaction'!

indexedValueAtIndex:idx
    ^ inspectedObject at:idx ifAbsent:nil.

!

indexedValueAtIndex:idx put:newValue
    inspectedObject at:idx put:newValue.
!

removeIndex
    "remove selected item from the collection"

    |idx|

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

!OrderedCollectionInspectorView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/OrderedCollectionInspectorView.st,v 1.44 2012/03/09 09:03:49 cg Exp $'
!

version_CVS
    ^ '§Header: /cvs/stx/stx/libtool/OrderedCollectionInspectorView.st,v 1.44 2012/03/09 09:03:49 cg Exp §'
!

version_SVN
    ^ '$Id: OrderedCollectionInspectorView.st 7952 2012-03-21 17:50:14Z vranyj1 $'
! !