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" "Opens a recent notebooks list"
| selection | | selection |
recentTrees isNil self recentNotebooks
ifFalse: [ ifNotEmpty: [
selection := UIManager default chooseFrom: recentTrees title: 'Elija una documento'. selection := UIManager default chooseFrom: recentNotebooks title: 'Elija una documento'.
GrafoscopioBrowser new openFromFile: (recentTrees at: selection) selection > 0
ifTrue: [ GrafoscopioNotebook new openFromFile: (recentNotebooks at: selection)]
ifFalse: [ self inform: 'No notebook selected!' ]
] ]
ifTrue: [self messageNoRecentDocuments]. ifEmpty: [self messageNoRecentDocuments]
"browser update".
@ -487,12 +488,12 @@ GrafoscopioGUI class >> openHelpInPdf [
{ #category : #accessing } { #category : #accessing }
GrafoscopioGUI class >> recentNotebooks [ GrafoscopioGUI class >> recentNotebooks [
^ recentNotebooks ifNil: [ ^ OrderedCollection new ] ^ recentNotebooks ifNil: [recentNotebooks := OrderedCollection new ]
] ]
{ #category : #accessing } { #category : #accessing }
GrafoscopioGUI class >> recentNotebooks: anObject [ GrafoscopioGUI class >> recentNotebooks: anOrderedCollection [
recentNotebooks := anObject recentNotebooks := anOrderedCollection
] ]
{ #category : #configuration } { #category : #configuration }
@ -711,7 +712,8 @@ GrafoscopioGUI class >> updatePrerrequisitesScript [
{ #category : #updating } { #category : #updating }
GrafoscopioGUI class >> updateRecentNotebooksWith: aFileReference [ GrafoscopioGUI class >> updateRecentNotebooksWith: aFileReference [
self recentNotebooks add: aFileReference. (self recentNotebooks includes: aFileReference)
ifFalse: [self recentNotebooks add: aFileReference].
] ]
{ #category : #updating } { #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' } { #category : #'ui-building' }
GrafoscopioGUI >> proyectSubMenu [ 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 ^ MenuModel new
addGroup: [ :group | addGroup: [ :group |
group addItem: [ :item | group addItem: [ :item |
@ -872,185 +785,3 @@ GrafoscopioGUI >> proyectSubMenu [
action: [ self inform: 'Por implementar ...' ] ] ] 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 } { #category : #accessing }
GrafoscopioNode >> tagAs: aTag [ 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 "Tags the recipient node with aTag. For the moment we will have only one tag.
know if a tag excludes others from the same node" In the future we will have several and there will be rules to know how tags interact with
each other"
tags := aTag. tags := aTag.
"aTag = 'código'
ifTrue: [self body: (GTPlayPage new content: self body) content]"
] ]
{ #category : #accessing } { #category : #accessing }

View File

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