Toggling support for code nodes.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-08-22 16:12:45 +00:00
parent a4dadda39b
commit 283a4523fd
3 changed files with 54 additions and 329 deletions

View File

@ -444,13 +444,14 @@ 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)
self recentNotebooks
ifNotEmpty: [
selection := UIManager default chooseFrom: recentNotebooks title: 'Elija una documento'.
selection > 0
ifTrue: [ GrafoscopioNotebook new openFromFile: (recentNotebooks at: selection)]
ifFalse: [ self inform: 'No notebook selected!' ]
]
ifTrue: [self messageNoRecentDocuments].
"browser update".
ifEmpty: [self messageNoRecentDocuments]
@ -487,12 +488,12 @@ GrafoscopioGUI class >> openHelpInPdf [
{ #category : #accessing }
GrafoscopioGUI class >> recentNotebooks [
^ recentNotebooks ifNil: [ ^ OrderedCollection new ]
^ recentNotebooks ifNil: [recentNotebooks := OrderedCollection new ]
]
{ #category : #accessing }
GrafoscopioGUI class >> recentNotebooks: anObject [
recentNotebooks := anObject
GrafoscopioGUI class >> recentNotebooks: anOrderedCollection [
recentNotebooks := anOrderedCollection
]
{ #category : #configuration }
@ -711,7 +712,8 @@ GrafoscopioGUI class >> updatePrerrequisitesScript [
{ #category : #updating }
GrafoscopioGUI class >> updateRecentNotebooksWith: aFileReference [
self recentNotebooks add: aFileReference.
(self recentNotebooks includes: aFileReference)
ifFalse: [self recentNotebooks add: aFileReference].
]
{ #category : #updating }
@ -744,100 +746,11 @@ GrafoscopioGUI class >> updateUI [
]
{ #category : #initialization }
GrafoscopioGUI >> initializePresenter [
tree.
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 [
"This should be integrated with the GrafoscopioNotebook same messages.
Was originally wrote in Spanish, and something is lost in translation, but Grafoscopio
should be available in several languages..."
^ MenuModel new
addGroup: [ :group |
group addItem: [ :item |
@ -872,185 +785,3 @@ GrafoscopioGUI >> proyectSubMenu [
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
]

View File

@ -609,12 +609,10 @@ GrafoscopioNode >> specModelClass [
{ #category : #accessing }
GrafoscopioNode >> tagAs: aTag [
"Tags the recipient node with aTag. For the moment we will have only one tag. In the future we will have several and there will be rules to
know if a tag excludes others from the same node"
"Tags the recipient node with aTag. For the moment we will have only one tag.
In the future we will have several and there will be rules to know how tags interact with
each other"
tags := aTag.
"aTag = 'código'
ifTrue: [self body: (GTPlayPage new content: self body) content]"
]
{ #category : #accessing }

View File

@ -51,10 +51,7 @@ GrafoscopioNotebook >> addNode [
| addedNode |
tree needRebuild: true.
addedNode := tree highlightedItem content addNodeAfterMe.
self notebookContent: notebook.
tree roots: tree roots.
self highlightItemFor: addedNode.
self buildWithSpecLayout: self class defaultSpec.
self updateTreeEditing: addedNode
]
{ #category : #accessing }
@ -96,10 +93,7 @@ GrafoscopioNotebook >> demoteNode [
| currentContent |
currentContent := tree highlightedItem content.
currentContent demote.
self notebookContent: notebook.
self highlightItemFor: currentContent.
tree needRebuild: true.
self buildWithSpecLayout: self class defaultSpec.
self updateTreeEditing: currentContent
]
{ #category : #persistence }
@ -115,9 +109,9 @@ GrafoscopioNotebook >> exportAsSton: aNotebook on: aFileStream [
aFileStream nextPutAll: stonPrettyString
]
{ #category : #accessing }
{ #category : #api }
GrafoscopioNotebook >> extent [
^800@500
^900@500
]
{ #category : #accessing }
@ -146,8 +140,7 @@ GrafoscopioNotebook >> highlightItemFor: nodeContent [
childrenSize := currentItem content parent children size.
index := allItems indexOf: currentItem.
(index < childrenSize) ifTrue: [
"{allItems . currentItem . index } inspect."
currentItem selected: false.
currentItem ifNotNil: [currentItem selected: false].
parentNode
highlightedItem: ((allItems at:(index+1)) selected:true;
takeHighlight;yourself).
@ -209,22 +202,18 @@ GrafoscopioNotebook >> initializeWidgets [
{ #category : #operation }
GrafoscopioNotebook >> moveNodeAfter [
| currentNode |
currentNode := tree selectedItem content.
currentNode moveAfter.
tree needRebuild: true.
tree roots: tree roots.
self buildWithSpecLayout: self class defaultSpec.
| currentContent |
currentContent := tree selectedItem content.
currentContent moveAfter.
self updateTreeEditing: currentContent
]
{ #category : #operation }
GrafoscopioNotebook >> moveNodeBefore [
| currentNode |
currentNode := tree selectedItem content.
currentNode moveBefore.
tree needRebuild: true.
tree roots: tree roots.
self buildWithSpecLayout: self class defaultSpec.
| currentContent |
currentContent := tree selectedItem content.
currentContent moveBefore.
self updateTreeEditing: currentContent
]
{ #category : #initialization }
@ -303,7 +292,7 @@ GrafoscopioNotebook >> newWindowMainMenu [
name: nil;
description: 'Togle: code <--> text';
icon: MendaIcons new smalltalkCodeIcon;
action: [ self inform: 'To be implemented...' ] ].
action: [ self toggleCodeNode ] ].
group addItem: [ :item |
item
name: nil;
@ -503,10 +492,7 @@ GrafoscopioNotebook >> promoteNode [
| currentContent |
currentContent := tree selectedItem content.
currentContent promote.
self notebookContent: notebook.
self highlightItemFor: currentContent.
tree needRebuild: true.
self buildWithSpecLayout: self class defaultSpec.
self updateTreeEditing: currentContent
]
{ #category : #operation }
@ -522,10 +508,7 @@ GrafoscopioNotebook >> removeNode [
]
ifFalse: [ newSelectedContent := parentContent ].
contentToDelete parent removeNode: contentToDelete.
self notebookContent: notebook.
self highlightItemFor: newSelectedContent.
tree needRebuild: true.
self buildWithSpecLayout: self class defaultSpec.
self updateTreeEditing: newSelectedContent
]
{ #category : #persistence }
@ -563,8 +546,20 @@ GrafoscopioNotebook >> saveWorkingNotebook [
"Saves the current tree to the user predefined file location used when he/she opened it."
self workingFile
ifNil: [ self saveToFileUI ]
ifNotNil: [ self saveToFile: workingFile ]
ifNotNil: [ self saveToFile: workingFile ].
GrafoscopioGUI updateRecentNotebooksWith: workingFile
]
{ #category : #operation }
GrafoscopioNotebook >> toggleCodeNode [
| currentNode |
currentNode := tree highlightedItem.
(currentNode content tags = 'código')
ifTrue: [ currentNode content tagAs: '' ]
ifFalse: [ currentNode content tagAs: 'código' ].
self changeBody: currentNode.
]
{ #category : #accessing }
@ -581,14 +576,15 @@ GrafoscopioNotebook >> tree: anObject [
GrafoscopioNotebook >> updateBodyFor: item [
item
ifNotNil: [ self changeBody: item ]
ifNil: [ ]
ifNil: [ "self inform: 'Select a node.'" ]
]
{ #category : #operation }
GrafoscopioNotebook >> updateBodyFor: item or: bufferedSelection [
item
ifNotNil: [ self changeBody: item ]
ifNil: [ self changeBody: bufferedSelection ]
GrafoscopioNotebook >> updateTreeEditing: currentContent [
self notebookContent: notebook.
self highlightItemFor: currentContent.
tree needRebuild: true.
self buildWithSpecLayout: self class defaultSpec
]
{ #category : #accessing }