diff -r 7b75ce74d9e1 -r 03af455029eb NewInspectorPanelView.st --- a/NewInspectorPanelView.st Wed Jan 15 14:32:46 1997 +0100 +++ b/NewInspectorPanelView.st Wed Jan 15 14:33:11 1997 +0100 @@ -15,6 +15,7 @@ example 1 ========= + [exBegin] |top slv| top := StandardSystemView new extent:600@400. @@ -22,11 +23,12 @@ slv inspect:top. slv action:[:el|Transcript showCR:el]. top open. + [exEnd] example 2 ========= - + [exBegin] |top slv edt a vvp| a := Array new:5. @@ -44,16 +46,14 @@ slv inspect:a. top open. - - - + [exEnd] " ! ! !InspectorPanelView class methodsFor:'constants'! minDepth - "returns the maximum of views + "returns the minimum of views assigned to a panel " ^ 4 ! ! @@ -138,43 +138,33 @@ inspectedObject "returns the current inspected object " - |i el| - - rightHistory notEmpty ifTrue:[ - el := rightHistory last - ] ifFalse:[ - el := listViews findLast:[:v|v hasSelection]. - el := listViews at:el. - ]. - ^ el inspectedObject + ^ self findLastValidListWithSelection inspectedObject ! selectedInstanceVar "returns the current selected instance var " - |el| - - rightHistory notEmpty ifTrue:[ - el := rightHistory last - ] ifFalse:[ - el := listViews findLast:[:v|v hasSelection]. - el := listViews at:el - ]. - ^ el selectedInstanceVar + ^ self findLastValidListWithSelection selectedInstanceVar ! ! !InspectorPanelView methodsFor:'actions'! accept:aText notifying:aView - self doItOrAccept:[:v|v accept:aText notifying:aView] + "evaluating aText on the last selected instance var. on success the views + are updated. + " + self doItOrAccept:[:aList|aList accept:aText notifying:aView] ! doIt:aCode notifying:aView - ^ self doItOrAccept:[:v|v doIt:aCode notifying:aView] + "evaluating aCode on the selected instance var; on success the views + are updated. + " + ^ self doItOrAccept:[:aList|aList doIt:aCode notifying:aView] ! inspect:anObject - "change the inspected object + "change the inspected object and all views " |view| @@ -190,12 +180,15 @@ !InspectorPanelView methodsFor:'event handling'! handlesKeyPress:key inView:someView + "all keys are handled by this instance itself + " ^ true ! keyPress:key x:x y:y view:someView - + "handle some special keys + " key == #CursorLeft ifTrue:[^ self moveContentsRight:1]. key == #CursorRight ifTrue:[^ self moveContentsLeft:1 ]. @@ -204,7 +197,7 @@ ! singleClickAt:anIndex - "the view changed its selection caused by a single click + "the view at an index changed its selection caused by a single click " |view start sivar| @@ -486,12 +479,12 @@ view hasSelection ifFalse:[^ nil]. inst := view selectedInstanceVar. - menu := PopUpMenu labels:#( 'update' '-') - selectors:#( #update nil) + menu := PopUpMenu labels:#( 'update' ) + selectors:#( #update ) receiver:self. menu actionAt:#update put:[ - view updateList. + view update. listViews from:(anIndex + 1) do:[:v| (view selectedInstanceType) ~~ #directory ifTrue:[ @@ -504,12 +497,18 @@ self update ]. + (InspectorList isTraceable:inst) ifFalse:[ + ^ menu + ]. + menu addLabels:#( + '-' 'trace' 'trap' 'untrace / untrap' ) selectors:#( + nil trace trap untrace @@ -537,44 +536,48 @@ !InspectorPanelView methodsFor:'private'! doItOrAccept:aBlock - "handle a doIt or accept action + "handle a doIt or accept action; on success all the folloed views are + updated " - |index view ivar rslt last stop| + |index list result instVar| - last := listViews last. - self moveContentsLeft:(rightHistory size). + list := self findLastValidListWithSelection. + result := aBlock value:list. + instVar := list selectedInstanceVar. + index := listViews findLast:[:v|v == list]. - last hasSelection ifTrue:[ - self moveContentsLeft:1. - index := (listViews size) - 1 - ] ifFalse:[ - index := listViews findLast:[:v|v hasSelection]. + (index ~~ 0 and:[index ~~ listViews size]) ifTrue:[ + index := index + 1. + (list selectedInstanceType) == #directory ifTrue:[ + (listViews at:index) inspect:instVar + ] ifFalse:[ + (listViews at:index) inspect:nil + ]. + self update + ]. + valueChangedAction notNil ifTrue:[ + valueChangedAction value:instVar ]. + ^ result +! + +findLastValidListWithSelection + "returns last valid list with a selection; if no selection exists in any + view, the list assigned to the inspected object is returned + " + |index| + + rightHistory notEmpty ifTrue:[ + ^ rightHistory first + ]. + index := listViews findLast:[:v| v hasSelection ]. index ~~ 0 ifTrue:[ - view := listViews at:index. - rslt := aBlock value:view. - stop := listViews size. - ivar := view selectedInstanceVar. - - index == stop ifTrue:[ - self moveContentsLeft:1. - ] ifFalse:[ - index := index + 1. + ^ listViews at:index + ]. - (view selectedInstanceType) == #directory ifTrue:[ - (listViews at:index) inspect:ivar - ] ifFalse:[ - (listViews at:index) inspect:nil - ]. - self update. - ]. - - valueChangedAction notNil ifTrue:[ - valueChangedAction value:ivar - ] - ]. - ^ rslt + leftHistory notEmpty ifTrue:[^ leftHistory last] + ifFalse:[^ listViews at:1] ! update @@ -648,7 +651,7 @@ ! createViewWithoutRedraw - "add a new view at end + "add a new view at end of the panel " |view frame label index| @@ -688,7 +691,7 @@ !InspectorPanelView methodsFor:'scrolling-basic'! moveContentsLeft:nTimes - "move the contents of each view one position left + "move the contents of all views one position left " |fView stop assoc inspObj pView index| @@ -702,14 +705,14 @@ pView := listViews at:stop. - [ leftHistory add:fView listHolder. + [ leftHistory add:(fView list). 1 to:stop do:[:i| - (listViews at:i) updateFromView:(listViews at:(i+1)) + (listViews at:i) list:(listViews at:(i+1)) ]. rightHistory notEmpty ifTrue:[ - (listViews last) updateFromList:(rightHistory removeLast) + (listViews last) list:(rightHistory removeLast) ] ifFalse:[ (listViews last) inspect:(pView selectedInstanceVar) ]. @@ -724,7 +727,7 @@ ! moveContentsRight:nTimes - "move the contents of all listViews one position right + "move the contents of all views one position right " |view assoc size index lView fView| @@ -740,12 +743,12 @@ 1 to:index do:[:i| lView hasSelection ifTrue:[ - rightHistory add:(lView listHolder) + rightHistory add:(lView list) ]. size to:2 by:-1 do:[:i| - (listViews at:i) updateFromView:(listViews at:(i-1)) + (listViews at:i) list:(listViews at:(i-1)) ]. - fView updateFromList:(leftHistory removeLast) + fView list:(leftHistory removeLast) ]. self update ] @@ -753,7 +756,7 @@ ! scrollTo:nPercent - "set views dependant on scroll bar + "set views and contents dependant on scroll bar " |dY no noScr pR|