Reorganizing protocols.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-06-28 16:22:00 +00:00
parent 24f32911b2
commit 1597d9ece5
4 changed files with 323 additions and 282 deletions

View File

@ -29,71 +29,6 @@ Class {
#category : #'Grafoscopio-UI'
}
{ #category : #updating }
GrafoscopioBrowser class >> docDataManual [
"I define some metadata associated to the manual document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'manual'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Manual/'
with: 'filename' -> 'manual-grafoscopio.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioBrowser class >> docDataTutorial [
"I define some metadata associated to the tutorial document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'tutorial'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Tutoriales/'
with: 'filename' -> 'tutorial.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioBrowser class >> docDownloadFor: aDocumentType [
"I download the interactive documentation in STON format, according to the document
type which can be: 'tutorial' or 'manual'.
If a the documentation is already present in the system I made a temporal backup and
download a new copy"
| docInfo rootFolder localDoc temporalBackup remoteDoc |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
rootFolder := (FileLocator documents asFileReference / 'Grafoscopio').
rootFolder exists ifFalse: [
rootFolder ensureCreateDirectory.
OSProcess command: ('exec mkdir -p ', rootFolder fullName, '/', (docInfo at: 'relativePath'))
].
localDoc := rootFolder fullName, '/', (docInfo at: 'relativePath'), (docInfo at: 'filename').
temporalBackup := rootFolder fullName, '/', (docInfo at: 'relativePath'), aDocumentType, '.temp.ston'.
remoteDoc :=
(self docDataTutorial at: 'remoteRepo'), 'doc/tip/',
(self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
localDoc asFileReference exists
ifTrue: [
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
localDoc asFileReference renameTo: aDocumentType, '.temp.ston'
].
self
downloadingFrom: remoteDoc
withMessage: 'Actualizando el ', aDocumentType,'...'
into: (rootFolder fullName, '/', (docInfo at: 'relativePath')).
]
{ #category : #'graphical interface' }
GrafoscopioBrowser class >> downloadingFrom: downloadUrl withMessage: aString into: location [
@ -112,32 +47,6 @@ GrafoscopioBrowser class >> downloadingFrom: downloadUrl withMessage: aString in
] asJob run.
]
{ #category : #updating }
GrafoscopioBrowser class >> isDocUpdatedFor: aDocumentType [
"I compare the cryptografic signatures of the local copy of aDocumentType and the remote one to see if the're the same,
in which case I return True or False in any other cases.
aDocumentType is a string that can be 'tutorial' or 'manual' according to the type of document we're querying for.
Now documentation is mainly on Spanish. When support for multiple languages be enabled this method needs revision"
| folderLastContents lastRemoteTutorial localTutorial docInfo |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
localTutorial := FileLocator documents / 'Grafoscopio', (docInfo at: 'relativePath'), (docInfo at: 'filename').
localTutorial exists
ifFalse: [
self docDownloadFor: 'tutorial'.
^ true.
]
ifTrue: [
folderLastContents := NeoJSONReader fromString:
(ZnEasy get: (docInfo at: 'remoteRepo'), 'json/dir?ci=tip&name=', (docInfo at: 'relativePath')) contents.
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
detect: [:entry | (entry at: 'name') = (docInfo at: 'filename') ].
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser class >> messageAbout [
"Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web"
@ -275,186 +184,6 @@ GrafoscopioBrowser class >> showSettings [
Transcript show: pandoc
]
{ #category : #updating }
GrafoscopioBrowser class >> updateDataviz [
"I'm update the Dataviz package with new versions of itself take from the source code repository.
DataViz contains Data visualization helpers"
Gofer it
smalltalkhubUser: 'Offray' project: 'Dataviz';
configurationOf: 'Dataviz';
loadVersion: #development.
self inform: 'Actualización del paquete Dataviz terminada'
]
{ #category : #updating }
GrafoscopioBrowser class >> updateDatavizUI [
"I'm the User Interface for updating the Dataviz package with new versions of itself take from the source code repository"
| update |
update := (UIManager default
question: 'Dataviz es un paquete de visualización de datos'
title: 'Actualizar paquete Dataviz').
update ifNotNil: [
update
ifTrue: [self updateDataviz]
ifFalse: [self inform: 'Actualización del paquete dataviz no realizada']]
]
{ #category : #updating }
GrafoscopioBrowser class >> updateDocumentation [
"Updates documentation (manual, tutorials) from official repository"
| docs |
docs := #('tutorial' 'manual').
docs do: [ :eachDoc |
(self isDocUpdatedFor: eachDoc)
ifFalse: [ self docDownloadFor: eachDoc]
ifTrue: [
self inform:
'NADA QUE ACTUALIZAR!', String cr,
'El ', eachDoc,' ya se encuentra en su versión más reciente.'
]
]
]
{ #category : #updating }
GrafoscopioBrowser class >> updateDocumentationUI [
"Updates documentation (manual, tutorials) from official repository"
| update |
update := (UIManager default
confirm: '¿Desea actualizar la documentación?'
label: 'Actualizar documentación').
update ifTrue: [self updateDocumentation]
]
{ #category : #updating }
GrafoscopioBrowser class >> updateGrafoscopio [
"Updates Grafoscopio with new versions of itself take from the source code repository and
the User Interface"
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio';
load.
self updateUI.
]
{ #category : #updating }
GrafoscopioBrowser class >> updateGrafoscopioUI [
"Updates Grafoscopio with new versions of itself take from the source code repository and
the User Interface"
| update |
update := (UIManager default
question: '¿Desea actualizar grafoscopio?'
title: 'Actualizar grafoscopio').
update ifNotNil: [
update
ifTrue: [
self updateGrafoscopio.
self inform: 'Actualización de grafoscopio terminada']
ifFalse: [self inform: 'Actualización de grafoscopio no realizada']]
]
{ #category : #updating }
GrafoscopioBrowser class >> updatePrerrequisitesScript [
"Updates the system prerequisites with new versions of itself take from the source code repository"
"Visualization library (which also makes main menu loadable)"
Gofer it
smalltalkhubUser: 'ObjectProfile' project: 'Roassal2';
configurationOf: 'Roassal2';
loadStable.
"Support for the STON format used in file persistance for grafoscopio notebooks"
Gofer new
smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON';
configurationOf: 'Ston';
loadBleedingEdge.
"Moose and Roassal integration"
Gofer new
smalltalkhubUser: 'Moose' project: 'Glamour';
package: 'Glamour-Tools';
package: 'Glamour-Roassal2-Presentations';
load.
Gofer new
smalltalkhubUser: 'Moose' project: 'GToolkit';
package: 'GT-InspectorExtensions-CoreRoassal';
load.
"Fast Table support"
Gofer it
smalltalkhubUser: 'estebanlm' project: 'FastTable';
package: 'FastTable';
load.
"Integration with external tools"
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio-ExternalTools';
load.
"HTML scrapping"
Gofer new
smalltalkhubUser: 'PharoExtras' project: 'Soup';
configurationOf: 'Soup';
loadStable.
"SQLite support"
Gofer new
url: 'http://smalltalkhub.com/mc/PharoExtras/NBSQLite3/main';
package: 'NBSQLite3';
load.
Gofer new
url: 'http://smalltalkhub.com/mc/PharoExtras/NBSQLite3/main';
package: 'NBSQLite3-Examples';
load.
"Support for Operative System integration"
Gofer new
squeaksource: 'OSProcess';
package: 'OSProcess';
load.
Gofer new
squeaksource: 'CommandShell';
package: 'CommandShell-Piping';
load.
"Bibliographic support"
Gofer new
squeaksource: 'Citezen';
package: 'ConfigurationOfCitezen';
load.
]
{ #category : #updating }
GrafoscopioBrowser class >> updateSystem [
"Updates the system with new versions of itself take from the source code repository"
| update |
update := (UIManager default
question: '¿Desea actualizar grafoscopio?'
title: 'Actualizar grafoscopio').
update ifNotNil: [
update
ifFalse: [ self inform: 'Actualización de todo el sistema NO realizada.' ]
ifTrue: [
self
updateGrafoscopio;
updateDocumentation;
updateDataviz.
ExternalApp installSQLite32Bits.
self inform: 'Actualización de todo el sistema terminada.']
]
]
{ #category : #updating }
GrafoscopioBrowser class >> updateUI [
"I update the User Interface (UI) with new versions of the docking bar or logos where available.

View File

@ -1,9 +1,9 @@
"
Please comment me using the following template inspired by Class Responsibility Collaborator (CRC) design:
I'm the Graphical User Interface for Grafoscopio environment.
I'm the graphical user interface for grafoscopio. I'm using Spec.
My main responsability is to provide grafoscopio with graphical widgets and other elements to manipulate grafoscopio trees, helping with common task of storing, opening and manipulating trees.
My main responsability is to provide grafoscopio with a docking bar
with menu options for open, browse notebooks, update the system
and its components and the help menu.
"
Class {
@ -13,15 +13,15 @@ Class {
'windowMainMenu',
'tree',
'nodeHeader',
'nodeBody',
'headerRefreshProcess',
'selected'
'nodeBody'
],
#classVars : [
'dockingBar'
'dockingBar',
'recentNotebooks'
],
#classInstVars : [
'dockingBar'
'dockingBar',
'recentNotebooks'
],
#category : #'Grafoscopio-UI'
}
@ -52,6 +52,71 @@ GrafoscopioGUI class >> defaultSpec [
yourself
]
{ #category : #updating }
GrafoscopioGUI class >> docDataManual [
"I define some metadata associated to the manual document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'manual'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Manual/'
with: 'filename' -> 'manual-grafoscopio.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioGUI class >> docDataTutorial [
"I define some metadata associated to the tutorial document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'tutorial'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Tutoriales/'
with: 'filename' -> 'tutorial.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioGUI class >> docDownloadFor: aDocumentType [
"I download the interactive documentation in STON format, according to the document
type which can be: 'tutorial' or 'manual'.
If a the documentation is already present in the system I made a temporal backup and
download a new copy"
| docInfo rootFolder localDoc temporalBackup remoteDoc |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
rootFolder := (FileLocator documents asFileReference / 'Grafoscopio').
rootFolder exists ifFalse: [
rootFolder ensureCreateDirectory.
OSProcess command: ('exec mkdir -p ', rootFolder fullName, '/', (docInfo at: 'relativePath'))
].
localDoc := rootFolder fullName, '/', (docInfo at: 'relativePath'), (docInfo at: 'filename').
temporalBackup := rootFolder fullName, '/', (docInfo at: 'relativePath'), aDocumentType, '.temp.ston'.
remoteDoc :=
(self docDataTutorial at: 'remoteRepo'), 'doc/tip/',
(self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
localDoc asFileReference exists
ifTrue: [
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
localDoc asFileReference renameTo: aDocumentType, '.temp.ston'
].
self
downloadingFrom: remoteDoc
withMessage: 'Actualizando el ', aDocumentType,'...'
into: (rootFolder fullName, '/', (docInfo at: 'relativePath')).
]
{ #category : #accessing }
GrafoscopioGUI class >> dockingBar [
^ dockingBar
@ -248,6 +313,42 @@ GrafoscopioGUI class >> initialize [
self startDockingBar.
]
{ #category : #updating }
GrafoscopioGUI class >> isDocUpdatedFor: aDocumentType [
"I compare the cryptografic signatures of the local copy of aDocumentType and the remote one to see if the're the same,
in which case I return True or False in any other cases.
aDocumentType is a string that can be 'tutorial' or 'manual' according to the type of document we're querying for.
Now documentation is mainly on Spanish. When support for multiple languages be enabled this method needs revision"
| folderLastContents lastRemoteTutorial localTutorial docInfo |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
localTutorial := FileLocator documents / 'Grafoscopio', (docInfo at: 'relativePath'), (docInfo at: 'filename').
localTutorial exists
ifFalse: [
self docDownloadFor: 'tutorial'.
^ true.
]
ifTrue: [
folderLastContents := NeoJSONReader fromString:
(ZnEasy get: (docInfo at: 'remoteRepo'), 'json/dir?ci=tip&name=', (docInfo at: 'relativePath')) contents.
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
detect: [:entry | (entry at: 'name') = (docInfo at: 'filename') ].
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex]
]
{ #category : #accessing }
GrafoscopioGUI class >> recentNotebooks [
^ recentNotebooks ifNil: [ ^ OrderedCollection new ]
]
{ #category : #accessing }
GrafoscopioGUI class >> recentNotebooks: anObject [
recentNotebooks := anObject
]
{ #category : #'graphical interface' }
GrafoscopioGUI 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.
@ -295,6 +396,191 @@ GrafoscopioGUI class >> startDockingBar [
openInWorld.
]
{ #category : #updating }
GrafoscopioGUI class >> updateDataviz [
"I'm update the Dataviz package with new versions of itself take from the source code repository.
DataViz contains Data visualization helpers"
Gofer it
smalltalkhubUser: 'Offray' project: 'Dataviz';
configurationOf: 'Dataviz';
loadVersion: #development.
self inform: 'Actualización del paquete Dataviz terminada'
]
{ #category : #updating }
GrafoscopioGUI class >> updateDatavizUI [
"I'm the User Interface for updating the Dataviz package with new versions of itself take from the source code repository"
| update |
update := (UIManager default
question: 'Dataviz es un paquete de visualización de datos'
title: 'Actualizar paquete Dataviz').
update ifNotNil: [
update
ifTrue: [self updateDataviz]
ifFalse: [self inform: 'Actualización del paquete dataviz no realizada']]
]
{ #category : #updating }
GrafoscopioGUI class >> updateDocumentation [
"Updates documentation (manual, tutorials) from official repository"
| docs |
docs := #('tutorial' 'manual').
docs do: [ :eachDoc |
(self isDocUpdatedFor: eachDoc)
ifFalse: [ self docDownloadFor: eachDoc]
ifTrue: [
self inform:
'NADA QUE ACTUALIZAR!', String cr,
'El ', eachDoc,' ya se encuentra en su versión más reciente.'
]
]
]
{ #category : #updating }
GrafoscopioGUI class >> updateDocumentationUI [
"Updates documentation (manual, tutorials) from official repository"
| update |
update := (UIManager default
confirm: '¿Desea actualizar la documentación?'
label: 'Actualizar documentación').
update ifTrue: [self updateDocumentation]
]
{ #category : #updating }
GrafoscopioGUI class >> updateGrafoscopio [
"Updates Grafoscopio with new versions of itself take from the source code repository and
the User Interface"
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio';
load.
self updateUI.
]
{ #category : #updating }
GrafoscopioGUI class >> updateGrafoscopioUI [
"Updates Grafoscopio with new versions of itself take from the source code repository and
the User Interface"
| update |
update := (UIManager default
question: '¿Desea actualizar grafoscopio?'
title: 'Actualizar grafoscopio').
update ifNotNil: [
update
ifTrue: [
self updateGrafoscopio.
self inform: 'Actualización de grafoscopio terminada']
ifFalse: [self inform: 'Actualización de grafoscopio no realizada']]
]
{ #category : #updating }
GrafoscopioGUI class >> updatePrerrequisitesScript [
"Updates the system prerequisites with new versions of itself take from the source code repository"
"Visualization library (which also makes main menu loadable)"
Gofer it
smalltalkhubUser: 'ObjectProfile' project: 'Roassal2';
configurationOf: 'Roassal2';
loadStable.
"Support for the STON format used in file persistance for grafoscopio notebooks"
Gofer new
smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON';
configurationOf: 'Ston';
loadBleedingEdge.
"Moose and Roassal integration"
Gofer new
smalltalkhubUser: 'Moose' project: 'Glamour';
package: 'Glamour-Tools';
package: 'Glamour-Roassal2-Presentations';
load.
Gofer new
smalltalkhubUser: 'Moose' project: 'GToolkit';
package: 'GT-InspectorExtensions-CoreRoassal';
load.
"Fast Table support"
Gofer it
smalltalkhubUser: 'estebanlm' project: 'FastTable';
package: 'FastTable';
load.
"Integration with external tools"
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio-ExternalTools';
load.
"HTML scrapping"
Gofer new
smalltalkhubUser: 'PharoExtras' project: 'Soup';
configurationOf: 'Soup';
loadStable.
"SQLite support"
Gofer new
url: 'http://smalltalkhub.com/mc/PharoExtras/NBSQLite3/main';
package: 'NBSQLite3';
load.
Gofer new
url: 'http://smalltalkhub.com/mc/PharoExtras/NBSQLite3/main';
package: 'NBSQLite3-Examples';
load.
"Support for Operative System integration"
Gofer new
squeaksource: 'OSProcess';
package: 'OSProcess';
load.
Gofer new
squeaksource: 'CommandShell';
package: 'CommandShell-Piping';
load.
"Bibliographic support"
Gofer new
squeaksource: 'Citezen';
package: 'ConfigurationOfCitezen';
load.
]
{ #category : #updating }
GrafoscopioGUI class >> updateRecentNotebooksWith: aFileReference [
self recentNotebooks add: aFileReference.
]
{ #category : #updating }
GrafoscopioGUI class >> updateSystem [
"Updates the system with new versions of itself take from the source code repository"
| update |
update := (UIManager default
question: '¿Desea actualizar grafoscopio?'
title: 'Actualizar grafoscopio').
update ifNotNil: [
update
ifFalse: [ self inform: 'Actualización de todo el sistema NO realizada.' ]
ifTrue: [
self
updateGrafoscopio;
updateDocumentation;
updateDataviz.
ExternalApp installSQLite32Bits.
self inform: 'Actualización de todo el sistema terminada.']
]
]
{ #category : #'graphical interface' }
GrafoscopioGUI class >> updateUI [
"I update the User Interface (UI) with new versions of the docking bar or logos where available.

View File

@ -193,7 +193,7 @@ GrafoscopioNode >> becomeDefaultTree [
self header: 'Arbol principal'.
node1 := GrafoscopioNode
header: 'Nodo 1'
body: 'Texto 1'.
body: ''.
self addNode: node1.
]

View File

@ -259,7 +259,7 @@ GrafoscopioNotebook >> notebookSubMenu [
item
name: 'Save as...';
icon: Smalltalk ui icons smallSaveAsIcon;
action: [ self inform: 'To be implemented...' ] ].
action: [ self saveToFileUI ] ].
group addItem: [ :item |
item
name: 'Export as html';
@ -346,6 +346,32 @@ GrafoscopioNotebook >> projectSubMenu [
]
{ #category : #persistence }
GrafoscopioNotebook >> saveToFile: aFileReference [
"I save the current tree/document to a file"
aFileReference ifNil: [ self inform: 'No file selected for saving. Save NOT done'. ^ self ].
workingFile := aFileReference.
[ self exportAsSton: self notebook on: (self workingFile writeStream) ]
ensure: [(self workingFile writeStream) ifNotNil: #close].
GrafoscopioGUI updateRecentNotebooksWith: aFileReference.
]
{ #category : #persistence }
GrafoscopioNotebook >> saveToFileUI [
| file |
file := UITheme builder
fileSave: 'Export notebook to file as...'
extensions: #('ston')
path: nil.
file
ifNil: [ self inform: 'Export cancelled'. ^ self ]
ifNotNil:[self saveToFile: file].
]
{ #category : #persistence }
GrafoscopioNotebook >> saveWorkingNotebook [
"Saves the current tree to the user predefined file location used when he/she opened it."