From 990ff595b156b80b41bff787d7fbfbad46aee99b Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 16 Jan 2015 15:57:44 +0000 Subject: [PATCH] Just before testing pager as a way to make custom visualization of nodes instead of opening a new file in a new mode. This save us from reloading the file, gives more flexibility and inmediate feedback according to the kind of node (as marked by tags ) we're located on. --- .../Grafoscopio/GrafoscopioBrowser.class.st | 10 ++++--- .../Grafoscopio/GrafoscopioNode.class.st | 30 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioBrowser.class.st b/repository/Grafoscopio/GrafoscopioBrowser.class.st index d67bd64..6898711 100644 --- a/repository/Grafoscopio/GrafoscopioBrowser.class.st +++ b/repository/Grafoscopio/GrafoscopioBrowser.class.st @@ -609,7 +609,7 @@ GrafoscopioBrowser >> panelBrowserForTransmediaton [ Opens grafoscopio in several 'modes'. Each mode corresponds to a operation way, with an specific interface. We will start with a 'transmediaton' mode to let the people create some transmedia content. After that we will enable other modes" - | transmediaNode | + | transmediaNode originalNode | browser := GLMTabulator new. browser @@ -624,9 +624,11 @@ GrafoscopioBrowser >> panelBrowserForTransmediaton [ format:[:eachNode | (eachNode tags) = 'original' ifFalse: [ '' ] - ifTrue: [ - transmediaNode := eachNode children detect: [:node | node tags = 'transmediado']. - eachNode body]]]. + ifTrue: [ + originalNode := eachNode. + originalNode children isNotNil + ifTrue: [transmediaNode := originalNode children detect: [:node | node tags = 'transmediado'] ifNone: [ transmediaNode := nil ] ]. + originalNode body]]]. (browser transmit) from: #original; toOutsidePort: #text. diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index ce85255..6812e55 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -82,6 +82,23 @@ GrafoscopioNode >> addNodeAfter [ ] +{ #category : #accessing } +GrafoscopioNode >> ancestors [ + "Returns a collection of all the nodes wich are ancestors of the receiver node" + | currentNode ancestors | + + currentNode := self. + ancestors := OrderedCollection new. + (self level - 1) + timesRepeat: [ + ancestors add: currentNode parent. + currentNode := currentNode parent.]. + ancestors := ancestors reversed. + ^ ancestors + + +] + { #category : #accessing } GrafoscopioNode >> ancestorsHeaders [ "Returns the headers of all the ancestors of the node. Maybe this and 'headers' should be integrated, so both act on a collection of @@ -108,7 +125,7 @@ GrafoscopioNode >> asMarkdown [ markdownOutput := '' writeStream. (self preorderTraversal) do: [ :eachNode | (eachNode level > 0) & (eachNode header notNil) ifTrue: [ - (eachNode hasAncestorWith: '%invisible') not + (eachNode hasAncestorHeaderWith: '%invisible') not ifTrue: [ markdownOutput nextPutAll: (eachNode markdownContent) ]]]. ^markdownOutput contents @@ -184,12 +201,21 @@ GrafoscopioNode >> demote [ ] { #category : #exporting } -GrafoscopioNode >> hasAncestorWith: aSpecialWord [ +GrafoscopioNode >> hasAncestorHeaderWith: aSpecialWord [ "Looks if the receptor node has an ancestor with a header with 'aSpecialWord' as the only or the first word" ^ (self ancestorsHeaders includes: aSpecialWord) | ((self ancestorsHeaders collect: [:eachHeader | (eachHeader findTokens: $ ) at: 1 ]) includes: aSpecialWord) +] + +{ #category : #exporting } +GrafoscopioNode >> hasAncestorTaggedAs: aSpecialWord [ + "Looks if the receptor node has an ancestor with a header with 'aSpecialWord' as the only or the first word" + + ^ self ancestors detect: [:eachAncestor | eachAncestor tags = aSpecialWord ] + + ] { #category : #accessing }