Class { #name : #GrafoscopioDocumentEditionPerspective, #superclass : #GrafoscopioPerspective, #instVars : [ 'tree', 'document' ], #category : 'Grafoscopio-New-UI' } { #category : #accessing } GrafoscopioDocumentEditionPerspective class >> defaultSpec [ ^ SpBoxLayout newVertical add: #toolbar height: self toolbarHeight; add: (SpBoxLayout newHorizontal add: #tree width: 100; add: #viewport; yourself) yourself ] { #category : #accessing } GrafoscopioDocumentEditionPerspective class >> icon [ ^ self iconNamed: #merge ] { #category : #'adding - convenience' } GrafoscopioDocumentEditionPerspective >> addAtBeginningNewNodeOfClass: aClass [ 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 ] ofClass: aClass. self modelChanged ] { #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 } GrafoscopioDocumentEditionPerspective >> createDefaultViewportVisitor [ ^ GrafoscopioViewportVisitor new ] { #category : #initialization } GrafoscopioDocumentEditionPerspective >> createViewport [ ^ self renderViewport: document ] { #category : #initialization } GrafoscopioDocumentEditionPerspective >> informNodeHasChanged: aNode [ | path | path := tree selection selectedPath. tree roots: {document}. tree selectPath: path. ] { #category : #initialization } GrafoscopioDocumentEditionPerspective >> initializeWidgets [ super initializeWidgets. tree := self newTreeTable. tree addColumn: (SpStringTableColumn evaluated: #name); children: [ :node | node isLeaf ifTrue: [ {} ] 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' } GrafoscopioDocumentEditionPerspective >> instantiateNode: aClass [ aClass class = GrafoscopioUnitNode species ifTrue: [ | name | name := UIManager default request: 'Unit name' initialAnswer: 'New unit'. ^ aClass new name: name; yourself ]. ^ aClass new ] { #category : #initialization } GrafoscopioDocumentEditionPerspective >> modelChanged [ | path | 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 ]