From b804779da60a08fce584561f528fcbd409c8863b Mon Sep 17 00:00:00 2001 From: OffrayLuna Date: Mon, 19 Dec 2016 12:50:07 +0000 Subject: [PATCH] Starting node links: this will allow to store web and local bookmarks and load content in the web browser, reload shared playgrounds, preview images and so on. Interesting possibilities. --- src/Grafoscopio/GrafoscopioNode.class.st | 23 +++++++++++++++++--- src/Grafoscopio/GrafoscopioNotebook.class.st | 21 ++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/Grafoscopio/GrafoscopioNode.class.st b/src/Grafoscopio/GrafoscopioNode.class.st index ddfa729..a5e3ad0 100644 --- a/src/Grafoscopio/GrafoscopioNode.class.st +++ b/src/Grafoscopio/GrafoscopioNode.class.st @@ -23,7 +23,8 @@ Class { 'node', 'level', 'nodesInPreorder', - 'metadata' + 'metadata', + 'links' ], #classInstVars : [ 'clipboard' @@ -384,8 +385,7 @@ GrafoscopioNode >> header: anObject [ { #category : #accessing } GrafoscopioNode >> headers [ - "Returns the headers of the receiver children" - + "I returns the headers of the receiver children" ^ headers := self children collect: [:currentNode | currentNode header ] ] @@ -433,6 +433,12 @@ GrafoscopioNode >> key: aUniqueKey [ key := aUniqueKey ] +{ #category : #accessing } +GrafoscopioNode >> lastLink [ + links ifNil: [ ^ '' ]. + ^ links last +] + { #category : #accessing } GrafoscopioNode >> level [ "Returns the level of the node. See the setter message for details" @@ -448,6 +454,17 @@ GrafoscopioNode >> level: anInteger [ level := anInteger ] +{ #category : #accessing } +GrafoscopioNode >> links [ + "I model local or remote links that are associated to a particular node." + ^ links ifNil: [ ^ links := OrderedCollection new ] +] + +{ #category : #accessing } +GrafoscopioNode >> links: anObject [ + links add: anObject +] + { #category : #exporting } GrafoscopioNode >> margin [ "I define the same margin of the page used for PDF exportations" diff --git a/src/Grafoscopio/GrafoscopioNotebook.class.st b/src/Grafoscopio/GrafoscopioNotebook.class.st index a8f7635..1627d41 100644 --- a/src/Grafoscopio/GrafoscopioNotebook.class.st +++ b/src/Grafoscopio/GrafoscopioNotebook.class.st @@ -15,6 +15,7 @@ Class { 'tree', 'header', 'body', + 'links', 'windowMainMenu', 'workingFile', 'notebook' @@ -43,7 +44,7 @@ GrafoscopioNotebook class >> defaultSpec [ ] width: 300. row newColumn: [ :bc | bc newRow: [ :bcr | bcr add: #header ] height: self toolbarHeight. - bc add: #body ]]] + bc add: #body; add: #links height: self toolbarHeight ]]] ] { #category : #'editing nodes' } @@ -155,6 +156,9 @@ GrafoscopioNotebook >> initializePresenter [ (tree highlightedItem) content header: arg. tree roots: tree roots. self updateForSpecialHeader]]. + links whenTextChanged: [ :arg | + (tree highlightedItem content links) = arg + ifFalse: [ (tree highlightedItem) content links: arg]] ] { #category : #initialization } @@ -164,6 +168,7 @@ GrafoscopioNotebook >> initializeWidgets [ body := self newText. body disable. body text: '<- Select a node'. + links := self newTextInput. tree := TreeModel new. tree childrenBlock: [:node | node children]; @@ -171,7 +176,18 @@ GrafoscopioNotebook >> initializeWidgets [ self focusOrder add: tree; add: header; - add: body. + add: body; + add: links. +] + +{ #category : #accessing } +GrafoscopioNotebook >> links [ + ^ links +] + +{ #category : #accessing } +GrafoscopioNotebook >> links: anObject [ + links := anObject ] { #category : #'editing nodes' } @@ -575,6 +591,7 @@ GrafoscopioNotebook >> updateBodyFor: aNodeContainer [ header text: aNode header. body := self instantiate: aNode specModelClass new. body content: aNode body. + links text: aNode lastLink. self autoSaveBodyOf: aNode. self buildWithSpecLayout: self class defaultSpec ]