Some usability. the new version sucks

This commit is contained in:
Santiago Bragagnolo 2020-02-24 14:33:31 +00:00 committed by Offray Luna
parent 7ddcb2d0bc
commit 4f251b08c5
7 changed files with 157 additions and 67 deletions

View File

@ -9,9 +9,63 @@ Class {
'parent', 'parent',
'tags' 'tags'
], ],
#classInstVars : [
'clipboard'
],
#category : 'Grafoscopio-Model' #category : 'Grafoscopio-Model'
} }
{ #category : #utility }
GrafoscopioAbstractNode class >> cleanTreeRootReferences [
| ref |
clipboard ifNil: [ ^ self ].
clipboard children ifNil: [ ^ self ].
clipboard preorderTraversal allButFirstDo: [ :n |
ref := n.
n level - 1 timesRepeat: [ ref := ref parent ].
ref parent = clipboard parent ifTrue: [ ref parent: nil ]].
clipboard parent: nil.
]
{ #category : #accessing }
GrafoscopioAbstractNode class >> clipboard [
^ clipboard
]
{ #category : #accessing }
GrafoscopioAbstractNode class >> clipboard: anObject [
clipboard := anObject
]
{ #category : #utility }
GrafoscopioAbstractNode class >> contentProviders [
"I list the domains of certain providers that are treated specially, because they
store and offer content like Smalltalk playgrounds or source code, that can be used
in particular ways while importing or exporting content in a node."
^ Dictionary new
at: 'playgrounds' put: #('ws.stfx.eu');
at: 'fossil' put: #('mutabit.com/repos.fossil');
at: 'etherpads' put: #('pad.tupale.co' );
yourself.
]
{ #category : #testing }
GrafoscopioAbstractNode class >> isAbstract [
^ self = GrafoscopioAbstractNode
]
{ #category : #utility }
GrafoscopioAbstractNode class >> specialWords [
"I return a list of word that were used in the first versions of Grafoscopio to mark node
headers to indicate special ways to handle them and their node contents.
Previous versions of first notebooks stored in Grafoscopio using this convention should be
migrated to newer versions where tags are used for the same function with simpler code"
^ #('%config' '%abstract' '%invisible' '%idea' '%footnote' '%metadata' '%output' '%embed' '%item').
]
{ #category : #'add/remove nodes' } { #category : #'add/remove nodes' }
GrafoscopioAbstractNode >> addNodeAfterMe: genericNode [ GrafoscopioAbstractNode >> addNodeAfterMe: genericNode [
"Adds a generic node after the given node so they become slibings of the same parent" "Adds a generic node after the given node so they become slibings of the same parent"
@ -120,6 +174,14 @@ GrafoscopioAbstractNode >> initialize [
edited := DateAndTime now edited := DateAndTime now
] ]
{ #category : #accessing }
GrafoscopioAbstractNode >> instantiateBody [
| body |
body := self specModelClass new.
body content: self content.
^ body
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioAbstractNode >> isLeaf [ GrafoscopioAbstractNode >> isLeaf [
^ true ^ true
@ -149,8 +211,11 @@ GrafoscopioAbstractNode >> moveUp [
{ #category : #accessing } { #category : #accessing }
GrafoscopioAbstractNode >> openIn: aNotebook [ GrafoscopioAbstractNode >> openIn: aNotebook [
aNotebook header text: self header. aNotebook header text: self header.
aNotebook body: (aNotebook instantiate: self specModelClass new). aNotebook
aNotebook body content: self content body:
(self instantiateBody
owner: aNotebook;
yourself)
] ]
{ #category : #accessing } { #category : #accessing }

View File

@ -8,6 +8,11 @@ Class {
#category : 'Grafoscopio-Model' #category : 'Grafoscopio-Model'
} }
{ #category : #'as yet unclassified' }
GrafoscopioCodeNode class >> nameForSelection [
^ 'New Code Node'
]
{ #category : #adding } { #category : #adding }
GrafoscopioCodeNode >> addNode: aNode [ GrafoscopioCodeNode >> addNode: aNode [
"Adds the given node to the receivers collection of children, and sets this object as the parent "Adds the given node to the receivers collection of children, and sets this object as the parent
@ -18,6 +23,16 @@ GrafoscopioCodeNode >> addNode: aNode [
^aNode ^aNode
] ]
{ #category : #'as yet unclassified' }
GrafoscopioCodeNode >> body [
^ body
]
{ #category : #'as yet unclassified' }
GrafoscopioCodeNode >> body: aBody [
body := aBody
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioCodeNode >> content [ GrafoscopioCodeNode >> content [
^ body ifNil:[ '' ] ^ body ifNil:[ '' ]
@ -28,6 +43,14 @@ GrafoscopioCodeNode >> header [
^ super header, ' (Code)' ^ super header, ' (Code)'
] ]
{ #category : #'as yet unclassified' }
GrafoscopioCodeNode >> instantiateBody [
| widget |
widget := super instantiateBody.
widget body whenTextChangedDo: [ :arg | self body: arg ].
^ widget
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioCodeNode >> shouldAskBeforeRemove [ GrafoscopioCodeNode >> shouldAskBeforeRemove [
^ self content isNotEmpty ^ self content isNotEmpty

View File

@ -58,7 +58,7 @@ GrafoscopioNewNotebook class >> defaultSpec [
{ #category : #'instance creation' } { #category : #'instance creation' }
GrafoscopioNewNotebook class >> kindsOfNode [ GrafoscopioNewNotebook class >> kindsOfNode [
^ GrafoscopioAbstractNode allSubclasses ^ GrafoscopioAbstractNode allSubclasses select: [ : c | c isAbstract not ]
] ]
{ #category : #'instance creation' } { #category : #'instance creation' }
@ -91,13 +91,16 @@ GrafoscopioNewNotebook >> addCommandFrom: dictionary into: stream [
{ #category : #'editing nodes' } { #category : #'editing nodes' }
GrafoscopioNewNotebook >> addNode [ GrafoscopioNewNotebook >> addNode [
| newNode kind | | newNode kind previousPath |
kind := self chooseKindOfNode. kind := self chooseKindOfNode.
kind isClass kind isClass
ifTrue: [ newNode := kind new. ifTrue: [ newNode := kind new.
self currentNode addNodeAfterMe: newNode. self currentNode addNodeAfterMe: newNode.
previousPath := tree selection selectedPath.
self notebookContent: notebook. self notebookContent: notebook.
self selectedItem: newNode ]
self selectedPathNextTo: previousPath ]
] ]
{ #category : #persistence } { #category : #persistence }
@ -137,7 +140,7 @@ GrafoscopioNewNotebook >> chooseKindOfNode [
| idx values | | idx values |
values := self kindsOfNode. values := self kindsOfNode.
idx := UIManager default idx := UIManager default
chooseFrom: values chooseFrom: (values collect: [ :v | v nameForSelection ])
lines: {} lines: {}
title: 'What kind of node? '. title: 'What kind of node? '.
^ idx = 0 ^ idx = 0
@ -501,18 +504,17 @@ GrafoscopioNewNotebook >> initialize [
{ #category : #initialization } { #category : #initialization }
GrafoscopioNewNotebook >> initializePresenter [ GrafoscopioNewNotebook >> initializePresenter [
tree tree
whenActivatedDo: whenSelectionChangedDo:
[ :selection | selection ifNotNil: [ self updateBodyFor: selection selectedItem ] ]. [ :selection | selection selectedItem ifNotNil: [ self updateBodyFor: selection selectedItem ] ].
header header
whenTextChangedDo: [ :arg | whenTextChangedDo: [ :arg |
tree selectedItem header = arg tree selectedItem header = arg
ifFalse: [ ifFalse: [ | item |
| item | item := tree selectedItem.
item := tree selectedItem. tree selectedItem header: arg.
tree selectedItem header: arg.
tree selectedItem updateEditionTimestamp. tree selectedItem updateEditionTimestamp.
tree roots: tree roots. tree roots: tree roots.
tree selectItem:item ] ]. tree selectItem: item ] ].
links links
whenTextChangedDo: [ :arg | whenTextChangedDo: [ :arg |
(tree respondsTo: #link:) (tree respondsTo: #link:)
@ -538,9 +540,6 @@ GrafoscopioNewNotebook >> initializeWidgets [
node isLeaf node isLeaf
ifTrue: [ {} ] ifTrue: [ {} ]
ifFalse: [ node children ] ]. ifFalse: [ node children ] ].
" tree
childrenBlock: [ :node | node children value ];
displayBlock: [ :node | node title value ]."
self focusOrder self focusOrder
add: tree; add: tree;
add: header; add: header;
@ -552,7 +551,7 @@ GrafoscopioNewNotebook >> initializeWidgets [
GrafoscopioNewNotebook >> initializeWindow: aWindowPresenter [ GrafoscopioNewNotebook >> initializeWindow: aWindowPresenter [
super initializeWindow: aWindowPresenter. super initializeWindow: aWindowPresenter.
aWindowPresenter aWindowPresenter
title: ' New | Grafoscopio notebook'; title: ' New | Grafoscopio 2.0 notebook';
windowIcon: self taskbarIcon; windowIcon: self taskbarIcon;
askOkToClose: true askOkToClose: true
] ]
@ -650,7 +649,8 @@ GrafoscopioNewNotebook >> moveSelectedNodeDown [
editedNode := tree selectedItem. editedNode := tree selectedItem.
editedNode moveDown. editedNode moveDown.
self notebookContent: notebook. self notebookContent: notebook.
tree needRebuild: true tree needRebuild: true.
tree selectItem: editedNode.
] ]
{ #category : #'editing nodes' } { #category : #'editing nodes' }
@ -966,8 +966,7 @@ GrafoscopioNewNotebook >> resetSelectedItem [
{ #category : #'editing nodes' } { #category : #'editing nodes' }
GrafoscopioNewNotebook >> resetSelectedItemTo: aPath [ GrafoscopioNewNotebook >> resetSelectedItemTo: aPath [
tree selectPath: {(aPath first min: notebook children size)}. self selectedPathPreviousTo: aPath
tree updatePresenter
] ]
{ #category : #persistence } { #category : #persistence }
@ -1027,6 +1026,30 @@ GrafoscopioNewNotebook >> selectedItem: anItem [
tree selectItem: (tree roots detect: [ : p | p = anItem ]). tree selectItem: (tree roots detect: [ : p | p = anItem ]).
] ]
{ #category : #'asdas yet unclassified' }
GrafoscopioNewNotebook >> selectedItem: aGrafoscopioTextNode path: aPath [
aPath
at: aPath size
put: (aPath at: aPath size) + 1.
tree selectPath: aPath
]
{ #category : #'asdas yet unclassified' }
GrafoscopioNewNotebook >> selectedPathNextTo: aPath [
aPath
at: aPath size
put: (aPath at: aPath size) + 1.
tree selectPath: aPath
]
{ #category : #'asdas yet unclassified' }
GrafoscopioNewNotebook >> selectedPathPreviousTo: aPath [
(aPath at: aPath size) - 1 > 0
ifTrue: [ aPath at: aPath size put: (aPath at: aPath size) - 1.
tree selectPath: aPath ]
ifFalse: [ self selectedPathPreviousTo: aPath allButLast ]
]
{ #category : #persistence } { #category : #persistence }
GrafoscopioNewNotebook >> subtreeAsMarkdown [ GrafoscopioNewNotebook >> subtreeAsMarkdown [
| currentNode | | currentNode |

View File

@ -17,56 +17,12 @@ Class {
'body', 'body',
'links' 'links'
], ],
#classInstVars : [
'clipboard'
],
#category : 'Grafoscopio-Model' #category : 'Grafoscopio-Model'
} }
{ #category : #utility } { #category : #'as yet unclassified' }
GrafoscopioTextNode class >> cleanTreeRootReferences [ GrafoscopioTextNode class >> nameForSelection [
^ 'New Text Node'
| ref |
clipboard ifNil: [ ^ self ].
clipboard children ifNil: [ ^ self ].
clipboard preorderTraversal allButFirstDo: [ :n |
ref := n.
n level - 1 timesRepeat: [ ref := ref parent ].
ref parent = clipboard parent ifTrue: [ ref parent: nil ]].
clipboard parent: nil.
]
{ #category : #accessing }
GrafoscopioTextNode class >> clipboard [
^ clipboard
]
{ #category : #accessing }
GrafoscopioTextNode class >> clipboard: anObject [
clipboard := anObject
]
{ #category : #utility }
GrafoscopioTextNode class >> contentProviders [
"I list the domains of certain providers that are treated specially, because they
store and offer content like Smalltalk playgrounds or source code, that can be used
in particular ways while importing or exporting content in a node."
^ Dictionary new
at: 'playgrounds' put: #('ws.stfx.eu');
at: 'fossil' put: #('mutabit.com/repos.fossil');
at: 'etherpads' put: #('pad.tupale.co' );
yourself.
]
{ #category : #utility }
GrafoscopioTextNode class >> specialWords [
"I return a list of word that were used in the first versions of Grafoscopio to mark node
headers to indicate special ways to handle them and their node contents.
Previous versions of first notebooks stored in Grafoscopio using this convention should be
migrated to newer versions where tags are used for the same function with simpler code"
^ #('%config' '%abstract' '%invisible' '%idea' '%footnote' '%metadata' '%output' '%embed' '%item').
] ]
{ #category : #operation } { #category : #operation }
@ -527,6 +483,14 @@ GrafoscopioTextNode >> initialize [
self body: '' self body: ''
] ]
{ #category : #accessing }
GrafoscopioTextNode >> instantiateBody [
| widget |
widget := super instantiateBody.
widget body whenTextChangedDo: [ :arg | self body: arg ].
^ widget
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioTextNode >> isEmpty [ GrafoscopioTextNode >> isEmpty [
body ifNil: [ ^ true ] ifNotNil: [ ^ false ] body ifNil: [ ^ true ] ifNotNil: [ ^ false ]

View File

@ -7,6 +7,11 @@ Class {
#category : 'Grafoscopio-Model' #category : 'Grafoscopio-Model'
} }
{ #category : #testing }
GrafoscopioTrunkNode class >> isAbstract [
^ self = GrafoscopioTrunkNode
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioTrunkNode >> children [ GrafoscopioTrunkNode >> children [
"Returns the receivers list of children" "Returns the receivers list of children"

View File

@ -7,6 +7,11 @@ Class {
#category : 'Grafoscopio-Model' #category : 'Grafoscopio-Model'
} }
{ #category : #'instance creation' }
GrafoscopioUrlCachedNode class >> nameForSelection [
^ 'New URL-Cached Node'
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioUrlCachedNode >> content [ GrafoscopioUrlCachedNode >> content [
^ content isEmptyOrNil ^ content isEmptyOrNil

View File

@ -7,6 +7,11 @@ Class {
#category : 'Grafoscopio-Model' #category : 'Grafoscopio-Model'
} }
{ #category : #'instance creation' }
GrafoscopioUrlNode class >> nameForSelection [
^ 'New URL Node'
]
{ #category : #'instance creation' } { #category : #'instance creation' }
GrafoscopioUrlNode class >> new [ GrafoscopioUrlNode class >> new [
^ super new ^ super new