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.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-12-19 12:50:07 +00:00 committed by SantiagoBragagnolo
parent cba173f6a7
commit b804779da6
2 changed files with 39 additions and 5 deletions

View File

@ -23,7 +23,8 @@ Class {
'node', 'node',
'level', 'level',
'nodesInPreorder', 'nodesInPreorder',
'metadata' 'metadata',
'links'
], ],
#classInstVars : [ #classInstVars : [
'clipboard' 'clipboard'
@ -384,8 +385,7 @@ GrafoscopioNode >> header: anObject [
{ #category : #accessing } { #category : #accessing }
GrafoscopioNode >> headers [ GrafoscopioNode >> headers [
"Returns the headers of the receiver children" "I returns the headers of the receiver children"
^ headers := self children collect: [:currentNode | currentNode header ] ^ headers := self children collect: [:currentNode | currentNode header ]
] ]
@ -433,6 +433,12 @@ GrafoscopioNode >> key: aUniqueKey [
key := aUniqueKey key := aUniqueKey
] ]
{ #category : #accessing }
GrafoscopioNode >> lastLink [
links ifNil: [ ^ '' ].
^ links last
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioNode >> level [ GrafoscopioNode >> level [
"Returns the level of the node. See the setter message for details" "Returns the level of the node. See the setter message for details"
@ -448,6 +454,17 @@ GrafoscopioNode >> level: anInteger [
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 } { #category : #exporting }
GrafoscopioNode >> margin [ GrafoscopioNode >> margin [
"I define the same margin of the page used for PDF exportations" "I define the same margin of the page used for PDF exportations"

View File

@ -15,6 +15,7 @@ Class {
'tree', 'tree',
'header', 'header',
'body', 'body',
'links',
'windowMainMenu', 'windowMainMenu',
'workingFile', 'workingFile',
'notebook' 'notebook'
@ -43,7 +44,7 @@ GrafoscopioNotebook class >> defaultSpec [
] width: 300. ] width: 300.
row newColumn: [ :bc | row newColumn: [ :bc |
bc newRow: [ :bcr | bcr add: #header ] height: self toolbarHeight. bc newRow: [ :bcr | bcr add: #header ] height: self toolbarHeight.
bc add: #body ]]] bc add: #body; add: #links height: self toolbarHeight ]]]
] ]
{ #category : #'editing nodes' } { #category : #'editing nodes' }
@ -155,6 +156,9 @@ GrafoscopioNotebook >> initializePresenter [
(tree highlightedItem) content header: arg. (tree highlightedItem) content header: arg.
tree roots: tree roots. tree roots: tree roots.
self updateForSpecialHeader]]. self updateForSpecialHeader]].
links whenTextChanged: [ :arg |
(tree highlightedItem content links) = arg
ifFalse: [ (tree highlightedItem) content links: arg]]
] ]
{ #category : #initialization } { #category : #initialization }
@ -164,6 +168,7 @@ GrafoscopioNotebook >> initializeWidgets [
body := self newText. body := self newText.
body disable. body disable.
body text: '<- Select a node'. body text: '<- Select a node'.
links := self newTextInput.
tree := TreeModel new. tree := TreeModel new.
tree tree
childrenBlock: [:node | node children]; childrenBlock: [:node | node children];
@ -171,7 +176,18 @@ GrafoscopioNotebook >> initializeWidgets [
self focusOrder self focusOrder
add: tree; add: tree;
add: header; add: header;
add: body. add: body;
add: links.
]
{ #category : #accessing }
GrafoscopioNotebook >> links [
^ links
]
{ #category : #accessing }
GrafoscopioNotebook >> links: anObject [
links := anObject
] ]
{ #category : #'editing nodes' } { #category : #'editing nodes' }
@ -575,6 +591,7 @@ GrafoscopioNotebook >> updateBodyFor: aNodeContainer [
header text: aNode header. header text: aNode header.
body := self instantiate: aNode specModelClass new. body := self instantiate: aNode specModelClass new.
body content: aNode body. body content: aNode body.
links text: aNode lastLink.
self autoSaveBodyOf: aNode. self autoSaveBodyOf: aNode.
self buildWithSpecLayout: self class defaultSpec self buildWithSpecLayout: self class defaultSpec
] ]