From 454c5826298c46b47512ff597ffe4c3aa0e68450 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 7 Jan 2015 13:24:02 +0000 Subject: [PATCH] Initial support for named windows. --- .../Grafoscopio/GrafoscopioBrowser.class.st | 54 +++++++++++++++++-- .../Grafoscopio/GrafoscopioNode.class.st | 28 +++++----- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioBrowser.class.st b/repository/Grafoscopio/GrafoscopioBrowser.class.st index 2e24506..171aa65 100644 --- a/repository/Grafoscopio/GrafoscopioBrowser.class.st +++ b/repository/Grafoscopio/GrafoscopioBrowser.class.st @@ -93,8 +93,9 @@ GrafoscopioBrowser >> bodyOn: constructor [ GrafoscopioBrowser >> buildBrowser [ "Main method for building the interface for trees and its nodes" + browser := GLMTabulator new - title: 'Grafoscopio'. + title: ' | Grafoscopio'. browser column: [:c | @@ -249,6 +250,50 @@ browser ] +{ #category : #'graphical interface' } +GrafoscopioBrowser >> buildBrowserNamed: aName [ +"Main method for building the interface for trees and its nodes" + + +browser := GLMTabulator new + title: aName, ' | Grafoscopio'. + +browser + column: [:c | + c row: #tree span: 6; + row: #nodeHeader span: 1] span: 2; + column: [ :c | + c row: #nodeBody span: 2] span: 5. +browser + updateOn: GLMItemAdded from: #yourself; + updateOn: GLMItemRemoved from: #yourself. + +(browser transmit) + to: #tree; + andShow: [:a | self treeOn: a]. +"Creating a self updatable body pane" +(browser transmit) + to: #nodeBody; + from: #tree; + andShow: [ :a | self bodyOn: a]. +(browser transmit ) + from: #tree port: #selection; + from: #nodeBody port: #text; + when: [:node :text | text notNil]; + to: #nodeBody port: #neverland; + transformed: [:node :text | node body: text asString]. +(browser transmit) + from: #tree; + to: #nodeHeader; + andShow: [ :h | self headerOn: h ]. +(browser transmit ) + from: #tree port: #selection; + from: #nodeHeader port: #text; + when: [:node :text | text notNil]; + to: #nodeHeader port: #neverland1; + transformed: [:node :text | node header: text asString] +] + { #category : #'graphical interface' } GrafoscopioBrowser >> buildBrowserTransmediaton [ "Main method for building the interface for trees and its nodes" @@ -455,12 +500,12 @@ GrafoscopioBrowser >> open [ This is changed when the file is saved with the 'Save as' menu option" | draftsLocation | "self configureSettings." - self buildBrowser. mainTree := GrafoscopioNode new. mainTree becomeDefaultTree. draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'. draftsLocation ensureCreateDirectory. workingFile := draftsLocation / 'draft.ston'. + self buildBrowserNamed: workingFile basenameWithIndicator. browser openOn: mainTree children. ] @@ -482,7 +527,6 @@ GrafoscopioBrowser >> openFromFile [ | fileStream currentChildren | self configureSettings. - self buildBrowser. fileStream := UITheme builder fileOpen: 'Elija un archivo .ston' extensions: #('ston'). @@ -490,11 +534,12 @@ GrafoscopioBrowser >> openFromFile [ fileStream isNil ifTrue: [ ^nil ]. workingFile := fileStream name asFileReference. currentChildren := (STON fromStream: fileStream). + self buildBrowserNamed: workingFile basenameWithIndicator. mainTree := GrafoscopioNode new header: 'Arbol principal'; level: 0. mainTree children: currentChildren. - browser openOn: mainTree children. + browser openOn: mainTree children. ] { #category : #persistence } @@ -886,6 +931,7 @@ GrafoscopioBrowser >> treeOn: constructor [ entitled: 'Save current tree'; "Menu options" + act: [ GrafoscopioBrowser open] entitled: 'Arbol > Nuevo ...'; act: [ GrafoscopioBrowser new openFromFile] entitled: 'Arbol > Abrir/Cargar ...'; act: [self saveToFile] entitled: 'Arbol > Guardar como ...'; act: [self exportAsHtml] entitled: 'Arbol > Exportar como html'; diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index f942f6a..2e1a9f6 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -128,27 +128,15 @@ GrafoscopioNode >> asSton [ { #category : #initialization } GrafoscopioNode >> becomeDefaultTree [ - | node1 node2 node3 | + | node1 | self level: 0. self header: 'Arbol principal'. node1 := GrafoscopioNode header: 'Nodo 1' body: 'Texto 1'. - - node2 := GrafoscopioNode - header: 'Nodo 2' - body: 'Texto 2'. - - node3 := GrafoscopioNode - header: 'Nodo 3' - body: 'Texto 3'. self - addNode: node1; - addNode: node2. - - node2 addNode: node3. - + addNode: node1. ] { #category : #accessing } @@ -292,7 +280,17 @@ GrafoscopioNode >> markdownContent [ markdown nextPutAll: (self header copyReplaceTokens: #cr with: #lf); crlf; crlf. embedNodes := self children select: [:each | ((each header findTokens: $ ) at: 1) = '%embed']. temporalBody := self body. - embedNodes ifNotNil: [ embedNodes do: [ :each | temporalBody := temporalBody copyReplaceAll: (each header) with: each body]]. + embedNodes ifNotNil: [ + (temporalBody includesSubstring: '%embed-all') + ifFalse: [embedNodes do: [ :each | temporalBody := temporalBody copyReplaceAll: (each header) with: each body]] + ifTrue: [ + embedNodes do: + [ :each | temporalBody := temporalBody copyReplaceAll: '%embed-all' with: (each body, + (String with: Character cr), + '%embed-all')]. + temporalBody := temporalBody copyReplaceAll: '%embed-all' with: '' + ] + ]. markdown nextPutAll: (temporalBody contents withInternetLineEndings ); crlf; crlf]. (self header = '%config')