Adding nodes "almost" done. Now the problem is deletion... :-/ ..anyway, I'm making progres :-)
This commit is contained in:
parent
b9448781ad
commit
a4dadda39b
@ -47,12 +47,13 @@ GrafoscopioNotebook class >> defaultSpec [
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
GrafoscopioNotebook >> addNode [
|
||||
GrafoscopioNotebook >> addNode [
|
||||
| addedNode |
|
||||
tree needRebuild: true.
|
||||
tree highlightedItem content addNodeAfterMe.
|
||||
addedNode := tree highlightedItem content addNodeAfterMe.
|
||||
self notebookContent: notebook.
|
||||
tree roots: tree roots.
|
||||
self highlightNextItem.
|
||||
self highlightItemFor: addedNode.
|
||||
self buildWithSpecLayout: self class defaultSpec.
|
||||
]
|
||||
|
||||
@ -92,11 +93,12 @@ GrafoscopioNotebook >> changeBody: aNode [
|
||||
|
||||
{ #category : #operation }
|
||||
GrafoscopioNotebook >> demoteNode [
|
||||
| currentNode |
|
||||
currentNode := tree selectedItem content.
|
||||
currentNode demote.
|
||||
| currentContent |
|
||||
currentContent := tree highlightedItem content.
|
||||
currentContent demote.
|
||||
self notebookContent: notebook.
|
||||
self highlightItemFor: currentContent.
|
||||
tree needRebuild: true.
|
||||
tree roots: tree roots.
|
||||
self buildWithSpecLayout: self class defaultSpec.
|
||||
]
|
||||
|
||||
@ -128,6 +130,31 @@ GrafoscopioNotebook >> 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 }
|
||||
GrafoscopioNotebook >> highlightNextItem [
|
||||
| currentItem |
|
||||
@ -473,26 +500,32 @@ GrafoscopioNotebook >> projectSubMenu [
|
||||
|
||||
{ #category : #operation }
|
||||
GrafoscopioNotebook >> promoteNode [
|
||||
| currentNode |
|
||||
currentNode := tree selectedItem content.
|
||||
currentNode promote.
|
||||
| currentContent |
|
||||
currentContent := tree selectedItem content.
|
||||
currentContent promote.
|
||||
self notebookContent: notebook.
|
||||
self highlightItemFor: currentContent.
|
||||
tree needRebuild: true.
|
||||
tree roots: tree roots.
|
||||
self buildWithSpecLayout: self class defaultSpec.
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
GrafoscopioNotebook >> removeNode [
|
||||
| nodeToDelete |
|
||||
nodeToDelete := tree selectedItem content.
|
||||
nodeToDelete parent removeNode: nodeToDelete.
|
||||
"tree selectedItem: tree selectedItem parentNode."
|
||||
tree selectOnlyLastHighlighted.
|
||||
| contentToDelete parentContent newSelectedContent children |
|
||||
contentToDelete := tree selectedItem content.
|
||||
parentContent := contentToDelete parent.
|
||||
children := parentContent children.
|
||||
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 roots: tree roots.
|
||||
self buildWithSpecLayout: self class defaultSpec.
|
||||
|
||||
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
|
Loading…
Reference in New Issue
Block a user