InspectorView.st
changeset 17872 096003c27b76
parent 17823 d68fc84f98a0
child 17938 873e0a718474
equal deleted inserted replaced
17871:7f0b6e10415d 17872:096003c27b76
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
    21 		suppressPseudoSlots dereferenceValueHolders suppressHeadline
    23 		suppressPseudoSlots dereferenceValueHolders suppressHeadline
    22 		headLineLabel sortOrder hideMessages hideHashes
    24 		headLineLabel sortOrder hideMessages hideHashes
    23 		holderChangeInterest sortOrderHolder'
    25 		holderChangeInterest sortOrderHolder'
    24 	classVariableNames:'DefaultIcon DefaultIntegerDisplayRadix ExpandArraysInAllLists
    26 	classVariableNames:'DefaultIcon DefaultIntegerDisplayRadix ExpandArraysInAllLists
    25 		IdDictionary LastExtent NextSequentialID SortOrderAlphabetical
    27 		IdDictionary LastExtent NextSequentialID SortOrderAlphabetical
    26 		SortOrderInstvarOrder DefaultHideMessages DefaultHideHashes'
    28 		SortOrderInstvarOrder DefaultHideMessages DefaultHideHashes
       
    29 		NoLongerPresentDummyObject'
    27 	poolDictionaries:''
    30 	poolDictionaries:''
    28 	category:'Interface-Inspector'
    31 	category:'Interface-Inspector'
    29 !
    32 !
    30 
    33 
    31 !InspectorView class methodsFor:'documentation'!
    34 !InspectorView class methodsFor:'documentation'!
   109 
   112 
   110 !InspectorView class methodsFor:'initialization'!
   113 !InspectorView class methodsFor:'initialization'!
   111 
   114 
   112 initialize
   115 initialize
   113     SortOrderAlphabetical := #alphabetical.
   116     SortOrderAlphabetical := #alphabetical.
   114     SortOrderInstvarOrder := #instvarOrder
   117     SortOrderInstvarOrder := #instvarOrder.
       
   118     NoLongerPresentDummyObject := Object new.
   115 ! !
   119 ! !
   116 
   120 
   117 !InspectorView class methodsFor:'instance creation'!
   121 !InspectorView class methodsFor:'instance creation'!
   118 
   122 
   119 for:anObject
   123 for:anObject
  2985 displayStringForValue:someValue
  2989 displayStringForValue:someValue
  2986     "return the value's displayString to be pasted into the workspace."
  2990     "return the value's displayString to be pasted into the workspace."
  2987 
  2991 
  2988     |idx sel extraAttributes|
  2992     |idx sel extraAttributes|
  2989 
  2993 
       
  2994     someValue == NoLongerPresentDummyObject ifTrue:[
       
  2995         "/ this is returned by collection-inspectors,
       
  2996         "/ when a field-index for a no-longer-present-index is selected
       
  2997         "/ (eg. if an OrderedCollection growed to a smaller size in the meantime)
       
  2998         ^ '«element no longer present»' withColor:Color grey.
       
  2999     ].
       
  3000 
  2990     idx := self theSingleSelectionIndex.
  3001     idx := self theSingleSelectionIndex.
  2991     idx notNil ifTrue:[
  3002     idx notNil ifTrue:[
  2992         sel := self listEntryAt:idx.
  3003         sel := self listEntryAt:idx.
  2993         sel isNil ifTrue:[^ someValue].
  3004         sel isNil ifTrue:[^ someValue].
  2994 
  3005 
  2995         extraAttributes := self myObjectsInspectorExtraAttributes.
  3006         extraAttributes := self myObjectsInspectorExtraAttributes.
  2996         (extraAttributes includesKey:sel) ifTrue:[
  3007         (extraAttributes includesKey:sel) ifTrue:[
  2997             ^ someValue "(extraAttributes at:sel) value" printString
  3008             ^ someValue "(extraAttributes at:sel) value" printString
  2998         ].
  3009         ].
  2999 
  3010 
  3000         (sel startsWith:'-all inst vars') ifTrue:[
  3011         (sel startsWith:$-) ifTrue:[
  3001             ^ self stringWithAllInstVarValues
  3012             (sel startsWith:'-all inst vars') ifTrue:[
  3002         ].
  3013                 ^ self stringWithAllInstVarValues
  3003         (sel startsWith:'-all class vars') ifTrue:[
  3014             ].
  3004             ^ self stringWithAllClassVarValues
  3015             (sel startsWith:'-all class vars') ifTrue:[
  3005         ].
  3016                 ^ self stringWithAllClassVarValues
  3006         (sel startsWith:'-all indexed vars') ifTrue:[
  3017             ].
  3007             ^ self stringWithAllIndexedVarValues
  3018             (sel startsWith:'-all indexed vars') ifTrue:[
  3008         ].
  3019                 ^ self stringWithAllIndexedVarValues
  3009         (sel startsWith:'-all messages') ifTrue:[
  3020             ].
  3010             ^ self stringWithMessages:#all
  3021             (sel startsWith:'-all messages') ifTrue:[
  3011         ].
  3022                 ^ self stringWithMessages:#all
  3012         (sel startsWith:'-local messages') ifTrue:[
  3023             ].
  3013             ^ self stringWithMessages:#local
  3024             (sel startsWith:'-local messages') ifTrue:[
  3014         ].
  3025                 ^ self stringWithMessages:#local
  3015         (sel startsWith:'-inherited messages') ifTrue:[
  3026             ].
  3016             ^ self stringWithMessages:#inherited
  3027             (sel startsWith:'-inherited messages') ifTrue:[
       
  3028                 ^ self stringWithMessages:#inherited
       
  3029             ].
  3017         ].
  3030         ].
  3018     ].
  3031     ].
  3019     someValue == nil ifTrue:[^ 'nil'].
  3032     someValue == nil ifTrue:[^ 'nil'].
  3020     ^ self basicDisplayStringForValue:someValue
  3033     ^ self basicDisplayStringForValue:someValue
  3021 
  3034 
  3025 iconForValue:arg
  3038 iconForValue:arg
  3026     ^ self class iconForValue:arg
  3039     ^ self class iconForValue:arg
  3027 !
  3040 !
  3028 
  3041 
  3029 listEntryForName:nameString value:value
  3042 listEntryForName:nameString value:value
       
  3043     "generates the fieldListEntry (icon + valueString)"
       
  3044 
  3030     |entryString|
  3045     |entryString|
  3031 
  3046 
  3032     UserPreferences current showTypeIndicatorInInspector ifFalse:[
  3047     UserPreferences current showTypeIndicatorInInspector ifFalse:[
  3033         ^ nameString
  3048         ^ nameString
  3034     ].
  3049     ].
  3271     |d actionItems valueItems otherItems|
  3286     |d actionItems valueItems otherItems|
  3272 
  3287 
  3273     d := self derivedFields.
  3288     d := self derivedFields.
  3274     (d isDictionary) ifTrue:[
  3289     (d isDictionary) ifTrue:[
  3275         actionItems := d keys select:[:k | k first == $!!] as:OrderedCollection .
  3290         actionItems := d keys select:[:k | k first == $!!] as:OrderedCollection .
  3276         valueItems := d keys select:[:k | '-¤' includes:k first] as:OrderedCollection.
  3291         valueItems := d keys select:[:k | '-¤' includes:k first] as:OrderedCollection.
  3277         otherItems := d keys select:[:k | ('!!-¤' includes: k first) not] as:OrderedCollection.
  3292         otherItems := d keys select:[:k | ('!!-¤' includes: k first) not] as:OrderedCollection.
  3278         ^ ((actionItems sort , valueItems sort) collect:[:k | (k copyTo:1),(k copyFrom:2) allItalic])
  3293         ^ ((actionItems sort , valueItems sort) collect:[:k | (k copyTo:1),(k copyFrom:2) allItalic])
  3279           ,
  3294           ,
  3280           otherItems sort
  3295           otherItems sort
  3281     ].
  3296     ].
  3282     ^ d collect:[:eachEntry |
  3297     ^ d collect:[:eachEntry |
  3509             [
  3524             [
  3510                 val := self indexedValueAtIndex:idx.
  3525                 val := self indexedValueAtIndex:idx.
  3511             ] on:Error do:[
  3526             ] on:Error do:[
  3512                 val := ''
  3527                 val := ''
  3513             ].
  3528             ].
  3514 "/            [
       
  3515 "/                val := object at:idx.
       
  3516 "/            ] on:Error do:[
       
  3517 "/                [
       
  3518 "/                    val := object basicAt:idx
       
  3519 "/                ] on:Error do:[
       
  3520 "/                    val := ''
       
  3521 "/                ]
       
  3522 "/            ].
       
  3523             self listEntryForName:nm value:val
  3529             self listEntryForName:nm value:val
  3524         ].
  3530         ].
  3525 
       
  3526 "/    ^ list.
       
  3527 
  3531 
  3528     "Modified: / 27-09-2012 / 21:51:58 / cg"
  3532     "Modified: / 27-09-2012 / 21:51:58 / cg"
  3529 !
  3533 !
  3530 
  3534 
  3531 indexedValueAtIndex:idx
  3535 indexedValueAtIndex:idx
  3891     (self hasSelfEntry
  3895     (self hasSelfEntry
  3892     and:[lineNr == 1 or:[lineNr isNil]]) ifTrue:[
  3896     and:[lineNr == 1 or:[lineNr isNil]]) ifTrue:[
  3893         ^ object
  3897         ^ object
  3894     ].
  3898     ].
  3895 
  3899 
       
  3900     "/ one of the special (pseudo) entries?
  3896     ((lineEntry := self listEntryAt:lineNr) startsWith:$-) ifTrue:[
  3901     ((lineEntry := self listEntryAt:lineNr) startsWith:$-) ifTrue:[
  3897         (lineEntry ~= '-' 
  3902         (lineEntry ~= '-' 
  3898           and:[(lineEntry at:2) isSeparator not
  3903           and:[(lineEntry at:2) isSeparator not
  3899           and:[(lineEntry at:2) isDigit not "negative number"]]
  3904           and:[(lineEntry at:2) isDigit not "negative number"]]
  3900         ) ifTrue:[
  3905         ) ifTrue:[
  3901             ^ self valueForSpecialLine:lineEntry
  3906             ^ self valueForSpecialLine:lineEntry
  3902         ].
  3907         ].
  3903     ].
  3908     ].
  3904     (lineEntry startsWith:$¤) ifTrue:[
  3909     "/ another special (pseudo) entries?
       
  3910     (lineEntry startsWith:$¤) ifTrue:[
  3905         ^ self valueForSpecialLine:lineEntry
  3911         ^ self valueForSpecialLine:lineEntry
  3906     ].
  3912     ].
  3907 
  3913 
  3908     "/ a named instVar ?
  3914     "/ a named instVar ?
  3909     idx := self instVarIndexForLine:lineNr.
  3915     idx := self instVarIndexForLine:lineNr.
  3910     idx notNil ifTrue:[
  3916     idx notNil ifTrue:[
  3911         BreakPointInterrupt catch:[
  3917         "/ avoid endless recursion in case there is a breakPoint on the getter
       
  3918         BreakPointInterrupt ignoreIn:[
  3912             ^ self namedFieldAt:idx
  3919             ^ self namedFieldAt:idx
  3913         ]
  3920         ]
  3914     ].
  3921     ].
  3915 
  3922 
  3916     "/ an extra named field ?
  3923     "/ an extra named field ?
  3917     idx := self extraNamedVarIndexForLine:lineNr.
  3924     idx := self extraNamedVarIndexForLine:lineNr.
  3918     idx notNil ifTrue:[
  3925     idx notNil ifTrue:[
  3919         BreakPointInterrupt catch:[
  3926         "/ avoid endless recursion in case there is a breakPoint on the getter
       
  3927         BreakPointInterrupt ignoreIn:[
  3920             val := ((self extraNamedFields) at:idx) value.
  3928             val := ((self extraNamedFields) at:idx) value.
  3921             val isBlock ifTrue:[ val := val value ].
  3929             val isBlock ifTrue:[ val := val value ].
  3922             ^ val
  3930             ^ val
  3923         ]
  3931         ]
  3924     ].
  3932     ].
  3925 
  3933 
  3926     "/ an indexed instVar ?
  3934     "/ an indexed instVar ?
  3927     idx := self keyIndexForLine:lineNr.
  3935     idx := self keyIndexForLine:lineNr.
  3928     idx notNil ifTrue:[
  3936     idx notNil ifTrue:[
  3929         BreakPointInterrupt catch:[
  3937         "/ avoid endless recursion in case there is a breakPoint on the getter
       
  3938         BreakPointInterrupt ignoreIn:[
  3930             ^ self indexedValueAtIndex:idx.
  3939             ^ self indexedValueAtIndex:idx.
  3931         ]
  3940         ]
  3932     ].
  3941     ].
  3933 
  3942 
  3934     "/ nope
  3943     "/ nope
  4301     "Created: 28.6.1996 / 15:06:38 / cg"
  4310     "Created: 28.6.1996 / 15:06:38 / cg"
  4302     "Modified: 18.3.1997 / 18:22:54 / cg"
  4311     "Modified: 18.3.1997 / 18:22:54 / cg"
  4303 !
  4312 !
  4304 
  4313 
  4305 tryToSelectKeyNamed:aString
  4314 tryToSelectKeyNamed:aString
  4306     "called from the debugger to try to select the previousöy selected
  4315     "called from the debugger to try to select the previousöy selected
  4307      field (by name)"
  4316      field (by name)"
  4308      
  4317      
  4309     |list idx aStringWithSpace|
  4318     |list idx aStringWithSpace|
  4310 
  4319 
  4311     aString isEmptyOrNil ifTrue:[^ self].
  4320     aString isEmptyOrNil ifTrue:[^ self].