Grafoscopio/repository/Grafoscopio/GrafoscopioBrowser.class.st

1162 lines
38 KiB
Smalltalk

"
An UbakyeExplorer is a graphical interface for showing trees and outlines.
Instance Variables
browser: <Object>
browser
- xxxxx
"
Class {
#name : #GrafoscopioBrowser,
#superclass : #Object,
#instVars : [
'browser',
'mainTree',
'tagsAvailable',
'\r\t\t\t\t\t\t\t\t\tnonVar1',
'cacheNode',
'workingFile',
'\r\t\t\t\t\t\t\t\t\tnonVar2',
'localRepository',
'remoteRepository',
'repositoryUser',
'repositoryPassword'
],
#classVars : [
'DefaultUbakyeBrowser',
'dockingBar',
'fossil',
'pandoc'
],
#category : #'Grafoscopio-UI'
}
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configureFossil [
"Stablish where is located fossil according to the operative system and the input of the user"
| fileStream |
fileStream := UITheme builder
fileOpen: 'Coloque la ruta de fossil'.
fileStream isNil ifTrue: [ ^nil ].
fossil := fileStream name asFileReference fullName.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configurePandoc [
"Stablish where is located pandoc according to the operative system and the input of the user"
| fileStream |
fileStream := UITheme builder
fileOpen: 'Coloque la ruta de pandoc'.
fileStream isNil ifTrue: [ ^nil ].
pandoc := fileStream name asFileReference fullName.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configureSettings [
"Stablish several 'global' settings according to the operative system"
Smalltalk platform name = 'unix'
ifTrue: [
fossil := (FileSystem disk workingDirectory parent / 'Platform' / 'Linux' / 'Programs' / 'Fossil'/ 'fossil') fullName.
pandoc := (FileSystem disk workingDirectory parent / 'Platform' / 'Linux' / 'Programs' / 'Pandoc' / 'pandoc') fullName].
Smalltalk platform name = 'Win32'
ifTrue: [
fossil := (FileSystem disk workingDirectory parent / 'Platform' / 'Windows' / 'Programs' / 'Fossil' / 'fossil.exe') fullName.
pandoc := (FileSystem disk workingDirectory parent / 'Platform' / 'Windows' / 'Programs' / 'Pandoc' / 'pandoc.exe') fullName].
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> messageAbout [
"Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web"
UIManager default alert:
'Grafosocpio',
(String with: Character cr),
'(c) Copyright 2014 by Offray Vladimir Luna Cárdenas',
(String with: Character cr),
'Covered under MIT license.',
(String with: Character cr),
(String with: Character cr),
'SPONSORS:',
(String with: Character cr),
'mutabiT | www.mutabit.com ',
(String with: Character cr),
'Fundación Universitaria Los Libertadores | www.ulibertadores.edu.co ',
(String with: Character cr),
(String with: Character cr),
'For further details and versions go to:',
(String with: Character cr),
(String with: Character cr),
'http://mutabit.com/grafoscopio'
title: 'About Grafoscopio'.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> messageNotImplementedYet [
"Shows that a feature is not implemeted and point to further documentation on the web"
UIManager default abort:
'Esta funcionalidad aún no está implementada!',
(String with: Character cr),
'Para información sobre futuras versiones, por favor visite: ',
(String with: Character cr),
(String with: Character cr),
'http://mutabit.com/grafoscopio',
(String with: Character cr),
(String with: Character cr)
title: 'No implementado aún'.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> open [
^ self new open
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openHelpInHtml [
"Launches the help manual in PDF format in an external viewer."
| htmlHelpFileLocation |
htmlHelpFileLocation := (FileSystem disk workingDirectory parent / 'Docs/Es/Manual/manual-grafoscopio.html') fullName.
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'xdg-open ', htmlHelpFileLocation.
].
Smalltalk platform name = 'Win32'
ifTrue: [
OSProcess command: 'explorer ', htmlHelpFileLocation.
].
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openHelpInPdf [
"Launches the help manual in PDF format in an external viewer."
| pdfHelpFileLocation |
pdfHelpFileLocation := (FileSystem disk workingDirectory parent / 'Docs/Es/Manual/manual-grafoscopio.pdf') fullName.
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'xdg-open ', pdfHelpFileLocation.
].
Smalltalk platform name = 'Win32'
ifTrue: [
OSProcess command: 'explorer ', pdfHelpFileLocation.
].
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> startDockingBar [
"Creates a custom docking bar for grafoscopio on top, with shorcuts for most used actions, and a fixed place for asking for help.
Some of the functionalities implemented now in the grafoscopio interface for document trees should be moved here, like the ones
related with help, external tools and grafoscopio updates and about"
| launchMenu helpMenu updateMenu |
launchMenu := MenuMorph new.
launchMenu
add: 'Documento interactivo nuevo' target: GrafoscopioBrowser action: #open;
add: 'Documentos interactivos recientes' target: GrafoscopioBrowser action: #messageNotImplementedYet;
add: 'Documentos interactivos de ejemplo' target: GrafoscopioBrowser action: #messageNotImplementedYet;
add: 'Ejemplos de visualizaciones en Roassal' target: (RTExampleBrowser new) action: #open;
add: 'Playground' target: (Smalltalk tools) action: #openWorkspace.
updateMenu := MenuMorph new.
updateMenu
add: 'Documentación' target: GrafoscopioBrowser action: #messageNotImplementedYet;
add: 'Grafoscopio' target: GrafoscopioBrowser action: #updateGrafoscopio;
add: 'Interface Gráfica' target: GrafoscopioBrowser action: #updateUI;
add: 'Prerrequisitos' target: GrafoscopioBrowser action: #updatePrerrequisites;
add: 'Herramientas externas' target: GrafoscopioBrowser action: #messageNotImplementedYet;
add: 'Ruta a pandoc' target: GrafoscopioBrowser action: #configurePandoc;
add: 'Ruta a fossil' target: GrafoscopioBrowser action: #configureFossil;
add: 'Todo el sistema' target: GrafoscopioBrowser action: #updateSystem.
helpMenu := MenuMorph new.
helpMenu
add: 'Manual en PDF' target: GrafoscopioBrowser action: #openHelpInPdf;
add: 'Manual en HTML' target: GrafoscopioBrowser action: #openHelpInHtml;
add: 'Manual en grafoscopio' target: (GrafoscopioBrowser new) action: #openHelpInGrafoscopio;
add: 'Ir a la documentación en línea' target: GrafoscopioBrowser action: #messageNotImplementedYet;
add: 'Acerca de Grafoscopio' target: GrafoscopioBrowser action: #messageAbout.
dockingBar := DockingBarMorph new.
dockingBar
add: 'Lanzar' subMenu: launchMenu;
add: 'Actualizar' subMenu: updateMenu;
add: 'Ayuda' subMenu: helpMenu.
dockingBar
adhereToTop;
openInWorld.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateGrafoscopio [
"Updates Grafoscopio with new versions of itself take from the source code repository"
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio';
load.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updatePrerrequisites [
"Updates the system with new versions of itself take from the source code repository"
Gofer new
smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON';
package: 'STON-Core';
load.
Gofer new
squeaksource: 'Citezen';
package: 'ConfigurationOfCitezen';
load.
(ConfigurationOfCitezen project latestVersion: #development) load.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateSystem [
"Updates the system with new versions of itself take from the source code repository"
Gofer new
smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON';
package: 'STON-Core';
load.
Gofer new squeaksource: 'Citezen';
package: 'ConfigurationOfCitezen';
load.
(ConfigurationOfCitezen project latestVersion: #development) load.
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio';
load.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateUI [
"Updates the User Interface (UI) with new versions of the docking bar or logos where available. Helpful while testing new functionality
that should be expossed to the user via the UI"
dockingBar delete.
self startDockingBar.
]
{ #category : #persistence }
GrafoscopioBrowser >> addFileToRepository [
"Adds a selected file to a defined repository."
| fileStream fileToAdd |
self buildBrowser.
fileStream := UITheme builder
fileOpen: 'Elija un archivo para agregar al repositorio'.
fileStream isNil ifTrue: [ ^nil ].
fileToAdd := fileStream fullName.
OSProcess command:
'cd ', localRepository parent fullName, '; ',
fossil, ' add ', fileToAdd, '; ',
'echo "Added file to enabled repository"'.
]
{ #category : #tags }
GrafoscopioBrowser >> addTagTo: aNode [
"Tags the node passed as argument with a value from the collection of tags available"
| selection |
tagsAvailable isNil
ifFalse: [
selection := UIManager default chooseFrom: tagsAvailable title: 'Elija una etiqueta'.
aNode tagAs: (tagsAvailable at: selection)
]
ifTrue: [self messageNoTagsAvailable].
browser update.
]
{ #category : #tags }
GrafoscopioBrowser >> addToTagsAvailable [
"Adds a tag to the collection of tags available"
| tag |
tagsAvailable isNil
ifTrue: [tagsAvailable := OrderedCollection new].
tag := UIManager default
textEntry: 'Nombre de la etiqueta'
title: 'Agregue una etiqueta'.
tagsAvailable add: tag.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyForCodeIn: constructor for: aNode [
"Shows the body in a constructor for selected node, if node is not tagged. If it is tagged it will return itself, so it can be rendered
properly for other messages"
| innerBrowser |
aNode tags = 'código'
ifFalse: [^self].
innerBrowser := GTPlayground new.
constructor custom: innerBrowser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyForTransmediaIn: constructor for: aNode [
"Shows the body of a transmedia type of nodes, which are tagged as 'original' and 'transmediado'"
aNode tags = 'original'
ifFalse: [^self ]
ifTrue: [constructor custom: (self panelTransmediaFor: aNode)]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyForTransmediaOn: constructor [
"Shows the body of a transmedia type of node"
constructor custom: self panelBrowserForTransmediaton.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyIn: constructor [
"Shows the body of a selected node"
(constructor text)
title: 'Texto ';
format:[:eachNode |
(eachNode body) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode body]].
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyIn: constructor for: aNode [
"Shows the body in a constructor for selected node, if node is not tagged. If it is tagged it will return itself, so it can be rendered
properly for other messages"
| specialTags |
specialTags := #('código' 'original').
(specialTags includes: aNode tags)
ifTrue: [^self ].
(constructor text)
title: 'Texto ';
format:[
aNode body isNil
ifTrue: [ '' ]
ifFalse: [ aNode body]].
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> browser [
"Returns de browser object, which represents the graphical interface. Useful for debugging purposes"
^ browser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowser [
"Main method for building the interface for trees and its nodes"
browser := GLMTabulator new
title: ' | Grafoscopio'.
browser
column: [:c |
c row: #tree span: 6;
row: #nodeHeader span: 1] span: 2;
column: [ :c |
c row: #nodeBody span: 2] span: 5.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
"Creating a self updateable body pane"
(browser transmit)
to: #nodeBody;
from: #tree;
andShow: [ :a | self bodyIn: a].
(browser transmit )
from: #tree port: #selection;
from: #nodeBody port: #text;
when: [:node :text | text notNil];
to: #nodeBody port: #neverland;
transformed: [:node :text | node body: text asString].
(browser transmit)
from: #tree;
to: #nodeHeader;
andShow: [ :h | self headerOn: h ].
(browser transmit )
from: #tree port: #selection;
from: #nodeHeader port: #text;
when: [:node :text | text notNil];
to: #nodeHeader port: #neverland1;
transformed: [:node :text | node header: text asString]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowserLandscape [
browser := GLMTabulator new
title: 'Grafoscopio'.
browser
column: #original span: 3;
column: #transmediado span: 3.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowserNamed: aName [
"Main method for building the interface for trees and its nodes. The name of the browser corresponds to the name of the file
where tree is stored (or is named 'draft.ston' by default)"
self configureInitialTags.
browser := GLMTabulator new
title: aName, ' | Grafoscopio'.
browser
column: [:c |
c row: #tree span: 6;
row: #nodeHeader span: 1] span: 2;
column: [ :c |
c row: #nodeBody span: 2] span: 5.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
"Creating a self updatable body pane"
(browser transmit)
from: #tree port: #selection;
to: #nodeBody;
when: [:selection | selection notNil];
andShow: [ :a :node |
self bodyIn: a for: node.
self bodyForCodeIn: a for: node.
self bodyForTransmediaIn: a for: node ].
(browser transmit )
from: #tree port: #selection;
from: #nodeBody port: #text;
when: [:node :text | text notNil & node notNil];
to: #nodeBody port: #neverland;
transformed: [:node :content |
node tags = 'código'
ifFalse: [node body: content asString]
ifTrue: [node body: content]].
(browser transmit)
from: #tree;
to: #nodeHeader;
andShow: [ :h | self headerOn: h ].
(browser transmit )
from: #tree port: #selection;
from: #nodeHeader port: #text;
to: #nodeHeader port: #neverland1;
when: [:node :text | text notNil & node notNil];
transformed: [:node :text | node header: text asString]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowserNamed: aName inMode: aModeName [
"Main method for building the interface for trees and its nodes. The name of the browser corresponds to the name of the file
where tree is stored (or is named 'draft.ston' by default). The name of the mode correspond to a way of showing and dealing with
the data.
The idea is to support several modes in the future, starting with the 'Transmediaton' mode and adding more as needed."
self configureInitialTags.
browser := GLMTabulator new
title: aName, ' | Grafoscopio'.
browser
column: [:c |
c row: #tree span: 6;
row: #nodeHeader span: 1] span: 2;
column: [ :c |
c row: #nodeBody span: 2] span: 5.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
"Creating a self updatable body pane"
(browser transmit)
to: #nodeBody;
from: #tree;
andShow: [ :a |
(aModeName = 'transmedia')
ifTrue: [self bodyForTransmediaOn: a]].
(browser transmit )
from: #tree port: #selection;
from: #nodeBody port: #text;
when: [:node :text | text notNil];
to: #nodeBody port: #neverland;
transformed: [:node :text | node body: text asString].
(browser transmit)
from: #tree;
to: #nodeHeader;
andShow: [ :h | self headerOn: h ].
(browser transmit )
from: #tree port: #selection;
from: #nodeHeader port: #text;
when: [:node :text | text notNil];
to: #nodeHeader port: #neverland1;
transformed: [:node :text | node header: text asString]
]
{ #category : #'system-support' }
GrafoscopioBrowser >> configureInitialTags [
"Configures a list of predefined tags available to use. More tags should be added from a repository.
The idea is that nodes are processed and show differently according to their tags. So users should be
able to define their own tags with custom UI and behaviour"
tagsAvailable := OrderedCollection new.
tagsAvailable
add: 'código';
add: 'ejercicio';
add: 'invisible';
add: 'obra';
add: 'original';
add: 'transmediado'.
]
{ #category : #persistence }
GrafoscopioBrowser >> copyNodeIntoCache: aNode [
"Copy the contents of the current node into cacheNode. It doesn't work recursively yet, so it doen't copy the children of the nodes"
cacheNode := GrafoscopioNode new.
cacheNode header: (aNode header).
cacheNode body: (aNode body).
self inform: 'Nodo copiado: ', aNode header
]
{ #category : #bibliography }
GrafoscopioBrowser >> customKeys [
"Replaces the default key in a BibTeX file for a custom key taken from the 'shorttitle' field.
Useful when autogenerated BibTeX has cryptic or non easy to memorize keys (for example in some
Zotero exports)"
| bibFile bibliography bibStream bibOutputer |
bibFile := ((workingFile parent) children
detect: [:each | each basename endsWith: 'bib' ] ifNone: [ ]).
bibFile ifNotNil: [
bibliography := CZBibParser parse: bibFile contents.
bibStream := '' writeStream.
(bibliography entries) do: [:bibItem |
bibItem fields do: [:some | some key = 'shorttitle'
ifTrue: [ bibItem key: some value ]].
bibOutputer := CZBibtexOutputer new.
bibStream nextPutAll:
(bibOutputer entryToBibtexString: bibItem); cr].
bibFile writeStreamDo: [:stream |
stream nextPutAll: bibStream contents withUnixLineEndings ]].
]
{ #category : #persistence }
GrafoscopioBrowser >> defineRemoteRepository [
"Defines a remote fossil repository from an url"
"| temporary variable names |
statements"
]
{ #category : #persistence }
GrafoscopioBrowser >> enableRepository [
"Just a temporary message to enable working with fossil on a specific repository. This should be generalized"
| repositoryLocalPath repositoryRemotePath |
(FileSystem disk workingDirectory / 'Grafoscopio' / 'Projects' / 'SoftwareLibre-Educacion') ensureCreateDirectory.
repositoryLocalPath := (FileSystem disk workingDirectory / 'Grafoscopio' / 'Projects' / 'SoftwareLibre-Educacion') fullName.
repositoryRemotePath := 'http://mutabit.com/deltas/repos.fossil/soliedu'.
OSProcess command: 'cd ', repositoryLocalPath,'; ',
fossil, ' clone ', repositoryRemotePath, ' soliedu.fossil; ',
fossil, ' open ', repositoryLocalPath, '/soliedu.fossil ;',
' echo "fossil repo OK"'.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsHtml [
"Exports the current tree to HTML, using the same name but different extension (.html)"
| markdownFileLocation htmlFileLocation |
markdownFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.markdown'.
htmlFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.html'.
pandoc notNil
ifTrue:[
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'exec ', pandoc, ' ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation.
OSProcess command: 'exec echo "exportando como html"'.
self inform: 'Archivo exportado como html en: ', htmlFileLocation.
self inform: pandoc].
Smalltalk platform name = 'Win32'
ifTrue: [ OSProcess command: pandoc, ' ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation ]]
ifFalse: [GrafoscopioBrowser configurePandoc ].
self customKeys.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsMarkdown: aTree on: locator [
locator writeStreamDo: [:stream | stream nextPutAll: aTree asMarkdown]
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsPdf [
"Exports the current tree to HTML, using the same name but different extension (.pdf).
IMPORTANT: The user needs to have installed TeX to create the pdf."
| markdownFileLocation pdfFileLocation |
markdownFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.markdown'.
pdfFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.pdf'.
pandoc notNil
ifTrue:[
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'exec ', pandoc, ' ', markdownFileLocation , ' -o ' , pdfFileLocation.
OSProcess command: 'exec echo "exportando como pdf"'.
self inform: 'Archivo exportado como pdf en: ', pdfFileLocation.].
Smalltalk platform name = 'Win32'
ifTrue: [ OSProcess command: pandoc, ' ', markdownFileLocation , ' -o ' , pdfFileLocation ]]
ifFalse: [GrafoscopioBrowser configurePandoc ].
self customKeys.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsSton: aTree on: locator [
locator nextPutAll: (STON toStringPretty: aTree children)
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> headerOn: constructor [
"Shows the body of a selected node"
(constructor text)
title: 'Cabecera ';
format:[:eachNode |
(eachNode header) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode header]].
]
{ #category : #'system-support' }
GrafoscopioBrowser >> installPandoc [
"Installs pandoc binary for each major platform: Linux, Windows, Mac"
| linuxSupplies |
linuxSupplies := (FileSystem disk workingDirectory
/ 'Platform' / 'Linux' / 'Programs' / 'Pandoc')
ensureCreateDirectory.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> messageNoTagsAvailable [
"Shows that there is no tags available and the procedure to add some tags"
UIManager default
abort:
'Use primero el menu:',
(String with: Character cr),
'"Etiquetas > Agregar a disponibles"',
(String with: Character cr),
'para agregar etiquetas y luego sí agregue etiquetas al nodo'
title: 'Sin etiquetas disponibles!'
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> messageNotImplementedYet [
"Shows that a feature is not implemeted and point to further documentation on the web"
UIManager default abort:
'Esta funcionalidad aún no está implementada!',
(String with: Character cr),
'Para información sobre futuras versiones, por favor visite: ',
(String with: Character cr),
(String with: Character cr),
'http://mutabit.com/grafoscopio',
(String with: Character cr),
(String with: Character cr)
title: 'No implementado aún'.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> open [
"Opens a new browser with a default tree and assigns a default draft file for storing it.
This is changed when the file is saved with the 'Save as' menu option"
| draftsLocation |
"self configureSettings."
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'.
draftsLocation ensureCreateDirectory.
workingFile := draftsLocation / 'draft.ston'.
self buildBrowserNamed: workingFile basenameWithIndicator.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openDefault [
"Opens a new browser with a default tree"
GrafoscopioBrowser configureSettings.
self buildBrowser.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openFromFile: aFileName [
"Opens a tree from a file named aFileName"
| currentChildren |
GrafoscopioBrowser configureSettings.
aFileName isNil ifTrue: [ ^nil ].
workingFile := aFileName name asFileReference.
currentChildren := (STON fromString: aFileName contents).
self buildBrowserNamed: aFileName basenameWithIndicator.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openFromFile: aFileName inMode: aModeName [
"Opens a tree from a file named aFileName"
| currentChildren |
GrafoscopioBrowser configureSettings.
aFileName isNil ifTrue: [ ^nil ].
workingFile := aFileName name asFileReference.
currentChildren := (STON fromString: aFileName contents).
self buildBrowserNamed: aFileName basenameWithIndicator inMode: aModeName.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openFromFileSelector [
"Opens a tree from a file by using the file selector GUI."
| fileStream currentChildren |
GrafoscopioBrowser configureSettings.
fileStream := UITheme builder
fileOpen: 'Elija un archivo .ston'
extensions: #('ston').
fileStream isNil ifTrue: [ ^nil ].
workingFile := fileStream name asFileReference.
currentChildren := (STON fromStream: fileStream).
self buildBrowserNamed: workingFile basenameWithIndicator.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openHelpInGrafoscopio [
"Opens the help tree from a file"
| currentChildren |
GrafoscopioBrowser configureSettings.
workingFile := (FileSystem disk workingDirectory parent / 'Docs' / 'Es' / 'Manual' / 'manual-grafoscopio.ston') asFileReference.
currentChildren := (STON fromString: workingFile contents).
self buildBrowserNamed: workingFile basenameWithIndicator.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser >> openLandscape [
"Opens a new browser with a default tree in landscape mode"
self buildBrowserLandscape.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openLast [
"Opens a new browser with a fixed 'last' working tree. May be this should be changed"
| workingFile currentChildren| "workingChildren would sound too cruel!"
self buildBrowser.
workingFile := '/home/offray/Documentos/U/Libertadores/Grafoscopio/bootstrapping-objeto-investigacion.ston' asFileReference readStream.
currentChildren := (STON fromStream: workingFile).
mainTree := GrafoscopioNode new
header: 'Bootstrapping the research object';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openWorking [
"Opens a new browser with the last working tree"
self buildBrowser.
mainTree := '/home/offray/Documentos/U/Libertadores/Grafoscopio/bootstrapping-objeto-investigacion.ston' asFileReference readStream.
browser openOn: mainTree children.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> panelAsCodeFor: aNode [
"Shows an interactive playground for Smalltalk code in a node body"
browser := GLMTabulator new.
browser title: 'Código'.
browser column: #code.
browser transmit
to: #code;
transformed: [ GTPlayPage new content: aNode body ];
andShow: [ :a | a custom: GTPlayground new ].
browser sendToOutside: #nodeBody from: #code -> #text.
^ browser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> panelBrowserForTransmediaton [
"**Experimental feature.**
Opens grafoscopio in several 'modes'. Each mode corresponds to a operation way, with an specific interface.
We will start with a 'transmediaton' mode to let the people create some transmedia content.
After that we will enable other modes"
| transmediaNode originalNode |
browser := GLMTabulator new.
browser
column: [ :c |
c row: [ :r | r column: #original; column: #transmediado] span: 7";
row: #buttons; span: 1"].
(browser transmit)
to: #original;
andShow: [ :a |
a text
title: 'Original';
format:[:eachNode |
(eachNode tags) = 'original'
ifFalse: [ '' ]
ifTrue: [
originalNode := eachNode.
originalNode children isNotNil
ifTrue: [transmediaNode := originalNode children detect: [:node | node tags = 'transmediado'] ifNone: [ transmediaNode := nil ] ].
originalNode body]]].
(browser transmit)
from: #original;
toOutsidePort: #text.
(browser transmit)
to: #transmediado;
andShow: [ :a |
a text
title: 'Transmediado';
format:[transmediaNode isNotNil
ifFalse: [ '' ]
ifTrue: [transmediaNode body]
]
].
" (browser transmit)
to: #buttons;
andShow: [ :a |
a actionList
act: [:entity | entity inspect ] entitled: 'Subir';
act: [:entity | entity explore ] entitled: 'Previsualizar';
act: [:entity | entity explore ] entitled: 'Publicar'].
"
^ browser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> panelTransmediaFor: aNode [
"**Experimental feature.**
Opens grafoscopio in several 'modes'. Each mode corresponds to a operation way, with an specific interface.
We will start with a 'transmediaton' mode to let the people create some transmedia content.
After that we will enable other modes"
| transmediaNode originalNode |
browser := GLMTabulator new.
browser
column: [ :c |
c row: [ :r | r column: #original; column: #transmediado] span: 7";
row: #buttons; span: 1"].
originalNode := aNode.
originalNode children isNotNil
ifTrue: [transmediaNode := originalNode children detect: [:node | node tags = 'transmediado'] ifNone: [ transmediaNode := nil ] ].
(browser transmit)
to: #original;
andShow: [ :a |
a text
title: 'Original';
format:[ aNode body isNil
ifTrue: [ '' ]
ifFalse: [ aNode body ]
]].
(browser transmit)
from: #original;
toOutsidePort: #text.
(browser transmit)
to: #transmediado;
andShow: [ :a |
a text
title: 'Transmediado';
format:[transmediaNode isNotNil
ifFalse: [ '' ]
ifTrue: [transmediaNode body]
]
].
" (browser transmit)
to: #buttons;
andShow: [ :a |
a actionList
act: [:entity | entity inspect ] entitled: 'Subir';
act: [:entity | entity explore ] entitled: 'Previsualizar';
act: [:entity | entity explore ] entitled: 'Publicar'].
"
^ browser.
]
{ #category : #persistence }
GrafoscopioBrowser >> replaceContentsFromCache: aNode [
"Replaces the contents of aNode from the ones in cacheNode. It doesn't work recursively yet, so it doen't copy the children of the nodes"
cacheNode notNil
ifTrue: [
aNode header: cacheNode header.
aNode body: cacheNode body.
self inform: 'Contenidos reemplazados']
ifFalse: [self inform: 'El nodo cache está vacio']
]
{ #category : #persistence }
GrafoscopioBrowser >> repositoryCommit [
"Commits current changes to the open repository"
fossil notNil ifTrue: [
OSProcess command:
'cd ', localRepository parent fullName, '; ',
fossil, ' commit -m "" --no-warnings; ',
'echo "Commited changes to the repository"'. ]
]
{ #category : #persistence }
GrafoscopioBrowser >> repositoryCredentials [
"Asks for the user credentials of the current project repository"
repositoryUser := UIManager default request: 'Ingrese su usuario en el repositorio del proyecto'.
repositoryPassword := UIManager default request: 'Ingrese su contraseña en el repositorio del proyecto'.
]
{ #category : #persistence }
GrafoscopioBrowser >> saveToFile [
"Saves the current tree to a file"
| file writeStream markdownFile |
file := UITheme builder
fileSave: 'Guardar archivo como...'
extensions: #('ston')
path: nil.
file ifNil: [ self inform: 'Exportación cancelada'. ^ self ].
writeStream := file writeStream.
workingFile := writeStream name asFileReference.
markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown').
[ self exportAsSton: mainTree on: writeStream.
self exportAsMarkdown: mainTree on: markdownFile ]
ensure: [ writeStream ifNotNil: #close ].
browser update.
]
{ #category : #persistence }
GrafoscopioBrowser >> saveWorkingTree [
"Saves the current tree to the user predefined file location used when he/she opened it."
| fileStream markdownFile |
fileStream := workingFile writeStream.
markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown').
[ self exportAsSton: mainTree on: fileStream.
self exportAsMarkdown: mainTree on: markdownFile ]
ensure: [ fileStream ifNotNil: #close.].
"self customKeys."
self inform: 'Archivo guardado como: ', workingFile asString.
]
{ #category : #tags }
GrafoscopioBrowser >> showTagsAvailable [
"Adds a tag to the collection of tags available"
tagsAvailable isNil
ifTrue: [self messageNoTagsAvailable]
ifFalse: [self messageNotImplementedYet]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> treeOn: constructor [
"Shows the correspondent tree of a node"
(constructor tree) "Layout"
title: mainTree header;
children: [ :eachNode |
(eachNode children) isNil
ifTrue: [ self inform: 'Seleccione un nodo para ver su contenido' ]
ifFalse:[ eachNode children ] ];
format:[:eachNode |
(eachNode header) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode header ]];
tags: [:eachNode |
(eachNode tags) isNil
ifFalse: [ (eachNode tags) asSymbol ]
ifTrue: [ #() ] ];
"Nodes Toolbar
=============="
"Adding nodes"
act: [:treePresentation |
(treePresentation selection) isNotNil
ifTrue: [treePresentation selection addNodeAfter].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousZoomIn
entitled: 'Adicionar nodo';
"Removing nodes"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [(treePresentation selection parent)
removeNode: treePresentation selection]
ifFalse: [treePresentation entity removeLast].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousZoomOut
entitled: 'Remover nodo';
"Move nodes in the same hierarchy"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection moveBefore].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousUp
entitled: 'Mover nodo hacia arriba';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection moveAfter].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousDown
entitled: 'Mover nodo hacia abajo';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection promote].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousLeft
entitled: 'Mover nodo hacia la izquierda';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection demote].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousRight
entitled: 'Mover nodo hacia la derecha';
act: [ :treePresentation | treePresentation update ]
icon: GLMUIThemeExtraIcons glamorousRefresh
entitled: 'Actualizar vista del árbol';
act: [self saveWorkingTree]
icon: GLMUIThemeExtraIcons glamorousSave
entitled: 'Guardar árbol';
"Options Menu
============="
"For trees"
act: [GrafoscopioBrowser open] entitled: 'Nuevo ...' categorized: 'Arbol';
act: [GrafoscopioBrowser new openFromFileSelector] entitled: 'Abrir/Cargar ...' categorized: 'Arbol';
act: [self saveToFile] entitled: 'Guardar como ...' categorized: 'Arbol';
act: [self saveWorkingTree; exportAsHtml] entitled: 'Exportar como HTML' categorized: 'Arbol';
act: [self saveWorkingTree; exportAsPdf] entitled: 'Exportar como PDF (requiere LaTeX)' categorized: 'Arbol';
act: [self messageNotImplementedYet] entitled: 'Ver HTML' categorized: 'Arbol';
act: [self messageNotImplementedYet] entitled: 'Ver PDF' categorized: 'Arbol';
"For nodes"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self copyNodeIntoCache: treePresentation selection].
treePresentation update] entitled: 'Copiar nodo' categorized: 'Nodo';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self replaceContentsFromCache: treePresentation selection].
treePresentation update] entitled: 'Pegar nodo' categorized: 'Nodo';
"For tags"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self addTagTo: treePresentation selection]]
entitled: 'Etiquetar nodo como...' categorized: 'Etiquetas';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [
treePresentation selection tagAs: nil.
browser update.
]]
entitled: 'Desetiquetar nodo como...' categorized: 'Etiquetas';
act: [self showTagsAvailable] entitled: 'Ver disponibles' categorized: 'Etiquetas';
act: [self addToTagsAvailable] entitled: 'Agregar a disponibles' categorized: 'Etiquetas';
"For projects"
act: [self messageNotImplementedYet "enableRepository"] entitled: 'Activar' categorized: 'Proyecto';
act: [self messageNotImplementedYet "addFileToRepository"] entitled: 'Agregar archivo' categorized: 'Proyecto';
act: [self messageNotImplementedYet] entitled: 'Eliminar archivo' categorized: 'Proyecto';
act: [self messageNotImplementedYet "repositoryCommit"] entitled: 'Enviar al histórico' categorized: 'Proyecto';
act: [self messageNotImplementedYet "repositoryCredentials"] entitled: 'Acreditarse' categorized: 'Proyecto'.
]