--- a/NewInspectorListView.st Wed Jan 15 14:32:46 1997 +0100
+++ b/NewInspectorListView.st Wed Jan 15 14:33:11 1997 +0100
@@ -1,7 +1,7 @@
"{ NameSpace: NewInspector }"
SelectionInListView subclass:#InspectorListView
- instanceVariableNames:'actionHolder listHolder includesSelf'
+ instanceVariableNames:'actionHolder inspectorList includesSelf'
classVariableNames:''
poolDictionaries:''
category:'Inspector'
@@ -11,7 +11,8 @@
examples
"
-
+ open a list view on an instance
+ [exBegin]
|top slv a|
a := OrderedCollection new.
@@ -27,129 +28,54 @@
slv inspect:top.
slv action:[:el|Transcript showCR:(el printString)].
top open
+ [exEnd]
"
! !
-!InspectorListView methodsFor:'accessing actions'!
-
-action:aOneArgAction
- "set the single click action block.
- If non-nil, that one is evaluated on single click, passing the
- selected instance as argument
- "
- actionHolder := aOneArgAction
-! !
-
-!InspectorListView methodsFor:'accessing attributes'!
-
-includesSelf
- ^ includesSelf
-!
+!InspectorListView methodsFor:'accessing'!
includesSelf:aBool
includesSelf := aBool
!
-inspectedObject
- ^ listHolder inspectedObject
-!
-
-isEmpty
- "returns true if view is empty
- "
- ^ listHolder size == 0
-!
-
-listHolder
- ^ listHolder
+list
+ ^ inspectorList
!
-notEmpty
- "returns true if view is empty
+list:aList
+ "set the lists contents from another list
"
- ^ listHolder size ~~ 0
-! !
-
-!InspectorListView methodsFor:'accessing contents'!
+ |list selNr|
-updateFromList:aListHolder
- "set the lists contents from a list
- "
- listHolder := aListHolder.
- listHolder includesSelf:includesSelf.
+ aList notNil ifTrue:[inspectorList := aList list]
+ ifFalse:[inspectorList := InspectorList new].
- super list:(listHolder instanceNames).
- self setSelection:(listHolder selection).
-
+ inspectorList includesSelf:includesSelf.
+ super list:(inspectorList instanceNames).
!
-updateFromView:aInspectorListView
- "update contents from other view
+update
+ "update the current list
"
- self updateFromList:(aInspectorListView listHolder)
-!
+ inspectorList update.
+ super list:(inspectorList instanceNames).
-updateList
- "set the lists contents dependant on the object
- "
- self updateList:(listHolder inspectedObject) selection:selection.
! !
-!InspectorListView methodsFor:'actions'!
-
-accept:aText notifying:aView
- "on error #Error is returned otherwise the inspected object instance
- "
- |res|
-
- res := listHolder accept:aText notifying:aView.
-
- res ~~ #Error ifTrue:[
- super list:(listHolder instanceNames).
- self setSelection:(listHolder selection)
- ].
- ^ res
-!
-
-doIt:aCode notifying:aView
- "on success the value returned from parser is returned otherwise #Error
- "
- |res|
-
- res := listHolder doIt:aCode notifying:aView.
+!InspectorListView methodsFor:'accessing actions'!
- res ~~ #Error ifTrue:[
- super list:(listHolder instanceNames).
- self setSelection:(listHolder selection)
- ].
- ^ res
-
-!
-
-inspect:anObject
- "inspect an object
+action:aOneArgAction
+ "set the single click action block. If non-nil, that one is evaluated on single
+ click, passing the selected instance as argument
"
- ^ self inspect:anObject selection:nil
-!
-
-inspect:anObject selection:aNumber
- "inspect an object and set the selection
- "
- aNumber notNil ifTrue:[
- selection := aNumber
- ] ifFalse:[
- (listHolder inspectedObject) ~~ anObject ifTrue:[
- selection := nil
- ]
- ].
- self updateList:anObject selection:selection
+ actionHolder := aOneArgAction
! !
!InspectorListView methodsFor:'drawing'!
drawVisibleLineSelected:visLineNr with:fg and:bg
- "redraw a single line as selected."
-
+ "redraw a single line as selected.
+ "
|nr|
(nr := self visibleLineToListLine:visLineNr) notNil ifTrue:[
@@ -160,13 +86,13 @@
!
redrawArrowVisibleLine:visLineNr
- "draw a right arrow for visible line"
-
+ "draw a right arrow for visible line
+ "
|nr|
nr := self visibleLineToListLine:visLineNr.
- (listHolder instanceTypeAt:nr) == #directory ifTrue:[
+ (inspectorList instanceTypeAt:nr) == #directory ifTrue:[
self drawRightArrowInVisibleLine:visLineNr
]
@@ -191,9 +117,11 @@
!
visibleLineNeedsSpecialCare:visLineNr
+ "returns true if the visible line needs special care
+ "
|nr|
- (listHolder instanceTypeAt:nr) == #directory ifTrue:[
+ (inspectorList instanceTypeAt:nr) == #directory ifTrue:[
^ true
].
^ super visibleLineNeedsSpecialCare:visLineNr
@@ -212,8 +140,8 @@
!InspectorListView methodsFor:'event handling'!
sizeChanged:how
- "redraw marks"
-
+ "redraw marks
+ "
super sizeChanged:how.
shown ifTrue:[self invalidate]
@@ -229,7 +157,7 @@
ignoreReselect := false.
includesSelf := false.
actionHolder := [:el|].
- listHolder := InspectorList for:nil.
+ inspectorList := InspectorList new.
actionBlock := [:dummy|
self setSelection:selection.
@@ -239,60 +167,99 @@
!InspectorListView methodsFor:'private'!
-updateList:inspObject selection:aSelection
- "set the lists contents dependant on the object
+doesNotUnderstand:aMessage
+ "forward a message to the inspectorList
"
- listHolder := InspectorList for:inspObject.
- listHolder includesSelf:includesSelf.
- super list:(listHolder instanceNames).
+ (inspectorList respondsTo:(aMessage selector)) ifTrue:[
+ ^ aMessage sendTo:inspectorList
+ ].
+ ^ super doesNotUnderstand:aMessage
+
+
+!
+
+list:aCollection keepSelection:aBoolean
+ "set the list - redefined, since setting the list implies unselecting
+ and clearing attributes."
+
+ |oldSelection|
- aSelection notNil ifTrue:[
- self setSelection:aSelection
- ] ifFalse:[
- includesSelf ifTrue:[
- self setSelection:1
- ]
- ]
+ "somewhat of a kludge: if selection is first line,
+ we have to remove the highlight frame by hand here"
+
+ (shown and:[hilightLevel ~~ 0]) ifTrue:[
+ selection == firstLineShown ifTrue:[
+ self paint:bgColor.
+ self fillRectangleX:margin y:margin
+ width:(width - (margin * 2))
+ height:(hilightLevel abs).
+ ].
+ ].
+ listAttributes := nil.
+ super list:aCollection expandTabs:false.
+ super setSelection:(inspectorList selection).
+
+
+
+
! !
!InspectorListView methodsFor:'selections'!
-selectedInstanceName
- "returns the name assigned to the selected instance or nil
+setSelection:aNumberOrNil
+ "select line, aNumber or deselect if argument is nil
+ "
+ |oldSize|
+
+ oldSize := inspectorList size.
+ inspectorList setSelection:aNumberOrNil.
+ oldSize == inspectorList size ifTrue:[super setSelection:(inspectorList selection)]
+ ifFalse:[super list:(inspectorList instanceNames)].
+! !
+
+!InspectorListView methodsFor:'user interaction'!
+
+accept:aText notifying:aView
+ "evaluating aText on the selected instance var; if an error occurs #Error
+ is returned otherwise the inspected object instance. On success the list
+ will be updated.
"
- ^ listHolder instanceNameAt:selection
+ |res|
+
+ res := inspectorList accept:aText notifying:aView.
+
+ res ~~ #Error ifTrue:[
+ super list:(inspectorList instanceNames)
+ ].
+ ^ res
+!
+
+doIt:aCode notifying:aView
+ "evaluating aCode on the selected instance var; if an error occurs #Error
+ is returned otherwise the result returned from the evaluator. On success
+ the list will be updated.
+ "
+ |res|
+
+ res := inspectorList doIt:aCode notifying:aView.
+
+ res ~~ #Error ifTrue:[
+ super list:(inspectorList instanceNames)
+ ].
+ ^ res
!
-selectedInstanceType
- "returns the type of the selected instance or nil
- known types are: #directory #normal or:#self
+inspect:anObject
+ "inspect a new instance; update contents
"
- ^ listHolder instanceTypeAt:selection
-!
-
-selectedInstanceVar
- "returns the value assigned to the selected instance or nil
- "
- ^ listHolder instanceVarAt:selection
-
-!
+ (inspectorList inspectedObject) == anObject ifTrue:[
+ ^ self update
+ ].
+ inspectorList := InspectorList for:anObject.
+ inspectorList includesSelf:includesSelf.
-setSelection:aNumberOrNil
- "select line, aNumber or deselect if argument is nil
- "
- |type|
-
- aNumberOrNil notNil ifTrue:[
- type := listHolder instanceTypeAt:aNumberOrNil.
- listHolder selection:aNumberOrNil.
-
- type == #grow ifTrue:[
- super list:(listHolder instanceNames)
- ]
- ].
- super setSelection:aNumberOrNil
-
+ super list:(inspectorList instanceNames).
! !
!InspectorListView class methodsFor:'documentation'!