Fighting against the selection of new nodes on Spec.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-08-10 12:05:37 +00:00
parent c9e410a36d
commit 6024ef8058
2 changed files with 29 additions and 15 deletions

View File

@ -85,11 +85,11 @@ GrafoscopioNode >> addNode: aNode [
GrafoscopioNode >> addNodeAfterMe [ GrafoscopioNode >> addNodeAfterMe [
"Adds a generic node after the given node so they become slibings of the same parent" "Adds a generic node after the given node so they become slibings of the same parent"
| genericNode | | genericNode |
genericNode := GrafoscopioNode genericNode := self class new header: 'newNode'; body: ''.
header: 'newNode' body: ''.
self parent children add: genericNode after: self. self parent children add: genericNode after: self.
genericNode parent: self parent. genericNode parent: self parent.
genericNode level: self level. genericNode level: self level.
^ genericNode
] ]

View File

@ -48,8 +48,9 @@ GrafoscopioNotebook class >> defaultSpec [
{ #category : #operation } { #category : #operation }
GrafoscopioNotebook >> addNode [ GrafoscopioNotebook >> addNode [
| newSelectedNode |
tree needRebuild: true. tree needRebuild: true.
tree selectedItem content addNodeAfterMe. newSelectedNode := tree selectedItem content addNodeAfterMe.
tree roots: tree roots. tree roots: tree roots.
self buildWithSpecLayout: self class defaultSpec. self buildWithSpecLayout: self class defaultSpec.
@ -70,6 +71,7 @@ GrafoscopioNotebook >> body: anObject [
GrafoscopioNotebook >> changeBody: aNode [ GrafoscopioNotebook >> changeBody: aNode [
self needRebuild: false. self needRebuild: false.
tree needRebuild: false. tree needRebuild: false.
body needRebuild: true.
body := self instantiate: aNode specModelClass new. body := self instantiate: aNode specModelClass new.
body content: aNode content. body content: aNode content.
@ -131,14 +133,14 @@ GrafoscopioNotebook >> header: anObject [
{ #category : #initialization } { #category : #initialization }
GrafoscopioNotebook >> initializePresenter [ GrafoscopioNotebook >> initializePresenter [
tree whenSelectedItemChanged: [ :item |
self updateBodyFor: item.
header whenTextChanged: [ :arg |
(tree selectedItem content header) = arg
ifFalse: [
(tree highlightedItem) content header: arg.
tree roots: tree roots]]]
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]]
] ]
{ #category : #initialization } { #category : #initialization }
@ -148,10 +150,8 @@ GrafoscopioNotebook >> initializeWidgets [
tree := TreeModel new. tree := TreeModel new.
header := self newTextInput. header := self newTextInput.
body := self newText. body := self newText.
body disable. body disable.
body text: '<-- Select a node in the left panel'. body text: '<- Select a node'.
tree tree
childrenBlock: [:node | node children]; childrenBlock: [:node | node children];
displayBlock: [:node | node title ]. displayBlock: [:node | node title ].
@ -518,6 +518,20 @@ GrafoscopioNotebook >> tree: anObject [
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 } { #category : #accessing }
GrafoscopioNotebook >> windowMainMenu [ GrafoscopioNotebook >> windowMainMenu [
^ windowMainMenu ^ windowMainMenu