more refactors. version 0,0001 ready

Co-authored-by: none <not@mail.given>
This commit is contained in:
Santiago Bragagnolo 2020-03-25 00:03:29 +00:00 committed by Offray Luna
parent b61a9e83de
commit 633613c3bc
15 changed files with 525 additions and 114 deletions

View File

@ -89,6 +89,11 @@ GrafoscopioAbstractNode >> isLeaf [
^ self class isLeaf ^ self class isLeaf
] ]
{ #category : #'as yet unclassified' }
GrafoscopioAbstractNode >> moveDown [
self subclassResponsibility
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioAbstractNode >> name [ GrafoscopioAbstractNode >> name [
^ name ^ name
@ -99,6 +104,11 @@ GrafoscopioAbstractNode >> name: aName [
name := aName name := aName
] ]
{ #category : #'as yet unclassified' }
GrafoscopioAbstractNode >> order [
^ order ifNil: [ 0 ]
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioAbstractNode >> tagAs: aTag [ GrafoscopioAbstractNode >> tagAs: aTag [
self self

View File

@ -27,10 +27,22 @@ GrafoscopioBranchNode >> acceptsChildsOfClass: aClass [
GrafoscopioUnitNode} includes: aClass 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 } { #category : #accessing }
GrafoscopioBranchNode >> addChild: aBlock ofClass: aClass [ GrafoscopioBranchNode >> addChild: aBlock ofClass: aClass [
(self acceptsChildsOfClass: aClass) (self acceptsChildsOfClass: aClass)
ifTrue: [ self children add: aBlock value ] ifTrue: [ | child |
child := aBlock value.
child parent: self.
self children add: child ]
] ]
{ #category : #accessing } { #category : #accessing }
@ -52,3 +64,24 @@ GrafoscopioBranchNode >> children: aCollection [
GrafoscopioBranchNode >> isLeaf [ GrafoscopioBranchNode >> isLeaf [
^ false ^ 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
]

View File

@ -24,13 +24,49 @@ GrafoscopioDocumentEditionPerspective class >> icon [
^ self iconNamed: #merge ^ self iconNamed: #merge
] ]
{ #category : #'as yet unclassified' } { #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeOfClass: aClass [ GrafoscopioDocumentEditionPerspective >> addAtBeginningNewNodeOfClass: aClass [
(tree selectedItem ifNil: [ document ]) self
addAtBeginningOf: (tree selectedItem ifNil: [ document ])
aNodeOfClass: aClass
]
{ #category : #'adding - base' }
GrafoscopioDocumentEditionPerspective >> addAtBeginningOf: aNode aNodeOfClass: aClass [
aNode
addAtBeginningChild: [ self instantiateNode: aClass ]
ofClass: aClass.
self modelChanged
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addAtLastNewNodeOfClass: aClass [
self
addAtLastOf: (tree selectedItem ifNil: [ document ])
aNodeOfClass: aClass
]
{ #category : #'adding - base' }
GrafoscopioDocumentEditionPerspective >> addAtLastOf: aNode aNodeOfClass: aClass [
aNode
addChild: [ self instantiateNode: aClass ] addChild: [ self instantiateNode: aClass ]
ofClass: aClass. ofClass: aClass.
self needRebuild: false. self modelChanged
self buildWithSpec ]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeAtBeginningOf: aNode [
self addAtBeginningOf: aNode aNodeOfClass: self chooseKindsOfNode
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeAtLastOf: aNode [
self addAtLastOf: aNode aNodeOfClass: self chooseKindsOfNode
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeOfClass: aClass [
^ self addAtLastNewNodeOfClass: aClass
] ]
{ #category : #initialization } { #category : #initialization }
@ -40,7 +76,17 @@ GrafoscopioDocumentEditionPerspective >> createDefaultViewportVisitor [
{ #category : #initialization } { #category : #initialization }
GrafoscopioDocumentEditionPerspective >> createViewport [ GrafoscopioDocumentEditionPerspective >> createViewport [
^ self createDefaultViewportVisitor createViewportFor: document into: self ^ self renderViewport: document
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> informNodeHasChanged: aNode [
| path |
path := tree selection selectedPath.
tree roots: {document}.
tree selectPath: path.
] ]
{ #category : #initialization } { #category : #initialization }
@ -52,7 +98,10 @@ GrafoscopioDocumentEditionPerspective >> initializeWidgets [
children: [ :node | children: [ :node |
node isLeaf node isLeaf
ifTrue: [ {} ] ifTrue: [ {} ]
ifFalse: [ node children ] ] ifFalse: [ node children reject:[: a | a isLeaf ] ]].
tree activateOnDoubleClick.
tree whenSelectionChangedDo: [ : a | self renderViewport: a selectedItem ].
tree whenActivatedDo: [ : a | self tooglePresenterForEdition: a ].
] ]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
@ -66,11 +115,37 @@ GrafoscopioDocumentEditionPerspective >> instantiateNode: aClass [
name: name; name: name;
yourself ]. yourself ].
^ aClass new ^ aClass new
" self error: 'Unexpected class'"
] ]
{ #category : #initialization } { #category : #initialization }
GrafoscopioDocumentEditionPerspective >> updateModel: aModel [ GrafoscopioDocumentEditionPerspective >> modelChanged [
document := aModel document. | path |
tree roots: aModel document children. viewport := self createViewport.
path := tree selection selectedPath.
tree roots: {document}.
tree selectPath: path.
self needRebuild: false.
self buildWithSpec
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> renderViewport: aNode [
^ self createDefaultViewportVisitor createViewportFor: ( aNode ifNil: [ document ]) into: self
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> setModelBeforeInitialization: aDomainObject [
super setModelBeforeInitialization: aDomainObject.
document := aDomainObject .
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> tooglePresenterForEdition: anObect [
self halt.
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> viewport [
^ viewport
] ]

View File

@ -21,6 +21,11 @@ GrafoscopioLeafNode >> acceptVisitor: aGrafoscopioVisitor [
] ]
{ #category : #accessing }
GrafoscopioLeafNode >> addAtBeginningChild: aBlock ofClass: aClass [
self error: 'Leaf nodes are abstract. '
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioLeafNode >> addChild: aBlock ofClass: aClass [ GrafoscopioLeafNode >> addChild: aBlock ofClass: aClass [
self error: 'Leaf nodes are abstract. ' self error: 'Leaf nodes are abstract. '
@ -33,6 +38,16 @@ GrafoscopioLeafNode >> level [
^ parent ifNil: [ 0 ] ifNotNil: [ 1 + parent level ] ^ parent ifNil: [ 0 ] ifNotNil: [ 1 + parent level ]
] ]
{ #category : #'as yet unclassified' }
GrafoscopioLeafNode >> moveDown [
parent moveDown: self.
]
{ #category : #'as yet unclassified' }
GrafoscopioLeafNode >> moveUp [
parent moveUp: self.
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioLeafNode >> parent [ GrafoscopioLeafNode >> parent [
"Returns the parent of the current node" "Returns the parent of the current node"
@ -41,13 +56,10 @@ GrafoscopioLeafNode >> parent [
{ #category : #accessing } { #category : #accessing }
GrafoscopioLeafNode >> parent: aNode [ GrafoscopioLeafNode >> parent: aNode [
"A parent is a node that has the current node in its children" parent := aNode
aNode ifNil: [ ]
parent := aNode.
^self ]. { #category : #'as yet unclassified' }
aNode parent = self ifTrue: [ ^ self ]. GrafoscopioLeafNode >> remove [
parent := aNode. parent remove: self.
(aNode children includes: self)
ifFalse: [ aNode addNode: self ]
] ]

View File

@ -1,8 +1,9 @@
Class { Class {
#name : #GrafoscopioNewCodeModel, #name : #GrafoscopioNewCodeModel,
#superclass : #SpPresenter, #superclass : #GrafoscopioNewTextModel,
#instVars : [ #instVars : [
'body' 'preview',
'previewButton'
], ],
#category : 'Grafoscopio-New-UI' #category : 'Grafoscopio-New-UI'
} }
@ -14,23 +15,91 @@ GrafoscopioNewCodeModel class >> defaultSpec [
yourself yourself
] ]
{ #category : #accessing } { #category : #initialization }
GrafoscopioNewCodeModel >> body [
^ body
]
{ #category : #accessing }
GrafoscopioNewCodeModel >> body: anObject [
body := anObject
]
{ #category : #API }
GrafoscopioNewCodeModel >> content: aGrafoscopioNodeContent [ GrafoscopioNewCodeModel >> content: aGrafoscopioNodeContent [
body text: aGrafoscopioNodeContent self layout: (self createLayoutFor: aGrafoscopioNodeContent).
body text: (aGrafoscopioNodeContent ifNil: [ '' ])
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> createLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #up;
add: #down;
add: #delete;
yourself)
width: 30;
add:
(SpBoxLayout newHorizontal
add: #body;
add: #previewButton width: 30;
add: #preview;
yourself);
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> editionLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #up;
add: #down;
add: #delete;
yourself)
width: 30;
add:
(SpBoxLayout newHorizontal
add: #body;
add: #previewButton width: 30;
add: #preview;
yourself);
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
] ]
{ #category : #initialization } { #category : #initialization }
GrafoscopioNewCodeModel >> initializeWidgets [ GrafoscopioNewCodeModel >> initializeWidgets [
super initializeWidgets.
body := self newCode. previewButton := self newButton.
previewButton icon: (self iconNamed: #smallFind).
previewButton action: [ self previewCode ].
preview := self newLabel
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> newTextComponent [
^ self newCode
whenTextChangedDo: [ model text: body text ];
autoAccept: true;
yourself
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> normalLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newHorizontal
add: #body;
add: #previewButton width: 30;
add: #preview;
yourself);
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> previewCode [
[ preview label: (self class compiler evaluate: body text) asString ]
on: Error
do: [ :e | preview label: e asString]
] ]

View File

@ -0,0 +1,85 @@
Class {
#name : #GrafoscopioNewTextInputModel,
#superclass : #SpDynamicPresenter,
#instVars : [
'#body',
'#model',
'=>',
'SpObservableSlot',
'#onModifyNodeLocationDo'
],
#category : 'Grafoscopio-New-UI'
}
{ #category : #specs }
GrafoscopioNewTextInputModel class >> defaultSpec [
^ SpBoxLayout newVertical
add: #body height: 300;
yourself
]
{ #category : #API }
GrafoscopioNewTextInputModel >> content: aGrafoscopioNodeContent [
self layout: (self createLayoutFor: aGrafoscopioNodeContent).
body text: (aGrafoscopioNodeContent ifNil: [ '' ])
]
{ #category : #API }
GrafoscopioNewTextInputModel >> createLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add: #body
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #'as yet unclassified' }
GrafoscopioNewTextInputModel >> heightFor: aGrafoscopioNodeContent [
^ aGrafoscopioNodeContent
ifNil: [ 100 ]
ifNotNil: [ (aGrafoscopioNodeContent asString lines size * self class toolbarHeight) max: 100 ]
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> informModification [
onModifyNodeLocationDo
ifNotNil: [ onModifyNodeLocationDo cull: self ]
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> initialize [
super initialize.
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> initializePrivateAnnouncements [
super initializePrivateAnnouncements.
self property: #model whenChangedDo: [ self modelChanged ]
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> initializeWidgets [
body := self newTextComponent.
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> model: aModel [
model := aModel
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> modelChanged [
self content: model text.
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> newTextComponent [
^ self newTextInput whenTextChangedDo: [
model text: body text.
self informModification ];
yourself
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> onModifyNodeLocationDo: aBlock [
onModifyNodeLocationDo := aBlock
]

View File

@ -1,37 +1,68 @@
Class { Class {
#name : #GrafoscopioNewTextModel, #name : #GrafoscopioNewTextModel,
#superclass : #SpPresenter, #superclass : #GrafoscopioNewTextInputModel,
#instVars : [ #instVars : [
'body' 'up',
'down',
'delete',
'editionMode'
], ],
#category : 'Grafoscopio-New-UI' #category : 'Grafoscopio-New-UI'
} }
{ #category : #specs } { #category : #initialization }
GrafoscopioNewTextModel class >> defaultSpec [ GrafoscopioNewTextModel >> createLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical ^ editionMode
add: #body height: 300; ifTrue: [ self editionLayoutFor: aGrafoscopioNodeContent ]
yourself ifFalse: [ self normalLayoutFor: aGrafoscopioNodeContent ]
]
{ #category : #accessing }
GrafoscopioNewTextModel >> body [
^ body
]
{ #category : #accessing }
GrafoscopioNewTextModel >> body: anObject [
body := anObject
]
{ #category : #API }
GrafoscopioNewTextModel >> content: aGrafoscopioNodeContent [
body text: aGrafoscopioNodeContent
] ]
{ #category : #initialization } { #category : #initialization }
GrafoscopioNewTextModel >> initializeWidgets [ GrafoscopioNewTextModel >> editionLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
body := self newText. add:
body autoAccept: true. (SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #up;
add: #down;
add: #delete;
yourself)
width: 30;
add: #body;
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewTextModel >> initializeWidgets [
super initializeWidgets .
editionMode := true.
up := self newButton icon: (self iconNamed: #up) ; color: Color transparent ; yourself .
down := self newButton icon: (self iconNamed: #down) ; color: Color transparent ; yourself .
delete := self newButton icon: (self iconNamed: #delete) ; color: Color transparent ; yourself .
up action: [ model moveUp. self informModification. ].
down action: [ model moveDown. self informModification.].
delete action: [ model remove .self informModification. ]
]
{ #category : #initialization }
GrafoscopioNewTextModel >> newTextComponent [
^ self newText
whenTextChangedDo: [ model text: body text ];
autoAccept: true;
yourself
]
{ #category : #initialization }
GrafoscopioNewTextModel >> normalLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add: #body
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewTextModel >> toogleEditionMode [
editionMode := editionMode not.
] ]

View File

@ -1,6 +1,6 @@
Class { Class {
#name : #GrafoscopioPerspective, #name : #GrafoscopioPerspective,
#superclass : #SpPresenter, #superclass : #SpPresenterWithModel,
#instVars : [ #instVars : [
'toolbar', 'toolbar',
'viewport' 'viewport'
@ -53,9 +53,8 @@ GrafoscopioPerspective >> addItemTo: aGroup [
GrafoscopioPerspective >> addingMenu [ GrafoscopioPerspective >> addingMenu [
| menu | | menu |
menu := self newMenu. menu := self newMenu.
GrafoscopioAbstractNode allSubclasses self kindsOfNode
select: [ :c | c showInMenu ] do: [ :n |
thenDo: [ :n |
menu menu
addItem: [ :item | addItem: [ :item |
item item
@ -65,6 +64,19 @@ GrafoscopioPerspective >> addingMenu [
^ menu ^ menu
] ]
{ #category : #'as yet unclassified' }
GrafoscopioPerspective >> chooseKindsOfNode [
| idx values |
values := self kindsOfNode.
idx := UIManager default
chooseFrom: values
lines: {}
title: 'What kind of node? '.
^ idx = 0
ifTrue: [ nil ]
ifFalse: [ values at: idx ]
]
{ #category : #initialization } { #category : #initialization }
GrafoscopioPerspective >> createToolbar [ GrafoscopioPerspective >> createToolbar [
| aMenu | | aMenu |
@ -144,6 +156,11 @@ GrafoscopioPerspective >> initializeWidgets [
viewport := self createViewport viewport := self createViewport
] ]
{ #category : #'as yet unclassified' }
GrafoscopioPerspective >> kindsOfNode [
^ GrafoscopioAbstractNode allSubclasses select: [ :c | c showInMenu ]
]
{ #category : #initialization } { #category : #initialization }
GrafoscopioPerspective >> subMenu [ GrafoscopioPerspective >> subMenu [
^ self newMenu ^ self newMenu

View File

@ -19,3 +19,8 @@ GrafoscopioProject >> initialize [
document := GrafoscopioRootNode new. document := GrafoscopioRootNode new.
dictionary := GrafoscopioRootNode new dictionary := GrafoscopioRootNode new
] ]
{ #category : #initialization }
GrafoscopioProject >> name: aName [
document name: aName
]

View File

@ -21,10 +21,22 @@ GrafoscopioRootNode >> acceptsChildsOfClass: aClass [
^ {GrafoscopioUnitNode} includes: aClass ^ {GrafoscopioUnitNode} includes: aClass
] ]
{ #category : #accessing }
GrafoscopioRootNode >> addAtBeginningChild: aBlock ofClass: aClass [
(self acceptsChildsOfClass: aClass)
ifTrue: [ | child |
child := aBlock value.
child parent: self.
self children addFirst: child ]
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioRootNode >> addChild: aBlock ofClass: aClass [ GrafoscopioRootNode >> addChild: aBlock ofClass: aClass [
(self acceptsChildsOfClass: aClass) (self acceptsChildsOfClass: aClass)
ifTrue: [ self children add: aBlock value ] ifTrue: [ | child |
child := aBlock value.
child parent: self.
self children add: child ]
] ]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
@ -44,3 +56,13 @@ GrafoscopioRootNode >> initialize [
GrafoscopioRootNode >> level [ GrafoscopioRootNode >> level [
^ 1 ^ 1
] ]
{ #category : #accessing }
GrafoscopioRootNode >> text [
^ name
]
{ #category : #accessing }
GrafoscopioRootNode >> text: aText [
name := aText
]

View File

@ -31,6 +31,11 @@ GrafoscopioTextNode >> acceptVisitor: aGrafoscopioVisitor [
] ]
{ #category : #'as yet unclassified' }
GrafoscopioTextNode >> text [
^ text
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioTextNode >> text: aString [ GrafoscopioTextNode >> text: aString [
text := aString text := aString

View File

@ -1,14 +1,12 @@
Class { Class {
#name : #GrafoscopioTreeNotebook, #name : #GrafoscopioTreeNotebook,
#superclass : #SpPresenter, #superclass : #SpPresenterWithModel,
#instVars : [ #instVars : [
'#sidebar', 'sidebar',
'#viewport', 'viewport',
'#model', 'model',
'=>', 'empty',
'SpObservableSlot', 'perspectives'
'#empty',
'#perspectives'
], ],
#category : 'Grafoscopio-New-UI' #category : 'Grafoscopio-New-UI'
} }
@ -26,43 +24,49 @@ GrafoscopioTreeNotebook class >> defaultSpec [
yourself yourself
] ]
{ #category : #'as yet unclassified' }
GrafoscopioTreeNotebook >> basicInstallPerspective: aPerspective [
viewport ifNotNil: [ viewport aboutToBeUninstalledFrom: self ].
viewport := self perspectives
at: aPerspective
ifAbsentPut: [ self instantiate: aPerspective on: model document ].
]
{ #category : #initialization } { #category : #initialization }
GrafoscopioTreeNotebook >> createDefaultComponent [ GrafoscopioTreeNotebook >> createDefaultComponent [
^ GrafoscopioPerspective defaultPerspective new ^ self basicInstallPerspective: GrafoscopioPerspective defaultPerspective
]
{ #category : #initialization }
GrafoscopioTreeNotebook >> initialize [
super initialize.
perspectives := Dictionary new.
]
{ #category : #initialization }
GrafoscopioTreeNotebook >> initializePrivateAnnouncements [
super initializePrivateAnnouncements.
self property: #model whenChangedDo: [ self updateModel ]
] ]
{ #category : #initialization } { #category : #initialization }
GrafoscopioTreeNotebook >> initializeWidgets [ GrafoscopioTreeNotebook >> initializeWidgets [
super initializeWidgets. super initializeWidgets.
sidebar := self sidebar. sidebar := self sidebar.
viewport := self createDefaultComponent. self createDefaultComponent.
empty := self newLabel. empty := self newLabel.
] ]
{ #category : #initialization } { #category : #initialization }
GrafoscopioTreeNotebook >> installPerspective: aPerspective [ GrafoscopioTreeNotebook >> installPerspective: aPerspective [
viewport ifNotNil: [ viewport aboutToBeUninstalledFrom: self ]. self basicInstallPerspective: aPerspective .
viewport := (perspectives at: aPerspective ifAbsentPut: [ self instantiate: aPerspective ]) . self modelChanged
self updateModel. ]
{ #category : #initialization }
GrafoscopioTreeNotebook >> modelChanged [
viewport modelChanged.
self needRebuild: false.
self buildWithSpec
]
{ #category : #initialization }
GrafoscopioTreeNotebook >> perspectives [
^ perspectives ifNil: [ perspectives := Dictionary new ]
] ]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioTreeNotebook >> open: aGrafoscopioProject [ GrafoscopioTreeNotebook >> setModelBeforeInitialization: aDomainObject [
model := aGrafoscopioProject. super setModelBeforeInitialization: aDomainObject.
self openWithSpec. model := aDomainObject
self updateModel
] ]
{ #category : #initialization } { #category : #initialization }
@ -74,12 +78,3 @@ GrafoscopioTreeNotebook >> sidebar [
[ :p | bar addAction: [ self installPerspective: p ] icon: p icon ]. [ :p | bar addAction: [ self installPerspective: p ] icon: p icon ].
^ bar ^ bar
] ]
{ #category : #initialization }
GrafoscopioTreeNotebook >> updateModel [
viewport updateModel: model.
self needRebuild: false.
self buildWithSpec
]

View File

@ -29,3 +29,13 @@ GrafoscopioUnitNode >> acceptVisitor: aGrafoscopioVisitor [
GrafoscopioUnitNode >> acceptsChildsOfClass: aClass [ GrafoscopioUnitNode >> acceptsChildsOfClass: aClass [
^ aClass isLeaf or: [ aClass = self class ] ^ aClass isLeaf or: [ aClass = self class ]
] ]
{ #category : #accessing }
GrafoscopioUnitNode >> text [
^ name
]
{ #category : #accessing }
GrafoscopioUnitNode >> text: aText [
name := aText
]

View File

@ -81,6 +81,16 @@ GrafoscopioUrlNode >> shouldAskBeforeRemove [
^ false ^ false
] ]
{ #category : #content }
GrafoscopioUrlNode >> text [
^ self content
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> text: aString [
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioUrlNode >> url [ GrafoscopioUrlNode >> url [
^ link ifNil: [ link := self getUrl ] ^ link ifNil: [ link := self getUrl ]

View File

@ -15,7 +15,8 @@ GrafoscopioViewportVisitor >> createViewportFor: aDocumentNode into: aPresenter
presenter := aPresenter. presenter := aPresenter.
items := OrderedCollection new. items := OrderedCollection new.
aDocumentNode acceptVisitor: self. aDocumentNode acceptVisitor: self.
viewport := aPresenter instantiate: SpComponentListPresenter. viewport := aPresenter viewport
ifNil: [ aPresenter instantiate: SpComponentListPresenter ].
viewport items: items. viewport items: items.
^ viewport ^ viewport
] ]
@ -23,23 +24,54 @@ GrafoscopioViewportVisitor >> createViewportFor: aDocumentNode into: aPresenter
{ #category : #visiting } { #category : #visiting }
GrafoscopioViewportVisitor >> visitCodeNode: aNode [ GrafoscopioViewportVisitor >> visitCodeNode: aNode [
| code | | code |
code := presenter newCode. code := presenter instantiate: GrafoscopioNewCodeModel.
code text: aNode text. code onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
code model: aNode.
items add: code. 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 } { #category : #visiting }
GrafoscopioViewportVisitor >> visitTextNode: aNode [ GrafoscopioViewportVisitor >> visitTextNode: aNode [
| text | | text |
text := presenter newText . text := presenter instantiate: GrafoscopioNewTextModel.
text text: aNode text. text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
text model: aNode.
items add: text. 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 } { #category : #visiting }
GrafoscopioViewportVisitor >> visitUrlNode: aNode [ GrafoscopioViewportVisitor >> visitUrlNode: aNode [
| text | | text |
text := presenter newText . text := presenter instantiate: GrafoscopioNewTextInputModel.
text text: aNode content. text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
items add: text. text model: aNode.
items add: text.
] ]