From 9f7422969c21ded0b768143e204628115acc04ab Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 26 Nov 2014 16:13:57 +0000 Subject: [PATCH] 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. --- .../Grafoscopio/GrafoscopioBrowser.class.st | 267 +++++++++++------- .../Grafoscopio/GrafoscopioNode.class.st | 25 +- 2 files changed, 190 insertions(+), 102 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioBrowser.class.st b/repository/Grafoscopio/GrafoscopioBrowser.class.st index dec8e2d..e8b6bb4 100644 --- a/repository/Grafoscopio/GrafoscopioBrowser.class.st +++ b/repository/Grafoscopio/GrafoscopioBrowser.class.st @@ -15,7 +15,10 @@ Class { 'browser', 'explorer', 'mainTree', + '\r\t\t\t\t\t\t\t\t\tnonVar1', + 'cacheNode', 'workingFile', + '\r\t\t\t\t\t\t\t\t\tnonVar2', 'fossil', 'localRepository', 'remoteRepository', @@ -34,6 +37,16 @@ GrafoscopioBrowser class >> 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' } GrafoscopioBrowser class >> openLandscape [ ^ self new openLandscape @@ -77,10 +90,11 @@ browser := GLMTabulator new title: 'Grafoscopio'. browser - column: #tree span: 2; + column: [:c | + c row: #tree; + row: #nodeHeader] span: 2; column: [ :c | - c row: #nodeBody span: 2; - row: #nodeHeader ] span: 4. + c row: #nodeBody span: 2] span: 4. browser updateOn: GLMItemAdded from: #yourself; updateOn: GLMItemRemoved from: #yourself. @@ -117,90 +131,27 @@ GrafoscopioBrowser >> buildBrowserLandscape [ browser := GLMTabulator new title: 'Grafoscopio'. browser - column: #tree span: 3; - column: #body span: 3; - column: #code span: 3. + column: #original span: 3; + column: #transmediado span: 3. browser updateOn: GLMItemAdded from: #yourself; updateOn: GLMItemRemoved from: #yourself. -(browser transmit) - to: #tree; - andShow: [ :a | - (a tree) "Layout" - title: mainTree header; - children: [ :eachNode | - (eachNode children) isNil - ifTrue: [ #() ] - ifFalse:[ eachNode children ] ]; - format:[:eachNode | - (eachNode header) isNil - ifTrue: [ '' ] - 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' } +GrafoscopioBrowser >> 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 : #'system-support' } @@ -234,21 +185,43 @@ GrafoscopioBrowser >> configureSettings [ 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 } 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 | + | bibFile bibliography bibStream bibOutputer | bibFile := ((workingFile parent) children detect: [:each | each basename endsWith: 'bib' ] ifNone: [ ]). - bibFile ifNotNil: - [ bibliography := CZBibParser parse: (bibFile contents). - 1 to: (bibliography size) do: [:index | - (((bibliography entries at: index) fields at: 2) key = 'shorttitle') - ifTrue: [ - (bibliography entries at: index) - key: ((bibliography entries at: index) fields at: 2) value ]]]. + 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 } @@ -370,6 +343,81 @@ GrafoscopioBrowser >> openFromFile [ 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' } GrafoscopioBrowser >> openLandscape [ "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 } GrafoscopioBrowser >> repositoryCommit [ "Commits current changes to the open repository" - - OSProcess command: + + fossil notNil ifTrue: [ + OSProcess command: 'cd ', localRepository parent fullName, '; ', fossil, ' commit -m "" --no-warnings; ', - 'echo "Commited changes to the repository"'. + 'echo "Commited changes to the repository"'. ] + + ] { #category : #persistence } @@ -453,7 +516,7 @@ GrafoscopioBrowser >> saveWorkingTree [ [ self exportAsSton: mainTree on: fileStream. self exportAsMarkdown: mainTree on: markdownFile ] ensure: [ fileStream ifNotNil: #close.]. - self customKeys. + "self customKeys." self inform: 'Archivo Guardado'. ] @@ -465,7 +528,7 @@ GrafoscopioBrowser >> treeOn: constructor [ title: mainTree header; children: [ :eachNode | (eachNode children) isNil - ifTrue: [ #() ] + ifTrue: [ self inform: 'Seleccione un nodo para ver su contenido' ] ifFalse:[ eachNode children ] ]; format:[:eachNode | (eachNode header) isNil @@ -517,6 +580,10 @@ GrafoscopioBrowser >> treeOn: constructor [ treePresentation update] icon: GLMUIThemeExtraIcons glamorousRight entitled: 'Move node rigt'; + + act: [ :treePresentation | treePresentation update ] + icon: GLMUIThemeExtraIcons glamorousRefresh + entitled: 'Update'; act: [self saveWorkingTree] icon: GLMUIThemeExtraIcons glamorousSave @@ -527,6 +594,14 @@ GrafoscopioBrowser >> treeOn: constructor [ act: [self saveToFile] entitled: 'Arbol > Guardar como ...'; act: [self exportAsHtml] entitled: 'Arbol > Exportar como html'; "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 addFileToRepository] entitled: 'Proyecto > Agregar archivo'; act: [:x | x printString inspect] entitled: 'Proyecto > Eliminar archivo'; diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index 7a4f18a..eba0674 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -21,7 +21,8 @@ Class { 'parent', 'node', 'level', - 'nodesInPreorder' + 'nodesInPreorder', + 'cacheNode' ], #category : #'Grafoscopio-Model' } @@ -105,7 +106,7 @@ GrafoscopioNode >> asMarkdown [ markdownOutput := '' writeStream. (self preorderTraversal) do: [ :eachNode | - (eachNode level > 0) ifTrue: [ + (eachNode level > 0) & (eachNode header notNil) ifTrue: [ (eachNode hasAncestorWith: '%invisible') not ifTrue: [ markdownOutput nextPutAll: (eachNode markdownContent) ]]]. @@ -370,7 +371,19 @@ GrafoscopioNode >> 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 [ nodesInPreorder := OrderedCollection new. self visitedGoTo: nodesInPreorder. @@ -393,7 +406,7 @@ GrafoscopioNode >> promote [ ] -{ #category : #'as yet unclassified' } +{ #category : #'add/remove nodes' } GrafoscopioNode >> removeLastNode [ "Adds the given node to the receivers collection of children, and sets this object as the parent of the node" @@ -402,7 +415,7 @@ GrafoscopioNode >> removeLastNode [ ] -{ #category : #'as yet unclassified' } +{ #category : #'add/remove nodes' } GrafoscopioNode >> removeNode: aNode [ "Adds the given node to the receivers collection of children, and sets this object as the parent of the node" @@ -411,7 +424,7 @@ GrafoscopioNode >> removeNode: aNode [ ] -{ #category : #'as yet unclassified' } +{ #category : #exporting } GrafoscopioNode >> returnConfig [ "Detects a children node containing the configuration for the creation of the output files. If nothing is detected, creates defaults for that. Pending: