Grafoscopio/repository/Grafoscopio/GrafoscopioGUI.class.st

1075 lines
32 KiB
Smalltalk

"
I'm the Graphical User Interface for Grafoscopio environment.
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 {
#name : #GrafoscopioGUI,
#superclass : #DynamicComposableModel,
#instVars : [
'windowMainMenu',
'tree',
'nodeHeader',
'nodeBody'
],
#classVars : [
'dockingBar',
'recentNotebooks'
],
#classInstVars : [
'dockingBar',
'recentNotebooks'
],
#category : #'Grafoscopio-UI'
}
{ #category : #'as yet unclassified' }
GrafoscopioGUI class >> defaultSpec [
<spec: #default>
^ SpecLayout composed
newColumn: [ :mainWindow |
mainWindow
newRow: [:menu |
menu add: #windowMainMenu
] height: 35;
newRow: [:outlineView |
outlineView
newColumn: [ :treePart |
treePart
newRow: [:tree | tree add: #tree];
addSplitter;
newRow: [:nodeHeader | nodeHeader add: #nodeHeader] height: 30
] right: 0.7;
addSplitter;
newColumn: [ :nodePart |
nodePart add: #nodeBody] left: 0.3.
].
];
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
]
{ #category : #accessing }
GrafoscopioGUI class >> dockingBar: anObject [
dockingBar := anObject
]
{ #category : #'graphical interface' }
GrafoscopioGUI class >> downloadingFrom: downloadUrl withMessage: aString into: location [
[: bar |
bar title: aString.
[ZnClient new
enforceHttpSuccess: true;
url: downloadUrl;
downloadTo: location;
signalProgress: true
]
on: HTTPProgress
do: [ :progress |
progress isEmpty ifFalse: [ bar current: progress percentage ].
progress resume ].
] asJob run.
]
{ #category : #examples }
GrafoscopioGUI class >> exampleBootstrapDynamicUI1 [
"Starting from an example UI from the Spec-Glamour, to customize towards the grafoscopio
UI and get some ideas"
|notebook leftUpperPanel leftPanel treeBrowser |
"Creating a notebook-tree with dummy data"
notebook := GrafoscopioNode new becomeDefaultTestTree.
"Defining the tree roots part"
leftUpperPanel := DynamicComposableModel new.
leftUpperPanel instantiateModels: #(tree TreeModel).
leftUpperPanel tree
roots: notebook children;
childrenBlock: [:node | node children ];
displayBlock: [:node | node title ].
leftUpperPanel layout: (SpecLayout composed
add: #tree;
yourself).
"to debug upto here uncomment the next line, and comment all other 'openWithSpec' ones"
"leftUpperPanel openWithSpec."
"Integrating the previous tree with the node header and creating the body according to
the tags on the node"
leftPanel := DynamicComposableModel new.
leftPanel assign: leftUpperPanel to: #roots.
leftPanel instantiateModels: #(header TextInputFieldModel).
treeBrowser := DynamicComposableModel new.
leftUpperPanel tree
whenSelectedItemChanged: [:node |
node
ifNil:[
leftPanel header text: ''.
treeBrowser instantiateModels: #(body TextModel).
Transcript show: 'Nada que mostrar', String cr]
ifNotNil: [
leftPanel header text: (leftUpperPanel tree selectedItem content header).
leftUpperPanel tree selectedItem content tags = 'código'
ifTrue: [
treeBrowser instantiateModels: #(body GlamourPresentationModel).
Transcript show: 'I am code', String cr.
Transcript show: treeBrowser body asString, String cr.
]
ifFalse: [
treeBrowser instantiateModels: #(body TextModel).
treeBrowser body text: (leftUpperPanel tree selectedItem content body).
Transcript show: 'I am NOT code', String cr.
Transcript show: treeBrowser body asString, String cr.
]
]
].
leftPanel layout:
(SpecLayout composed
newColumn: [:column |
column
add: #roots;
add: #header height: 35];
yourself).
"Integrating the previous tree with node body content"
treeBrowser assign: leftPanel to: #leftTree.
treeBrowser layout:
(SpecLayout composed
newRow: [:r | r add: #leftTree; add: #body ];
yourself
).
treeBrowser openWithSpec.
]
{ #category : #examples }
GrafoscopioGUI class >> exampleBootstrapDynamicUI2 [
"Starting from an example UI from the Spec-Glamour, to customize towards the grafoscopio
UI and get some ideas"
|notebook leftUpperPanel leftPanel treeBrowser |
"Creating a notebook-tree with dummy data"
notebook := GrafoscopioNode new becomeDefaultTestTree.
"Defining the tree roots part"
leftUpperPanel := DynamicComposableModel new.
leftUpperPanel instantiateModels: #(tree TreeModel).
leftUpperPanel tree
roots: notebook children;
childrenBlock: [:node | node children ];
displayBlock: [:node | node title ].
leftUpperPanel layout: (SpecLayout composed
add: #tree;
yourself).
"to debug upto here uncomment the next line, and comment all other 'openWithSpec' ones"
"leftUpperPanel openWithSpec."
"Integrating the previous tree with the node header and creating the body according to
the tags on the node"
leftPanel := DynamicComposableModel new.
leftPanel assign: leftUpperPanel to: #roots.
leftPanel instantiateModels: #(header TextInputFieldModel).
treeBrowser := DynamicComposableModel new.
leftUpperPanel tree
whenSelectedItemChanged: [:node |
node
ifNil:[
leftPanel header text: ''.
treeBrowser instantiateModels: #(body TextModel).
Transcript show: 'Nada que mostrar', String cr]
ifNotNil: [
leftPanel header text: (leftUpperPanel tree selectedItem content header).
leftUpperPanel tree selectedItem content tags = 'código'
ifTrue: [
treeBrowser instantiateModels: #(body GlamourPresentationModel).
treeBrowser assign: leftPanel to: #leftTree.
treeBrowser layout:
(SpecLayout composed
newRow: [:r | r add: #leftTree; add: #body ];
yourself
).
Transcript show: 'I am code', String cr.
Transcript show: treeBrowser body asString, String cr.
]
ifFalse: [
treeBrowser instantiateModels: #(body TextModel).
treeBrowser body text: (leftUpperPanel tree selectedItem content body).
treeBrowser assign: leftPanel to: #leftTree.
treeBrowser layout:
(SpecLayout composed
newRow: [:r | r add: #leftTree; add: #body ];
yourself
).
Transcript show: 'I am NOT code', String cr.
Transcript show: treeBrowser body asString, String cr.
]
]
].
leftPanel layout:
(SpecLayout composed
newColumn: [:column |
column
add: #roots;
add: #header height: 35];
yourself).
"Integrating the previous tree with node body content"
treeBrowser openWithSpec.
]
{ #category : #examples }
GrafoscopioGUI class >> exampleBootstrapUI [
"Starting from an example UI from the Spec-Glamour, to customize towards the grafoscopio
UI and get some ideas"
|ui lay notebook |
ui := DynamicComposableModel new.
ui title: 'new | Grafoscopio'.
ui instantiateModels: #(
tree TreeModel
header TextInputFieldModel
bodyWhenMarkup TextModel
bodyWhenCode GlamourPresentationModel).
notebook := GrafoscopioNode new becomeDefaultTestTree.
ui tree
roots: notebook children;
childrenBlock: [:node | node children];
displayBlock: [:node | node title ].
lay := SpecLayout composed
newRow: [:row |
row
newColumn: [:column |
column
newRow: #tree top: 0.2;
addHSplitter;
newRow: #header bottom: 0.8] right: 0.7;
addVSplitter;
newColumn: #bodyWhenCode];
yourself.
ui openWithSpecLayout: lay.
]
{ #category : #'as yet unclassified' }
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 : #'graphical interface' }
GrafoscopioGUI class >> messageAbout [
"Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web"
LongMessageDialogWindow new
entryText:
'_.:| Grafoscopio |:._',
(String with: Character cr),
'(c) Copyright 2014-2016 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),
'HiTec Lab, Fundación Universitaria Los Libertadores | www.ulibertadores.edu.co ',
(String with: Character cr),
(String with: Character cr),
'[ Thanks to ]',
(String with: Character cr),
'HackBo, Hackerspace Bogota | http://hackbo.co',
(String with: Character cr),
'// Regular workshops attendees \\
Rafael Medida, Iván Pulido, Camilo Hurtado',
(String with: Character cr),
'// Coffe talk (mostly about grafoscopio) \\
Yanneth Gil, Andrés Calderón, Luis Alejandro Bernal',
(String with: Character cr),
'// Pharo, Moose and Agile Visualization communities \\
Tudor Girba, Alexandre Bergel, Nicolai Hess, Peter Uhnák, Milton Mamani ',
(String with: Character cr),
'// Family support while writing, coding & travelling (among others!) \\
Divian Luna, Hilda Cárdenas',
(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';
open.
]
{ #category : #'graphical interface' }
GrafoscopioGUI class >> messageNoRecentDocuments [
"Shows that a feature is not implemeted and point to further documentation on the web"
UIManager default abort:
'No hay documentos recientes.',
(String with: Character cr),
'Abra un documento usando el menú:',
(String with: Character cr),
(String with: Character cr),
'"Lanzar > Documento interactivo desde archivo"',
(String with: Character cr),
(String with: Character cr)
title: 'No hay documentos recientes'.
]
{ #category : #'graphical interface' }
GrafoscopioGUI 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 : #'graphical interface' }
GrafoscopioGUI class >> open [
^ self new open
]
{ #category : #'graphical interface' }
GrafoscopioGUI class >> openFromRecentlyUsed [
"Opens a recent notebooks list"
| selection |
recentTrees isNil
ifFalse: [
selection := UIManager default chooseFrom: recentTrees title: 'Elija una documento'.
GrafoscopioBrowser new openFromFile: (recentTrees at: selection)
]
ifTrue: [self messageNoRecentDocuments].
"browser update".
]
{ #category : #'graphical interface' }
GrafoscopioGUI 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].
Smalltalk platform name = 'Mac OS'
ifTrue: [OSProcess command: 'open ', htmlHelpFileLocation].
]
{ #category : #'graphical interface' }
GrafoscopioGUI 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].
Smalltalk platform name = 'Mac OS'
ifTrue: [OSProcess command: 'open ', pdfHelpFileLocation].
]
{ #category : #accessing }
GrafoscopioGUI class >> recentNotebooks [
^ recentNotebooks ifNil: [ ^ OrderedCollection new ]
]
{ #category : #accessing }
GrafoscopioGUI class >> recentNotebooks: anObject [
recentNotebooks := anObject
]
{ #category : #configuration }
GrafoscopioGUI class >> showSettings [
"Shows the settings in a Transcript. This should return a dictionary for better management of the settings. For the moment
is a quick a dirty hack"
Transcript show: fossil; cr.
Transcript show: pandoc
]
{ #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.
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: 'New notebook' target: (GrafoscopioNotebook new) selector: #openDefault;
add: 'Notebook from file...' target: (GrafoscopioNotebook new) selector: #openFromFileSelector;
add: 'Notebook from Internet...' target: (self new) selector: #openFromUrlUI;
add: 'Recent notebooks...' target: self selector: #openFromRecentlyUsed;
add: 'Example notebooks...' target: self selector: #messageNotImplementedYet;
add: 'Roassal visualizations gallery' target: (RTExampleBrowser new) selector: #open;
add: 'Playground' target: (Smalltalk tools) selector: #openWorkspace;
add: 'Transcript' target: (Smalltalk tools) selector: #openTranscript.
updateMenu := MenuMorph new.
updateMenu
add: 'Grafoscopio' target: self selector: #updateGrafoscopioUI;
add: 'Documentation' target: self selector: #updateDocumentationUI;
add: 'DataViz package' target: self selector: #updateDatavizUI;
add: 'Database engine' target: ExternalApp selector: #installSQLite32BitsUI;
add: 'Pandoc path' target: ExternalApp selector: #configurePandoc;
add: 'Fossil path' target: ExternalApp selector: #configureFossil;
add: 'All the system' target: self selector: #updateSystem.
helpMenu := MenuMorph new.
helpMenu
add: 'Tutorial in Grafoscopio' target: (GrafoscopioNotebook new) selector: #openTutorial;
add: 'PDF Manual' target: self selector: #openHelpInPdf;
add: 'HTML Manual' target: self selector: #openHelpInHtml;
add: 'Manual in grafoscopio' target: (self new) selector: #openHelpInGrafoscopio;
add: 'About Grafoscopio' target: self selector: #messageAbout.
dockingBar := DockingBarMorph new.
dockingBar
add: 'Launch' subMenu: launchMenu;
add: 'Update' subMenu: updateMenu;
add: 'Help' subMenu: helpMenu.
dockingBar
adhereToTop;
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 : #updating }
GrafoscopioGUI class >> updateUI [
"I update the User Interface (UI) with new versions of the docking bar or logos where available.
I'm helpful while testing new functionality that should be expossed to the user via the UI"
dockingBar delete.
GrafoscopioGUI startDockingBar.
]
{ #category : #initialization }
GrafoscopioGUI >> initializePresenter [
tree.
nodeHeader acceptBlock: [ :text|
tree selectedItem
ifNotNil: [:x |
x content: text.
self updateTree
]
]
]
{ #category : #initialization }
GrafoscopioGUI >> initializePresenter2 [
tree whenSelectedItemChanged: [:node |
node tag = 'código'
ifTrue: [ ]
ifFalse: [ ]
].
nodeHeader acceptBlock: [ :text|
tree selectedItem
ifNotNil: [:x |
x content: text.
self updateTree
]
]
]
{ #category : #initialization }
GrafoscopioGUI >> initializeWidgets [
"Buils graphical interface elements"
windowMainMenu := self windowMainMenu.
tree := self tree.
nodeHeader := self newTextInput.
nodeBody :=
tree selectedItem
ifNotNil: [ self updateBody ]
ifNil: [nodeBody := self newText].
windowMainMenu applyTo: self.
self focusOrder
add: windowMainMenu;
add: tree;
add: nodeHeader;
add: nodeBody.
]
{ #category : #accessing }
GrafoscopioGUI >> nodeBody [
^ nodeBody
]
{ #category : #accessing }
GrafoscopioGUI >> nodeBody: anObject [
nodeBody := anObject
]
{ #category : #accessing }
GrafoscopioGUI >> nodeHeader [
^ nodeHeader
]
{ #category : #accessing }
GrafoscopioGUI >> nodeHeader: anObject [
nodeHeader := anObject
]
{ #category : #'ui-building' }
GrafoscopioGUI >> notebookSubMenu [
^ MenuModel new
addGroup: [ :group |
group addItem: [ :item |
item
name: 'Guardar';
icon: Smalltalk ui icons smallSaveIcon;
shortcut: $s command;
action: [ self inform: 'Guardar | Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Guardar como...';
icon: Smalltalk ui icons smallSaveAsIcon;
action: [ self inform: 'Guardar | Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Exportar como html';
icon: Smalltalk ui icons smallWindowIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Exportar como pdf';
icon: Smalltalk ui icons smallPrintIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Ver html';
icon: Smalltalk ui icons smallInspectItIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Ver pdf';
icon: Smalltalk ui icons smallInspectItIcon;
action: [ self inform: 'Por implementar ...' ] ] ]
]
{ #category : #'ui-building' }
GrafoscopioGUI >> proyectSubMenu [
^ MenuModel new
addGroup: [ :group |
group addItem: [ :item |
item
name: 'Activar repositorio remoto...';
icon: Smalltalk ui icons smallPushpinIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Activar repositorio local...';
icon: Smalltalk ui icons homeIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Agregar archivo...';
icon: Smalltalk ui icons newerPackagesAvailableIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Eliminar archivo...';
icon: Smalltalk ui icons packageDeleteIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Enviar al histórico';
icon: Smalltalk ui icons smallScreenshotIcon;
action: [ self inform: 'Por implementar ...' ] ].
group addItem: [ :item |
item
name: 'Acreditarse';
icon: Smalltalk ui icons userIcon;
action: [ self inform: 'Por implementar ...' ] ] ]
]
{ #category : #accessing }
GrafoscopioGUI >> selected [
^ selected value
]
{ #category : #accessing }
GrafoscopioGUI >> selected: aBoolean [
selected value: aBoolean
]
{ #category : #api }
GrafoscopioGUI >> title [
^ ' | Grafoscopio'
]
{ #category : #accessing }
GrafoscopioGUI >> tree [
| notebook |
notebook := GrafoscopioNode new becomeDefaultTestTree.
tree := TreeModel new.
tree
roots: notebook children;
childrenBlock: [:node | node children];
displayBlock: [:node | node title ].
tree whenHighlightedItemChanged:
[tree selectedItem notNil
ifTrue: [
self updateHeader.
self updateBody.
]
].
^ tree
]
{ #category : #accessing }
GrafoscopioGUI >> tree: anObject [
tree := anObject
]
{ #category : #update }
GrafoscopioGUI >> updateBody [
"update the displayed content associated to the body of a node"
(tree selectedItem content tags = 'código')
ifTrue: [
^ nodeBody text: 'I should be playground because I am tagged as ', tree selectedItem content tags
]
ifFalse: [
"nodeBody := self newText."
^ nodeBody text: tree selectedItem content body
]
]
{ #category : #update }
GrafoscopioGUI >> updateBody2 [
"update the displayed content associated to the body of a node"
(tree selectedItem content tags = 'código')
ifTrue: [
^ nodeBody text: 'I should be playground because I am tagged as ', tree selectedItem content tags
]
ifFalse: [
"nodeBody := self newText."
^ nodeBody text: tree selectedItem content body
]
]
{ #category : #update }
GrafoscopioGUI >> updateHeader [
"update the displayed text associated to the header of a node"
^ nodeHeader text: tree selectedItem content header.
]
{ #category : #accessing }
GrafoscopioGUI >> windowMainMenu [
windowMainMenu := MenuModel new
addGroup: [ :group |
group addItem: [ :item |
item
name: 'Cuaderno';
icon: Smalltalk ui icons smallObjectsIcon;
subMenu: self notebookSubMenu ].
group addItem: [ :item |
item
name: 'Proyecto';
icon: Smalltalk ui icons catalogIcon;
subMenu: self proyectSubMenu ] ];
addGroup: [ :group |
group addItem: [ :item |
item
name: nil;
description: 'Guardar documento';
icon: Smalltalk ui icons smallSaveIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Deshacer';
icon: Smalltalk ui icons smallUndoIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Rehacer';
icon: Smalltalk ui icons smallRedoIcon;
action: [ self inform: 'Por implementar...' ] ]];
addGroup: [ :group |
group addItem: [ :item |
item
name: nil;
description: 'Agregar nodo';
icon: MendaIcons new plusIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Eliminar nodo';
icon: MendaIcons new minusIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Subir nodo';
icon: MendaIcons new arrowUpIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Bajar nodo';
icon: MendaIcons new arrowDownIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Mover nodo a la izquierda';
icon: MendaIcons new arrowLeftIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Mover nodo a la derecha';
icon: MendaIcons new arrowRightIcon;
action: [ self inform: 'Por implementar...' ] ]];
addGroup: [ :group |
group addItem: [ :item |
item
name: nil;
description: 'Intercambiar: código <--> texto';
icon: MendaIcons new smalltalkCodeIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Etiquetar como...';
icon: MendaIcons new tagAddIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Desetiquetar ....';
icon: MendaIcons new tagMinusIcon;
action: [ self inform: 'Por implementar...' ] ].
group addItem: [ :item |
item
name: nil;
description: 'Editar etiquetas...';
icon: FontAwesomeIcons new tagsIcon;
action: [ self inform: 'Por implementar...' ] ]. ].
^ windowMainMenu
]
{ #category : #accessing }
GrafoscopioGUI >> windowMainMenu: anObject [
windowMainMenu := anObject
]