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 [
"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
]

View File

@ -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