NewInspectorPanelView.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 2621 285fa261cbcb
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

- All source *.st files are now Unicode UTF8 without BOM
Files are in two groups (fileOut works this way in Smalltalk/X):
- containing a unicode character have "{ Encoding: utf8 }" at the header
- ASCII only are without the header
cg@809
     1
"
cg@809
     2
 COPYRIGHT (c) 1997 by eXept Software AG
cg@2621
     3
	      All Rights Reserved
cg@809
     4
cg@809
     5
 This software is furnished under a license and may be used
cg@809
     6
 only in accordance with the terms of that license and with the
cg@809
     7
 inclusion of the above copyright notice.   This software may not
cg@809
     8
 be provided or otherwise made available to, or used by, any
cg@809
     9
 other person.  No title to or ownership of the software is
cg@809
    10
 hereby transferred.
cg@809
    11
"
sv@2171
    12
"{ Package: 'stx:libtool2' }"
cg@809
    13
cg@2621
    14
"{ NameSpace: Tools }"
ca@35
    15
cg@1213
    16
SimpleView subclass:#NewInspectorPanelView
ca@35
    17
	instanceVariableNames:'frames labelViews listViews scrollBar maxDepth leftHistory
ca@35
    18
		rightHistory hzpView actionBlock valueChangedAction'
ca@35
    19
	classVariableNames:''
ca@35
    20
	poolDictionaries:''
cg@1213
    21
	category:'Interface-NewInspector'
ca@35
    22
!
ca@35
    23
cg@1213
    24
!NewInspectorPanelView class methodsFor:'documentation'!
ca@35
    25
cg@809
    26
copyright
cg@809
    27
"
cg@809
    28
 COPYRIGHT (c) 1997 by eXept Software AG
cg@2621
    29
	      All Rights Reserved
cg@809
    30
cg@809
    31
 This software is furnished under a license and may be used
cg@809
    32
 only in accordance with the terms of that license and with the
cg@809
    33
 inclusion of the above copyright notice.   This software may not
cg@809
    34
 be provided or otherwise made available to, or used by, any
cg@809
    35
 other person.  No title to or ownership of the software is
cg@809
    36
 hereby transferred.
cg@809
    37
"
cg@809
    38
cg@809
    39
cg@809
    40
!
cg@809
    41
ca@35
    42
examples
ca@35
    43
"
ca@35
    44
    example 1
ca@35
    45
    =========
ca@35
    46
cg@2621
    47
									[exBegin]
ca@35
    48
    |top slv|
ca@35
    49
ca@35
    50
    top := StandardSystemView new extent:600@400.
cg@2621
    51
    slv := Tools::NewInspectorPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
ca@35
    52
    slv inspect:top.
ca@35
    53
    slv action:[:el|Transcript showCR:el].
ca@35
    54
    top open.
cg@2621
    55
									[exEnd]
ca@35
    56
ca@35
    57
ca@35
    58
    example 2
ca@35
    59
    =========
cg@2621
    60
									[exBegin]
ca@35
    61
    |top slv edt a vvp|
ca@35
    62
ca@35
    63
    a := Array new:5.
ca@35
    64
    a at:4 put:(Array new:6).
ca@35
    65
ca@35
    66
    top := StandardSystemView new extent:600@400.
ca@35
    67
    vvp := VariableVerticalPanel origin:0.0@0.0  corner:1.0@1.0 in:top.
ca@35
    68
cg@2621
    69
    slv := Tools::NewInspectorPanelView origin:0.0@0.0 corner:1.0@0.5 in:vvp.
ca@35
    70
    edt := Workspace origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:vvp.
ca@35
    71
    edt acceptAction:[:theText|slv accept:theText notifying:edt].
ca@35
    72
    edt   doItAction:[:theCode|slv doIt:theCode   notifying:edt].
ca@35
    73
ca@35
    74
    slv action:[:el| Transcript showCR:(el printString)].
ca@35
    75
    slv inspect:a.
ca@35
    76
ca@35
    77
    top open.
cg@2621
    78
									[exEnd]
ca@35
    79
"
ca@35
    80
! !
ca@35
    81
cg@1213
    82
!NewInspectorPanelView class methodsFor:'constants'!
ca@35
    83
ca@35
    84
minDepth
ca@39
    85
    "returns the minimum of views assigned to a panel
ca@35
    86
    "
ca@35
    87
    ^ 4
ca@35
    88
! !
ca@35
    89
cg@1213
    90
!NewInspectorPanelView methodsFor:'accessing'!
ca@35
    91
ca@35
    92
depth
ca@35
    93
    "returns number of listViews
ca@35
    94
    "
ca@35
    95
  ^ listViews size
ca@35
    96
!
ca@35
    97
ca@35
    98
depth:aDepth
ca@35
    99
    "change the number of existing listViews
ca@35
   100
    "
ca@35
   101
    |sz min|
ca@35
   102
ca@35
   103
    min := self class minDepth.
ca@35
   104
ca@35
   105
    aDepth > min ifTrue:[
cg@2621
   106
	sz := aDepth min:maxDepth.
ca@35
   107
cg@2621
   108
	sz < listViews size ifTrue:[
cg@2621
   109
	    sz := listViews size
cg@2621
   110
	]
ca@35
   111
    ] ifFalse:[
cg@2621
   112
	sz := min
ca@35
   113
    ].
ca@35
   114
ca@35
   115
    listViews size == sz ifTrue:[
cg@2621
   116
	sz == aDepth ifFalse:[self moveContentsLeft:1].
ca@35
   117
    ] ifFalse:[
cg@2621
   118
	[self createViewWithoutRedraw. listViews size ~~ sz] whileTrue.
cg@2621
   119
	self computeExtentOfFrames.
ca@35
   120
cg@2621
   121
	(self topView shown) ifTrue:[
cg@2621
   122
	    hzpView sizeChanged:nil.
cg@2621
   123
	    hzpView realizeAllSubViews.
cg@2621
   124
	]
ca@35
   125
    ]
ca@35
   126
!
ca@35
   127
ca@35
   128
maxDepth
ca@35
   129
    ^ maxDepth
ca@35
   130
!
ca@35
   131
ca@35
   132
maxDepth:aNumber
ca@35
   133
    "change max depth for instance
ca@35
   134
    "
ca@35
   135
    aNumber > listViews size ifTrue:[
cg@2621
   136
	aNumber >= (self class minDepth) ifTrue:[
cg@2621
   137
	    maxDepth := aNumber.
ca@35
   138
cg@2621
   139
	    maxDepth < listViews size ifTrue:[
cg@2621
   140
		self depth:maxDepth
cg@2621
   141
	    ]
cg@2621
   142
	]
ca@35
   143
    ]
ca@35
   144
! !
ca@35
   145
cg@1213
   146
!NewInspectorPanelView methodsFor:'accessing actions'!
ca@35
   147
ca@35
   148
action:aOneArgBlock
ca@35
   149
    "set the single click action block.
ca@35
   150
     If non-nil, that one is evaluated on single click, passing the
ca@35
   151
     selected instance as argument
ca@35
   152
    "
ca@35
   153
    actionBlock := aOneArgBlock
ca@35
   154
ca@35
   155
ca@35
   156
!
ca@35
   157
ca@35
   158
valueChangedAction:aOneArgBlock
ca@35
   159
    "evaluated if an instnace changed its value; passing
ca@35
   160
     the instance as argument
ca@35
   161
    "
ca@35
   162
    valueChangedAction := aOneArgBlock
ca@35
   163
! !
ca@35
   164
cg@1213
   165
!NewInspectorPanelView methodsFor:'accessing selections'!
ca@35
   166
ca@35
   167
inspectedObject
ca@35
   168
    "returns the current inspected object
ca@35
   169
    "
ca@39
   170
    ^ self findLastValidListWithSelection inspectedObject
ca@35
   171
!
ca@35
   172
ca@35
   173
selectedInstanceVar
ca@35
   174
    "returns the current selected instance var
ca@35
   175
    "
ca@39
   176
    ^ self findLastValidListWithSelection selectedInstanceVar
ca@35
   177
! !
ca@35
   178
cg@1213
   179
!NewInspectorPanelView methodsFor:'actions'!
ca@35
   180
ca@35
   181
accept:aText notifying:aView
ca@39
   182
    "evaluating aText on the last selected instance var. on success the views
ca@39
   183
     are updated.
ca@39
   184
    "
ca@39
   185
    self doItOrAccept:[:aList|aList accept:aText notifying:aView]
ca@35
   186
!
ca@35
   187
ca@35
   188
doIt:aCode notifying:aView
ca@39
   189
    "evaluating aCode on the selected instance var; on success the views
ca@39
   190
     are updated.
ca@39
   191
    "
ca@39
   192
    ^ self doItOrAccept:[:aList|aList doIt:aCode notifying:aView]
ca@35
   193
!
ca@35
   194
ca@35
   195
inspect:anObject
ca@39
   196
    "change the inspected object and all views
ca@35
   197
    "
ca@35
   198
    |view|
ca@35
   199
ca@35
   200
    view := listViews first.
ca@35
   201
    leftHistory  removeAll.
ca@35
   202
    rightHistory removeAll.
ca@35
   203
ca@35
   204
    view inspect:anObject.
ca@35
   205
    listViews from:2 do:[:v|v inspect:nil].
ca@35
   206
    self update.
ca@35
   207
! !
ca@35
   208
cg@1213
   209
!NewInspectorPanelView methodsFor:'event handling'!
ca@35
   210
ca@35
   211
handlesKeyPress:key inView:someView
ca@39
   212
    "all keys are handled by this instance itself
ca@39
   213
    "
ca@35
   214
    ^ true
ca@35
   215
ca@35
   216
!
ca@35
   217
ca@35
   218
keyPress:key x:x y:y view:someView
ca@39
   219
    "handle some special keys
ca@39
   220
    "
ca@35
   221
    key == #CursorLeft  ifTrue:[^ self moveContentsRight:1].
ca@35
   222
    key == #CursorRight ifTrue:[^ self moveContentsLeft:1 ].
ca@35
   223
ca@35
   224
    someView keyPress:key x:x y:y.
ca@35
   225
ca@35
   226
!
ca@35
   227
ca@35
   228
singleClickAt:anIndex
ca@39
   229
    "the view at an index changed its selection caused by a single click
ca@35
   230
    "
ca@35
   231
    |view start sivar|
ca@35
   232
ca@35
   233
    rightHistory removeAll.
ca@35
   234
ca@35
   235
    view  := listViews at:anIndex.
ca@35
   236
    start := anIndex + 1.
ca@35
   237
    sivar := view selectedInstanceVar.
ca@35
   238
ca@35
   239
    start > listViews size ifTrue:[
cg@2621
   240
	start >= maxDepth ifTrue:[
cg@2621
   241
	    self moveContentsLeft:1.
cg@2621
   242
	  ^ actionBlock value:sivar.
cg@2621
   243
	].
ca@35
   244
    ].
ca@35
   245
ca@35
   246
    (view selectedInstanceType) == #directory ifTrue:[
cg@2621
   247
	(listViews at:start) setSelection:nil.
cg@2621
   248
	(listViews at:start) inspect:sivar.
cg@2621
   249
cg@2621
   250
	start := start + 1.
ca@35
   251
    ].
ca@35
   252
ca@35
   253
    listViews from:start do:[:v|v inspect:nil].
ca@35
   254
    self update.
ca@35
   255
    actionBlock value:sivar.
ca@35
   256
! !
ca@35
   257
cg@1213
   258
!NewInspectorPanelView methodsFor:'initializing'!
ca@35
   259
ca@35
   260
initialize
ca@35
   261
    "initialize instance
ca@35
   262
    "
ca@35
   263
    super initialize.
ca@35
   264
ca@35
   265
    frames       := OrderedCollection new.
ca@35
   266
    listViews    := OrderedCollection new.
ca@35
   267
    labelViews   := OrderedCollection new.
ca@35
   268
    leftHistory  := OrderedCollection new.
ca@35
   269
    rightHistory := OrderedCollection new.
ca@35
   270
    maxDepth     := self class minDepth.
ca@35
   271
ca@35
   272
    actionBlock := [:el| ].
ca@35
   273
ca@35
   274
    hzpView    := VariableHorizontalPanel origin:0.0@0.0 corner:1.0@1.0 in:self.
ca@35
   275
    scrollBar  := HorizontalScrollBar origin:0.0@1.0 corner:1.0@1.0 in:self.
cg@2299
   276
    "/ scrollBar asynchronousOperation.
ca@35
   277
ca@35
   278
    hzpView bottomInset:(scrollBar preferredExtent y).
ca@35
   279
ca@35
   280
    scrollBar topInset:(scrollBar preferredExtent y) negated.
ca@35
   281
    scrollBar thumbHeight:100.
ca@35
   282
    scrollBar scrollAction:[:percent | self scrollTo:percent].
ca@35
   283
    scrollBar scrollRightAction:[self moveContentsLeft:1].
ca@35
   284
    scrollBar scrollLeftAction:[self moveContentsRight:1].
ca@35
   285
ca@35
   286
    self depth:maxDepth.
ca@35
   287
! !
ca@35
   288
cg@1213
   289
!NewInspectorPanelView methodsFor:'menu - labels & actions'!
ca@35
   290
ca@35
   291
browse:anIndex
ca@35
   292
    self classAtLabel:anIndex do:[:cls| cls browserClass openInClass:cls selector:nil ]
ca@35
   293
ca@35
   294
!
ca@35
   295
ca@35
   296
browseClassHierarchy:anIndex
ca@35
   297
    self classAtLabel:anIndex do:[:cls| cls browserClass browseClassHierarchy:cls ]
ca@35
   298
ca@35
   299
!
ca@35
   300
ca@35
   301
browseFullClassProtocol:anIndex
ca@35
   302
    self classAtLabel:anIndex do:[:cls| cls browserClass browseFullClassProtocol:cls ]
ca@35
   303
ca@35
   304
!
ca@35
   305
ca@35
   306
classAtLabel:anIndex do:anAction
ca@35
   307
    "evaluate action on class assigned to label
ca@35
   308
    "
ca@35
   309
    |cls|
ca@35
   310
ca@35
   311
    anIndex <= labelViews size ifTrue:[
cg@2621
   312
	(cls := Smalltalk classNamed:((labelViews at:anIndex) label)) notNil ifTrue:[
cg@2621
   313
	    anAction value:cls
cg@2621
   314
	]
ca@35
   315
    ]
ca@35
   316
ca@35
   317
!
ca@35
   318
ca@35
   319
labelMenu
ca@35
   320
    "popup menu required by any label. Delegate the request to the corresponding label
ca@35
   321
    "
ca@35
   322
    |sqNr view|
ca@35
   323
sv@2171
   324
    view := (WindowGroup lastEventQuerySignal query) view.
ca@35
   325
    sqNr := labelViews findFirst:[:v| v == view].
ca@35
   326
ca@35
   327
    sqNr ~~ 0 ifTrue:[
cg@2621
   328
	view := labelViews at:sqNr.
ca@35
   329
cg@2621
   330
	view label notEmpty ifTrue:[
cg@2621
   331
	    ^ self labelMenu:sqNr
cg@2621
   332
	]
ca@35
   333
    ].
ca@35
   334
    ^ nil
ca@35
   335
!
ca@35
   336
ca@35
   337
labelMenu:anIndex
ca@35
   338
    "popup menu required for a label identified by its sequence number
ca@35
   339
    "
ca@35
   340
    |menu|
ca@35
   341
ca@35
   342
    menu := PopUpMenu labels:#(
cg@2621
   343
			      'browse'
cg@2621
   344
			      'browse class hierarchy'
cg@2621
   345
			      'browse full class protocol'
cg@2621
   346
			      )
cg@2621
   347
		   selectors:#(
cg@2621
   348
			      browse:
cg@2621
   349
			      browseClassHierarchy:
cg@2621
   350
			      browseFullClassProtocol:
cg@2621
   351
			      )
cg@2621
   352
		    receiver:self.
ca@35
   353
ca@35
   354
   menu args:(Array new:(menu labels size) withAll:anIndex).
ca@35
   355
 ^ menu
ca@35
   356
ca@35
   357
! !
ca@35
   358
cg@1213
   359
!NewInspectorPanelView methodsFor:'menu - views & actions'!
ca@35
   360
ca@35
   361
doTrace:anInstance
ca@35
   362
    "place a trace on messages sent to the instance
ca@35
   363
    "
ca@35
   364
    |selectors|
ca@35
   365
ca@35
   366
    selectors := self messageMenu:anInstance.
ca@35
   367
ca@35
   368
    selectors notNil ifTrue:[
cg@2621
   369
	self topView withWaitCursorDo:[MessageTracer trace:anInstance selectors:selectors]
ca@35
   370
    ].
ca@35
   371
ca@35
   372
!
ca@35
   373
ca@35
   374
doTraceAll:anInstance
ca@35
   375
    "place a trace on all messages sent to the instance
ca@35
   376
    "
ca@35
   377
    self topView withWaitCursorDo:[MessageTracer traceAll:anInstance]
ca@35
   378
!
ca@35
   379
ca@35
   380
doTrap:anInstance
ca@35
   381
    "place a trap on a message sent to the instance
ca@35
   382
    "
ca@35
   383
    |selectors|
ca@35
   384
ca@35
   385
    selectors := self messageMenu:anInstance.
ca@35
   386
ca@35
   387
    selectors notNil ifTrue:[
cg@2621
   388
	self topView withWaitCursorDo:[MessageTracer trap:anInstance selectors:selectors]
ca@35
   389
    ]
ca@35
   390
!
ca@35
   391
ca@35
   392
doTrapAll:anInstance
ca@35
   393
    "place a trap on all messages sent to the instance
ca@35
   394
    "
ca@35
   395
    self topView withWaitCursorDo:[MessageTracer trapAll:anInstance]
ca@35
   396
ca@35
   397
!
ca@35
   398
ca@35
   399
doUntrace:anInstance
ca@35
   400
    "remove all traps and traces to the instance
ca@35
   401
    "
ca@35
   402
    self topView withWaitCursorDo:[MessageTracer untrace:anInstance].
ca@35
   403
ca@35
   404
!
ca@35
   405
ca@35
   406
messageMenu:anInstance
ca@35
   407
    "open menu to select messages; on accepted a list of messages is returned
ca@35
   408
    "
ca@35
   409
    |sll acl lst inset top hzp slv acv dblClcAct btp b1 b2 accepted viewSpacing|
ca@35
   410
ca@35
   411
    top := StandardSystemView new.
ca@35
   412
    top extent:500 @ 400.
ca@35
   413
    top label:(anInstance printString).
ca@35
   414
ca@35
   415
    (Label origin:(0.0 @  0.0) corner:(0.5 @ 20) in:top) label:'messages'.
ca@35
   416
    (Label origin:(0.5 @  0.0) corner:(1.0 @ 20) in:top) label:'selected'.
ca@35
   417
    hzp := VariableHorizontalPanel origin:(0.0 @ 20) corner:(1.0 @ 1.0) in:top.
ca@35
   418
    btp := HorizontalPanelView origin:(0.0 @1.0) corner:(1.0 @ 1.0) in:top.
ca@35
   419
ca@35
   420
    b1 := Button abortButtonIn:btp.
ca@35
   421
    b2 := Button okButtonIn:btp.
ca@35
   422
    accepted := false.
ca@35
   423
ca@35
   424
    b1 action:[accepted := false. top destroy].
ca@35
   425
    b2 action:[accepted := true.  top destroy].
ca@35
   426
ca@35
   427
    btp horizontalLayout:#fitSpace.
ca@35
   428
    viewSpacing := top class viewSpacing.
ca@35
   429
    inset       := (b2 preferredExtent y) + viewSpacing.
ca@35
   430
    viewSpacing := viewSpacing // 2.
ca@35
   431
ca@35
   432
    hzp bottomInset:inset.
ca@35
   433
    btp topInset:((inset - viewSpacing) negated).
ca@35
   434
    btp bottomInset:viewSpacing.
ca@35
   435
ca@35
   436
    slv := ScrollableView for:SelectionInListView
cg@2621
   437
		miniScrollerV:true
cg@2621
   438
		       origin:(0.0 @ 0.0)
cg@2621
   439
		       corner:(0.5 @ 1.0)
cg@2621
   440
			   in:hzp.
ca@35
   441
ca@35
   442
    acv := ScrollableView for:SelectionInListView
cg@2621
   443
		miniScrollerV:true
cg@2621
   444
		       origin:(0.5 @ 0.0)
cg@2621
   445
		       corner:(1.0 @ 1.0)
cg@2621
   446
			   in:hzp.
ca@35
   447
ca@35
   448
    slv := slv scrolledView.
ca@35
   449
    acv := acv scrolledView.
ca@35
   450
ca@35
   451
    sll := (MessageTracer realClassOf:anInstance) selectors.
ca@35
   452
    acl := OrderedCollection new.
ca@35
   453
ca@35
   454
    (MessageTracer wrappedSelectorsOf:anInstance) do:[:el|
cg@2621
   455
	el notNil ifTrue:[
cg@2621
   456
	    acl add:el.
cg@2621
   457
	    sll remove:el ifAbsent:nil
cg@2621
   458
	]
ca@35
   459
    ].
cg@2621
   460
ca@35
   461
    slv list:(sll copy).
ca@35
   462
    acv list:(acl copy).
ca@35
   463
ca@35
   464
    dblClcAct := [:from :to|
cg@2621
   465
	to add:(from selectionValue).
cg@2621
   466
	from removeIndex:(from selection).
cg@2621
   467
	from redraw.
ca@35
   468
    ].
ca@35
   469
ca@35
   470
    slv doubleClickAction:[:index| dblClcAct value:slv value:acv].
ca@35
   471
    acv doubleClickAction:[:index| dblClcAct value:acv value:slv].
ca@35
   472
ca@35
   473
    top openModal.
ca@35
   474
ca@35
   475
    accepted ifFalse:[
cg@2621
   476
	^ nil
ca@35
   477
    ].
ca@35
   478
    lst := acv list.
ca@35
   479
ca@35
   480
"undo existing traps            HACK: removes traps and traces"
ca@35
   481
ca@35
   482
    acl notEmpty ifTrue:[
cg@2621
   483
	MessageTracer untrace:anInstance
ca@35
   484
    ].
ca@35
   485
ca@35
   486
    lst notEmpty ifTrue:[^ lst]
cg@2621
   487
		ifFalse:[^ nil]
ca@35
   488
!
ca@35
   489
ca@35
   490
viewMenu
ca@35
   491
    "popup menu required by any view. Delegate the request to the corresponding view
ca@35
   492
    "
ca@35
   493
    |sqNr view|
ca@35
   494
sv@2171
   495
    view := (WindowGroup lastEventQuerySignal query) view.
ca@35
   496
    sqNr := listViews findFirst:[:v| v == view].
ca@35
   497
ca@35
   498
    sqNr notNil ifTrue:[^ self viewMenu:sqNr]
cg@2621
   499
	       ifFalse:[^ nil]
ca@35
   500
!
ca@35
   501
ca@35
   502
viewMenu:anIndex
ca@35
   503
    "popup menu required for a view identified by its sequence number
ca@35
   504
    "
cg@327
   505
    |view menu inst args lbls|
ca@35
   506
ca@35
   507
    view := listViews at:anIndex.
ca@35
   508
    view hasSelection ifFalse:[^ nil].
ca@35
   509
    inst := view selectedInstanceVar.
ca@35
   510
ca@39
   511
    menu := PopUpMenu labels:#( 'update' )
cg@2621
   512
		   selectors:#( #update  )
cg@2621
   513
		    receiver:self.
ca@35
   514
ca@35
   515
    menu actionAt:#update put:[
cg@2621
   516
	view update.
ca@35
   517
cg@2621
   518
	listViews from:(anIndex + 1) do:[:v|
cg@2621
   519
	    (view selectedInstanceType) ~~ #directory ifTrue:[
cg@2621
   520
		v inspect:nil
cg@2621
   521
	    ] ifFalse:[
cg@2621
   522
		v inspect:(view selectedInstanceVar).
cg@2621
   523
		view := v.
cg@2621
   524
	    ]
cg@2621
   525
	].
cg@2621
   526
	self update
ca@35
   527
    ].
ca@35
   528
cg@1213
   529
    (NewInspectorList isTraceable:inst) ifFalse:[
cg@2621
   530
	^ menu
ca@39
   531
    ].
ca@39
   532
ca@35
   533
    menu  addLabels:#(
cg@2621
   534
		      '-'
cg@2621
   535
		      'trace'
cg@2621
   536
		      'trap'
cg@2621
   537
		      'untrace / untrap'
cg@2621
   538
		     )
cg@2621
   539
	  selectors:#(
cg@2621
   540
		      nil
cg@2621
   541
		      trace
cg@2621
   542
		      trap
cg@2621
   543
		      untrace
cg@2621
   544
		     ).
ca@35
   545
ca@35
   546
    menu actionAt:#untrace put:[self doUntrace:inst].
ca@35
   547
ca@35
   548
    args := Array new:2 withAll:inst.
ca@35
   549
    lbls := Array with:'message'
cg@2621
   550
		  with:((Text string:' all ' emphasis:#underline), ' messages').
ca@35
   551
ca@35
   552
    menu subMenuAt:#trace put:(
cg@2621
   553
	PopUpMenu labels:lbls selectors:#(doTrace: doTraceAll:) args:args
ca@35
   554
    ).
ca@35
   555
ca@35
   556
    menu subMenuAt:#trap put:(
cg@2621
   557
	PopUpMenu labels:lbls selectors:#(doTrap: doTrapAll:) args:args
ca@35
   558
    ).
ca@35
   559
ca@35
   560
  ^ menu
ca@35
   561
ca@35
   562
ca@35
   563
! !
ca@35
   564
cg@1213
   565
!NewInspectorPanelView methodsFor:'private'!
ca@35
   566
ca@35
   567
doItOrAccept:aBlock
ca@39
   568
    "handle a doIt or accept action; on success all the folloed views are
ca@39
   569
     updated
ca@35
   570
    "
ca@39
   571
    |index list result instVar|
ca@35
   572
ca@39
   573
    list    := self findLastValidListWithSelection.
ca@39
   574
    result  := aBlock value:list.
ca@39
   575
    instVar := list selectedInstanceVar.
ca@39
   576
    index   := listViews findLast:[:v|v == list].
ca@35
   577
ca@39
   578
    (index ~~ 0 and:[index ~~ listViews size]) ifTrue:[
cg@2621
   579
	index := index + 1.
cg@2621
   580
	(list selectedInstanceType) == #directory ifTrue:[
cg@2621
   581
	    (listViews at:index) inspect:instVar
cg@2621
   582
	] ifFalse:[
cg@2621
   583
	    (listViews at:index) inspect:nil
cg@2621
   584
	].
cg@2621
   585
	self update
ca@39
   586
    ].
ca@39
   587
    valueChangedAction notNil ifTrue:[
cg@2621
   588
	valueChangedAction value:instVar
ca@39
   589
    ].
ca@39
   590
    ^ result
ca@39
   591
!
ca@39
   592
ca@39
   593
findLastValidListWithSelection
ca@39
   594
    "returns last valid list with a selection; if no selection exists in any
ca@39
   595
     view, the list assigned to the inspected object is returned
ca@39
   596
    "
ca@39
   597
    |index|
ca@39
   598
ca@39
   599
    rightHistory notEmpty ifTrue:[
cg@2621
   600
	^ rightHistory first
ca@39
   601
    ].
ca@39
   602
    index := listViews findLast:[:v| v hasSelection ].
ca@39
   603
ca@39
   604
    index ~~ 0 ifTrue:[
cg@2621
   605
	^ listViews at:index
ca@35
   606
    ].
ca@35
   607
ca@39
   608
    leftHistory notEmpty ifTrue:[^ leftHistory last]
cg@2621
   609
			ifFalse:[^ listViews at:1]
ca@35
   610
!
ca@35
   611
ca@35
   612
update
ca@35
   613
    "update labels and scrollbar
ca@35
   614
    "
ca@35
   615
    |pview cview stop index ispObj label|
ca@35
   616
ca@35
   617
"UPDATE LABELS
ca@35
   618
"
ca@35
   619
    index := 1.
ca@35
   620
    stop  := listViews size.
ca@35
   621
ca@35
   622
    [   cview  := listViews at:index.
cg@2621
   623
	ispObj := cview inspectedObject.
cg@2621
   624
	label  := labelViews at:index.
cg@2621
   625
	index  := index + 1.
ca@35
   626
cg@2621
   627
	ispObj notNil ifTrue:[
cg@2621
   628
	    label label:(ispObj class name asString).
cg@2621
   629
	    pview := cview.
cg@2621
   630
	] ifFalse:[
cg@2621
   631
	    [index <= stop] whileTrue:[
cg@2621
   632
		(labelViews at:index) label:''.
cg@2621
   633
		index := index + 1
cg@2621
   634
	    ].
ca@35
   635
cg@2621
   636
	    (pview isNil or:[pview selectedInstanceType == #normal]) ifTrue:[
cg@2621
   637
		pview notNil ifTrue:[ispObj := pview selectedInstanceVar].
cg@2621
   638
		label label:ispObj class name asString
cg@2621
   639
	    ] ifFalse:[
cg@2621
   640
		label label:''
cg@2621
   641
	    ]
cg@2621
   642
	].
cg@2621
   643
	index > stop
ca@35
   644
ca@35
   645
    ] whileFalse.
ca@35
   646
ca@35
   647
"UPDATE SCROLLBARS
ca@35
   648
"
ca@35
   649
    index := listViews size + leftHistory size + rightHistory size.
ca@35
   650
ca@35
   651
    (listViews last) selectedInstanceType notNil ifTrue:[
cg@2621
   652
	index := index + 1
ca@35
   653
    ].
ca@35
   654
    scrollBar thumbHeight:(stop / index) * 100.
ca@35
   655
    scrollBar thumbOrigin:(100  / index * leftHistory size).
ca@35
   656
ca@35
   657
! !
ca@35
   658
cg@1213
   659
!NewInspectorPanelView methodsFor:'private frames'!
ca@35
   660
ca@35
   661
computeExtentOfFrames
ca@35
   662
    "compute the extent of all frames (origin/corner)
ca@35
   663
    "
ca@35
   664
    |orig corn offset newX|
ca@35
   665
ca@35
   666
    orig := ( 0.0 @ 0.0 ).
ca@35
   667
    corn := ( 0.0 @ 1.0 ).
ca@35
   668
ca@35
   669
    offset := 1.0 / (frames size).
ca@35
   670
    newX   := 0.0.
ca@35
   671
ca@35
   672
    frames do:[:frame|
cg@2621
   673
	(newX := newX + offset) > 1.0 ifTrue:[ newX := 1.0 ].
cg@2621
   674
	corn  := newX @ corn y.
cg@2621
   675
	frame origin:orig corner:corn.
cg@2621
   676
	orig  := newX @ orig y.
ca@35
   677
    ].
ca@35
   678
ca@35
   679
ca@35
   680
!
ca@35
   681
ca@35
   682
createViewWithoutRedraw
ca@39
   683
    "add a new view at end of the panel
ca@35
   684
    "
ca@35
   685
    |view frame label index|
ca@35
   686
ca@35
   687
    frame := SimpleView in:hzpView.
ca@35
   688
ca@35
   689
    label := Label origin:0.0@0.0 corner:1.0@20 in:frame.
ca@35
   690
    label  leftInset:15.
ca@35
   691
    label rightInset:2.
ca@35
   692
cg@2621
   693
    view  := ScrollableView for:NewInspectorListView miniScroller:true origin:0.0@20
cg@2621
   694
			 corner:1.0@1.0 in:frame.
ca@35
   695
ca@35
   696
    view := view scrolledView.
ca@35
   697
ca@35
   698
    frames add:frame.
ca@35
   699
    labelViews add:label.
ca@35
   700
    listViews  add:view.
ca@35
   701
ca@35
   702
    index := listViews size.
ca@35
   703
ca@35
   704
    index == 1 ifTrue:[
cg@2621
   705
	view includesSelf:true
ca@35
   706
    ].
ca@35
   707
ca@35
   708
    label adjust:#left.
ca@35
   709
    label label:''.
ca@35
   710
    label level:1.
ca@35
   711
    label menuHolder:self; menuMessage:#labelMenu; menuPerformer:self.
ca@35
   712
ca@35
   713
    view action:[:el|self singleClickAt:index].
ca@35
   714
ca@35
   715
    view delegate:self.
ca@35
   716
    view menuHolder:self; menuMessage:#viewMenu; menuPerformer:self.
ca@35
   717
ca@35
   718
! !
ca@35
   719
cg@1213
   720
!NewInspectorPanelView methodsFor:'scrolling-basic'!
ca@35
   721
ca@35
   722
moveContentsLeft:nTimes
ca@39
   723
    "move the contents of all views one position left
ca@35
   724
    "
cg@327
   725
    |fView stop pView index|
ca@35
   726
ca@35
   727
    (nTimes < 1 or:[listViews last isEmpty]) ifTrue:[
cg@2621
   728
	^ self
ca@35
   729
    ].
ca@35
   730
ca@35
   731
    index := nTimes.
ca@35
   732
    stop  := (listViews size) - 1.
ca@35
   733
    fView := listViews first.
ca@35
   734
    pView := listViews at:stop.
ca@35
   735
ca@35
   736
ca@39
   737
    [   leftHistory add:(fView list).
ca@35
   738
cg@2621
   739
	1 to:stop do:[:i|
cg@2621
   740
	    (listViews at:i) list:(listViews at:(i+1))
cg@2621
   741
	].
ca@35
   742
cg@2621
   743
	rightHistory notEmpty ifTrue:[
cg@2621
   744
	    (listViews last) list:(rightHistory removeLast)
cg@2621
   745
	] ifFalse:[
cg@2621
   746
	    (listViews last) inspect:(pView selectedInstanceVar)
cg@2621
   747
	].
cg@2621
   748
	((index := index - 1) == 0 or:[listViews last isEmpty])
ca@35
   749
ca@35
   750
    ] whileFalse.
ca@35
   751
ca@35
   752
    self update.
ca@35
   753
ca@35
   754
ca@35
   755
ca@35
   756
!
ca@35
   757
ca@35
   758
moveContentsRight:nTimes
ca@39
   759
    "move the contents of all views one position right
ca@35
   760
    "
cg@327
   761
    |size index lView fView|
ca@35
   762
ca@35
   763
    size := leftHistory size.
ca@35
   764
ca@35
   765
    (nTimes > 0 and:[size ~~ 0]) ifTrue:[
cg@2621
   766
	nTimes > size ifFalse:[index := nTimes]
cg@2621
   767
		       ifTrue:[index := size].
ca@35
   768
cg@2621
   769
	size  := listViews size.
cg@2621
   770
	lView := listViews last.
cg@2621
   771
	fView := listViews first.
ca@35
   772
cg@2621
   773
	1 to:index do:[:i|
cg@2621
   774
	    lView hasSelection ifTrue:[
cg@2621
   775
		rightHistory add:(lView list)
cg@2621
   776
	    ].
cg@2621
   777
	    size to:2 by:-1 do:[:i|
cg@2621
   778
		(listViews at:i) list:(listViews at:(i-1))
cg@2621
   779
	    ].
cg@2621
   780
	    fView list:(leftHistory removeLast)
cg@2621
   781
	].
cg@2621
   782
	self update
ca@35
   783
    ]
ca@35
   784
ca@35
   785
!
ca@35
   786
ca@35
   787
scrollTo:nPercent
ca@39
   788
    "set views and contents dependant on scroll bar
ca@35
   789
    "
ca@35
   790
    |dY no noScr pR|
ca@35
   791
ca@35
   792
    noScr := listViews size + leftHistory size + rightHistory size.
ca@35
   793
ca@35
   794
    (listViews last) selectedInstanceType notNil ifTrue:[
cg@2621
   795
	noScr := noScr + 1
ca@35
   796
    ].
ca@35
   797
    dY := 100 / noScr.
ca@35
   798
    pR := nPercent roundTo:dY.
ca@35
   799
ca@35
   800
    no := ((dY * leftHistory size) - pR) / dY.
ca@35
   801
ca@35
   802
    no == 0 ifTrue:[
cg@2621
   803
	(nPercent - pR) > 0 ifTrue:[no := -1]
cg@2621
   804
			   ifFalse:[no :=  1]
ca@35
   805
    ].
ca@35
   806
    no < 0 ifTrue:[self moveContentsLeft:(no negated)]
cg@2621
   807
	  ifFalse:[self moveContentsRight:no]
ca@35
   808
! !
ca@35
   809
cg@1213
   810
!NewInspectorPanelView class methodsFor:'documentation'!
ca@35
   811
ca@35
   812
version
ca@35
   813
    ^ '$Header$'
ca@35
   814
! !