added an itemConverterBlock, which can generate ListEntries
from HierarchyNodes (for better look)
--- a/SelHierV.st Tue Apr 15 18:07:26 1997 +0200
+++ b/SelHierV.st Wed Apr 16 13:29:29 1997 +0200
@@ -12,7 +12,7 @@
"
SelectionInListView subclass:#SelectionInHierarchyView
- instanceVariableNames:'itemList showConnectingLines itemClass'
+ instanceVariableNames:'itemList showConnectingLines itemClass indent itemPrintConverter'
classVariableNames:''
poolDictionaries:''
category:'Views-Text'
@@ -46,7 +46,7 @@
W. Olberding AEG Factory Automation
[See also:]
- SelectionInHierarchy
+ SelectionInHierarchy HierarchyNode
SelectionInListView
"
!
@@ -97,7 +97,7 @@
"
! !
-!SelectionInHierarchyView methodsFor:'accessing'!
+!SelectionInHierarchyView methodsFor:'accessing - selection'!
selectElement:anObject
"select the element with same printString as the argument, anObject"
@@ -105,20 +105,37 @@
|index|
index:= 1.
-
list notNil ifTrue:[
-
- list do:[:each|
- ((each withoutSpaces) = (anObject printString)) ifTrue:[
- self selection: index.
- ^index
- ].
- index:= index + 1.
- ].
+ list do:[:each|
+ ((each withoutSpaces) = (anObject printString)) ifTrue:[
+ self selection:index.
+ ^ index
+ ].
+ index:= index + 1.
+ ].
].
^index
- "Modified: 10.10.94 / 16:13:39 / W.Olberding"! !
+ "Modified: 10.10.1994 / 16:13:39 / W.Olberding"
+ "Modified: 16.4.1997 / 12:40:05 / cg"
+!
+
+selection: anIndex
+ "Pass the selection along to the model."
+
+ super selection: anIndex.
+ model selection: anIndex.
+
+ "Modified: 10.10.94 / 16:13:38 / W.Olberding"!
+
+selectionIndex: anIndex
+ "Pass the selection along to the model."
+
+ super selection: anIndex.
+ model selection: anIndex.
+
+ "Modified: 10.10.94 / 16:13:38 / W.Olberding"
+! !
!SelectionInHierarchyView methodsFor:'event handling'!
@@ -162,37 +179,33 @@
super keyPress:key x:x y:y
- "Modified: 10.10.94 / 16:13:38 / W.Olberding"!
-
-selection: anIndex
- "Pass the selection along to the model."
-
- super selection: anIndex.
- model selection: anIndex.
-
- "Modified: 10.10.94 / 16:13:38 / W.Olberding"!
-
-selectionIndex: anIndex
- "Pass the selection along to the model."
-
- super selection: anIndex.
- model selection: anIndex.
-
- "Modified: 10.10.94 / 16:13:38 / W.Olberding"
-! !
+ "Modified: 10.10.94 / 16:13:38 / W.Olberding"! !
!SelectionInHierarchyView methodsFor:'initialization'!
initialize
super initialize.
+
showConnectingLines := true.
+ indent := 2.
self doubleClickAction:
- [:selection | model doubleClickSelection: selection ].
- "this will usualy initiate a hide/show operation"
+ [:selection | model doubleClickSelection: selection ].
+ "this will usualy initiate a hide/show operation"
+
+ "Modified: 10.10.1994 / 16:13:39 / W.Olberding"
+ "Modified: 16.4.1997 / 12:37:38 / cg"
+!
- "Modified: 10.10.94 / 16:13:39 / W.Olberding"
+itemPrintConverter:aBlock
+ "set a converter block, which returns a listEntry
+ for a passed node. If left undefined, an indented string
+ based upon the nodes name is generated."
+
+ itemPrintConverter := aBlock
+
+ "Modified: 16.4.1997 / 13:06:22 / cg"
!
showConnectingLines:aBoolean
@@ -212,106 +225,112 @@
"Get list entries from model.
Answer them as idented Text."
- |listOfNodes textList textLine treeLevels isLastOnLevel oldLevel
+ |listOfNodes itemList textLine treeLevels isLastOnLevel oldLevel
blockGraphicCharacters|
listOfNodes := model list.
listOfNodes isNil ifTrue:[^ #()].
- showConnectingLines ifFalse:[
- textList := listOfNodes collect: [ :aNode |
- textLine := ReadWriteStream on: String new.
- aNode level timesRepeat: [
- textLine space; space.
- ].
- textLine nextPutAll: aNode name.
- aNode isExpandable ifTrue: [
- textLine nextPutAll: ' ...'.
- ].
- textLine contents.
+ itemPrintConverter notNil ifTrue:[
+ "/ externally provided node-to-listentry converter
+ "/ allows hierarchyNodes to be presented in any
+ "/ programmer defined way ...
+
+ itemList := listOfNodes collect:[:aNode |
+ itemPrintConverter value:aNode
].
- ] ifTrue:[
- "/ claus:
- "/ mhmh - the AEG code depends on those blockGraphic
- "/ characters being in the font.
- "/
- "/ how can we find out what characters there are ?
- "/ (X maps missing chars to a space).
- "/ we should really rewrite this to use a private bitmap font ...
-
-"/ blockGraphicCharacters := Array with:$|
-"/ with:$+
-"/ with:$+
-"/ with:$-.
-
- blockGraphicCharacters := Array with:(Character value:25)
- with:(Character value:14)
- with:(Character value:21)
- with:(Character value:18).
-
- isLastOnLevel:=Set new.
- treeLevels:=Set new.
- oldLevel:=0.
-
- listOfNodes reverseDo: [ :aNode |
- (treeLevels includes:(aNode level)) ifFalse:[
- isLastOnLevel add:aNode.
- treeLevels add:(aNode level).
+ ] ifFalse:[
+ showConnectingLines ifFalse:[
+ itemList := listOfNodes collect: [ :aNode |
+ textLine := ReadWriteStream on: String new.
+ aNode level timesRepeat: [
+ textLine spaces:indent.
+ ].
+ textLine nextPutAll: aNode name.
+ aNode isExpandable ifTrue: [
+ textLine nextPutAll: ' ...'.
+ ].
+ textLine contents.
].
- aNode level < oldLevel ifTrue:[
- treeLevels remove:oldLevel.
- ].
- oldLevel:=aNode level.
- ].
+ ] ifTrue:[
+ "/ claus:
+ "/ mhmh - the AEG code depends on those blockGraphic
+ "/ characters being in the font.
+ "/
+ "/ how can we find out what characters there are ?
+ "/ (X maps missing chars to a space).
+ "/ we should really rewrite this to use a private bitmap font ...
+
+ blockGraphicCharacters := Array with:$|
+ with:$+
+ with:$+
+ with:$-.
- treeLevels:=Set new.
- oldLevel:=0.
- textList := listOfNodes collect: [ :aNode |
- textLine := ReadWriteStream on: String new.
+ "/ blockGraphicCharacters := Array with:(Character value:25)
+ "/ with:(Character value:14)
+ "/ with:(Character value:21)
+ "/ with:(Character value:18).
+
+ isLastOnLevel:=Set new.
+ treeLevels:=Set new.
+ oldLevel:=0.
- 1 to:((aNode level)-1) do: [ :l |
- (treeLevels includes:l) ifTrue:[
-"/ original: textLine space; nextPutAll:((Character value:25)printString); space.
- textLine space; nextPut:(blockGraphicCharacters at:1); space.
- ]ifFalse:[
- textLine space; space; space.
- ]
+ listOfNodes reverseDo: [ :aNode |
+ (treeLevels includes:(aNode level)) ifFalse:[
+ isLastOnLevel add:aNode.
+ treeLevels add:(aNode level).
+ ].
+ aNode level < oldLevel ifTrue:[
+ treeLevels remove:oldLevel.
+ ].
+ oldLevel:=aNode level.
].
- treeLevels add:(aNode level).
- oldLevel:=aNode level.
+
+ treeLevels:=Set new.
+ oldLevel:=0.
+ itemList := listOfNodes collect: [ :aNode |
+ textLine := ReadWriteStream on: String new.
- (aNode = (listOfNodes first)) ifFalse:[
- textLine space.
- (isLastOnLevel includes:aNode)ifTrue:[
-"/ original: textLine nextPutAll:((Character value:14)printString).
- textLine nextPut:(blockGraphicCharacters at:2).
- treeLevels remove:(aNode level).
- ] ifFalse:[
-"/ original: textLine nextPutAll:((Character value:21)printString).
- textLine nextPut:(blockGraphicCharacters at:3).
+ 1 to:((aNode level)-1) do: [ :l |
+ (treeLevels includes:l) ifTrue:[
+ textLine space; nextPut:(blockGraphicCharacters at:1); space.
+ ]ifFalse:[
+ textLine space; space; space.
+ ]
].
-"/ original: textLine nextPutAll:((Character value:18)printString).
- textLine nextPut:(blockGraphicCharacters at:4).
- ].
- aNode isExpandable ifTrue: [
- textLine nextPutAll: '[+]'.
- ] ifFalse:[
- aNode isCollapsable ifTrue: [
- textLine nextPutAll: '[-]'.
- ] ifFalse:[
-"/ original: textLine nextPutAll:((Character value:18)printString).
+ treeLevels add:(aNode level).
+ oldLevel:=aNode level.
+
+ (aNode = (listOfNodes first)) ifFalse:[
+ textLine space.
+ (isLastOnLevel includes:aNode)ifTrue:[
+ textLine nextPut:(blockGraphicCharacters at:2).
+ treeLevels remove:(aNode level).
+ ] ifFalse:[
+ textLine nextPut:(blockGraphicCharacters at:3).
+ ].
textLine nextPut:(blockGraphicCharacters at:4).
].
- ].
+ aNode isExpandable ifTrue: [
+ textLine nextPutAll: '[+]'.
+ ] ifFalse:[
+ aNode isCollapsable ifTrue: [
+ textLine nextPutAll: '[-]'.
+ ] ifFalse:[
+ textLine nextPut:(blockGraphicCharacters at:4).
+ ].
+ ].
- textLine nextPutAll:' ', aNode name.
- textLine contents.
- ].
+ textLine nextPutAll:' ', aNode name.
+ textLine contents.
+ ].
+ ]
].
- ^textList
+ ^itemList
- "Modified: 10.10.94 / 16:13:39 / W.Olberding"
+ "Modified: 10.10.1994 / 16:13:39 / W.Olberding"
+ "Modified: 16.4.1997 / 12:43:20 / cg"
!
getSelectionFromModel
@@ -357,5 +376,5 @@
!SelectionInHierarchyView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelHierV.st,v 1.7 1996-10-22 21:48:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelHierV.st,v 1.8 1997-04-16 11:29:29 cg Exp $'
! !
--- a/SelectionInHierarchyView.st Tue Apr 15 18:07:26 1997 +0200
+++ b/SelectionInHierarchyView.st Wed Apr 16 13:29:29 1997 +0200
@@ -12,7 +12,7 @@
"
SelectionInListView subclass:#SelectionInHierarchyView
- instanceVariableNames:'itemList showConnectingLines itemClass'
+ instanceVariableNames:'itemList showConnectingLines itemClass indent itemPrintConverter'
classVariableNames:''
poolDictionaries:''
category:'Views-Text'
@@ -46,7 +46,7 @@
W. Olberding AEG Factory Automation
[See also:]
- SelectionInHierarchy
+ SelectionInHierarchy HierarchyNode
SelectionInListView
"
!
@@ -97,7 +97,7 @@
"
! !
-!SelectionInHierarchyView methodsFor:'accessing'!
+!SelectionInHierarchyView methodsFor:'accessing - selection'!
selectElement:anObject
"select the element with same printString as the argument, anObject"
@@ -105,20 +105,37 @@
|index|
index:= 1.
-
list notNil ifTrue:[
-
- list do:[:each|
- ((each withoutSpaces) = (anObject printString)) ifTrue:[
- self selection: index.
- ^index
- ].
- index:= index + 1.
- ].
+ list do:[:each|
+ ((each withoutSpaces) = (anObject printString)) ifTrue:[
+ self selection:index.
+ ^ index
+ ].
+ index:= index + 1.
+ ].
].
^index
- "Modified: 10.10.94 / 16:13:39 / W.Olberding"! !
+ "Modified: 10.10.1994 / 16:13:39 / W.Olberding"
+ "Modified: 16.4.1997 / 12:40:05 / cg"
+!
+
+selection: anIndex
+ "Pass the selection along to the model."
+
+ super selection: anIndex.
+ model selection: anIndex.
+
+ "Modified: 10.10.94 / 16:13:38 / W.Olberding"!
+
+selectionIndex: anIndex
+ "Pass the selection along to the model."
+
+ super selection: anIndex.
+ model selection: anIndex.
+
+ "Modified: 10.10.94 / 16:13:38 / W.Olberding"
+! !
!SelectionInHierarchyView methodsFor:'event handling'!
@@ -162,37 +179,33 @@
super keyPress:key x:x y:y
- "Modified: 10.10.94 / 16:13:38 / W.Olberding"!
-
-selection: anIndex
- "Pass the selection along to the model."
-
- super selection: anIndex.
- model selection: anIndex.
-
- "Modified: 10.10.94 / 16:13:38 / W.Olberding"!
-
-selectionIndex: anIndex
- "Pass the selection along to the model."
-
- super selection: anIndex.
- model selection: anIndex.
-
- "Modified: 10.10.94 / 16:13:38 / W.Olberding"
-! !
+ "Modified: 10.10.94 / 16:13:38 / W.Olberding"! !
!SelectionInHierarchyView methodsFor:'initialization'!
initialize
super initialize.
+
showConnectingLines := true.
+ indent := 2.
self doubleClickAction:
- [:selection | model doubleClickSelection: selection ].
- "this will usualy initiate a hide/show operation"
+ [:selection | model doubleClickSelection: selection ].
+ "this will usualy initiate a hide/show operation"
+
+ "Modified: 10.10.1994 / 16:13:39 / W.Olberding"
+ "Modified: 16.4.1997 / 12:37:38 / cg"
+!
- "Modified: 10.10.94 / 16:13:39 / W.Olberding"
+itemPrintConverter:aBlock
+ "set a converter block, which returns a listEntry
+ for a passed node. If left undefined, an indented string
+ based upon the nodes name is generated."
+
+ itemPrintConverter := aBlock
+
+ "Modified: 16.4.1997 / 13:06:22 / cg"
!
showConnectingLines:aBoolean
@@ -212,106 +225,112 @@
"Get list entries from model.
Answer them as idented Text."
- |listOfNodes textList textLine treeLevels isLastOnLevel oldLevel
+ |listOfNodes itemList textLine treeLevels isLastOnLevel oldLevel
blockGraphicCharacters|
listOfNodes := model list.
listOfNodes isNil ifTrue:[^ #()].
- showConnectingLines ifFalse:[
- textList := listOfNodes collect: [ :aNode |
- textLine := ReadWriteStream on: String new.
- aNode level timesRepeat: [
- textLine space; space.
- ].
- textLine nextPutAll: aNode name.
- aNode isExpandable ifTrue: [
- textLine nextPutAll: ' ...'.
- ].
- textLine contents.
+ itemPrintConverter notNil ifTrue:[
+ "/ externally provided node-to-listentry converter
+ "/ allows hierarchyNodes to be presented in any
+ "/ programmer defined way ...
+
+ itemList := listOfNodes collect:[:aNode |
+ itemPrintConverter value:aNode
].
- ] ifTrue:[
- "/ claus:
- "/ mhmh - the AEG code depends on those blockGraphic
- "/ characters being in the font.
- "/
- "/ how can we find out what characters there are ?
- "/ (X maps missing chars to a space).
- "/ we should really rewrite this to use a private bitmap font ...
-
-"/ blockGraphicCharacters := Array with:$|
-"/ with:$+
-"/ with:$+
-"/ with:$-.
-
- blockGraphicCharacters := Array with:(Character value:25)
- with:(Character value:14)
- with:(Character value:21)
- with:(Character value:18).
-
- isLastOnLevel:=Set new.
- treeLevels:=Set new.
- oldLevel:=0.
-
- listOfNodes reverseDo: [ :aNode |
- (treeLevels includes:(aNode level)) ifFalse:[
- isLastOnLevel add:aNode.
- treeLevels add:(aNode level).
+ ] ifFalse:[
+ showConnectingLines ifFalse:[
+ itemList := listOfNodes collect: [ :aNode |
+ textLine := ReadWriteStream on: String new.
+ aNode level timesRepeat: [
+ textLine spaces:indent.
+ ].
+ textLine nextPutAll: aNode name.
+ aNode isExpandable ifTrue: [
+ textLine nextPutAll: ' ...'.
+ ].
+ textLine contents.
].
- aNode level < oldLevel ifTrue:[
- treeLevels remove:oldLevel.
- ].
- oldLevel:=aNode level.
- ].
+ ] ifTrue:[
+ "/ claus:
+ "/ mhmh - the AEG code depends on those blockGraphic
+ "/ characters being in the font.
+ "/
+ "/ how can we find out what characters there are ?
+ "/ (X maps missing chars to a space).
+ "/ we should really rewrite this to use a private bitmap font ...
+
+ blockGraphicCharacters := Array with:$|
+ with:$+
+ with:$+
+ with:$-.
- treeLevels:=Set new.
- oldLevel:=0.
- textList := listOfNodes collect: [ :aNode |
- textLine := ReadWriteStream on: String new.
+ "/ blockGraphicCharacters := Array with:(Character value:25)
+ "/ with:(Character value:14)
+ "/ with:(Character value:21)
+ "/ with:(Character value:18).
+
+ isLastOnLevel:=Set new.
+ treeLevels:=Set new.
+ oldLevel:=0.
- 1 to:((aNode level)-1) do: [ :l |
- (treeLevels includes:l) ifTrue:[
-"/ original: textLine space; nextPutAll:((Character value:25)printString); space.
- textLine space; nextPut:(blockGraphicCharacters at:1); space.
- ]ifFalse:[
- textLine space; space; space.
- ]
+ listOfNodes reverseDo: [ :aNode |
+ (treeLevels includes:(aNode level)) ifFalse:[
+ isLastOnLevel add:aNode.
+ treeLevels add:(aNode level).
+ ].
+ aNode level < oldLevel ifTrue:[
+ treeLevels remove:oldLevel.
+ ].
+ oldLevel:=aNode level.
].
- treeLevels add:(aNode level).
- oldLevel:=aNode level.
+
+ treeLevels:=Set new.
+ oldLevel:=0.
+ itemList := listOfNodes collect: [ :aNode |
+ textLine := ReadWriteStream on: String new.
- (aNode = (listOfNodes first)) ifFalse:[
- textLine space.
- (isLastOnLevel includes:aNode)ifTrue:[
-"/ original: textLine nextPutAll:((Character value:14)printString).
- textLine nextPut:(blockGraphicCharacters at:2).
- treeLevels remove:(aNode level).
- ] ifFalse:[
-"/ original: textLine nextPutAll:((Character value:21)printString).
- textLine nextPut:(blockGraphicCharacters at:3).
+ 1 to:((aNode level)-1) do: [ :l |
+ (treeLevels includes:l) ifTrue:[
+ textLine space; nextPut:(blockGraphicCharacters at:1); space.
+ ]ifFalse:[
+ textLine space; space; space.
+ ]
].
-"/ original: textLine nextPutAll:((Character value:18)printString).
- textLine nextPut:(blockGraphicCharacters at:4).
- ].
- aNode isExpandable ifTrue: [
- textLine nextPutAll: '[+]'.
- ] ifFalse:[
- aNode isCollapsable ifTrue: [
- textLine nextPutAll: '[-]'.
- ] ifFalse:[
-"/ original: textLine nextPutAll:((Character value:18)printString).
+ treeLevels add:(aNode level).
+ oldLevel:=aNode level.
+
+ (aNode = (listOfNodes first)) ifFalse:[
+ textLine space.
+ (isLastOnLevel includes:aNode)ifTrue:[
+ textLine nextPut:(blockGraphicCharacters at:2).
+ treeLevels remove:(aNode level).
+ ] ifFalse:[
+ textLine nextPut:(blockGraphicCharacters at:3).
+ ].
textLine nextPut:(blockGraphicCharacters at:4).
].
- ].
+ aNode isExpandable ifTrue: [
+ textLine nextPutAll: '[+]'.
+ ] ifFalse:[
+ aNode isCollapsable ifTrue: [
+ textLine nextPutAll: '[-]'.
+ ] ifFalse:[
+ textLine nextPut:(blockGraphicCharacters at:4).
+ ].
+ ].
- textLine nextPutAll:' ', aNode name.
- textLine contents.
- ].
+ textLine nextPutAll:' ', aNode name.
+ textLine contents.
+ ].
+ ]
].
- ^textList
+ ^itemList
- "Modified: 10.10.94 / 16:13:39 / W.Olberding"
+ "Modified: 10.10.1994 / 16:13:39 / W.Olberding"
+ "Modified: 16.4.1997 / 12:43:20 / cg"
!
getSelectionFromModel
@@ -357,5 +376,5 @@
!SelectionInHierarchyView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInHierarchyView.st,v 1.7 1996-10-22 21:48:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInHierarchyView.st,v 1.8 1997-04-16 11:29:29 cg Exp $'
! !