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

View File

@ -246,6 +246,12 @@ GrafoscopioNode >> content: anObject [
body := anObject body := anObject
] ]
{ #category : #'add/remove nodes' }
GrafoscopioNode >> copyToClipboard [
GrafoscopioGUI nodesClipboard: self copy.
]
{ #category : #movement } { #category : #movement }
GrafoscopioNode >> demote [ GrafoscopioNode >> demote [
"Moves the current node down in the hierachy, making a children of its current previous slibing" "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" "Creates a empty new node"
super initialize. super initialize.
self header: 'newHeader'. self
self body: ''. header: 'newHeader';
self key: '' body: '';
level: 0
] ]
{ #category : #accessing } { #category : #accessing }
@ -532,6 +539,14 @@ GrafoscopioNode >> parent: aNode [
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 } { #category : #exporting }
GrafoscopioNode >> preorderTraversal [ GrafoscopioNode >> preorderTraversal [
nodesInPreorder := OrderedCollection new. nodesInPreorder := OrderedCollection new.