diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index 42830a7..962025d 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -85,11 +85,11 @@ GrafoscopioNode >> addNode: aNode [ GrafoscopioNode >> addNodeAfterMe [ "Adds a generic node after the given node so they become slibings of the same parent" | genericNode | - genericNode := GrafoscopioNode - header: 'newNode' body: ''. + genericNode := self class new header: 'newNode'; body: ''. self parent children add: genericNode after: self. genericNode parent: self parent. - genericNode level: self level. + genericNode level: self level. + ^ genericNode ] diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index f28acc6..4f20eab 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -48,8 +48,9 @@ GrafoscopioNotebook class >> defaultSpec [ { #category : #operation } GrafoscopioNotebook >> addNode [ + | newSelectedNode | tree needRebuild: true. - tree selectedItem content addNodeAfterMe. + newSelectedNode := tree selectedItem content addNodeAfterMe. tree roots: tree roots. self buildWithSpecLayout: self class defaultSpec. @@ -70,6 +71,7 @@ GrafoscopioNotebook >> body: anObject [ GrafoscopioNotebook >> changeBody: aNode [ self needRebuild: false. tree needRebuild: false. + body needRebuild: true. body := self instantiate: aNode specModelClass new. body content: aNode content. @@ -131,14 +133,14 @@ GrafoscopioNotebook >> header: anObject [ { #category : #initialization } GrafoscopioNotebook >> initializePresenter [ - - tree whenSelectedItemsChanged: [ :arg | - arg isEmpty ifFalse: [self changeBody: tree selectedItem content ]]. - header whenTextChanged: [ :arg | - (tree selectedItem content header) = arg - ifFalse: [ - (tree selectedItem) content header: arg. - tree roots: tree roots]] + tree whenSelectedItemChanged: [ :item | + self updateBodyFor: item. + header whenTextChanged: [ :arg | + (tree selectedItem content header) = arg + ifFalse: [ + (tree highlightedItem) content header: arg. + tree roots: tree roots]]] + ] { #category : #initialization } @@ -148,10 +150,8 @@ GrafoscopioNotebook >> initializeWidgets [ tree := TreeModel new. header := self newTextInput. body := self newText. - body disable. - body text: '<-- Select a node in the left panel'. - + body text: '<- Select a node'. tree childrenBlock: [:node | node children]; displayBlock: [:node | node title ]. @@ -518,6 +518,20 @@ GrafoscopioNotebook >> tree: anObject [ tree := anObject ] +{ #category : #operation } +GrafoscopioNotebook >> updateBodyFor: item [ + item + ifNotNil: [ self changeBody: item ] + ifNil: [ self inform: 'Nil node' ] +] + +{ #category : #operation } +GrafoscopioNotebook >> updateBodyFor: item or: bufferedSelection [ + item + ifNotNil: [ self changeBody: item ] + ifNil: [ self changeBody: bufferedSelection ] +] + { #category : #accessing } GrafoscopioNotebook >> windowMainMenu [ ^ windowMainMenu