From 61940a3c4d59cee3b7448dd4f5421ce7173058df Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 28 Jul 2016 11:26:03 +0000 Subject: [PATCH] New GUI: Basic outlining implemented for promote/demote & before/after operations. Next, proper saving of body (text first, then code). --- .../Grafoscopio/GrafoscopioNotebook.class.st | 59 ++++++++++++++----- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index b4b1482..7834c88 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -67,22 +67,31 @@ GrafoscopioNotebook >> body: anObject [ ] { #category : #operation } -GrafoscopioNotebook >> changeBody: aNodeCollection [ - | node | - node := aNodeCollection first. +GrafoscopioNotebook >> changeBody: aNode [ self needRebuild: false. tree needRebuild: false. - body := self instantiate: node specModelClass new. - body content: node content. - body needRebuild: true. - body body whenTextChanged: [ :arg | node body: arg ]. - header text: node header. - + body := self instantiate: aNode specModelClass new. + body content: aNode content. + body body class = TextModel + ifTrue: [ + body body whenTextChanged: [ :arg | aNode body: arg ]]. + header text: aNode header. + body needRebuild: true. self buildWithSpecLayout: self class defaultSpec. ] +{ #category : #operation } +GrafoscopioNotebook >> demoteNode [ + | currentNode | + currentNode := tree selectedItem content. + currentNode demote. + tree needRebuild: true. + tree roots: tree roots. + self buildWithSpecLayout: self class defaultSpec. +] + { #category : #persistence } GrafoscopioNotebook >> exportAsSton: aNotebook on: aFileStream [ | stonPrettyString | @@ -115,16 +124,12 @@ GrafoscopioNotebook >> header: anObject [ GrafoscopioNotebook >> initializePresenter [ tree whenSelectedItemsChanged: [ :arg | - arg isEmpty ifFalse: [self changeBody: arg ]]. + arg isEmpty ifFalse: [self changeBody: tree selectedItem content ]]. header whenTextChanged: [ :arg | - Transcript show: arg. (tree selectedItem content header) = arg ifFalse: [ (tree selectedItem) content header: arg. - tree roots: tree roots]]. - body whenTextChanged: [:arg | - Transcript show: arg - ] + tree roots: tree roots]] ] { #category : #initialization } @@ -147,9 +152,21 @@ GrafoscopioNotebook >> initializeWidgets [ add: body. ] +{ #category : #operation } +GrafoscopioNotebook >> moveNodeAfter [ + | currentNode | + currentNode := tree selectedItem content. + currentNode moveAfter. + tree needRebuild: true. + tree roots: tree roots. + self buildWithSpecLayout: self class defaultSpec. +] + { #category : #operation } GrafoscopioNotebook >> moveNodeBefore [ - tree selectedItem content moveAfter. + | currentNode | + currentNode := tree selectedItem content. + currentNode moveBefore. tree needRebuild: true. tree roots: tree roots. self buildWithSpecLayout: self class defaultSpec. @@ -419,6 +436,16 @@ GrafoscopioNotebook >> projectSubMenu [ ] +{ #category : #operation } +GrafoscopioNotebook >> promoteNode [ + | currentNode | + currentNode := tree selectedItem content. + currentNode promote. + tree needRebuild: true. + tree roots: tree roots. + self buildWithSpecLayout: self class defaultSpec. +] + { #category : #operation } GrafoscopioNotebook >> removeNode [ | currentNode |