Making notebook to work in pharo 8
This commit is contained in:
parent
bb9dda9eef
commit
4b59a7cd30
@ -120,6 +120,11 @@ GrafoscopioAbstractNode >> initialize [
|
||||
edited := DateAndTime now
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioAbstractNode >> isLeaf [
|
||||
^ true
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioAbstractNode >> level [
|
||||
"Returns the level of the node. See the setter message for details"
|
||||
@ -189,7 +194,7 @@ GrafoscopioAbstractNode >> shouldAskBeforeRemove [
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioAbstractNode >> specModelClass [
|
||||
^ GrafoscopioTextModel
|
||||
^ GrafoscopioNewTextModel
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -4,7 +4,7 @@ embedded interactive Playground.
|
||||
"
|
||||
Class {
|
||||
#name : #GrafoscopioCodeModel,
|
||||
#superclass : #SpPresenter,
|
||||
#superclass : #ComposablePresenter,
|
||||
#instVars : [
|
||||
'body'
|
||||
],
|
||||
|
@ -1,6 +1,6 @@
|
||||
Class {
|
||||
#name : #GrafoscopioCodeNode,
|
||||
#superclass : #GrafoscopioAbstractNode,
|
||||
#superclass : #GrafoscopioTrunkNode,
|
||||
#instVars : [
|
||||
'icon',
|
||||
'body'
|
||||
@ -35,5 +35,5 @@ GrafoscopioCodeNode >> shouldAskBeforeRemove [
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioCodeNode >> specModelClass [
|
||||
^ GrafoscopioCodeModel
|
||||
^ GrafoscopioNewCodeModel
|
||||
]
|
||||
|
62
repository/Grafoscopio/GrafoscopioNewCodeModel.class.st
Normal file
62
repository/Grafoscopio/GrafoscopioNewCodeModel.class.st
Normal file
@ -0,0 +1,62 @@
|
||||
Class {
|
||||
#name : #GrafoscopioNewCodeModel,
|
||||
#superclass : #SpPresenter,
|
||||
#instVars : [
|
||||
'body'
|
||||
],
|
||||
#category : 'Grafoscopio-New-UI'
|
||||
}
|
||||
|
||||
{ #category : #specs }
|
||||
GrafoscopioNewCodeModel class >> defaultSpec [
|
||||
^ SpBoxLayout newVertical
|
||||
add: #body;
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioNewCodeModel >> body [
|
||||
^ body
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioNewCodeModel >> body: anObject [
|
||||
body := anObject
|
||||
]
|
||||
|
||||
{ #category : #API }
|
||||
GrafoscopioNewCodeModel >> content: aGrafoscopioNodeContent [
|
||||
body text: aGrafoscopioNodeContent
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioNewCodeModel >> extractHtmlImages [
|
||||
"comment stating purpose of message"
|
||||
|imgSoup imgHost imgList src|
|
||||
|
||||
imgList := Set new.
|
||||
imgSoup := Soup fromString: self body.
|
||||
(imgSoup findAllTags: 'img') do: [ :each|
|
||||
src := (each attributeAt: 'src') asUrl.
|
||||
(src host) ifNil: [src host: self links last asUrl removeLastPathSegment].
|
||||
imgList add: src.
|
||||
"imgList add: (each attributeAt: 'src') asUrl."
|
||||
|
||||
"OSProcess waitForCommand: 'wget ', (each attributeAt: 'src')."
|
||||
"imgHost := self links last removeLastPathSegment."
|
||||
|
||||
"imgPath:= ((each attributeAt: 'src') asUrl). "
|
||||
"ZnEasy getJpeg: (imgHost , imgPath) asUrl."
|
||||
|
||||
"OSProcess waitForCommand: ('mkdir ', imgPath)."
|
||||
|
||||
"Transcript show: ' wget ', imgPath , '/',(each attributeAt: 'src'). "
|
||||
].
|
||||
^imgList .
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
GrafoscopioNewCodeModel >> initializeWidgets [
|
||||
|
||||
body := self newCode.
|
||||
]
|
@ -26,7 +26,7 @@ Class {
|
||||
#classInstVars : [
|
||||
'recents'
|
||||
],
|
||||
#category : 'Grafoscopio-UI'
|
||||
#category : 'Grafoscopio-New-UI'
|
||||
}
|
||||
|
||||
{ #category : #utility }
|
||||
@ -112,30 +112,6 @@ GrafoscopioNewNotebook >> askToSaveBeforeClosing [
|
||||
^ saveChanges
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
GrafoscopioNewNotebook >> autoSaveBodyOf: aNode [
|
||||
| playground bodyContents |
|
||||
bodyContents := aNode content.
|
||||
self body class = GrafoscopioTextModel
|
||||
ifTrue: [ self body body
|
||||
whenTextChangedDo: [ :arg |
|
||||
aNode content: arg.
|
||||
"self body body whenTextIsAccepted: [:bodyText |
|
||||
self inform: bodyText.
|
||||
aNode updateEditionTimestamp ]."
|
||||
bodyContents = arg
|
||||
ifFalse: [ "self inform: arg.""aNode updateEditionTimestamp" ] ] ].
|
||||
self body body class = GlamourPresentationModel
|
||||
ifFalse: [ ^ self ].
|
||||
playground := self body body glmPres.
|
||||
playground
|
||||
onChangeOfPort: #text
|
||||
act: [ :x |
|
||||
aNode content: (x pane port: #entity) value content
|
||||
"aNode updateEditionTimestamp."
|
||||
"self inform: aNode edited" ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioNewNotebook >> body [
|
||||
^ body
|
||||
@ -530,9 +506,13 @@ GrafoscopioNewNotebook >> initializePresenter [
|
||||
header
|
||||
whenTextChangedDo: [ :arg |
|
||||
tree selectedItem header = arg
|
||||
ifFalse: [ tree selectedItem header: arg.
|
||||
ifFalse: [
|
||||
| item |
|
||||
item := tree selectedItem.
|
||||
tree selectedItem header: arg.
|
||||
tree selectedItem updateEditionTimestamp.
|
||||
tree roots: tree roots ] ].
|
||||
tree roots: tree roots.
|
||||
tree selectItem:item ] ].
|
||||
links
|
||||
whenTextChangedDo: [ :arg |
|
||||
(tree respondsTo: #link:)
|
||||
@ -554,7 +534,10 @@ GrafoscopioNewNotebook >> initializeWidgets [
|
||||
tree := self newTreeTable.
|
||||
tree
|
||||
addColumn: (SpStringTableColumn evaluated: #title);
|
||||
children: [ : node | node children ].
|
||||
children: [ :node |
|
||||
node isLeaf
|
||||
ifTrue: [ {} ]
|
||||
ifFalse: [ node children ] ].
|
||||
" tree
|
||||
childrenBlock: [ :node | node children value ];
|
||||
displayBlock: [ :node | node title value ]."
|
||||
@ -1265,11 +1248,14 @@ GrafoscopioNewNotebook >> tree: anObject [
|
||||
|
||||
{ #category : #operation }
|
||||
GrafoscopioNewNotebook >> updateBodyFor: aNode [
|
||||
| item |
|
||||
self needRebuild: false.
|
||||
tree needRebuild: false.
|
||||
item := tree selectedItem.
|
||||
body needRebuild: true.
|
||||
aNode openIn: self.
|
||||
self buildWithSpec
|
||||
self buildWithSpec.
|
||||
tree selectItem: item.
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
|
37
repository/Grafoscopio/GrafoscopioNewTextModel.class.st
Normal file
37
repository/Grafoscopio/GrafoscopioNewTextModel.class.st
Normal file
@ -0,0 +1,37 @@
|
||||
Class {
|
||||
#name : #GrafoscopioNewTextModel,
|
||||
#superclass : #SpPresenter,
|
||||
#instVars : [
|
||||
'body'
|
||||
],
|
||||
#category : 'Grafoscopio-New-UI'
|
||||
}
|
||||
|
||||
{ #category : #specs }
|
||||
GrafoscopioNewTextModel class >> defaultSpec [
|
||||
^ SpBoxLayout newVertical
|
||||
add: #body;
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioNewTextModel >> body [
|
||||
^ body
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioNewTextModel >> body: anObject [
|
||||
body := anObject
|
||||
]
|
||||
|
||||
{ #category : #API }
|
||||
GrafoscopioNewTextModel >> content: aGrafoscopioNodeContent [
|
||||
body text: aGrafoscopioNodeContent
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
GrafoscopioNewTextModel >> initializeWidgets [
|
||||
|
||||
body := self newText.
|
||||
body autoAccept: true.
|
||||
]
|
@ -107,25 +107,24 @@ GrafoscopioNotebook >> askToSaveBeforeClosing [
|
||||
GrafoscopioNotebook >> autoSaveBodyOf: aNode [
|
||||
| playground bodyContents |
|
||||
bodyContents := aNode body.
|
||||
self body class = GrafoscopioTextModel
|
||||
ifTrue: [ self body body whenTextChanged: [ :arg |
|
||||
aNode body: arg.
|
||||
"self body body whenTextIsAccepted: [:bodyText |
|
||||
self body class = GrafoscopioTextModel
|
||||
ifTrue: [ self body body
|
||||
whenTextChangedDo: [ :arg |
|
||||
aNode body: arg.
|
||||
"self body body whenTextIsAccepted: [:bodyText |
|
||||
self inform: bodyText.
|
||||
aNode updateEditionTimestamp ]."
|
||||
bodyContents = arg ifFalse: [
|
||||
"self inform: arg."
|
||||
"aNode updateEditionTimestamp" ]]].
|
||||
bodyContents = arg
|
||||
ifFalse: [ "self inform: arg.""aNode updateEditionTimestamp" ] ] ].
|
||||
self body body class = GlamourPresentationModel
|
||||
ifFalse: [ ^ self ].
|
||||
playground := self body body glmPres.
|
||||
playground
|
||||
onChangeOfPort: #text
|
||||
act: [ :x |
|
||||
aNode body: (x pane port: #entity) value content.
|
||||
aNode body: (x pane port: #entity) value content
|
||||
"aNode updateEditionTimestamp."
|
||||
"self inform: aNode edited" ]
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -521,21 +520,21 @@ GrafoscopioNotebook >> initializeWidgets [
|
||||
header := self newTextInput.
|
||||
header autoAccept: true.
|
||||
body := self newText.
|
||||
body class logCr.
|
||||
body class traceCr.
|
||||
body disable.
|
||||
body text: '<- Select a node'.
|
||||
body autoAccept: true.
|
||||
links := self newTextInput.
|
||||
tree := self newTree.
|
||||
tree
|
||||
childrenBlock: [:node | node children];
|
||||
displayBlock: [:node | node title ].
|
||||
self focusOrder
|
||||
tree
|
||||
childrenBlock: [ :node | node children ];
|
||||
displayBlock: [ :node | node title ].
|
||||
self focusOrder
|
||||
add: tree;
|
||||
add: header;
|
||||
add: body;
|
||||
add: links.
|
||||
self askOkToClose: true.
|
||||
self askOkToClose: true
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
@ -1207,7 +1206,7 @@ GrafoscopioNotebook >> updateBodyFor: aNodeContainer [
|
||||
body := self instantiate: aNode specModelClass new.
|
||||
body content: aNode body.
|
||||
links text: aNode lastLink.
|
||||
self autoSaveBodyOf: aNode.
|
||||
|
||||
self buildWithSpecLayout: self class defaultSpec
|
||||
]
|
||||
|
||||
|
@ -4,7 +4,7 @@ Usually my content is markdown text.
|
||||
"
|
||||
Class {
|
||||
#name : #GrafoscopioTextModel,
|
||||
#superclass : #SpPresenter,
|
||||
#superclass : #ComposablePresenter,
|
||||
#instVars : [
|
||||
'body'
|
||||
],
|
||||
|
@ -10,12 +10,11 @@ node
|
||||
"
|
||||
Class {
|
||||
#name : #GrafoscopioTextNode,
|
||||
#superclass : #GrafoscopioAbstractNode,
|
||||
#superclass : #GrafoscopioTrunkNode,
|
||||
#instVars : [
|
||||
'key',
|
||||
'icon',
|
||||
'body',
|
||||
'children',
|
||||
'links'
|
||||
],
|
||||
#classInstVars : [
|
||||
@ -257,21 +256,6 @@ GrafoscopioTextNode >> checksumForRootSubtree [
|
||||
"^ (SHA1 new hashMessage: self root flatten asStonFromRoot) hex"
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioTextNode >> children [
|
||||
"Returns the receivers list of children"
|
||||
|
||||
^ children ifNil: [ children := OrderedCollection new ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioTextNode >> children: aCollection [
|
||||
"Sets the receivers children"
|
||||
|
||||
aCollection do: [:currentNode | currentNode parent: self ].
|
||||
children := aCollection.
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioTextNode >> content [
|
||||
^ body
|
||||
@ -730,27 +714,9 @@ GrafoscopioTextNode >> metadataAsYamlIn: markdownStream [
|
||||
nextPutAll: String cr, String cr.
|
||||
]
|
||||
|
||||
{ #category : #movement }
|
||||
GrafoscopioTextNode >> moveDown: aNode [
|
||||
| index |
|
||||
"Moves the current node a place before in the children collection where is located"
|
||||
index := (children indexOf: aNode) max: 1 .
|
||||
|
||||
children swap: index with: (index + 1 min: children size)
|
||||
]
|
||||
|
||||
{ #category : #movement }
|
||||
GrafoscopioTextNode >> moveUp: aNode [
|
||||
| index |
|
||||
"Moves the current node a place before in the children collection where is located"
|
||||
index := children indexOf: aNode.
|
||||
children swap: index with: (index - 1 max: 1)
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioTextNode >> openIn: aNotebook [
|
||||
super openIn: aNotebook.
|
||||
aNotebook autoSaveBodyOf: self.
|
||||
aNotebook links text: self lastLink
|
||||
]
|
||||
|
||||
@ -898,7 +864,7 @@ GrafoscopioTextNode >> shouldAskBeforeRemove [
|
||||
GrafoscopioTextNode >> specModelClass [
|
||||
"por defecto"
|
||||
|
||||
^ GrafoscopioTextModel
|
||||
^ GrafoscopioNewTextModel
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
|
45
repository/Grafoscopio/GrafoscopioTrunkNode.class.st
Normal file
45
repository/Grafoscopio/GrafoscopioTrunkNode.class.st
Normal file
@ -0,0 +1,45 @@
|
||||
Class {
|
||||
#name : #GrafoscopioTrunkNode,
|
||||
#superclass : #GrafoscopioAbstractNode,
|
||||
#instVars : [
|
||||
'children'
|
||||
],
|
||||
#category : 'Grafoscopio-Model'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioTrunkNode >> children [
|
||||
"Returns the receivers list of children"
|
||||
|
||||
^ children ifNil: [ children := OrderedCollection new ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioTrunkNode >> children: aCollection [
|
||||
"Sets the receivers children"
|
||||
|
||||
aCollection do: [:currentNode | currentNode parent: self ].
|
||||
children := aCollection.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GrafoscopioTrunkNode >> isLeaf [
|
||||
^ false
|
||||
]
|
||||
|
||||
{ #category : #movement }
|
||||
GrafoscopioTrunkNode >> moveDown: aNode [
|
||||
| index |
|
||||
"Moves the current node a place before in the children collection where is located"
|
||||
index := (children indexOf: aNode) max: 1 .
|
||||
|
||||
children swap: index with: (index + 1 min: children size)
|
||||
]
|
||||
|
||||
{ #category : #movement }
|
||||
GrafoscopioTrunkNode >> moveUp: aNode [
|
||||
| index |
|
||||
"Moves the current node a place before in the children collection where is located"
|
||||
index := children indexOf: aNode.
|
||||
children swap: index with: (index - 1 max: 1)
|
||||
]
|
@ -7,6 +7,13 @@ Class {
|
||||
#category : 'Grafoscopio-Model'
|
||||
}
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
GrafoscopioUrlNode class >> new [
|
||||
^ super new
|
||||
content;
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioUrlNode >> content [
|
||||
^ (self url
|
||||
|
Loading…
Reference in New Issue
Block a user