88 lines
2.2 KiB
Smalltalk
88 lines
2.2 KiB
Smalltalk
"
|
|
Branch node. this kind of node has no content
|
|
"
|
|
Class {
|
|
#name : #GrafoscopioBranchNode,
|
|
#superclass : #GrafoscopioLeafNode,
|
|
#instVars : [
|
|
'children'
|
|
],
|
|
#category : #'Grafoscopio-Model'
|
|
}
|
|
|
|
{ #category : #'instance creation' }
|
|
GrafoscopioBranchNode class >> isLeaf [
|
|
^ false
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> acceptVisitor: aGrafoscopioVisitor [
|
|
aGrafoscopioVisitor visitBranchNode: self.
|
|
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> acceptsChildsOfClass: aClass [
|
|
^ {GrafoscopioBranchNode.
|
|
GrafoscopioUnitNode} includes: aClass
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> addAtBeginningChild: aBlock ofClass: aClass [
|
|
(self acceptsChildsOfClass: aClass)
|
|
ifTrue: [| child |
|
|
child := aBlock value.
|
|
child parent: self.
|
|
self children addFirst: child]
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> addChild: aBlock ofClass: aClass [
|
|
(self acceptsChildsOfClass: aClass)
|
|
ifTrue: [ | child |
|
|
child := aBlock value.
|
|
child parent: self.
|
|
self children add: child ]
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> children [
|
|
"Returns the receivers list of children"
|
|
|
|
^ children ifNil: [ children := OrderedCollection new ]
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> children: aCollection [
|
|
"Sets the receivers children"
|
|
|
|
aCollection do: [:currentNode | currentNode parent: self ].
|
|
children := aCollection.
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioBranchNode >> isLeaf [
|
|
^ false
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioBranchNode >> moveDown: aNode [
|
|
| index |
|
|
"Moves the current node a place before in the children collection where is located"
|
|
index := children indexOf: aNode.
|
|
children swap: index with: (index + 1 min: children size)
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioBranchNode >> moveUp: aNode [
|
|
| index |
|
|
"Moves the current node a place before in the children collection where is located"
|
|
index := children indexOf: aNode.
|
|
children swap: index with: (index - 1 max: 1)
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioBranchNode >> remove: aGrafoscopioTextNode [
|
|
children remove: aGrafoscopioTextNode
|
|
]
|