InspView.st
changeset 1895 8b51d61d9c0a
parent 1873 5fd55aa184d4
child 1930 fc38f714f4ab
equal deleted inserted replaced
1894:b7b2f4b09bf0 1895:8b51d61d9c0a
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 SimpleView subclass:#InspectorView
    13 SimpleView subclass:#InspectorView
    14 	instanceVariableNames:'listView labelView workspace inspectedObject selectedLine nShown
    14 	instanceVariableNames:'listView labelView workspace inspectedObject selectedLine nShown
    15 		hasMore monitorProcess hideReceiver showHex'
    15 		hasMore monitorProcess hideReceiver showHex
       
    16 		inspectHistory isStandaloneInspector'
    16 	classVariableNames:'DefaultIcon'
    17 	classVariableNames:'DefaultIcon'
    17 	poolDictionaries:''
    18 	poolDictionaries:''
    18 	category:'Interface-Inspector'
    19 	category:'Interface-Inspector'
    19 !
    20 !
    20 
    21 
    58 
    59 
    59     You can also open a monitoring inspector, which displays some instance
    60     You can also open a monitoring inspector, which displays some instance
    60     variable in regular intervals. See #openOn:monitor:.
    61     variable in regular intervals. See #openOn:monitor:.
    61 
    62 
    62     examples:
    63     examples:
    63             #(1 2 3 4) asOrderedCollection inspect
    64 	    #(1 2 3 4) asOrderedCollection inspect
    64             #(1 2 3 4) asOrderedCollection basicInspect
    65 	    #(1 2 3 4) asOrderedCollection basicInspect
    65             (Array new:10000) inspect
    66 	    (Array new:10000) inspect
    66             (Image fromFile:'bitmaps/claus.gif') inspect
    67 	    (Image fromFile:'bitmaps/claus.gif') inspect
    67             (Image fromFile:'bitmaps/claus.gif') basicInspect
    68 	    (Image fromFile:'bitmaps/claus.gif') basicInspect
    68             (Image fromFile:'bitmaps/SBrowser.xbm') inspect
    69 	    (Image fromFile:'bitmaps/SBrowser.xbm') inspect
    69             (Image fromFile:'bitmaps/SBrowser.xbm') basicInspect
    70 	    (Image fromFile:'bitmaps/SBrowser.xbm') basicInspect
    70 
    71 
    71             InspectorView openOn:Display
    72 	    InspectorView openOn:Display
    72             InspectorView openOn:Display monitor:'shiftDown'
    73 	    InspectorView openOn:Display monitor:'shiftDown'
    73 
    74 
    74     [author:]
    75     [author:]
    75         Claus Gittinger
    76 	Claus Gittinger
    76 "
    77 "
    77 ! !
    78 ! !
    78 
    79 
    79 !InspectorView class methodsFor:'instance creation'!
    80 !InspectorView class methodsFor:'instance creation'!
    80 
    81 
   110     "create and launch a new inspector for anObject.
   111     "create and launch a new inspector for anObject.
   111      If anInstVarName is nonNil, let the inspector monitor it."
   112      If anInstVarName is nonNil, let the inspector monitor it."
   112 
   113 
   113     |topView inspectorView|
   114     |topView inspectorView|
   114 
   115 
   115     topView := StandardSystemView
   116     topView := StandardSystemView new.
   116                     label:(self labelFor:anObject)
   117     topView label:(self labelFor:anObject).
   117                      icon:self defaultIcon
   118     topView icon:self defaultIcon.
   118                 minExtent:(100 @ 100).
   119     topView minExtent:(100 @ 100).
   119 
   120 
   120     topView iconLabel:(self labelNameFor:anObject).
   121     topView iconLabel:(self labelNameFor:anObject).
   121     topView extent:(self defaultExtent).
   122     topView extent:(self defaultExtent).
   122 
   123 
   123     inspectorView := self origin:(0.0 @ 0.0)
   124     inspectorView := self origin:(0.0 @ 0.0)
   124                           corner:(1.0 @ 1.0)
   125 			  corner:(1.0 @ 1.0)
   125                              in:topView.
   126 			     in:topView.
   126 
   127 
   127     "kludge: must realize first, to be able to set menu again"
   128     "kludge: must realize first, to be able to set menu again"
   128     topView openAndWait.
   129     topView openAndWait.
   129     topView windowGroup 
   130     topView windowGroup 
   130         focusSequence:(Array with:inspectorView listView
   131 	focusSequence:(Array 
   131                              with:inspectorView workspace).
   132 			    with:inspectorView listView
       
   133 			    with:inspectorView workspace).
       
   134     inspectorView isStandaloneInspector:true.
   132     inspectorView inspect:anObject.
   135     inspectorView inspect:anObject.
   133 
   136 
   134     anInstVarName notNil ifTrue:[
   137     anInstVarName notNil ifTrue:[
   135         inspectorView monitor:anInstVarName
   138 	inspectorView monitor:anInstVarName
   136     ].
   139     ].
   137 
   140 
   138     ^ inspectorView
   141     ^ inspectorView
   139 
   142 
   140     "
   143     "
   142 
   145 
   143      m := 1 asValue.
   146      m := 1 asValue.
   144      InspectorView openOn:m monitor:'value'.
   147      InspectorView openOn:m monitor:'value'.
   145 
   148 
   146      2 to:10 do:[:i |
   149      2 to:10 do:[:i |
   147          Delay waitForSeconds:1.
   150 	 Delay waitForSeconds:1.
   148          m value:i
   151 	 m value:i
   149      ]
   152      ]
   150     "
   153     "
   151 
   154 
   152     "
   155     "
   153      |o|
   156      |o|
   157      Delay waitForSeconds:1.
   160      Delay waitForSeconds:1.
   158      o at:2 put:20
   161      o at:2 put:20
   159     "
   162     "
   160 
   163 
   161     "Created: / 1.3.1996 / 19:30:50 / cg"
   164     "Created: / 1.3.1996 / 19:30:50 / cg"
   162     "Modified: / 7.9.1998 / 14:15:38 / cg"
   165     "Modified: / 22.9.1998 / 22:41:52 / cg"
   163 ! !
   166 ! !
   164 
   167 
   165 !InspectorView class methodsFor:'defaults'!
   168 !InspectorView class methodsFor:'defaults'!
   166 
   169 
   167 defaultExtent
   170 defaultExtent
   177     <resource: #style (#ICON #ICON_FILE)>
   180     <resource: #style (#ICON #ICON_FILE)>
   178 
   181 
   179     |nm i|
   182     |nm i|
   180 
   183 
   181     (i := DefaultIcon) isNil ifTrue:[
   184     (i := DefaultIcon) isNil ifTrue:[
   182         i := self classResources at:'ICON' default:nil.
   185 	i := self classResources at:'ICON' default:nil.
   183         i isNil ifTrue:[
   186 	i isNil ifTrue:[
   184             nm := ClassResources at:'ICON_FILE' default:'Inspector.xbm'.
   187 	    nm := ClassResources at:'ICON_FILE' default:'Inspector.xbm'.
   185             i := Image fromFile:nm resolution:100.
   188 	    i := Image fromFile:nm resolution:100.
   186             i isNil ifTrue:[
   189 	    i isNil ifTrue:[
   187                 i := Image fromFile:('bitmaps/' , nm) resolution:100.
   190 		i := Image fromFile:('bitmaps/' , nm) resolution:100.
   188                 i isNil ifTrue:[
   191 		i isNil ifTrue:[
   189                     i := StandardSystemView defaultIcon
   192 		    i := StandardSystemView defaultIcon
   190                 ]
   193 		]
   191             ]
   194 	    ]
   192         ].
   195 	].
   193         i notNil ifTrue:[
   196 	i notNil ifTrue:[
   194             DefaultIcon := i := i on:Display
   197 	    DefaultIcon := i := i on:Display
   195         ]
   198 	]
   196     ].
   199     ].
   197     ^ i
   200     ^ i
   198 
   201 
   199     "Modified: 18.4.1997 / 15:16:53 / cg"
   202     "Modified: 18.4.1997 / 15:16:53 / cg"
   200 !
   203 !
   237 
   240 
   238     sameObject := anObject == inspectedObject.
   241     sameObject := anObject == inspectedObject.
   239     inspectedObject := anObject.
   242     inspectedObject := anObject.
   240 
   243 
   241     sameObject ifFalse:[
   244     sameObject ifFalse:[
   242         hasMore := false.
   245 	hasMore := false.
   243         aList := self fieldList.
   246 	aList := self fieldList.
   244         hasMore ifTrue:[
   247 	hasMore ifTrue:[
   245             aList add:' ... '
   248 	    aList add:' ... '
   246         ].
   249 	].
   247     ].
   250     ].
   248 
   251 
   249     sameObject ifTrue:[
   252     sameObject ifTrue:[
   250 "/        listView setContents:aList.
   253 "/        listView setContents:aList.
   251     ] ifFalse:[
   254     ] ifFalse:[
   252         listView contents:aList.
   255 	listView contents:aList.
   253 
   256 
   254         workspace contents:nil.
   257 	workspace contents:nil.
   255         self setDoItAction.
   258 	self setDoItAction.
       
   259 
       
   260 	isStandaloneInspector == true ifTrue:[
       
   261 	    self topView label:(self class labelFor:anObject).
       
   262 	    self topView iconLabel:(self class labelNameFor:anObject).
       
   263 	]
   256     ].
   264     ].
   257 
   265 
   258     selectedLine := nil
   266     selectedLine := nil
   259 
   267 
   260     "Modified: / 30.7.1998 / 13:36:55 / cg"
   268     "Modified: / 22.9.1998 / 22:40:56 / cg"
       
   269 !
       
   270 
       
   271 isStandaloneInspector:aBoolean
       
   272     isStandaloneInspector := aBoolean
   261 !
   273 !
   262 
   274 
   263 label:aString
   275 label:aString
   264     labelView label:aString
   276     labelView label:aString
   265 
   277 
   281 
   293 
   282     super initialize.
   294     super initialize.
   283 
   295 
   284     hideReceiver := false.
   296     hideReceiver := false.
   285     showHex := false.
   297     showHex := false.
       
   298     isStandaloneInspector := false.
   286 
   299 
   287     panel := VariableHorizontalPanel 
   300     panel := VariableHorizontalPanel 
   288                 origin:(0.0 @ 0.0)
   301 		origin:(0.0 @ 0.0)
   289                 corner:(1.0 @ 1.0)
   302 		corner:(1.0 @ 1.0)
   290                 in:self.
   303 		in:self.
   291 
   304 
   292     helpView := View origin:(0.0 @ 0.0) corner:(0.3 @ 1.0) in:panel.
   305     helpView := View origin:(0.0 @ 0.0) corner:(0.3 @ 1.0) in:panel.
   293     helpView level:0; borderWidth:0.
   306     helpView level:0; borderWidth:0.
   294 
   307 
   295     labelView := Label origin:0.0@0.0 corner:1.0@0.0 in:helpView.
   308     labelView := Label origin:0.0@0.0 corner:1.0@0.0 in:helpView.
   296     labelView label:(self defaultLabel).
   309     labelView label:(self defaultLabel).
   297     labelView bottomInset:(labelView preferredExtent y negated).
   310     labelView bottomInset:(labelView preferredExtent y negated).
   298 
   311 
   299     v := HVScrollableView 
   312     v := HVScrollableView 
   300                 for:SelectionInListView 
   313 		for:SelectionInListView 
   301                 miniScrollerH:true
   314 		miniScrollerH:true
   302                 miniScrollerV:false
   315 		miniScrollerV:false
   303                 in:helpView.
   316 		in:helpView.
   304     v autoHideScrollBars:true.
   317     v autoHideScrollBars:true.
   305     v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   318     v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   306     v topInset:(labelView preferredExtent y).
   319     v topInset:(labelView preferredExtent y).
   307 
   320 
   308     listView := v scrolledView.
   321     listView := v scrolledView.
   317     labelView2 := Label origin:0.0@0.0 corner:1.0@0.0 in:helpView.
   330     labelView2 := Label origin:0.0@0.0 corner:1.0@0.0 in:helpView.
   318     labelView2 label:''.
   331     labelView2 label:''.
   319     labelView2 bottomInset:(labelView preferredExtent y negated).
   332     labelView2 bottomInset:(labelView preferredExtent y negated).
   320 
   333 
   321     v := HVScrollableView 
   334     v := HVScrollableView 
   322                 for:CodeView 
   335 		for:CodeView 
   323                 miniScrollerH:true
   336 		miniScrollerH:true
   324                 miniScrollerV:true
   337 		miniScrollerV:true
   325                 in:helpView.
   338 		in:helpView.
   326     v autoHideScrollBars:true.
   339     v autoHideScrollBars:true.
   327     v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   340     v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   328     v topInset:(labelView2 preferredExtent y).
   341     v topInset:(labelView2 preferredExtent y).
   329     workspace := v scrolledView.
   342     workspace := v scrolledView.
   330 
   343 
   342 
   355 
   343     |o|
   356     |o|
   344 
   357 
   345     super realize.
   358     super realize.
   346     inspectedObject notNil ifTrue:[
   359     inspectedObject notNil ifTrue:[
   347         "
   360 	"
   348          kludge to trick inspect:, which ignores setting the
   361 	 kludge to trick inspect:, which ignores setting the
   349          same object again ...
   362 	 same object again ...
   350         "
   363 	"
   351         o := inspectedObject.
   364 	o := inspectedObject.
   352         inspectedObject := nil.
   365 	inspectedObject := nil.
   353         self inspect:o
   366 	self inspect:o
   354     ]
   367     ]
   355 
   368 
   356     "Created: 30.5.1996 / 09:38:37 / cg"
   369     "Created: 30.5.1996 / 09:38:37 / cg"
   357 ! !
   370 ! !
   358 
   371 
   364     <resource: #programMenu>
   377     <resource: #programMenu>
   365 
   378 
   366     |items labels selectors m|
   379     |items labels selectors m|
   367 
   380 
   368     items := #(
   381     items := #(
   369                         ('inspect'                      #doInspect              )
   382 			('inspect'                      #doInspect              )
   370                         ('basicInspect'                 #doBasicInspect         )
   383 			('basicInspect'                 #doBasicInspect         )
   371                         ('inspect hierarchical'         #doNewInspect           )
   384 			('inspect hierarchical'         #doNewInspect           )
   372                         ('-')
   385 			('-')
   373                         ('ref chains'                   #showReferences         )
   386 			('ref chains'                   #showReferences         )
   374                         ('-')
   387 			('-')
   375                         ('browse'                       #browse                 )
   388 			('browse'                       #browse                 )
   376                         ('browse class hierarchy'       #browseClassHierarchy   )
   389 			('browse class hierarchy'       #browseClassHierarchy   )
   377                         ('browse full class protocol'   #browseFullClassProtocol)
   390 			('browse full class protocol'   #browseFullClassProtocol)
   378                         ('-')
   391 			('-')
   379                         ('trace messages'               #doTrace                )
   392 			('trace messages'               #doTrace                )
   380                         ('trap message'                 #doTrapAll              )
   393 			('trap message'                 #doTrapAll              )
   381                         ('trap all messages'            #doTrap                 )
   394 			('trap all messages'            #doTrap                 )
   382                         ('untrace/untrap'               #doUntrace              )
   395 			('untrace/untrap'               #doUntrace              )
   383               ).
   396 	      ).
       
   397 
       
   398     isStandaloneInspector ifTrue:[
       
   399 	items := #(
       
   400 			    ('follow'                       #doFollow              )
       
   401 			    ('back'                         #doBack              )
       
   402 		  )
       
   403 		 ,
       
   404 		 items.
       
   405     ].
   384 
   406 
   385     hasMore ifTrue:[
   407     hasMore ifTrue:[
   386         items := items , #(
   408 	items := items , #(
   387                         ('-')
   409 			('-')
   388                         ('show more'                    #showMore               )
   410 			('show more'                    #showMore               )
   389                           )
   411 			  )
   390     ].
   412     ].
   391 
   413 
   392     monitorProcess isNil ifTrue:[
   414     monitorProcess isNil ifTrue:[
   393         items := items , #(
   415 	items := items , #(
   394                         ('-')
   416 			('-')
   395                         ('start monitor'                #doStartMonitor         )
   417 			('start monitor'                #doStartMonitor         )
   396                           ).
   418 			  ).
   397     ] ifFalse:[
   419     ] ifFalse:[
   398         items := items , #(
   420 	items := items , #(
   399                         ('-')
   421 			('-')
   400                         ('stop monitor'                #doStopMonitor           )
   422 			('stop monitor'                #doStopMonitor           )
   401                           ).
   423 			  ).
   402     ].
   424     ].
   403 
   425 
   404     showHex ifTrue:[
   426     showHex ifTrue:[
   405         items := items , #(
   427 	items := items , #(
   406                         ('-')
   428 			('-')
   407                         ('decimal integers'  #toggleHex               )
   429 			('decimal integers'  #toggleHex               )
   408                           )
   430 			  )
   409     ] ifFalse:[
   431     ] ifFalse:[
   410         items := items , #(
   432 	items := items , #(
   411                         ('-')
   433 			('-')
   412                         ('hex integers'      #toggleHex               )
   434 			('hex integers'      #toggleHex               )
   413                           )
   435 			  )
   414     ].
   436     ].
   415 
   437 
   416     m := PopUpMenu
   438     m := PopUpMenu
   417           itemList:items
   439 	  itemList:items
   418           resources:resources.
   440 	  resources:resources.
   419 
   441 
   420     selectedLine isNil ifTrue:[
   442     selectedLine isNil ifTrue:[
   421         m disableAll:#(doInspect doBasicInspect doNewInspect
   443 	m disableAll:#(doFollow doInspect doBasicInspect doNewInspect
   422                        browse browseClassHierarchy browseFullClassProtocol
   444 		       browse browseClassHierarchy browseFullClassProtocol
   423                        doStartMonitor)
   445 		       doStartMonitor)
   424     ].
   446     ].
   425 
   447     (selectedLine == 1) ifTrue:[
       
   448 	m disableAll:#(doFollow)
       
   449     ].
       
   450 
       
   451     inspectHistory size == 0 ifTrue:[
       
   452 	m disable:#doBack
       
   453     ].
   426     ^ m
   454     ^ m
   427 
   455 
   428     "Modified: / 7.5.1998 / 19:37:50 / cg"
   456     "Modified: / 22.9.1998 / 22:45:25 / cg"
   429 ! !
   457 ! !
   430 
   458 
   431 !InspectorView methodsFor:'menu actions'!
   459 !InspectorView methodsFor:'menu actions'!
   432 
   460 
   433 browse
   461 browse
   434     |objectToBrowseClass cls|
   462     |objectToBrowseClass cls|
   435 
   463 
   436     selectedLine notNil ifTrue:[
   464     selectedLine notNil ifTrue:[
   437         objectToBrowseClass := self valueAtLine:selectedLine.
   465 	objectToBrowseClass := self valueAtLine:selectedLine.
   438     ] ifFalse:[
   466     ] ifFalse:[
   439         objectToBrowseClass := inspectedObject
   467 	objectToBrowseClass := inspectedObject
   440     ].
   468     ].
   441     cls := objectToBrowseClass class.
   469     cls := objectToBrowseClass class.
   442     cls browserClass openInClass:cls selector:nil
   470     cls browserClass openInClass:cls selector:nil
   443 
   471 
   444     "Created: 14.12.1995 / 19:15:50 / cg"
   472     "Created: 14.12.1995 / 19:15:50 / cg"
   447 
   475 
   448 browseClass
   476 browseClass
   449     |objectToBrowseClass cls|
   477     |objectToBrowseClass cls|
   450 
   478 
   451     selectedLine notNil ifTrue:[
   479     selectedLine notNil ifTrue:[
   452         objectToBrowseClass := self valueAtLine:selectedLine.
   480 	objectToBrowseClass := self valueAtLine:selectedLine.
   453     ] ifFalse:[
   481     ] ifFalse:[
   454         objectToBrowseClass := inspectedObject
   482 	objectToBrowseClass := inspectedObject
   455     ].
   483     ].
   456     cls := objectToBrowseClass class.
   484     cls := objectToBrowseClass class.
   457     cls browserClass browseClass:cls
   485     cls browserClass browseClass:cls
   458 
   486 
   459     "Modified: 3.5.1996 / 12:39:32 / cg"
   487     "Modified: 3.5.1996 / 12:39:32 / cg"
   461 
   489 
   462 browseClassHierarchy
   490 browseClassHierarchy
   463     |objectToBrowseClass cls|
   491     |objectToBrowseClass cls|
   464 
   492 
   465     selectedLine notNil ifTrue:[
   493     selectedLine notNil ifTrue:[
   466         objectToBrowseClass := self valueAtLine:selectedLine.
   494 	objectToBrowseClass := self valueAtLine:selectedLine.
   467     ] ifFalse:[
   495     ] ifFalse:[
   468         objectToBrowseClass := inspectedObject
   496 	objectToBrowseClass := inspectedObject
   469     ].
   497     ].
   470     cls := objectToBrowseClass class.
   498     cls := objectToBrowseClass class.
   471     cls browserClass browseClassHierarchy:cls
   499     cls browserClass browseClassHierarchy:cls
   472 
   500 
   473     "Modified: 3.5.1996 / 12:40:04 / cg"
   501     "Modified: 3.5.1996 / 12:40:04 / cg"
   475 
   503 
   476 browseFullClassProtocol
   504 browseFullClassProtocol
   477     |objectToBrowseClass cls|
   505     |objectToBrowseClass cls|
   478 
   506 
   479     selectedLine notNil ifTrue:[
   507     selectedLine notNil ifTrue:[
   480         objectToBrowseClass := self valueAtLine:selectedLine.
   508 	objectToBrowseClass := self valueAtLine:selectedLine.
   481     ] ifFalse:[
   509     ] ifFalse:[
   482         objectToBrowseClass := inspectedObject
   510 	objectToBrowseClass := inspectedObject
   483     ].
   511     ].
   484     cls := objectToBrowseClass class.
   512     cls := objectToBrowseClass class.
   485     cls browserClass browseFullClassProtocol:cls
   513     cls browserClass browseFullClassProtocol:cls
   486 
   514 
   487     "Modified: 3.5.1996 / 12:40:17 / cg"
   515     "Modified: 3.5.1996 / 12:40:17 / cg"
   491     "user selected inspect-menu entry"
   519     "user selected inspect-menu entry"
   492 
   520 
   493     self doInspect:true 
   521     self doInspect:true 
   494 !
   522 !
   495 
   523 
       
   524 doBack
       
   525     "user selected back-menu entry"
       
   526 
       
   527     |objectToInspect|
       
   528 
       
   529     inspectHistory size > 0 ifTrue:[
       
   530 	objectToInspect := inspectHistory removeLast.
       
   531 	inspectHistory size == 0 ifTrue:[
       
   532 	    inspectHistory := nil
       
   533 	].
       
   534 	self inspect:objectToInspect.
       
   535     ]
       
   536 
       
   537     "Created: / 22.9.1998 / 18:22:01 / cg"
       
   538     "Modified: / 22.9.1998 / 18:22:28 / cg"
       
   539 !
       
   540 
       
   541 doFollow
       
   542     "user selected follow-menu entry"
       
   543 
       
   544     |objectToInspect|
       
   545 
       
   546     selectedLine notNil ifTrue:[
       
   547 	objectToInspect := self valueAtLine:selectedLine.
       
   548 	inspectHistory isNil ifTrue:[
       
   549 	    inspectHistory := OrderedCollection new
       
   550 	].
       
   551 	inspectHistory addLast:inspectedObject.
       
   552 	self inspect:objectToInspect.
       
   553     ]
       
   554 
       
   555     "Created: / 22.9.1998 / 18:21:08 / cg"
       
   556     "Modified: / 22.9.1998 / 18:22:23 / cg"
       
   557 !
       
   558 
   496 doInspect
   559 doInspect
   497     "user selected inspect-menu entry"
   560     "user selected inspect-menu entry"
   498 
   561 
   499     self doInspect:false
   562     self doInspect:false
   500 !
   563 !
   508 
   571 
   509 doStartMonitor
   572 doStartMonitor
   510     "start a monitoring process"
   573     "start a monitoring process"
   511 
   574 
   512     monitorProcess isNil ifTrue:[
   575     monitorProcess isNil ifTrue:[
   513         monitorProcess :=
   576 	monitorProcess :=
   514             [
   577 	    [
   515                 |sel|
   578 		|sel|
   516 
   579 
   517                 [true] whileTrue:[
   580 		[true] whileTrue:[
   518                     (sel := selectedLine) notNil ifTrue:[
   581 		    (sel := selectedLine) notNil ifTrue:[
   519                         self showSelection:sel 
   582 			self showSelection:sel 
   520                     ].
   583 		    ].
   521                     (Delay forSeconds:0.5) wait
   584 		    (Delay forSeconds:0.5) wait
   522                 ]
   585 		]
   523             ] forkAt:Processor userBackgroundPriority
   586 	    ] forkAt:Processor userBackgroundPriority
   524     ]
   587     ]
   525 
   588 
   526     "Modified: 12.4.1996 / 14:20:06 / cg"
   589     "Modified: 12.4.1996 / 14:20:06 / cg"
   527 !
   590 !
   528 
   591 
   545     |string selector|
   608     |string selector|
   546 
   609 
   547     string := Dialog request:'Selector to trap on:' onCancel:nil.
   610     string := Dialog request:'Selector to trap on:' onCancel:nil.
   548 
   611 
   549     string notNil ifTrue:[
   612     string notNil ifTrue:[
   550         selector := string asSymbolIfInterned.
   613 	selector := string asSymbolIfInterned.
   551 
   614 
   552         selector isNil ifTrue:[
   615 	selector isNil ifTrue:[
   553             self warn:'no such selector'
   616 	    self warn:'no such selector'
   554         ] ifFalse:[
   617 	] ifFalse:[
   555             self topView withWaitCursorDo:[MessageTracer trap:inspectedObject 
   618 	    self topView withWaitCursorDo:[MessageTracer trap:inspectedObject 
   556                                                          selector:selector]
   619 							 selector:selector]
   557         ]
   620 	]
   558     ]
   621     ]
   559 
   622 
   560     "Modified: 12.4.1996 / 14:07:01 / cg"
   623     "Modified: 12.4.1996 / 14:07:01 / cg"
   561 
   624 
   562 
   625 
   631 
   694 
   632     aList := OrderedCollection new.
   695     aList := OrderedCollection new.
   633     hideReceiver ifFalse:[aList add:'self'].
   696     hideReceiver ifFalse:[aList add:'self'].
   634     cls := inspectedObject class.
   697     cls := inspectedObject class.
   635     cls allInstVarNames do:[:instVarName |
   698     cls allInstVarNames do:[:instVarName |
   636         aList add:instVarName
   699 	aList add:instVarName
   637     ].
   700     ].
   638 
   701 
   639     cls isVariable ifTrue:[
   702     cls isVariable ifTrue:[
   640         n := inspectedObject basicSize.
   703 	n := inspectedObject basicSize.
   641         (n > nShown) ifTrue:[
   704 	(n > nShown) ifTrue:[
   642             n := nShown.
   705 	    n := nShown.
   643             hasMore := true.
   706 	    hasMore := true.
   644         ].
   707 	].
   645         1 to:n do:[:index |
   708 	1 to:n do:[:index |
   646             aList add:(index printString)
   709 	    aList add:(index printString)
   647         ].
   710 	].
   648     ].
   711     ].
   649     ^ aList
   712     ^ aList
   650 
   713 
   651     "Modified: 28.6.1996 / 15:08:51 / cg"
   714     "Modified: 28.6.1996 / 15:08:51 / cg"
   652 !
   715 !
   660 
   723 
   661 setDoItAction
   724 setDoItAction
   662     "set the codeViews doit action"
   725     "set the codeViews doit action"
   663 
   726 
   664     workspace 
   727     workspace 
   665         doItAction:[:theCode |
   728 	doItAction:[:theCode |
   666             |evaluator|
   729 	    |evaluator|
   667 
   730 
   668             (evaluator := inspectedObject class evaluatorClass)
   731 	    (evaluator := inspectedObject class evaluatorClass)
   669             notNil ifTrue:[
   732 	    notNil ifTrue:[
   670                 evaluator
   733 		evaluator
   671                     evaluate:theCode 
   734 		    evaluate:theCode 
   672                     in:nil 
   735 		    in:nil 
   673                     receiver:inspectedObject 
   736 		    receiver:inspectedObject 
   674                     notifying:workspace 
   737 		    notifying:workspace 
   675                     logged:true 
   738 		    logged:true 
   676                     ifFail:nil
   739 		    ifFail:nil
   677             ] ifFalse:[
   740 	    ] ifFalse:[
   678                 'objects class provides no evaluator'
   741 		'objects class provides no evaluator'
   679             ]
   742 	    ]
   680         ].
   743 	].
   681 
   744 
   682     inspectedObject class evaluatorClass isNil ifTrue:[
   745     inspectedObject class evaluatorClass isNil ifTrue:[
   683         workspace doItAction:nil.
   746 	workspace doItAction:nil.
   684         workspace acceptAction:nil.
   747 	workspace acceptAction:nil.
   685     ]
   748     ]
   686 
   749 
   687     "Modified: 1.8.1997 / 21:47:09 / cg"
   750     "Modified: 1.8.1997 / 21:47:09 / cg"
   688 !
   751 !
   689 
   752 
   690 showMore
   753 showMore
   691     |o|
   754     |o|
   692 
   755 
   693     hasMore ifTrue:[
   756     hasMore ifTrue:[
   694         nShown := nShown * 2.
   757 	nShown := nShown * 2.
   695         "/ force update (which is otherwise ignored)
   758 	"/ force update (which is otherwise ignored)
   696         o := inspectedObject.
   759 	o := inspectedObject.
   697         inspectedObject := nil.
   760 	inspectedObject := nil.
   698         self inspect:o
   761 	self inspect:o
   699     ]
   762     ]
   700 
   763 
   701     "Modified: / 26.8.1998 / 19:05:25 / cg"
   764     "Modified: / 26.8.1998 / 19:05:25 / cg"
   702 ! !
   765 ! !
   703 
   766 
   710      (for example, the debugger does this), the inspected object
   773      (for example, the debugger does this), the inspected object
   711      would be kept from being freed or freed very late."
   774      would be kept from being freed or freed very late."
   712 
   775 
   713 "
   776 "
   714     inspectedObject notNil ifTrue:[
   777     inspectedObject notNil ifTrue:[
   715         inspectedObject removeDependent:self
   778 	inspectedObject removeDependent:self
   716     ].
   779     ].
   717 "
   780 "
   718     inspectedObject := nil.
   781     inspectedObject := nil.
   719     self setDoItAction.      "/ to release ref to inspectedObject in doItBlock
   782     self setDoItAction.      "/ to release ref to inspectedObject in doItBlock
   720     workspace contents:nil.
   783     workspace contents:nil.
   765     "user selected inspect-menu entry"
   828     "user selected inspect-menu entry"
   766 
   829 
   767     |objectToInspect|
   830     |objectToInspect|
   768 
   831 
   769     selectedLine notNil ifTrue:[
   832     selectedLine notNil ifTrue:[
   770         objectToInspect := self valueAtLine:selectedLine.
   833 	objectToInspect := self valueAtLine:selectedLine.
   771         basic == #new ifTrue:[
   834 	basic == #new ifTrue:[
   772             NewInspector::InspectorView inspect:objectToInspect
   835 	    NewInspector::InspectorView inspect:objectToInspect
   773         ] ifFalse:[
   836 	] ifFalse:[
   774             basic ifTrue:[
   837 	    basic ifTrue:[
   775                 objectToInspect basicInspect
   838 		objectToInspect basicInspect
   776             ] ifFalse:[
   839 	    ] ifFalse:[
   777                 objectToInspect inspect
   840 		objectToInspect inspect
   778             ]
   841 	    ]
   779         ]
   842 	]
   780     ]
   843     ]
   781 
   844 
   782     "Modified: / 31.10.1997 / 12:46:53 / cg"
   845     "Modified: / 31.10.1997 / 12:46:53 / cg"
   783 !
   846 !
   784 
   847 
   785 keyPress:aKey x:x y:y
   848 keyPress:aKey x:x y:y
   786     "all my input is passed on to the workspace-field"
   849     "all my input is passed on to the workspace-field"
   787 
   850 
   788     x notNil ifTrue:[
   851     x notNil ifTrue:[
   789         "/ not already delegated
   852 	"/ not already delegated
   790 
   853 
   791         workspace keyPress:aKey x:-1 y:-1
   854 	workspace keyPress:aKey x:-1 y:-1
   792     ].
   855     ].
   793 
   856 
   794     "Modified: 4.3.1996 / 22:21:37 / cg"
   857     "Modified: 4.3.1996 / 22:21:37 / cg"
   795 !
   858 !
   796 
   859 
   809 
   872 
   810     |lastIdx|
   873     |lastIdx|
   811 
   874 
   812     lastIdx := listView list size.
   875     lastIdx := listView list size.
   813     lastIdx ~~ 0 ifTrue:[
   876     lastIdx ~~ 0 ifTrue:[
   814         self showSelection:lastIdx.
   877 	self showSelection:lastIdx.
   815         listView selection:lastIdx.
   878 	listView selection:lastIdx.
   816     ]
   879     ]
   817 
   880 
   818     "Created: 28.6.1996 / 15:06:38 / cg"
   881     "Created: 28.6.1996 / 15:06:38 / cg"
   819     "Modified: 18.3.1997 / 18:22:54 / cg"
   882     "Modified: 18.3.1997 / 18:22:54 / cg"
   820 !
   883 !
   823     "user selected references-menu entry"
   886     "user selected references-menu entry"
   824 
   887 
   825     |objectToInspect|
   888     |objectToInspect|
   826 
   889 
   827     selectedLine isNil ifTrue:[
   890     selectedLine isNil ifTrue:[
   828         objectToInspect := inspectedObject.
   891 	objectToInspect := inspectedObject.
   829     ] ifFalse:[
   892     ] ifFalse:[
   830         objectToInspect := self valueAtLine:selectedLine.
   893 	objectToInspect := self valueAtLine:selectedLine.
   831     ].
   894     ].
   832     ObjectMemory displayRefChainTo:objectToInspect
   895     ObjectMemory displayRefChainTo:objectToInspect
   833 
   896 
   834     "Modified: / 30.7.1998 / 14:03:16 / cg"
   897     "Modified: / 30.7.1998 / 14:03:16 / cg"
   835 !
   898 !
   838     "user clicked on an instvar - show value in workspace"
   901     "user clicked on an instvar - show value in workspace"
   839 
   902 
   840     |val obj|
   903     |val obj|
   841 
   904 
   842     (hasMore and:[lineNr == listView list size]) ifTrue:[
   905     (hasMore and:[lineNr == listView list size]) ifTrue:[
   843         "clicked on the '...' entry"
   906 	"clicked on the '...' entry"
   844         self showMore.
   907 	self showMore.
   845         listView setSelection:lineNr.
   908 	listView setSelection:lineNr.
   846     ].
   909     ].
   847 
   910 
   848     hideReceiver ifFalse:[
   911     hideReceiver ifFalse:[
   849         (self hasSelfEntry and:[lineNr == 1]) ifTrue:[
   912 	(self hasSelfEntry and:[lineNr == 1]) ifTrue:[
   850             "selecting self also does a re-set, this allows updating the list"
   913 	    "selecting self also does a re-set, this allows updating the list"
   851             obj := inspectedObject.    "/ force re-evaluation of the fieldList.
   914 	    obj := inspectedObject.    "/ force re-evaluation of the fieldList.
   852             inspectedObject := nil.
   915 	    inspectedObject := nil.
   853             self inspect:obj.
   916 	    self inspect:obj.
   854         ].
   917 	].
   855     ].
   918     ].
   856     val := self valueAtLine:lineNr.
   919     val := self valueAtLine:lineNr.
   857     selectedLine := lineNr.
   920     selectedLine := lineNr.
   858     self showValue:val.
   921     self showValue:val.
   859 
   922 
   862 
   925 
   863 showValue:someValue 
   926 showValue:someValue 
   864     "user clicked on an entry - show value in workspace"
   927     "user clicked on an entry - show value in workspace"
   865 
   928 
   866     self topView withWaitCursorDo:[
   929     self topView withWaitCursorDo:[
   867         |s|
   930 	|s|
   868 
   931 
   869         s := someValue displayString.
   932 	s := someValue displayString.
   870         showHex ifTrue:[
   933 	showHex ifTrue:[
   871             someValue isInteger ifTrue:[
   934 	    someValue isInteger ifTrue:[
   872                 s := '16r' , someValue hexPrintString
   935 		s := '16r' , someValue hexPrintString
   873             ]
   936 	    ]
   874         ].
   937 	].
   875         workspace replace:s.
   938 	workspace replace:s.
   876     ].
   939     ].
   877 
   940 
   878     "Modified: / 7.5.1998 / 01:57:05 / cg"
   941     "Modified: / 7.5.1998 / 01:57:05 / cg"
   879 !
   942 !
   880 
   943 
   882     |sel|
   945     |sel|
   883 
   946 
   884     showHex := showHex not.
   947     showHex := showHex not.
   885     sel := listView selection.
   948     sel := listView selection.
   886     sel notNil ifTrue:[
   949     sel notNil ifTrue:[
   887         self showSelection:sel
   950 	self showSelection:sel
   888     ]
   951     ]
   889 
   952 
   890     "Created: / 7.5.1998 / 01:54:52 / cg"
   953     "Created: / 7.5.1998 / 01:54:52 / cg"
   891     "Modified: / 7.5.1998 / 02:00:10 / cg"
   954     "Modified: / 7.5.1998 / 02:00:10 / cg"
   892 !
   955 !
   909     "helper - return the value of the selected entry"
   972     "helper - return the value of the selected entry"
   910 
   973 
   911     |index instSize|
   974     |index instSize|
   912 
   975 
   913     hideReceiver ifFalse:[
   976     hideReceiver ifFalse:[
   914         (lineNr isNil or:[lineNr == 1]) ifTrue:[
   977 	(lineNr isNil or:[lineNr == 1]) ifTrue:[
   915             ^ inspectedObject
   978 	    ^ inspectedObject
   916         ].
   979 	].
   917         index := lineNr - 1.   "/ skip self
   980 	index := lineNr - 1.   "/ skip self
   918     ] ifTrue:[
   981     ] ifTrue:[
   919         index := lineNr
   982 	index := lineNr
   920     ].
   983     ].
   921 
   984 
   922     instSize := inspectedObject class instSize.
   985     instSize := inspectedObject class instSize.
   923 
   986 
   924     (inspectedObject class isVariable not
   987     (inspectedObject class isVariable not
   925     or:[index <= instSize]) ifTrue:[
   988     or:[index <= instSize]) ifTrue:[
   926         ^ inspectedObject instVarAt:index
   989 	^ inspectedObject instVarAt:index
   927     ].
   990     ].
   928     index := index - instSize.
   991     index := index - instSize.
   929     ^ inspectedObject basicAt:index
   992     ^ inspectedObject basicAt:index
   930 
   993 
   931     "Modified: 28.6.1996 / 15:11:27 / cg"
   994     "Modified: 28.6.1996 / 15:11:27 / cg"
   932 ! !
   995 ! !
   933 
   996 
   934 !InspectorView class methodsFor:'documentation'!
   997 !InspectorView class methodsFor:'documentation'!
   935 
   998 
   936 version
   999 version
   937     ^ '$Header: /cvs/stx/stx/libtool/Attic/InspView.st,v 1.80 1998-09-08 11:18:22 cg Exp $'
  1000     ^ '$Header: /cvs/stx/stx/libtool/Attic/InspView.st,v 1.81 1998-09-24 10:07:12 cg Exp $'
   938 ! !
  1001 ! !