Dirty support for different views of the browser according to the task. This one is for making transmedia marathons. There is need for sub-browsers in panels. I need to explore that.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2014-11-26 16:13:57 +00:00
parent f89d088de6
commit 9f7422969c
2 changed files with 190 additions and 102 deletions

View File

@ -15,7 +15,10 @@ Class {
'browser', 'browser',
'explorer', 'explorer',
'mainTree', 'mainTree',
'\r\t\t\t\t\t\t\t\t\tnonVar1',
'cacheNode',
'workingFile', 'workingFile',
'\r\t\t\t\t\t\t\t\t\tnonVar2',
'fossil', 'fossil',
'localRepository', 'localRepository',
'remoteRepository', 'remoteRepository',
@ -34,6 +37,16 @@ GrafoscopioBrowser class >> open [
^ self new open ^ self new open
] ]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openInMode: aMode [
^ self new openInMode: aMode
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openInModeTransmediaton [
^ self new openInModeTransmediaton
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openLandscape [ GrafoscopioBrowser class >> openLandscape [
^ self new openLandscape ^ self new openLandscape
@ -77,10 +90,11 @@ browser := GLMTabulator new
title: 'Grafoscopio'. title: 'Grafoscopio'.
browser browser
column: #tree span: 2; column: [:c |
c row: #tree;
row: #nodeHeader] span: 2;
column: [ :c | column: [ :c |
c row: #nodeBody span: 2; c row: #nodeBody span: 2] span: 4.
row: #nodeHeader ] span: 4.
browser browser
updateOn: GLMItemAdded from: #yourself; updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself. updateOn: GLMItemRemoved from: #yourself.
@ -117,90 +131,27 @@ GrafoscopioBrowser >> buildBrowserLandscape [
browser := GLMTabulator new browser := GLMTabulator new
title: 'Grafoscopio'. title: 'Grafoscopio'.
browser browser
column: #tree span: 3; column: #original span: 3;
column: #body span: 3; column: #transmediado span: 3.
column: #code span: 3.
browser browser
updateOn: GLMItemAdded from: #yourself; updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself. updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree; ]
andShow: [ :a |
(a tree) "Layout" { #category : #'system-support' }
title: mainTree header; GrafoscopioBrowser >> configureFossil [
children: [ :eachNode | "Stablish where is located fossil according to the operative system and the input of the user"
(eachNode children) isNil | fileStream |
ifTrue: [ #() ] fileStream := UITheme builder
ifFalse:[ eachNode children ] ]; fileOpen: 'Coloque la ruta de fossil'.
format:[:eachNode |
(eachNode header) isNil fileStream isNil ifTrue: [ ^nil ].
ifTrue: [ '' ] fossil := fileStream name asFileReference fullName.
ifFalse: [ eachNode header ]];
"Adding nodes"
act: [:treePresentation |
(treePresentation selection) isNotNil
ifTrue: [treePresentation selection addNodeAfter].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousZoomIn
entitled: 'Add node';
"Removing nodes"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [(treePresentation selection parent)
removeNode: treePresentation selection]
ifFalse: [treePresentation entity removeLast].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousZoomOut
entitled: 'Remove node';
"Inspecting nodes, for debugging purposes, DISABLE THIS ON PRODUCTION"
act: [:treePresentation | treePresentation selection inspect ]
icon: GLMUIThemeExtraIcons glamorousInspect
entitled: 'Inspect selection';
"Move nodes in the same hierarchy"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection moveBefore].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousUp
entitled: 'Move node up';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection moveAfter].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousDown
entitled: 'Move node down';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection promote].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousLeft
entitled: 'Move node left';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection demote].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousRight
entitled: 'Move node left'.
].
(browser transmit)
to: #body;
from: #tree;
andShow: [ :a |
(a text)
title: 'Original';
format:[:eachNode |
(eachNode body) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode body ]]].
(browser transmit)
to: #code;
andShow: [ :a |
a smalltalkCode
title: 'Transmediado';
populate: #acceptedCode
icon: GLMUIThemeExtraIcons glamorousAccept
on: $s entitled: 'Accept' with: [:text | text text ]].
] ]
{ #category : #'system-support' } { #category : #'system-support' }
@ -234,21 +185,43 @@ GrafoscopioBrowser >> configureSettings [
remoteRepository := 'http://mutabit.com/deltas/repos.fossil/soliedu'. remoteRepository := 'http://mutabit.com/deltas/repos.fossil/soliedu'.
] ]
{ #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 } { #category : #bibliography }
GrafoscopioBrowser >> customKeys [ GrafoscopioBrowser >> customKeys [
"Replaces the default key in a BibTeX file for a custom key taken from the 'shorttitle' field. "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 Useful when autogenerated BibTeX has cryptic or non easy to memorize keys (for example in some
Zotero exports)" Zotero exports)"
| bibFile bibliography | | bibFile bibliography bibStream bibOutputer |
bibFile := ((workingFile parent) children bibFile := ((workingFile parent) children
detect: [:each | each basename endsWith: 'bib' ] ifNone: [ ]). detect: [:each | each basename endsWith: 'bib' ] ifNone: [ ]).
bibFile ifNotNil: bibFile ifNotNil: [
[ bibliography := CZBibParser parse: (bibFile contents). bibliography := CZBibParser parse: bibFile contents.
1 to: (bibliography size) do: [:index | bibStream := '' writeStream.
(((bibliography entries at: index) fields at: 2) key = 'shorttitle') (bibliography entries) do: [:bibItem |
ifTrue: [ bibItem fields do: [:some | some key = 'shorttitle'
(bibliography entries at: index) ifTrue: [ bibItem key: some value ]].
key: ((bibliography entries at: index) fields at: 2) 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 } { #category : #persistence }
@ -370,6 +343,81 @@ GrafoscopioBrowser >> openFromFile [
browser openOn: mainTree children. browser openOn: mainTree children.
] ]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> openInMode: aMode [
"**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"
browser := GLMTabulator new
title: 'Grafoscopio'.
browser
column: #original span: 3;
column: #transmediado span: 3.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
" browser := GLMTabulator new.
browser
row: #main;
row: [ :r | r column: #selectionInterval; column: #selectedText; column: #full ].
(browser transmit)
to: #main;
andShow: [ :a | a text ].
(browser transmit)
to: #selectionInterval;
from: #main port: #selectionInterval;
andShow: [ :a | a text title: '#selectionInterval port' ].
(browser transmit)
to: #selectedText;
from: #main port: #selectedText;
andShow: [ :a | a text title: '#selectedText port' ].
(browser transmit)
to: #full;
from: #main port: #text;
andShow: [ :a | a text title: '#text port']."
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> openInModeTransmediaton [
"**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"
browser := GLMTabulator new
title: 'Transmediatón ', ' | Grafoscopio'.
browser
column: #tree span: 2;
column: [ :c |
c row: [ :r | r column: #original; column: #transmediado];
row: #buttons].
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
(browser transmit)
to: #original;
andShow: [ :a | a text title: 'Original' ].
(browser transmit)
to: #transmediado;
andShow: [ :a | a text title: 'Transmediado' ].
(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 openOn: ''
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioBrowser >> openLandscape [ GrafoscopioBrowser >> openLandscape [
"Opens a new browser with a default tree in landscape mode" "Opens a new browser with a default tree in landscape mode"
@ -404,14 +452,29 @@ GrafoscopioBrowser >> openWorking [
] ]
{ #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 } { #category : #persistence }
GrafoscopioBrowser >> repositoryCommit [ GrafoscopioBrowser >> repositoryCommit [
"Commits current changes to the open repository" "Commits current changes to the open repository"
OSProcess command: fossil notNil ifTrue: [
OSProcess command:
'cd ', localRepository parent fullName, '; ', 'cd ', localRepository parent fullName, '; ',
fossil, ' commit -m "" --no-warnings; ', fossil, ' commit -m "" --no-warnings; ',
'echo "Commited changes to the repository"'. 'echo "Commited changes to the repository"'. ]
] ]
{ #category : #persistence } { #category : #persistence }
@ -453,7 +516,7 @@ GrafoscopioBrowser >> saveWorkingTree [
[ self exportAsSton: mainTree on: fileStream. [ self exportAsSton: mainTree on: fileStream.
self exportAsMarkdown: mainTree on: markdownFile ] self exportAsMarkdown: mainTree on: markdownFile ]
ensure: [ fileStream ifNotNil: #close.]. ensure: [ fileStream ifNotNil: #close.].
self customKeys. "self customKeys."
self inform: 'Archivo Guardado'. self inform: 'Archivo Guardado'.
] ]
@ -465,7 +528,7 @@ GrafoscopioBrowser >> treeOn: constructor [
title: mainTree header; title: mainTree header;
children: [ :eachNode | children: [ :eachNode |
(eachNode children) isNil (eachNode children) isNil
ifTrue: [ #() ] ifTrue: [ self inform: 'Seleccione un nodo para ver su contenido' ]
ifFalse:[ eachNode children ] ]; ifFalse:[ eachNode children ] ];
format:[:eachNode | format:[:eachNode |
(eachNode header) isNil (eachNode header) isNil
@ -518,6 +581,10 @@ GrafoscopioBrowser >> treeOn: constructor [
icon: GLMUIThemeExtraIcons glamorousRight icon: GLMUIThemeExtraIcons glamorousRight
entitled: 'Move node rigt'; entitled: 'Move node rigt';
act: [ :treePresentation | treePresentation update ]
icon: GLMUIThemeExtraIcons glamorousRefresh
entitled: 'Update';
act: [self saveWorkingTree] act: [self saveWorkingTree]
icon: GLMUIThemeExtraIcons glamorousSave icon: GLMUIThemeExtraIcons glamorousSave
entitled: 'Save current tree'; entitled: 'Save current tree';
@ -527,6 +594,14 @@ GrafoscopioBrowser >> treeOn: constructor [
act: [self saveToFile] entitled: 'Arbol > Guardar como ...'; act: [self saveToFile] entitled: 'Arbol > Guardar como ...';
act: [self exportAsHtml] entitled: 'Arbol > Exportar como html'; act: [self exportAsHtml] entitled: 'Arbol > Exportar como html';
"act: [:x | x printString inspect] entitled: 'Arbol > Definir título';" "act: [:x | x printString inspect] entitled: 'Arbol > Definir título';"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self copyNodeIntoCache: treePresentation selection].
treePresentation update] entitled: 'Nodo > Copiar nodo';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self replaceContentsFromCache: treePresentation selection].
treePresentation update] entitled: 'Nodo > Pegar nodo';
act: [self enableRepository] entitled: 'Proyecto > Activar'; act: [self enableRepository] entitled: 'Proyecto > Activar';
act: [self addFileToRepository] entitled: 'Proyecto > Agregar archivo'; act: [self addFileToRepository] entitled: 'Proyecto > Agregar archivo';
act: [:x | x printString inspect] entitled: 'Proyecto > Eliminar archivo'; act: [:x | x printString inspect] entitled: 'Proyecto > Eliminar archivo';

View File

@ -21,7 +21,8 @@ Class {
'parent', 'parent',
'node', 'node',
'level', 'level',
'nodesInPreorder' 'nodesInPreorder',
'cacheNode'
], ],
#category : #'Grafoscopio-Model' #category : #'Grafoscopio-Model'
} }
@ -105,7 +106,7 @@ GrafoscopioNode >> asMarkdown [
markdownOutput := '' writeStream. markdownOutput := '' writeStream.
(self preorderTraversal) do: [ :eachNode | (self preorderTraversal) do: [ :eachNode |
(eachNode level > 0) ifTrue: [ (eachNode level > 0) & (eachNode header notNil) ifTrue: [
(eachNode hasAncestorWith: '%invisible') not (eachNode hasAncestorWith: '%invisible') not
ifTrue: [ markdownOutput nextPutAll: (eachNode markdownContent) ]]]. ifTrue: [ markdownOutput nextPutAll: (eachNode markdownContent) ]]].
@ -370,7 +371,19 @@ GrafoscopioNode >> parent: aNode [
parent := aNode parent := aNode
] ]
{ #category : #'as yet unclassified' } { #category : #'add/remove nodes' }
GrafoscopioNode >> pasteNodeFromCache [
"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 notNil
ifTrue: [
self header: cacheNode header.
self body: cacheNode body.]
ifFalse: [self inform: 'El nodo cache está vacio']
]
{ #category : #exporting }
GrafoscopioNode >> preorderTraversal [ GrafoscopioNode >> preorderTraversal [
nodesInPreorder := OrderedCollection new. nodesInPreorder := OrderedCollection new.
self visitedGoTo: nodesInPreorder. self visitedGoTo: nodesInPreorder.
@ -393,7 +406,7 @@ GrafoscopioNode >> promote [
] ]
{ #category : #'as yet unclassified' } { #category : #'add/remove nodes' }
GrafoscopioNode >> removeLastNode [ GrafoscopioNode >> removeLastNode [
"Adds the given node to the receivers collection of children, and sets this object as the parent "Adds the given node to the receivers collection of children, and sets this object as the parent
of the node" of the node"
@ -402,7 +415,7 @@ GrafoscopioNode >> removeLastNode [
] ]
{ #category : #'as yet unclassified' } { #category : #'add/remove nodes' }
GrafoscopioNode >> removeNode: aNode [ GrafoscopioNode >> removeNode: aNode [
"Adds the given node to the receivers collection of children, and sets this object as the parent "Adds the given node to the receivers collection of children, and sets this object as the parent
of the node" of the node"
@ -411,7 +424,7 @@ GrafoscopioNode >> removeNode: aNode [
] ]
{ #category : #'as yet unclassified' } { #category : #exporting }
GrafoscopioNode >> returnConfig [ GrafoscopioNode >> returnConfig [
"Detects a children node containing the configuration for the creation of the output files. If nothing is detected, "Detects a children node containing the configuration for the creation of the output files. If nothing is detected,
creates defaults for that. Pending: creates defaults for that. Pending: