Grafoscopio/repository/Grafoscopio/GrafoscopioViewportVisitor.class.st
2020-05-09 18:41:07 +00:00

78 lines
2.1 KiB
Smalltalk

Class {
#name : #GrafoscopioViewportVisitor,
#superclass : #GrafoscopioVisitor,
#instVars : [
'viewport',
'stack',
'items',
'presenter'
],
#category : 'Grafoscopio-New-UI'
}
{ #category : #visiting }
GrafoscopioViewportVisitor >> createViewportFor: aDocumentNode into: aPresenter [
presenter := aPresenter.
items := OrderedCollection new.
aDocumentNode acceptVisitor: self.
viewport := aPresenter viewport
ifNil: [ aPresenter instantiate: SpComponentListPresenter ].
viewport items: items.
^ viewport
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitCodeNode: aNode [
| code |
code := presenter instantiate: GrafoscopioNewCodeModel.
code onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
code model: aNode.
items add: code.
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitRootNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextInputModel.
text model: aNode.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
items add: text.
super visitRootNode: aNode.
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitTextNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextModel.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
text model: aNode.
items add: text.
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitUnitNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextInputModel.
text model: aNode.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
items add: text.
items add: (presenter newButton
label: ' Add node on the beginning ';
action: [ presenter addNewNodeAtBeginningOf: aNode ];
yourself).
super visitUnitNode: aNode.
items add: (presenter newButton
label: ' Add node on the end ';
action: [ presenter addNewNodeAtLastOf: aNode ];
yourself)
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitUrlNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextInputModel.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
text model: aNode.
items add: text.
]