Copy & paste suport in the model.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-12-17 14:52:25 +00:00
parent ea63230b0e
commit 3ad5f00c8f
2 changed files with 29 additions and 14 deletions

View File

@ -22,21 +22,11 @@ Class {
#classInstVars : [
'dockingBar',
'recentNotebooks',
'cacheNode'
'nodesClipboard'
],
#category : #'Grafoscopio-UI'
}
{ #category : #accessing }
GrafoscopioGUI class >> cacheNode [
^ cacheNode
]
{ #category : #accessing }
GrafoscopioGUI class >> cacheNode: anObject [
cacheNode := anObject
]
{ #category : #specs }
GrafoscopioGUI class >> defaultSpec [
<spec: #default>
@ -389,6 +379,16 @@ GrafoscopioGUI class >> messageNotImplementedYet [
title: 'No implementado aún'.
]
{ #category : #accessing }
GrafoscopioGUI class >> nodesClipboard [
^ nodesClipboard
]
{ #category : #accessing }
GrafoscopioGUI class >> nodesClipboard: anObject [
nodesClipboard := anObject
]
{ #category : #'graphical interface' }
GrafoscopioGUI class >> open [
^ self new open

View File

@ -246,6 +246,12 @@ GrafoscopioNode >> content: anObject [
body := anObject
]
{ #category : #'add/remove nodes' }
GrafoscopioNode >> copyToClipboard [
GrafoscopioGUI nodesClipboard: self copy.
]
{ #category : #movement }
GrafoscopioNode >> demote [
"Moves the current node down in the hierachy, making a children of its current previous slibing"
@ -368,9 +374,10 @@ GrafoscopioNode >> initialize [
"Creates a empty new node"
super initialize.
self header: 'newHeader'.
self body: ''.
self key: ''
self
header: 'newHeader';
body: '';
level: 0
]
{ #category : #accessing }
@ -532,6 +539,14 @@ GrafoscopioNode >> parent: aNode [
parent := aNode
]
{ #category : #'add/remove nodes' }
GrafoscopioNode >> pasteFromClipboard [
GrafoscopioGUI nodesClipboard
ifNotNil: [ self addNode: GrafoscopioGUI nodesClipboard ]
ifNil: [ self inform: 'Cache is emtpy. Pleas cut/copy a node before pasting' ]
]
{ #category : #exporting }
GrafoscopioNode >> preorderTraversal [
nodesInPreorder := OrderedCollection new.