2016-05-12 11:42:48 +00:00
|
|
|
"
|
|
|
|
I am a Grafoscopio Notebook.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
| testTree nb |
|
|
|
|
testTree := GrafoscopioNode new becomeDefaultTestTree.
|
|
|
|
nb := GrafoscopioNotebook new.
|
|
|
|
nb notebookContent: testTree.
|
|
|
|
nb openWithSpec
|
|
|
|
"
|
2016-05-03 15:15:02 +00:00
|
|
|
Class {
|
|
|
|
#name : #GrafoscopioNotebook,
|
|
|
|
#superclass : #ComposableModel,
|
|
|
|
#instVars : [
|
|
|
|
'tree',
|
|
|
|
'header',
|
2016-05-12 11:42:48 +00:00
|
|
|
'body',
|
2016-12-19 12:50:07 +00:00
|
|
|
'links',
|
2016-05-18 15:08:33 +00:00
|
|
|
'windowMainMenu',
|
2016-05-26 17:01:26 +00:00
|
|
|
'workingFile',
|
2017-05-03 11:17:44 +00:00
|
|
|
'notebook',
|
2017-12-02 21:16:51 +00:00
|
|
|
'debugMessage',
|
|
|
|
'imagesList'
|
2016-05-03 15:15:02 +00:00
|
|
|
],
|
|
|
|
#category : #'Grafoscopio-UI'
|
|
|
|
}
|
|
|
|
|
2016-05-18 15:08:33 +00:00
|
|
|
{ #category : #utility }
|
|
|
|
GrafoscopioNotebook class >> SHA1For: aFile is: aSHA1String [
|
|
|
|
"I verify that a file has the same signature that the one in a given string,
|
|
|
|
returning true in that case or false otherwise"
|
|
|
|
^ (SHA1 new hashMessage: aFile asFileReference binaryReadStream contents) hex = aSHA1String
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2016-05-03 15:15:02 +00:00
|
|
|
{ #category : #specs }
|
|
|
|
GrafoscopioNotebook class >> defaultSpec [
|
|
|
|
|
|
|
|
^ SpecLayout composed
|
2016-05-12 11:42:48 +00:00
|
|
|
newColumn: [:tcol|
|
|
|
|
tcol newRow: [ :wrow | wrow add: #windowMainMenu ] height: (self toolbarHeight);
|
|
|
|
newRow: [:row |
|
|
|
|
row newColumn: [ :tc |
|
|
|
|
tc add: #tree
|
|
|
|
] width: 300.
|
|
|
|
row newColumn: [ :bc |
|
|
|
|
bc newRow: [ :bcr | bcr add: #header ] height: self toolbarHeight.
|
2016-12-19 12:50:07 +00:00
|
|
|
bc add: #body; add: #links height: self toolbarHeight ]]]
|
2016-07-21 12:19:22 +00:00
|
|
|
]
|
|
|
|
|
2017-07-31 18:27:57 +00:00
|
|
|
{ #category : #'instance creation' }
|
2017-07-06 21:26:44 +00:00
|
|
|
GrafoscopioNotebook class >> newDefault [
|
|
|
|
^ self new.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #'instance creation' }
|
|
|
|
GrafoscopioNotebook class >> open: aFileReference [
|
|
|
|
self newDefault openFromFile: aFileReference
|
|
|
|
]
|
|
|
|
|
2017-08-18 02:22:52 +00:00
|
|
|
{ #category : #utilities }
|
|
|
|
GrafoscopioNotebook >> addCommandFrom: dictionary into: stream [
|
|
|
|
dictionary keysAndValuesDo: [ :k :v |
|
2017-08-19 19:19:04 +00:00
|
|
|
k = 'thisNotebook'
|
|
|
|
ifTrue: [
|
|
|
|
stream nextPutAll: (GrafoscopioUtils perform: v on: self) ]]
|
2017-08-18 02:22:52 +00:00
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
2016-08-18 19:48:10 +00:00
|
|
|
GrafoscopioNotebook >> addNode [
|
2017-08-29 19:54:11 +00:00
|
|
|
self currentNodeContent addNodeAfterMe.
|
2016-09-09 11:39:47 +00:00
|
|
|
self notebookContent: notebook.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> autoSaveBodyOf: aNode [
|
2017-04-14 19:35:04 +00:00
|
|
|
| playground |
|
2016-09-09 11:39:47 +00:00
|
|
|
body body class = TextModel
|
|
|
|
ifTrue: [ body body whenTextChanged: [ :arg | aNode body: arg ] ].
|
|
|
|
body body class = GlamourPresentationModel
|
2017-04-14 19:35:04 +00:00
|
|
|
ifFalse: [ ^ self ].
|
|
|
|
playground := body body glmPres.
|
|
|
|
playground
|
|
|
|
onChangeOfPort: #text
|
2017-11-28 14:20:50 +00:00
|
|
|
act: [ :x | aNode body: (x pane port: #text) value ]";
|
2017-04-14 19:35:04 +00:00
|
|
|
onChangeOfPort: #activePresentation
|
2017-04-20 17:39:48 +00:00
|
|
|
act: [ aNode output: aNode processOutput ]"
|
2016-05-03 15:15:02 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> body [
|
|
|
|
^ body
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> body: anObject [
|
|
|
|
body := anObject
|
|
|
|
]
|
|
|
|
|
2017-07-31 18:27:57 +00:00
|
|
|
{ #category : #utilities }
|
2017-08-10 13:27:10 +00:00
|
|
|
GrafoscopioNotebook >> checksum [
|
2017-08-18 02:22:52 +00:00
|
|
|
"I return the checksum (crypto hash) of the workingFile where this notebook is being stored.
|
|
|
|
I'm useful for data provenance and traceability of derivated files coming from this source
|
2017-07-31 18:27:57 +00:00
|
|
|
notebook."
|
|
|
|
self workingFile ifNil: [ ^ self ].
|
|
|
|
self workingFile contents = '' ifTrue: [ ^ self ].
|
2017-08-18 02:22:52 +00:00
|
|
|
^ GrafoscopioUtils checksumFor: self workingFile
|
2017-07-31 18:27:57 +00:00
|
|
|
]
|
|
|
|
|
2017-08-10 13:27:10 +00:00
|
|
|
{ #category : #'editing nodes' }
|
|
|
|
GrafoscopioNotebook >> copyNodeToClipboard [
|
|
|
|
tree highlightedItem content copyToClipboard.
|
|
|
|
self notebookContent: notebook.
|
|
|
|
]
|
|
|
|
|
2017-08-27 14:00:45 +00:00
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> currentNode [
|
|
|
|
| currentNode |
|
|
|
|
currentNode := tree highlightedItem.
|
|
|
|
currentNode ifNil: [ ^ self ].
|
|
|
|
^ currentNode
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> currentNodeContent [
|
|
|
|
^ self currentNode content
|
|
|
|
]
|
|
|
|
|
2016-12-18 14:33:00 +00:00
|
|
|
{ #category : #'editing nodes' }
|
|
|
|
GrafoscopioNotebook >> cutNodeToClipboard [
|
|
|
|
self copyNodeToClipboard; removeNode.
|
|
|
|
]
|
|
|
|
|
2017-05-03 11:17:44 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> debugMessage [
|
|
|
|
^ debugMessage ifNil: [ self defineDebugMessageUI ]
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> debugMessage: aGrafoscopioNodeSelector [
|
|
|
|
"I define a message that can be used for debugging purposes in the current notebook."
|
|
|
|
debugMessage := aGrafoscopioNodeSelector
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> debugWithSelector: aSymbol [
|
|
|
|
"I invoke a message to debug in the current node. In the future the debugging scope can be changed to
|
|
|
|
include different elements instead of the current node."
|
|
|
|
| currentNode nodeContent |
|
|
|
|
currentNode := tree highlightedItem.
|
|
|
|
currentNode ifNil: [ ^ self ].
|
|
|
|
nodeContent := currentNode content.
|
|
|
|
^ (nodeContent perform: aSymbol asSymbol) inspect
|
|
|
|
]
|
|
|
|
|
2017-07-31 18:27:57 +00:00
|
|
|
{ #category : #utilities }
|
2017-05-03 11:17:44 +00:00
|
|
|
GrafoscopioNotebook >> defineDebugMessageUI [
|
|
|
|
| answer |
|
|
|
|
answer := UIManager default
|
|
|
|
request: 'Define debug message to be send to a selected node in this notebook.'
|
|
|
|
initialAnswer: 'messageNoDebugSelector'.
|
|
|
|
self debugMessage: answer
|
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
|
|
|
GrafoscopioNotebook >> demoteNode [
|
|
|
|
| editedNode |
|
|
|
|
editedNode := tree highlightedItem content.
|
|
|
|
editedNode demote.
|
|
|
|
self notebookContent: notebook.
|
2016-05-03 15:15:02 +00:00
|
|
|
]
|
|
|
|
|
2017-04-01 13:20:17 +00:00
|
|
|
{ #category : #persistence }
|
2017-04-06 11:49:28 +00:00
|
|
|
GrafoscopioNotebook >> exportAllSubtreesAsMarkdow [
|
2017-04-01 13:20:17 +00:00
|
|
|
| toBeExported |
|
2017-04-06 11:49:28 +00:00
|
|
|
toBeExported := self notebook selectMarkdownSubtreesToExport.
|
|
|
|
toBeExported ifEmpty: [ ^ self ].
|
|
|
|
toBeExported do: [ :each | self subtreeAsMarkdownFor: each ].
|
|
|
|
self inform: toBeExported size asString , ' exported markdown subtrees.'
|
2017-04-01 13:20:17 +00:00
|
|
|
]
|
|
|
|
|
2017-02-20 20:31:41 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> exportAsHTML [
|
|
|
|
"I export the current tree/document to a HTML file, using pandoc external app.
|
|
|
|
I suppose pandoc is already installed and available in the system."
|
|
|
|
| htmlFile |
|
|
|
|
self markdownFile exists ifTrue: [ self markdownFile delete ].
|
|
|
|
self exportAsMarkdown.
|
|
|
|
htmlFile := self markdownFile parent fullName,'/', self markdownFile basenameWithoutExtension, '.html'.
|
|
|
|
htmlFile asFileReference exists ifTrue: [ htmlFile asFileReference delete ].
|
2017-12-01 20:15:04 +00:00
|
|
|
Smalltalk platformName = 'unix'
|
|
|
|
ifTrue: [OSProcess command: 'pandoc --standalone ', self markdownFile fullName, ' -o ', htmlFile].
|
|
|
|
Smalltalk platformName = 'Win32'
|
|
|
|
ifTrue: [WindowsProcess command: 'pandoc --standalone ', self markdownFile fullName, ' -o ', htmlFile].
|
2017-02-20 20:31:41 +00:00
|
|
|
self inform: ('File exported as: ', String cr, htmlFile).
|
|
|
|
]
|
|
|
|
|
2017-02-02 22:00:40 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> exportAsLaTeX [
|
|
|
|
"I export the current tree/document to a LaTeX file, using pandoc external app.
|
|
|
|
I suppose pandoc is already installed and available in the system."
|
|
|
|
| texFile |
|
|
|
|
self markdownFile exists ifTrue: [ self markdownFile delete ].
|
2017-08-19 19:19:04 +00:00
|
|
|
"self exportAsMarkdown.""<- This violates the separation of concenrs. Markdown exportation should
|
|
|
|
be explicit. There is still the issue of how to deal with desynchronization between a notebook
|
|
|
|
which has unsaved changes as markdown.... TO BE REVIWED!"
|
2017-02-02 22:00:40 +00:00
|
|
|
texFile := self markdownFile parent fullName,'/', self markdownFile basenameWithoutExtension, '.tex'.
|
2017-02-20 20:31:41 +00:00
|
|
|
texFile asFileReference exists ifTrue: [ texFile asFileReference delete ].
|
|
|
|
OSProcess command: 'pandoc --standalone ', self markdownFile fullName, ' -o ', texFile.
|
2017-02-02 22:00:40 +00:00
|
|
|
self inform: ('File exported as: ', String cr, texFile).
|
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> exportAsMarkdown [
|
2017-04-01 13:20:17 +00:00
|
|
|
"I export the current working tree/document to a markdown file."
|
|
|
|
workingFile
|
2016-09-09 11:39:47 +00:00
|
|
|
ifNil: [ self inform: 'File NOT exported. Please save the notebook on hard drive first' ]
|
2017-04-01 13:20:17 +00:00
|
|
|
ifNotNil: [ self exportNode: (self notebook) asMarkdownIn: (self markdownFile) ]
|
2017-02-02 22:00:40 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> exportAsPDF [
|
|
|
|
"I export the current tree/document to a PDF file, using pandoc and LaTeX external apps.
|
|
|
|
The latex engine used is xelatex, to minimize errors and warnings related with UTF8 support.
|
|
|
|
I suppose all them are already installed and defined in the system."
|
2017-12-06 16:48:02 +00:00
|
|
|
| pandocCommonCommand |
|
2017-08-19 19:19:04 +00:00
|
|
|
self markdownFile exists ifFalse: [ self exportAsMarkdown ].
|
|
|
|
self pdfFile ensureDelete.
|
2017-12-06 16:48:02 +00:00
|
|
|
pandocCommonCommand := 'pandoc ', self pandocOptionsComputed, ' ', self markdownFile fullName,
|
|
|
|
' --output ', self pdfFile fullName.
|
|
|
|
Smalltalk platformName = 'unix'
|
|
|
|
ifTrue: [ ExternalOSProcess command: 'cd ', self markdownFile parent fullName,'; ', pandocCommonCommand ].
|
2017-12-01 21:07:00 +00:00
|
|
|
Smalltalk platformName = 'Win32'
|
2017-12-06 16:48:02 +00:00
|
|
|
ifTrue: [ WinProcess createProcess: pandocCommonCommand ].
|
2017-08-19 19:19:04 +00:00
|
|
|
self inform: ('File exported as: ', String cr, self pdfFile fullName)
|
2016-07-28 11:26:03 +00:00
|
|
|
]
|
|
|
|
|
2016-05-26 17:01:26 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> exportAsSton: aNotebook on: aFileStream [
|
|
|
|
aNotebook flatten.
|
2017-05-26 08:51:57 +00:00
|
|
|
(STON writer on: aFileStream)
|
|
|
|
newLine: String crlf;
|
|
|
|
prettyPrint: true;
|
|
|
|
keepNewLines: true;
|
|
|
|
nextPut: aNotebook children
|
2016-05-26 17:01:26 +00:00
|
|
|
]
|
|
|
|
|
2017-03-28 20:53:14 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> exportNode: aGrafoscopioNode asMarkdownIn: aFile [
|
|
|
|
"I export the current tree/document to a markdown file"
|
2017-08-18 02:22:52 +00:00
|
|
|
aFile ensureDelete.
|
2017-03-28 20:53:14 +00:00
|
|
|
aFile
|
|
|
|
ensureCreateFile;
|
2017-08-18 02:22:52 +00:00
|
|
|
writeStreamDo: [:stream |
|
|
|
|
stream
|
|
|
|
nextPutAll:
|
2017-12-01 17:58:08 +00:00
|
|
|
('---', String cr,
|
|
|
|
'exportedFrom: ', self checksum, String cr) withInternetLineEndings.
|
2017-08-18 02:22:52 +00:00
|
|
|
aGrafoscopioNode metadataAsYamlIn: stream.
|
|
|
|
stream
|
|
|
|
nextPutAll:
|
2017-12-01 17:58:08 +00:00
|
|
|
('---', String cr, String cr) withInternetLineEndings,
|
2017-08-18 02:22:52 +00:00
|
|
|
aGrafoscopioNode asMarkdown ].
|
2017-04-20 17:39:48 +00:00
|
|
|
self inform: 'Exported as: ', String cr, aFile fullName
|
2017-03-28 20:53:14 +00:00
|
|
|
]
|
|
|
|
|
2016-08-22 16:12:45 +00:00
|
|
|
{ #category : #api }
|
2016-05-03 15:15:02 +00:00
|
|
|
GrafoscopioNotebook >> extent [
|
2016-08-22 16:12:45 +00:00
|
|
|
^900@500
|
2016-05-03 15:15:02 +00:00
|
|
|
]
|
|
|
|
|
2017-09-16 20:23:34 +00:00
|
|
|
{ #category : #'as yet unclassified' }
|
|
|
|
GrafoscopioNotebook >> findAndReplace [
|
2017-09-16 21:21:06 +00:00
|
|
|
| currentNode replaceGUI findString replaceString |
|
2017-09-16 20:23:34 +00:00
|
|
|
currentNode := tree highlightedItem content.
|
2017-09-16 21:21:06 +00:00
|
|
|
replaceGUI := GrafoscopioReplace new.
|
|
|
|
replaceGUI openWithSpec.
|
2017-09-25 09:34:16 +00:00
|
|
|
replaceGUI ok
|
|
|
|
on: [ ]
|
|
|
|
do: [
|
2017-09-16 21:21:06 +00:00
|
|
|
findString := replaceGUI returnValues at: 'find'.
|
|
|
|
replaceString := replaceGUI returnValues at: 'replace'.
|
|
|
|
currentNode find: findString andReplaceWith: replaceString. ]
|
|
|
|
|
2017-09-16 20:23:34 +00:00
|
|
|
]
|
|
|
|
|
2016-05-03 15:15:02 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> header [
|
|
|
|
^ header
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> header: anObject [
|
|
|
|
header := anObject
|
|
|
|
]
|
|
|
|
|
2017-08-26 18:28:38 +00:00
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> htmlToMarkdown [
|
2017-08-27 14:00:45 +00:00
|
|
|
self currentNodeContent htmlToMarkdown.
|
|
|
|
self updateBodyFor: self currentNode
|
2017-08-26 18:28:38 +00:00
|
|
|
]
|
|
|
|
|
2017-08-26 21:07:56 +00:00
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> htmlToMarkdownSubtree [
|
2017-08-27 14:00:45 +00:00
|
|
|
self currentNodeContent htmlToMarkdownSubtree.
|
|
|
|
self updateBodyFor: self currentNode
|
2017-08-26 21:07:56 +00:00
|
|
|
]
|
|
|
|
|
2017-12-02 21:16:51 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> imagesList [
|
|
|
|
imagesList ifNil: [ ^ #('No images list for this notebook') ].
|
|
|
|
^ imagesList
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> imagesList: anObject [
|
|
|
|
imagesList := anObject
|
|
|
|
]
|
|
|
|
|
2017-12-06 20:57:33 +00:00
|
|
|
{ #category : #'as yet unclassified' }
|
|
|
|
GrafoscopioNotebook >> importImages [
|
|
|
|
self imagesList: (Pandoc listImagesFrom: self markdownFile).
|
|
|
|
self inform: 'All notebook images has been imported.', String cr, 'Now you can list and download them.'
|
|
|
|
]
|
|
|
|
|
2017-08-05 17:00:38 +00:00
|
|
|
{ #category : #operation }
|
|
|
|
GrafoscopioNotebook >> importLinkContent [
|
|
|
|
"I see if a node header is an url located at 'http://ws.stfx.eu', wich means that is a shared
|
|
|
|
workspace, and convert the node body to an interactive playground"
|
|
|
|
| currentNode nodeContent |
|
|
|
|
currentNode := tree highlightedItem.
|
|
|
|
currentNode ifNil: [ ^ self ].
|
|
|
|
nodeContent := currentNode content.
|
|
|
|
nodeContent importPlaygroundLink.
|
|
|
|
nodeContent importHtmlLink.
|
|
|
|
self updateBodyFor: currentNode
|
|
|
|
]
|
|
|
|
|
2017-07-31 18:27:57 +00:00
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> initialize [
|
|
|
|
super initialize.
|
|
|
|
self
|
|
|
|
notebook: (GrafoscopioNode new becomeDefaultTree);
|
|
|
|
title: ' New | Grafoscopio notebook'.
|
|
|
|
self notebookContent: self notebook.
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2017-08-26 20:06:10 +00:00
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> initializeDefaultTest [
|
|
|
|
super initialize.
|
|
|
|
self
|
|
|
|
notebook: (GrafoscopioNode new becomeDefaultTestTree);
|
|
|
|
title: ' New test | Grafoscopio notebook'.
|
|
|
|
self notebookContent: self notebook.
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2016-05-03 15:15:02 +00:00
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> initializePresenter [
|
2016-09-14 11:35:24 +00:00
|
|
|
tree whenHighlightedItemChanged: [ :item |
|
|
|
|
tree highlightedItem ifNotNil: [self updateBodyFor: item]].
|
2016-09-09 11:39:47 +00:00
|
|
|
tree whenTreeUpdated: [ :item | item ifNotNil: [self updateBodyFor: item]].
|
2016-08-18 17:31:14 +00:00
|
|
|
header whenTextChanged: [ :arg |
|
|
|
|
(tree highlightedItem content header) = arg
|
2016-09-09 11:47:34 +00:00
|
|
|
ifFalse: [
|
2017-08-10 13:27:10 +00:00
|
|
|
tree highlightedItem content header: arg.
|
2017-02-05 20:04:31 +00:00
|
|
|
tree roots: tree roots]].
|
2017-08-10 13:27:10 +00:00
|
|
|
links whenTextChanged: [ :arg | tree highlightedItem content addLink: arg ]
|
2016-05-03 15:15:02 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> initializeWidgets [
|
2017-03-27 17:19:27 +00:00
|
|
|
windowMainMenu := self topBar.
|
2016-05-12 11:42:48 +00:00
|
|
|
header := self newTextInput.
|
2017-03-27 17:19:27 +00:00
|
|
|
header autoAccept: true.
|
2016-07-27 22:15:25 +00:00
|
|
|
body := self newText.
|
2016-05-03 15:15:02 +00:00
|
|
|
body disable.
|
2016-08-10 12:05:37 +00:00
|
|
|
body text: '<- Select a node'.
|
2016-12-19 12:50:07 +00:00
|
|
|
links := self newTextInput.
|
2016-08-14 15:37:40 +00:00
|
|
|
tree := TreeModel new.
|
2016-07-27 22:15:25 +00:00
|
|
|
tree
|
|
|
|
childrenBlock: [:node | node children];
|
2016-05-03 15:15:02 +00:00
|
|
|
displayBlock: [:node | node title ].
|
2016-07-27 22:15:25 +00:00
|
|
|
self focusOrder
|
|
|
|
add: tree;
|
|
|
|
add: header;
|
2016-12-19 12:50:07 +00:00
|
|
|
add: body;
|
|
|
|
add: links.
|
2017-01-31 13:33:01 +00:00
|
|
|
self askOkToClose: true.
|
2016-12-19 12:50:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> links [
|
|
|
|
^ links
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> links: anObject [
|
|
|
|
links := anObject
|
2016-07-27 22:15:25 +00:00
|
|
|
]
|
|
|
|
|
2017-12-02 21:16:51 +00:00
|
|
|
{ #category : #'as yet unclassified' }
|
|
|
|
GrafoscopioNotebook >> listImagesUI [
|
|
|
|
ListModel new
|
|
|
|
title: 'Images files list';
|
|
|
|
items: self imagesList ;
|
|
|
|
openWithSpec
|
|
|
|
]
|
|
|
|
|
2017-08-18 02:22:52 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> loadFromFile: aFileReference [
|
2017-11-28 14:20:50 +00:00
|
|
|
"I load the contents of aFileReference into a GrafoscopioNotebook, without opening it."
|
|
|
|
(aFileReference basename endsWith: 'ston') ifFalse: [ ^ self ].
|
2017-08-18 02:22:52 +00:00
|
|
|
self workingFile: aFileReference.
|
|
|
|
self notebook: ((STON fromString: self workingFile contents) at: 1) parent.
|
|
|
|
self title: self workingFile basenameWithIndicator, ' | Grafoscopio notebook'.
|
|
|
|
self notebookContent: self notebook.
|
|
|
|
]
|
|
|
|
|
2017-02-02 22:00:40 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> markdownFile [
|
|
|
|
"I define the location of the markdown file where the notebook will be exported"
|
|
|
|
| markdownFile |
|
|
|
|
markdownFile := (((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.markdown') asFileReference.
|
|
|
|
^ markdownFile
|
|
|
|
]
|
|
|
|
|
2017-08-18 02:22:52 +00:00
|
|
|
{ #category : #utilities }
|
|
|
|
GrafoscopioNotebook >> markdownFileChecksum [
|
|
|
|
self workingFile ifNil: [ ^ self ].
|
|
|
|
self workingFile contents = '' ifTrue: [ ^ self ].
|
|
|
|
^ GrafoscopioUtils checksumFor: self markdownFile
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #utilities }
|
2017-08-19 19:19:04 +00:00
|
|
|
GrafoscopioNotebook >> markdownFileChecksumUpto: anInteger [
|
|
|
|
"I cut the markdownFileCheckup upto a given integer.
|
|
|
|
Type coersion is needed, because this message argument can be read from a string in %metadata nodes.
|
|
|
|
Maybe the way used by playgrounds to import text as commands can be useful here."
|
|
|
|
^ self markdownFileChecksum copyFrom: 1 to: anInteger asInteger.
|
2017-08-18 02:22:52 +00:00
|
|
|
]
|
|
|
|
|
2017-11-21 19:05:17 +00:00
|
|
|
{ #category : #utilities }
|
|
|
|
GrafoscopioNotebook >> metadata [
|
|
|
|
^ self notebook metadata
|
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
2016-07-28 11:26:03 +00:00
|
|
|
GrafoscopioNotebook >> moveNodeAfter [
|
2016-09-09 11:39:47 +00:00
|
|
|
| editedNode |
|
|
|
|
editedNode := tree selectedItem content.
|
|
|
|
editedNode moveAfter.
|
|
|
|
self notebookContent: notebook
|
2016-07-28 11:26:03 +00:00
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
2016-07-27 22:15:25 +00:00
|
|
|
GrafoscopioNotebook >> moveNodeBefore [
|
2016-09-09 11:39:47 +00:00
|
|
|
| editedNode |
|
|
|
|
editedNode := tree highlightedItem content.
|
|
|
|
editedNode moveBefore.
|
|
|
|
self notebookContent: notebook
|
2016-05-03 15:15:02 +00:00
|
|
|
]
|
|
|
|
|
2017-03-28 20:53:14 +00:00
|
|
|
{ #category : #utilities }
|
|
|
|
GrafoscopioNotebook >> navigateRelativePathFor: aFileString [
|
2017-04-06 11:49:28 +00:00
|
|
|
"Given a relative path according to location of the notebook's workingFile,
|
|
|
|
I navigate to that file if exist and create it, including subdirectories if it does not exist.
|
|
|
|
If the relative path is located in a subdirectory that shares the route with the notebooks working
|
|
|
|
file, it must start with the folders name,
|
2017-04-01 13:20:17 +00:00
|
|
|
without using './' to point the same shared root "
|
2017-03-28 20:53:14 +00:00
|
|
|
|
2017-04-01 13:20:17 +00:00
|
|
|
| finalLocation pathSegments |
|
2017-04-06 11:49:28 +00:00
|
|
|
aFileString ifEmpty: [ ^ self ].
|
|
|
|
aFileString asUrl host ifNotNil: [ ^self ].
|
2017-03-28 20:53:14 +00:00
|
|
|
finalLocation := workingFile parent.
|
2017-04-01 13:20:17 +00:00
|
|
|
pathSegments := aFileString splitOn: '/'.
|
|
|
|
pathSegments allButLastDo: [ :segment |
|
2017-03-28 20:53:14 +00:00
|
|
|
(segment = '..')
|
|
|
|
ifTrue: [ finalLocation := finalLocation parent ]
|
2017-04-01 13:20:17 +00:00
|
|
|
ifFalse: [
|
|
|
|
finalLocation := finalLocation / segment.
|
|
|
|
finalLocation exists ifFalse: [ finalLocation ensureCreateDirectory ]]].
|
|
|
|
finalLocation := finalLocation / (pathSegments last).
|
|
|
|
finalLocation exists ifFalse: [ finalLocation ensureCreateFile ].
|
2017-03-28 20:53:14 +00:00
|
|
|
^ finalLocation
|
|
|
|
]
|
|
|
|
|
2016-05-26 17:01:26 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> notebook [
|
|
|
|
^ notebook
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> notebook: anObject [
|
|
|
|
notebook := anObject
|
|
|
|
]
|
|
|
|
|
2016-05-12 11:42:48 +00:00
|
|
|
{ #category : #api }
|
2016-05-03 15:15:02 +00:00
|
|
|
GrafoscopioNotebook >> notebookContent: aTree [
|
|
|
|
|
2016-08-14 15:37:40 +00:00
|
|
|
| nodeBlock |
|
|
|
|
nodeBlock:= [:gfcNode | |node|
|
|
|
|
node := TreeNodeModel new.
|
|
|
|
node
|
|
|
|
hasChildren: [ gfcNode children isNotEmpty ];
|
|
|
|
children: [ gfcNode children collect: [:subNode | nodeBlock value: subNode ]];
|
|
|
|
content: gfcNode].
|
|
|
|
tree roots: (aTree children collect:[ :gfcNode | nodeBlock value: gfcNode])
|
2016-05-03 15:15:02 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2016-05-12 11:42:48 +00:00
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> notebookSubMenu [
|
|
|
|
^ MenuModel new
|
2017-12-06 16:48:02 +00:00
|
|
|
addGroup: [ :group |
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Save';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallSave);
|
|
|
|
shortcut: $s command;
|
|
|
|
action: [ self saveWorkingNotebook ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Save as...';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallSaveAs);
|
|
|
|
action: [ self saveToFileUI ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
2017-12-06 20:57:33 +00:00
|
|
|
name: 'Import images';
|
2017-12-06 16:48:02 +00:00
|
|
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
2017-12-06 20:57:33 +00:00
|
|
|
action: [ self importImages ] ].
|
2017-12-06 16:48:02 +00:00
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
2017-12-06 20:57:33 +00:00
|
|
|
name: 'Download images';
|
2017-12-06 16:48:02 +00:00
|
|
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
2017-12-06 20:57:33 +00:00
|
|
|
action: [ self downloadImages ] ].
|
2017-12-06 16:48:02 +00:00
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Export as markdown';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallSaveAs);
|
|
|
|
action: [ self exportAsMarkdown ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Export as html';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallWindow);
|
|
|
|
action: [ self exportAsHTML ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Export as LaTeX';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallPrint);
|
|
|
|
action: [ self exportAsLaTeX ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Export as pdf';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallPrint);
|
|
|
|
action: [ self exportAsPDF ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'See html';
|
|
|
|
icon: #smallInspectIt asIcon;
|
|
|
|
action: [ self inform: 'To be implemented...' ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'See pdf';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #smallInspectIt);
|
|
|
|
action: [ self inform: 'To be implemented...' ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'See images list';
|
|
|
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
|
|
|
action: [ self listImagesUI ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Define debug message...';
|
|
|
|
icon: Smalltalk ui icons glamorousBug;
|
|
|
|
action: [ self defineDebugMessageUI ] ] ]
|
2016-05-12 11:42:48 +00:00
|
|
|
]
|
|
|
|
|
2017-01-31 13:33:01 +00:00
|
|
|
{ #category : #private }
|
|
|
|
GrafoscopioNotebook >> okToChange [
|
|
|
|
^ true
|
|
|
|
]
|
|
|
|
|
2016-07-19 13:56:25 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> openDefault [
|
|
|
|
"I open a new default notebook"
|
2017-07-31 18:27:57 +00:00
|
|
|
|
|
|
|
^ self class new openWithSpec.
|
2016-07-19 13:56:25 +00:00
|
|
|
]
|
|
|
|
|
2016-05-06 16:51:51 +00:00
|
|
|
{ #category : #persistence }
|
2017-07-06 21:26:44 +00:00
|
|
|
GrafoscopioNotebook >> openFromFile: aFileReference [
|
2016-05-06 16:51:51 +00:00
|
|
|
|
2017-08-18 02:22:52 +00:00
|
|
|
self loadFromFile: aFileReference.
|
2016-05-26 17:01:26 +00:00
|
|
|
^ self openWithSpec.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> openFromFileSelector [
|
|
|
|
|
|
|
|
| fileStream nb |
|
2017-01-20 17:46:55 +00:00
|
|
|
fileStream := UIManager default
|
2016-05-26 17:01:26 +00:00
|
|
|
fileOpen: 'Choose a file'
|
|
|
|
extensions: #('ston').
|
|
|
|
fileStream ifNil: [
|
|
|
|
self inform: 'No file selected'.
|
|
|
|
^ self ].
|
|
|
|
self workingFile: fileStream name asFileReference.
|
2016-05-06 16:51:51 +00:00
|
|
|
nb := self class new.
|
2016-10-18 17:10:40 +00:00
|
|
|
nb openFromFile: self workingFile.
|
2017-03-27 17:19:27 +00:00
|
|
|
GrafoscopioDockingBar updateRecentNotebooksWith: workingFile
|
2016-05-06 16:51:51 +00:00
|
|
|
]
|
|
|
|
|
2016-07-22 12:52:44 +00:00
|
|
|
{ #category : #persistence }
|
2017-08-10 13:27:10 +00:00
|
|
|
GrafoscopioNotebook >> openFromUrl: url [
|
2016-07-22 12:52:44 +00:00
|
|
|
"Opens a tree from a file named aFileName"
|
|
|
|
|
2017-08-10 13:27:10 +00:00
|
|
|
| fileName sanitized |
|
|
|
|
sanitized := GrafoscopioUtils sanitize: url.
|
|
|
|
fileName := sanitized segments last.
|
|
|
|
GrafoscopioUtils
|
|
|
|
downloadingFrom: sanitized
|
2016-07-22 12:52:44 +00:00
|
|
|
withMessage: 'Downloading document...'
|
|
|
|
into: FileLocator temp.
|
2016-09-23 09:05:24 +00:00
|
|
|
self class new openFromFile: (FileLocator temp / fileName)
|
2016-07-22 12:52:44 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> openFromUrlUI [
|
|
|
|
"This method generates the UI for the openFromUrl: method, it asks for a URL from the user"
|
|
|
|
|
|
|
|
| fileUrl |
|
|
|
|
"GrafoscopioBrowser configureSettings."
|
|
|
|
fileUrl := UIManager default
|
2017-04-06 11:49:28 +00:00
|
|
|
textEntry: 'Enter the URL'
|
|
|
|
title: 'Open notebook from URL'.
|
2016-07-22 12:52:44 +00:00
|
|
|
fileUrl isNil ifTrue: [ ^nil ].
|
|
|
|
self class new openFromUrl: fileUrl
|
|
|
|
]
|
|
|
|
|
2017-08-18 02:22:52 +00:00
|
|
|
{ #category : #utilities }
|
|
|
|
GrafoscopioNotebook >> pandocOptions [
|
|
|
|
^ self notebook pandocOptions
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #utilities }
|
|
|
|
GrafoscopioNotebook >> pandocOptionsComputed [
|
|
|
|
"I convert the pandoc options array into a single line that can be used with the pandoc command."
|
|
|
|
|
|
|
|
| result |
|
|
|
|
result := '' writeStream.
|
2017-12-11 16:09:44 +00:00
|
|
|
self pandocOptions ifNil: [ ^ '' ].
|
2017-08-18 02:22:52 +00:00
|
|
|
self pandocOptions
|
|
|
|
do: [ :option |
|
|
|
|
option isDictionary
|
|
|
|
ifTrue: [
|
|
|
|
self addCommandFrom: option into: result ]
|
|
|
|
ifFalse: [
|
|
|
|
result
|
|
|
|
nextPutAll: option] ].
|
|
|
|
^ result contents
|
|
|
|
]
|
|
|
|
|
2016-12-18 14:33:00 +00:00
|
|
|
{ #category : #'editing nodes' }
|
|
|
|
GrafoscopioNotebook >> pasteNodeFromClipboard [
|
|
|
|
tree highlightedItem content pasteFromClipboard.
|
|
|
|
self notebookContent: notebook.
|
|
|
|
]
|
|
|
|
|
2017-08-19 19:19:04 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> pdfFile [
|
|
|
|
"I define the location of the markdown file where the notebook will be exported"
|
|
|
|
| pdfFile |
|
|
|
|
pdfFile := (self markdownFile parent fullName,'/', self markdownFile basenameWithoutExtension, '.pdf') asFileReference.
|
|
|
|
^ pdfFile.
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2016-05-12 11:42:48 +00:00
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> projectSubMenu [
|
|
|
|
|
|
|
|
^ MenuModel new
|
|
|
|
addGroup: [ :group |
|
|
|
|
group addItem: [ :item |
|
|
|
|
item
|
2016-07-21 12:19:22 +00:00
|
|
|
name: 'Activate remote repository...';
|
2016-05-12 11:42:48 +00:00
|
|
|
icon: Smalltalk ui icons smallPushpinIcon;
|
2016-07-21 12:19:22 +00:00
|
|
|
action: [ self inform: 'To be implemented ...' ] ].
|
2016-05-12 11:42:48 +00:00
|
|
|
group addItem: [ :item |
|
|
|
|
item
|
2016-07-21 12:19:22 +00:00
|
|
|
name: 'Activate local repository...';
|
2016-05-12 11:42:48 +00:00
|
|
|
icon: Smalltalk ui icons homeIcon;
|
2016-07-21 12:19:22 +00:00
|
|
|
action: [ self inform: 'To be implemented ...' ] ].
|
2016-05-12 11:42:48 +00:00
|
|
|
group addItem: [ :item |
|
|
|
|
item
|
2016-07-21 12:19:22 +00:00
|
|
|
name: 'Add file...';
|
2016-05-12 11:42:48 +00:00
|
|
|
icon: Smalltalk ui icons newerPackagesAvailableIcon;
|
2016-07-21 12:19:22 +00:00
|
|
|
action: [ self inform: 'To be implemented ...' ] ].
|
2016-05-12 11:42:48 +00:00
|
|
|
group addItem: [ :item |
|
|
|
|
item
|
2016-07-21 12:19:22 +00:00
|
|
|
name: 'Delete file...';
|
2016-05-12 11:42:48 +00:00
|
|
|
icon: Smalltalk ui icons packageDeleteIcon;
|
2016-07-21 12:19:22 +00:00
|
|
|
action: [ self inform: 'To be implemented ...' ] ].
|
2016-05-12 11:42:48 +00:00
|
|
|
group addItem: [ :item |
|
|
|
|
item
|
2016-07-21 12:19:22 +00:00
|
|
|
name: 'Commit to repository';
|
2016-05-12 11:42:48 +00:00
|
|
|
icon: Smalltalk ui icons smallScreenshotIcon;
|
2016-07-21 12:19:22 +00:00
|
|
|
action: [ self inform: 'To be implemented ...' ] ].
|
2016-05-12 11:42:48 +00:00
|
|
|
group addItem: [ :item |
|
|
|
|
item
|
2016-07-21 12:19:22 +00:00
|
|
|
name: 'Credentials';
|
2016-05-12 11:42:48 +00:00
|
|
|
icon: Smalltalk ui icons userIcon;
|
2016-07-21 12:19:22 +00:00
|
|
|
action: [ self inform: 'To be implemented ...' ] ] ]
|
2016-05-12 11:42:48 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
2016-07-28 11:26:03 +00:00
|
|
|
GrafoscopioNotebook >> promoteNode [
|
2016-09-09 11:39:47 +00:00
|
|
|
| editedNote |
|
|
|
|
editedNote := tree selectedItem content.
|
|
|
|
editedNote promote.
|
|
|
|
self notebookContent: notebook
|
2016-07-28 11:26:03 +00:00
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
2016-07-27 22:15:25 +00:00
|
|
|
GrafoscopioNotebook >> removeNode [
|
2016-08-18 19:48:10 +00:00
|
|
|
| contentToDelete parentContent newSelectedContent children |
|
|
|
|
contentToDelete := tree selectedItem content.
|
|
|
|
parentContent := contentToDelete parent.
|
|
|
|
children := parentContent children.
|
|
|
|
children size > 1
|
|
|
|
ifTrue: [
|
|
|
|
children last = contentToDelete
|
|
|
|
ifTrue: [ newSelectedContent := children at: (children size - 1) ]
|
|
|
|
]
|
|
|
|
ifFalse: [ newSelectedContent := parentContent ].
|
|
|
|
contentToDelete parent removeNode: contentToDelete.
|
2016-09-09 11:39:47 +00:00
|
|
|
self notebookContent: notebook
|
2016-07-27 22:15:25 +00:00
|
|
|
]
|
|
|
|
|
2016-06-28 16:22:00 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> saveToFile: aFileReference [
|
2017-08-10 13:27:10 +00:00
|
|
|
"I save the current tree/document to a file."
|
2016-06-28 16:22:00 +00:00
|
|
|
|
2017-08-18 02:22:52 +00:00
|
|
|
aFileReference ifNil: [ self inform: 'No file selected for saving. Save NOT done.'. ^ self ].
|
2016-06-28 16:22:00 +00:00
|
|
|
workingFile := aFileReference.
|
2017-08-10 13:27:10 +00:00
|
|
|
self workingFile ensureDelete.
|
|
|
|
self workingFile writeStreamDo: [:stream |
|
2017-08-18 02:22:52 +00:00
|
|
|
self exportAsSton: self notebook on: stream ].
|
2016-07-19 13:56:25 +00:00
|
|
|
self title: self workingFile basenameWithIndicator, ' | Grafoscopio notebook'.
|
2016-07-19 12:41:41 +00:00
|
|
|
self inform: ('File saved at: ', String cr, self workingFile fullName).
|
2017-03-27 17:19:27 +00:00
|
|
|
GrafoscopioDockingBar updateRecentNotebooksWith: aFileReference.
|
2016-06-28 16:22:00 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> saveToFileUI [
|
|
|
|
|
|
|
|
| file |
|
|
|
|
|
2017-01-20 17:46:55 +00:00
|
|
|
file := UIManager default
|
2016-06-28 16:22:00 +00:00
|
|
|
fileSave: 'Export notebook to file as...'
|
|
|
|
extensions: #('ston')
|
2017-03-27 17:19:27 +00:00
|
|
|
path: (workingFile ifNotNil: [ workingFile parent ] ifNil: [ FileLocator documents ] ).
|
2016-06-28 16:22:00 +00:00
|
|
|
file
|
|
|
|
ifNil: [ self inform: 'Export cancelled'. ^ self ]
|
|
|
|
ifNotNil:[self saveToFile: file].
|
|
|
|
]
|
|
|
|
|
2016-05-26 17:01:26 +00:00
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> saveWorkingNotebook [
|
|
|
|
"Saves the current tree to the user predefined file location used when he/she opened it."
|
2016-07-19 12:41:41 +00:00
|
|
|
self workingFile
|
|
|
|
ifNil: [ self saveToFileUI ]
|
2016-08-22 16:12:45 +00:00
|
|
|
ifNotNil: [ self saveToFile: workingFile ].
|
2017-03-27 17:19:27 +00:00
|
|
|
GrafoscopioDockingBar updateRecentNotebooksWith: workingFile
|
2016-08-22 16:12:45 +00:00
|
|
|
|
2016-07-19 12:41:41 +00:00
|
|
|
|
2016-05-26 17:01:26 +00:00
|
|
|
]
|
|
|
|
|
2017-03-28 20:53:14 +00:00
|
|
|
{ #category : #persistence }
|
2017-04-06 11:49:28 +00:00
|
|
|
GrafoscopioNotebook >> subtreeAsMarkdown [
|
|
|
|
| currentNode |
|
2017-03-28 20:53:14 +00:00
|
|
|
currentNode := tree highlightedItem content.
|
2017-04-06 11:49:28 +00:00
|
|
|
self inform: ('Exported as: ', String cr, (self subtreeAsMarkdownFor: currentNode) fullName )
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #persistence }
|
|
|
|
GrafoscopioNotebook >> subtreeAsMarkdownFor: aNode [
|
|
|
|
| exportedFile |
|
|
|
|
aNode links ifEmpty: [ ^ self ].
|
|
|
|
exportedFile:= self navigateRelativePathFor: aNode links last.
|
|
|
|
exportedFile class = GrafoscopioNotebook ifTrue: [ ^ self ].
|
|
|
|
self exportNode: aNode asMarkdownIn: exportedFile.
|
|
|
|
^ exportedFile
|
2017-03-28 20:53:14 +00:00
|
|
|
]
|
|
|
|
|
2016-09-09 11:39:47 +00:00
|
|
|
{ #category : #'editing nodes' }
|
2016-08-22 16:12:45 +00:00
|
|
|
GrafoscopioNotebook >> toggleCodeNode [
|
|
|
|
| currentNode |
|
|
|
|
currentNode := tree highlightedItem.
|
2017-08-05 17:00:38 +00:00
|
|
|
currentNode content toggleCodeText.
|
2016-09-09 11:39:47 +00:00
|
|
|
self updateBodyFor: currentNode.
|
2016-08-22 16:12:45 +00:00
|
|
|
]
|
|
|
|
|
2017-03-27 17:19:27 +00:00
|
|
|
{ #category : #initialization }
|
|
|
|
GrafoscopioNotebook >> topBar [
|
2017-08-05 17:00:38 +00:00
|
|
|
^ MenuModel new
|
|
|
|
addGroup: [ :group |
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Notebook';
|
|
|
|
icon: #smallObjects asIcon;
|
|
|
|
subMenu: self notebookSubMenu ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: 'Project';
|
|
|
|
icon: #catalog asIcon;
|
|
|
|
subMenu: self projectSubMenu ] ];
|
|
|
|
addGroup: [ :group |
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Save notebook';
|
|
|
|
icon: #glamorousSave asIcon;
|
|
|
|
action: [ self saveWorkingNotebook ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Export all markdown subtrees';
|
|
|
|
icon: #glamorousMore asIcon;
|
|
|
|
action: [ self exportAllSubtreesAsMarkdow ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Cut';
|
|
|
|
icon: #smallCut asIcon;
|
|
|
|
action: [ self cutNodeToClipboard ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Copy';
|
|
|
|
icon: #smallCopy asIcon;
|
|
|
|
action: [ self copyNodeToClipboard ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Paste';
|
|
|
|
icon: #smallPaste asIcon;
|
2017-09-16 19:31:23 +00:00
|
|
|
action: [ self pasteNodeFromClipboard ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Find & Replace';
|
|
|
|
icon: #smallFind asIcon;
|
2017-09-16 20:23:34 +00:00
|
|
|
action: [ self findAndReplace ] ] ];
|
2017-08-05 17:00:38 +00:00
|
|
|
addGroup: [ :group |
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Add node';
|
|
|
|
icon: MendaIcons new plusIcon;
|
|
|
|
action: [ self addNode ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Delete node';
|
|
|
|
icon: MendaIcons new minusIcon;
|
|
|
|
action: [ self removeNode ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Move node up';
|
|
|
|
icon: MendaIcons new arrowUpIcon;
|
|
|
|
action: [ self moveNodeBefore ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Move node down';
|
|
|
|
icon: MendaIcons new arrowDownIcon;
|
|
|
|
action: [ self moveNodeAfter ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Move node left';
|
|
|
|
icon: MendaIcons new arrowLeftIcon;
|
|
|
|
action: [ self promoteNode ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Move node right';
|
|
|
|
icon: MendaIcons new arrowRightIcon;
|
|
|
|
action: [ self demoteNode ] ] ];
|
|
|
|
addGroup: [ :group |
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Toggle: code <--> text';
|
|
|
|
icon: MendaIcons new smalltalkCodeIcon;
|
|
|
|
action: [ self toggleCodeNode ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Visit link';
|
|
|
|
icon: #glamorousRight asIcon;
|
|
|
|
action: [ self visitNodeLink ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
2017-08-10 13:27:10 +00:00
|
|
|
description: 'Import link content';
|
2017-08-05 17:00:38 +00:00
|
|
|
icon: #glamorousRefresh asIcon;
|
|
|
|
action: [ self importLinkContent ] ].
|
2017-08-26 18:28:38 +00:00
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'HTML to Markdown';
|
|
|
|
icon: #smallProfile asIcon;
|
|
|
|
action: [ self htmlToMarkdown ] ].
|
2017-08-26 21:07:56 +00:00
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'HTML to Markdown subtree';
|
|
|
|
icon: #hierarchy asIcon;
|
|
|
|
action: [ self htmlToMarkdownSubtree ] ].
|
2017-08-05 17:00:38 +00:00
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Tag as...';
|
|
|
|
icon: MendaIcons new tagAddIcon;
|
|
|
|
action: [ self inform: 'To be implemented...' ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Untag ....';
|
|
|
|
icon: MendaIcons new tagMinusIcon;
|
|
|
|
action: [ self inform: 'To be implemented...' ] ].
|
|
|
|
group
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Edit tags...';
|
|
|
|
icon: FontAwesomeIcons new tagsIcon;
|
|
|
|
action: [ self inform: 'To be implemented...' ] ] ];
|
|
|
|
addGroup: [ :debug |
|
|
|
|
debug
|
|
|
|
addItem: [ :item |
|
|
|
|
item
|
|
|
|
name: nil;
|
|
|
|
description: 'Debug';
|
|
|
|
icon: #glamorousBug asIcon;
|
|
|
|
action: [ self debugWithSelector: self debugMessage ] ] ]
|
2017-03-27 17:19:27 +00:00
|
|
|
]
|
|
|
|
|
2016-05-03 15:15:02 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> tree [
|
|
|
|
^ tree
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> tree: anObject [
|
|
|
|
tree := anObject
|
|
|
|
]
|
2016-05-12 11:42:48 +00:00
|
|
|
|
2016-08-10 12:05:37 +00:00
|
|
|
{ #category : #operation }
|
2016-09-09 11:39:47 +00:00
|
|
|
GrafoscopioNotebook >> updateBodyFor: aNodeContainer [
|
|
|
|
| aNode |
|
|
|
|
self needRebuild: false.
|
|
|
|
tree needRebuild: false.
|
|
|
|
body needRebuild: true.
|
|
|
|
aNode := aNodeContainer content.
|
|
|
|
header text: aNode header.
|
|
|
|
body := self instantiate: aNode specModelClass new.
|
|
|
|
body content: aNode body.
|
2016-12-19 12:50:07 +00:00
|
|
|
links text: aNode lastLink.
|
2016-09-09 11:39:47 +00:00
|
|
|
self autoSaveBodyOf: aNode.
|
2016-08-22 16:12:45 +00:00
|
|
|
self buildWithSpecLayout: self class defaultSpec
|
2016-08-10 12:05:37 +00:00
|
|
|
]
|
|
|
|
|
2017-12-06 20:57:33 +00:00
|
|
|
{ #category : #operation }
|
2016-12-19 18:24:06 +00:00
|
|
|
GrafoscopioNotebook >> visitNodeLink [
|
|
|
|
|
|
|
|
tree highlightedItem content visitLastLink.
|
|
|
|
]
|
|
|
|
|
2016-05-12 11:42:48 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> windowMainMenu [
|
|
|
|
^ windowMainMenu
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> windowMainMenu: anObject [
|
|
|
|
windowMainMenu := anObject
|
|
|
|
]
|
2016-05-26 17:01:26 +00:00
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioNotebook >> workingFile [
|
|
|
|
^ workingFile
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
2017-08-18 02:22:52 +00:00
|
|
|
GrafoscopioNotebook >> workingFile: aFileReference [
|
|
|
|
workingFile := aFileReference.
|
2016-05-26 17:01:26 +00:00
|
|
|
]
|