Cut, copy & paste debugged. Long needed feature finally implemented.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-12-18 14:33:00 +00:00 committed by SantiagoBragagnolo
parent 4b9309bf1a
commit cba173f6a7
4 changed files with 67 additions and 22 deletions

View File

@ -21,8 +21,7 @@ Class {
],
#classInstVars : [
'dockingBar',
'recentNotebooks',
'nodesClipboard'
'recentNotebooks'
],
#category : #'Grafoscopio-UI'
}
@ -379,16 +378,6 @@ 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

@ -23,12 +23,37 @@ Class {
'node',
'level',
'nodesInPreorder',
'cacheNode',
'metadata'
],
#classInstVars : [
'clipboard'
],
#category : #'Grafoscopio-Model'
}
{ #category : #utility }
GrafoscopioNode class >> cleanTreeRootReferences [
| ref |
clipboard ifNil: [ ^ self ].
clipboard children ifNil: [ ^ self ].
clipboard preorderTraversal allButFirstDo: [ :n |
ref := n.
n level - 1 timesRepeat: [ ref := ref parent ].
ref parent: nil
]
]
{ #category : #accessing }
GrafoscopioNode class >> clipboard [
^ clipboard
]
{ #category : #accessing }
GrafoscopioNode class >> clipboard: anObject [
clipboard := anObject
]
{ #category : #'instance creation' }
GrafoscopioNode class >> header: aHeader body: aText [
"Create a new instance with given header and body"
@ -59,7 +84,7 @@ GrafoscopioNode class >> named: aString [
yourself
]
{ #category : #'as yet unclassified' }
{ #category : #utility }
GrafoscopioNode class >> specialWords [
"I return a list of word that were used in the first versions of grafoscopio to mark node
headers to indicate special ways to handle them and their node contents.
@ -248,8 +273,17 @@ GrafoscopioNode >> content: anObject [
{ #category : #'add/remove nodes' }
GrafoscopioNode >> copyToClipboard [
GrafoscopioGUI nodesClipboard: self copy.
self class clipboard: self copy.
self class cleanTreeRootReferences
]
{ #category : #utility }
GrafoscopioNode >> deleteReferencesToRoot: aRootNode [
| sparseTree |
sparseTree := self preorderTraversal.
]
{ #category : #movement }
@ -541,8 +575,8 @@ GrafoscopioNode >> parent: aNode [
{ #category : #'add/remove nodes' }
GrafoscopioNode >> pasteFromClipboard [
GrafoscopioGUI nodesClipboard
ifNotNil: [ self addNode: GrafoscopioGUI nodesClipboard ]
self class clipboard
ifNotNil: [ self addNode: self class clipboard ]
ifNil: [ self inform: 'Cache is emtpy. Pleas cut/copy a node before pasting' ]
]

View File

@ -81,6 +81,17 @@ GrafoscopioNotebook >> body: anObject [
body := anObject
]
{ #category : #'editing nodes' }
GrafoscopioNotebook >> copyNodeToClipboard [
tree highlightedItem content copyToClipboard.
self notebookContent: notebook.
]
{ #category : #'editing nodes' }
GrafoscopioNotebook >> cutNodeToClipboard [
self copyNodeToClipboard; removeNode.
]
{ #category : #'editing nodes' }
GrafoscopioNotebook >> demoteNode [
| editedNode |
@ -205,19 +216,19 @@ GrafoscopioNotebook >> newWindowMainMenu [
name: nil;
description: 'Cut';
icon: Smalltalk ui icons smallCutIcon;
action: [ self inform: 'To be implemented...' ] ].
action: [ self cutNodeToClipboard ] ].
group addItem: [ :item |
item
name: nil;
description: 'Copy';
icon: Smalltalk ui icons smallCopyIcon;
action: [ self inform: 'To be implemented...' ] ].
action: [ self copyNodeToClipboard ] ].
group addItem: [ :item |
item
name: nil;
description: 'Paste';
icon: Smalltalk ui icons smallPasteIcon;
action: [ self inform: 'To be implemented...' ] ]];
action: [ self pasteNodeFromClipboard ] ]];
addGroup: [ :group |
group addItem: [ :item |
item
@ -425,6 +436,12 @@ GrafoscopioNotebook >> openTutorial [
ifFalse: [ GrafoscopioGUI updateDocumentationUI ]
]
{ #category : #'editing nodes' }
GrafoscopioNotebook >> pasteNodeFromClipboard [
tree highlightedItem content pasteFromClipboard.
self notebookContent: notebook.
]
{ #category : #initialization }
GrafoscopioNotebook >> projectSubMenu [

View File

@ -18,6 +18,11 @@ ManifestGrafoscopio class >> ruleRBEqualsTrueRuleV1FalsePositive [
]
{ #category : #'code-critics' }
ManifestGrafoscopio class >> ruleRBSentNotImplementedRuleV1FalsePositive [
^ #(#(#(#RGMetaclassDefinition #(#'GrafoscopioGUI class' #GrafoscopioGUI)) #'2015-12-23T10:38:16.706667-05:00') #(#(#RGClassDefinition #(#GrafoscopioGUI)) #'2016-01-06T18:53:45.844051-05:00') )
ManifestGrafoscopio class >> ruleRBLongMethodsRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#GrafoscopioNotebook #newWindowMainMenu #false)) #'2016-12-17T18:51:33.99062-05:00') )
]
{ #category : #'code-critics' }
ManifestGrafoscopio class >> ruleRBSentNotImplementedRuleV1FalsePositive [
^ #(#(#(#RGMetaclassDefinition #(#'GrafoscopioGUI class' #GrafoscopioGUI)) #'2015-12-23T10:38:16.706667-05:00') #(#(#RGClassDefinition #(#GrafoscopioGUI)) #'2016-01-06T18:53:45.844051-05:00') #(#(#RGMethodDefinition #(#GrafoscopioNotebook #newWindowMainMenu #false)) #'2016-12-17T18:51:40.617924-05:00') )
]