New GUI: Preliminary presistence support.
This commit is contained in:
parent
4ee483c541
commit
d756846b86
@ -818,7 +818,7 @@ GrafoscopioBrowser >> openFromFile: aFileName [
|
|||||||
GrafoscopioBrowser >> openFromFileSelector [
|
GrafoscopioBrowser >> openFromFileSelector [
|
||||||
"Opens a tree from a file by using the file selector GUI."
|
"Opens a tree from a file by using the file selector GUI."
|
||||||
"REFACTORING NOTES: This sould call openFromFile, instead of having the code repeated here.
|
"REFACTORING NOTES: This sould call openFromFile, instead of having the code repeated here.
|
||||||
This creates errors on debugging and worse on proper behaviour"
|
This creates errors on debugging and worse on proper behavior"
|
||||||
| fileStream currentChildren |
|
| fileStream currentChildren |
|
||||||
"GrafoscopioBrowser configureSettings."
|
"GrafoscopioBrowser configureSettings."
|
||||||
fileStream := UITheme builder
|
fileStream := UITheme builder
|
||||||
|
@ -17,6 +17,12 @@ Class {
|
|||||||
'headerRefreshProcess',
|
'headerRefreshProcess',
|
||||||
'selected'
|
'selected'
|
||||||
],
|
],
|
||||||
|
#classVars : [
|
||||||
|
'dockingBar'
|
||||||
|
],
|
||||||
|
#classInstVars : [
|
||||||
|
'dockingBar'
|
||||||
|
],
|
||||||
#category : #'Grafoscopio-UI'
|
#category : #'Grafoscopio-UI'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +52,16 @@ GrafoscopioGUI class >> defaultSpec [
|
|||||||
yourself
|
yourself
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioGUI class >> dockingBar [
|
||||||
|
^ dockingBar
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioGUI class >> dockingBar: anObject [
|
||||||
|
dockingBar := anObject
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #examples }
|
{ #category : #examples }
|
||||||
GrafoscopioGUI class >> exampleBootstrapDynamicUI1 [
|
GrafoscopioGUI class >> exampleBootstrapDynamicUI1 [
|
||||||
"Starting from an example UI from the Spec-Glamour, to customize towards the grafoscopio
|
"Starting from an example UI from the Spec-Glamour, to customize towards the grafoscopio
|
||||||
@ -238,7 +254,7 @@ GrafoscopioGUI class >> startDockingBar [
|
|||||||
launchMenu := MenuMorph new.
|
launchMenu := MenuMorph new.
|
||||||
launchMenu
|
launchMenu
|
||||||
add: 'New notebook' target: self selector: #open;
|
add: 'New notebook' target: self selector: #open;
|
||||||
add: 'Notebook from file...' target: (self new) selector: #openFromFileSelector;
|
add: 'Notebook from file...' target: (GrafoscopioNotebook new) selector: #openFromFileSelector;
|
||||||
add: 'Notebook from Internet...' target: (self new) selector: #openFromUrlUI;
|
add: 'Notebook from Internet...' target: (self new) selector: #openFromUrlUI;
|
||||||
add: 'Recent notebooks...' target: self selector: #openFromRecentlyUsed;
|
add: 'Recent notebooks...' target: self selector: #openFromRecentlyUsed;
|
||||||
add: 'Example notebooks...' target: self selector: #messageNotImplementedYet;
|
add: 'Example notebooks...' target: self selector: #messageNotImplementedYet;
|
||||||
@ -274,6 +290,18 @@ GrafoscopioGUI class >> startDockingBar [
|
|||||||
openInWorld.
|
openInWorld.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'graphical interface' }
|
||||||
|
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"
|
||||||
|
|
||||||
|
self dockingBar
|
||||||
|
ifNil: [^ self ]
|
||||||
|
ifNotNil: [
|
||||||
|
self dockingBar delete.
|
||||||
|
self startDockingBar]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
GrafoscopioGUI >> initializePresenter [
|
GrafoscopioGUI >> initializePresenter [
|
||||||
tree.
|
tree.
|
||||||
|
@ -16,7 +16,8 @@ Class {
|
|||||||
'header',
|
'header',
|
||||||
'body',
|
'body',
|
||||||
'windowMainMenu',
|
'windowMainMenu',
|
||||||
'workingFile'
|
'workingFile',
|
||||||
|
'notebook'
|
||||||
],
|
],
|
||||||
#category : #'Grafoscopio-UI'
|
#category : #'Grafoscopio-UI'
|
||||||
}
|
}
|
||||||
@ -72,6 +73,19 @@ GrafoscopioNotebook >> changeBody: aNodeCollection [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #persistence }
|
||||||
|
GrafoscopioNotebook >> exportAsSton: aNotebook on: aFileStream [
|
||||||
|
| stonPrettyString |
|
||||||
|
aNotebook flatten.
|
||||||
|
stonPrettyString := String streamContents: [ :stream |
|
||||||
|
(STON writer on: stream)
|
||||||
|
newLine: String crlf;
|
||||||
|
prettyPrint: true;
|
||||||
|
keepNewLines: true;
|
||||||
|
nextPut: aNotebook children].
|
||||||
|
aFileStream nextPutAll: stonPrettyString
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNotebook >> extent [
|
GrafoscopioNotebook >> extent [
|
||||||
^800@500
|
^800@500
|
||||||
@ -136,7 +150,7 @@ GrafoscopioNotebook >> newWindowMainMenu [
|
|||||||
name: nil;
|
name: nil;
|
||||||
description: 'Save notebook';
|
description: 'Save notebook';
|
||||||
icon: Smalltalk ui icons smallSaveIcon;
|
icon: Smalltalk ui icons smallSaveIcon;
|
||||||
action: [ self inform: 'To be implemented...' ] ].
|
action: [ self saveWorkingNotebook ] ].
|
||||||
group addItem: [ :item |
|
group addItem: [ :item |
|
||||||
item
|
item
|
||||||
name: nil;
|
name: nil;
|
||||||
@ -213,6 +227,16 @@ GrafoscopioNotebook >> newWindowMainMenu [
|
|||||||
action: [ self inform: 'To be implemented...' ] ]].
|
action: [ self inform: 'To be implemented...' ] ]].
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNotebook >> notebook [
|
||||||
|
^ notebook
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNotebook >> notebook: anObject [
|
||||||
|
notebook := anObject
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #api }
|
{ #category : #api }
|
||||||
GrafoscopioNotebook >> notebookContent: aTree [
|
GrafoscopioNotebook >> notebookContent: aTree [
|
||||||
|
|
||||||
@ -230,7 +254,7 @@ GrafoscopioNotebook >> notebookSubMenu [
|
|||||||
name: 'Save';
|
name: 'Save';
|
||||||
icon: Smalltalk ui icons smallSaveIcon;
|
icon: Smalltalk ui icons smallSaveIcon;
|
||||||
shortcut: $s command;
|
shortcut: $s command;
|
||||||
action: [ self inform: 'To be implemented...' ] ].
|
action: [ self saveWorkingNotebook ] ].
|
||||||
group addItem: [ :item |
|
group addItem: [ :item |
|
||||||
item
|
item
|
||||||
name: 'Save as...';
|
name: 'Save as...';
|
||||||
@ -262,14 +286,26 @@ GrafoscopioNotebook >> notebookSubMenu [
|
|||||||
GrafoscopioNotebook >> openFromFile: aFileName [
|
GrafoscopioNotebook >> openFromFile: aFileName [
|
||||||
"I open a notebook from a file named aFileName containing a grafoscopio tree"
|
"I open a notebook from a file named aFileName containing a grafoscopio tree"
|
||||||
|
|
||||||
| root nb |
|
self workingFile: aFileName.
|
||||||
|
self notebook: ((STON fromString: self workingFile contents) at: 1) parent.
|
||||||
|
self title: self workingFile basenameWithIndicator, ' | Grafoscopio notebook'.
|
||||||
|
self notebookContent: self notebook.
|
||||||
|
^ self openWithSpec.
|
||||||
|
]
|
||||||
|
|
||||||
workingFile := aFileName.
|
{ #category : #persistence }
|
||||||
root := ((STON fromString: aFileName contents) at: 1) parent.
|
GrafoscopioNotebook >> openFromFileSelector [
|
||||||
|
|
||||||
|
| fileStream nb |
|
||||||
|
fileStream := UITheme builder
|
||||||
|
fileOpen: 'Choose a file'
|
||||||
|
extensions: #('ston').
|
||||||
|
fileStream ifNil: [
|
||||||
|
self inform: 'No file selected'.
|
||||||
|
^ self ].
|
||||||
|
self workingFile: fileStream name asFileReference.
|
||||||
nb := self class new.
|
nb := self class new.
|
||||||
nb title: aFileName basenameWithIndicator, ' | Grafoscopio notebook'.
|
nb openFromFile: self workingFile.
|
||||||
nb notebookContent: root.
|
|
||||||
^ nb openWithSpec.
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
@ -310,6 +346,17 @@ GrafoscopioNotebook >> projectSubMenu [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #persistence }
|
||||||
|
GrafoscopioNotebook >> saveWorkingNotebook [
|
||||||
|
"Saves the current tree to the user predefined file location used when he/she opened it."
|
||||||
|
|
||||||
|
self workingFile exists ifTrue: [self workingFile delete].
|
||||||
|
self workingFile ensureCreateFile.
|
||||||
|
[ self exportAsSton: self notebook on: (self workingFile writeStream)]
|
||||||
|
ensure: [ (self workingFile writeStream) ifNotNil: #close ].
|
||||||
|
self inform: ('File saved at: ', String cr, self workingFile fullName).
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNotebook >> tree [
|
GrafoscopioNotebook >> tree [
|
||||||
^ tree
|
^ tree
|
||||||
@ -329,3 +376,13 @@ GrafoscopioNotebook >> windowMainMenu [
|
|||||||
GrafoscopioNotebook >> windowMainMenu: anObject [
|
GrafoscopioNotebook >> windowMainMenu: anObject [
|
||||||
windowMainMenu := anObject
|
windowMainMenu := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNotebook >> workingFile [
|
||||||
|
^ workingFile
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNotebook >> workingFile: aFile [
|
||||||
|
workingFile := aFile.
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user