Adding nodes "almost" done. Now the problem is deletion... :-/ ..anyway, I'm making progres :-)

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-08-18 19:48:10 +00:00
parent b9448781ad
commit a4dadda39b

View File

@ -47,12 +47,13 @@ GrafoscopioNotebook class >> defaultSpec [
] ]
{ #category : #operation } { #category : #operation }
GrafoscopioNotebook >> addNode [ GrafoscopioNotebook >> addNode [
| addedNode |
tree needRebuild: true. tree needRebuild: true.
tree highlightedItem content addNodeAfterMe. addedNode := tree highlightedItem content addNodeAfterMe.
self notebookContent: notebook. self notebookContent: notebook.
tree roots: tree roots. tree roots: tree roots.
self highlightNextItem. self highlightItemFor: addedNode.
self buildWithSpecLayout: self class defaultSpec. self buildWithSpecLayout: self class defaultSpec.
] ]
@ -92,11 +93,12 @@ GrafoscopioNotebook >> changeBody: aNode [
{ #category : #operation } { #category : #operation }
GrafoscopioNotebook >> demoteNode [ GrafoscopioNotebook >> demoteNode [
| currentNode | | currentContent |
currentNode := tree selectedItem content. currentContent := tree highlightedItem content.
currentNode demote. currentContent demote.
self notebookContent: notebook.
self highlightItemFor: currentContent.
tree needRebuild: true. tree needRebuild: true.
tree roots: tree roots.
self buildWithSpecLayout: self class defaultSpec. self buildWithSpecLayout: self class defaultSpec.
] ]
@ -128,6 +130,31 @@ GrafoscopioNotebook >> header: anObject [
header := anObject header := anObject
] ]
{ #category : #operation }
GrafoscopioNotebook >> highlightItemFor: nodeContent [
| currentItem |
currentItem := tree highlightedItem.
currentItem
ifNotNil: [ | allItems index childrenSize parentNode |
currentItem parentNode
ifNil: [
parentNode := currentItem container.
allItems := parentNode roots ]
ifNotNil: [
parentNode := currentItem parentNode.
allItems := parentNode children value. ].
childrenSize := currentItem content parent children size.
index := allItems indexOf: currentItem.
(index < childrenSize) ifTrue: [
"{allItems . currentItem . index } inspect."
currentItem selected: false.
parentNode
highlightedItem: ((allItems at:(index+1)) selected:true;
takeHighlight;yourself).
]
]
]
{ #category : #operation } { #category : #operation }
GrafoscopioNotebook >> highlightNextItem [ GrafoscopioNotebook >> highlightNextItem [
| currentItem | | currentItem |
@ -473,26 +500,32 @@ GrafoscopioNotebook >> projectSubMenu [
{ #category : #operation } { #category : #operation }
GrafoscopioNotebook >> promoteNode [ GrafoscopioNotebook >> promoteNode [
| currentNode | | currentContent |
currentNode := tree selectedItem content. currentContent := tree selectedItem content.
currentNode promote. currentContent promote.
self notebookContent: notebook.
self highlightItemFor: currentContent.
tree needRebuild: true. tree needRebuild: true.
tree roots: tree roots.
self buildWithSpecLayout: self class defaultSpec. self buildWithSpecLayout: self class defaultSpec.
] ]
{ #category : #operation } { #category : #operation }
GrafoscopioNotebook >> removeNode [ GrafoscopioNotebook >> removeNode [
| nodeToDelete | | contentToDelete parentContent newSelectedContent children |
nodeToDelete := tree selectedItem content. contentToDelete := tree selectedItem content.
nodeToDelete parent removeNode: nodeToDelete. parentContent := contentToDelete parent.
"tree selectedItem: tree selectedItem parentNode." children := parentContent children.
tree selectOnlyLastHighlighted. children size > 1
ifTrue: [
children last = contentToDelete
ifTrue: [ newSelectedContent := children at: (children size - 1) ]
]
ifFalse: [ newSelectedContent := parentContent ].
contentToDelete parent removeNode: contentToDelete.
self notebookContent: notebook.
self highlightItemFor: newSelectedContent.
tree needRebuild: true. tree needRebuild: true.
tree roots: tree roots.
self buildWithSpecLayout: self class defaultSpec. self buildWithSpecLayout: self class defaultSpec.
] ]
{ #category : #persistence } { #category : #persistence }