From 25bcbdbb17cafded8275924ad58540650dbd2ccb Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 6 Feb 2015 20:03:36 +0000 Subject: [PATCH] Embeddable playgrounds as node "executable visualizations" finally! :-). **Pending | Bug**: Storing properly the playground contents because when the node is revisited, they become nill. --- .../Grafoscopio/GrafoscopioBrowser.class.st | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioBrowser.class.st b/repository/Grafoscopio/GrafoscopioBrowser.class.st index fd44f36..353ce8b 100644 --- a/repository/Grafoscopio/GrafoscopioBrowser.class.st +++ b/repository/Grafoscopio/GrafoscopioBrowser.class.st @@ -85,6 +85,17 @@ GrafoscopioBrowser >> addToTagsAvailable [ ] +{ #category : #'graphical interface' } +GrafoscopioBrowser >> body2ForCodeIn: constructor for: aNode [ + "Shows the body of a selected node as executable code." + + aNode tags = 'código' + ifFalse: [ ^self ] + ifTrue: [constructor custom: (self panelAsCodeFor: aNode)]. + + +] + { #category : #'graphical interface' } GrafoscopioBrowser >> bodyForCodeIn: constructor for: aNode [ "Shows the body of a selected node as executable code." @@ -122,10 +133,9 @@ GrafoscopioBrowser >> bodyForCodeOn: constructor [ GrafoscopioBrowser >> bodyForTransmediaIn: constructor for: aNode [ "Shows the body of a transmedia type of nodes, which are tagged as 'original' and 'transmediado'" - aNode tags notNil - ifTrue: [aNode tags = 'original' - ifFalse: [^self ] - ifTrue: [constructor custom: (self panelTransmediaFor: aNode)]] + aNode tags = 'original' + ifFalse: [^self ] + ifTrue: [constructor custom: (self panelTransmediaFor: aNode)] ] @@ -248,13 +258,13 @@ browser andShow: [:a | self treeOn: a]. "Creating a self updatable body pane" (browser transmit) - from: #tree port: #selection; - to: #nodeBody; - andShow: [ :a :node | + from: #tree port: #selection; + to: #nodeBody; + when: [:selection | selection notNil]; + andShow: [ :a :node | self bodyIn: a for: node. - self bodyForCodeIn: a for: node. - self bodyForTransmediaIn: a for: node ]; - when: [:selection | selection notNil]. + self body2ForCodeIn: a for: node. + self bodyForTransmediaIn: a for: node ]. (browser transmit ) from: #tree port: #selection; from: #nodeBody port: #text; @@ -268,8 +278,8 @@ browser (browser transmit ) from: #tree port: #selection; from: #nodeHeader port: #text; - when: [:node :text | text notNil & node notNil]; to: #nodeHeader port: #neverland1; + when: [:node :text | text notNil & node notNil]; transformed: [:node :text | node header: text asString] ] @@ -669,6 +679,29 @@ GrafoscopioBrowser >> openWorking [ ] +{ #category : #'graphical interface' } +GrafoscopioBrowser >> panelAsCodeFor: aNode [ + "Shows an interactive playground for Smalltalk code in a node body" + +" browser := GLMTabulator new. + browser title: 'Playground'. + browser row: #code. + browser transmit + to: #code; + transformed: [GTPlayPage new content: aNode body]; + andShow: [ :a | a custom GTPlayground new ]. + ^ browser." + +browser := GLMTabulator new. +browser title: 'Código'. +browser column: #code. +browser transmit + to: #code; + transformed: [ GTPlayPage new content: aNode body ]; + andShow: [ :a | a custom: GTPlayground new ]. +^ browser. +] + { #category : #'graphical interface' } GrafoscopioBrowser >> panelBrowserForTransmediaton [ "**Experimental feature.**