113 lines
2.2 KiB
Smalltalk
113 lines
2.2 KiB
Smalltalk
"
|
|
I'm just a way to explore Spec and its documentation for learning purposes.
|
|
"
|
|
Class {
|
|
#name : #DynamicDict,
|
|
#superclass : #ComposableModel,
|
|
#instVars : [
|
|
'data',
|
|
'list',
|
|
'content'
|
|
],
|
|
#category : #'Grafoscopio-UI'
|
|
}
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
DynamicDict class >> defaultSpec [
|
|
<spec: #default>
|
|
|
|
^ SpecLayout composed
|
|
newRow: [:row |
|
|
row
|
|
add: #list right: 0.7;
|
|
add: #content left: 0.3];
|
|
yourself
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DynamicDict >> content [
|
|
^ content
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DynamicDict >> content: anObject [
|
|
content := anObject
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DynamicDict >> data [
|
|
data := {'first' -> 'I am just text' . 'second' -> 'ProfStef openPharoZenWorkspace' } asOrderedDictionary.
|
|
^ data
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
DynamicDict >> initializePresenter [
|
|
list whenSelectedItemChanged: [:item |
|
|
item = 'first'
|
|
ifTrue: [ self rebuildWithTextLayoutFor: item ].
|
|
item = 'second'
|
|
ifTrue: [ self rebuildWithCodeLayoutFor: item ].
|
|
]
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
DynamicDict >> initializeWidgets [
|
|
|
|
|
|
list := self newList.
|
|
list items: self data keys.
|
|
content := self newText.
|
|
self focusOrder
|
|
add: list;
|
|
add: content.
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DynamicDict >> list [
|
|
^ list
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DynamicDict >> list: anObject [
|
|
list := anObject
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
DynamicDict >> rebuildWithCodeLayoutFor: key [
|
|
| newLayout |
|
|
|
|
content := GlamourPresentationModel new.
|
|
content presentationClass: GTPlayground startOn: (GTPlayPage new saveContent: (data at: key)).
|
|
newLayout := SpecLayout composed
|
|
newRow: [:row |
|
|
row
|
|
add: #list right: 0.7;
|
|
add: #content left: 0.3];
|
|
yourself.
|
|
self needRebuild: false.
|
|
content needRebuild: true.
|
|
self buildWithSpecLayout: newLayout.
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
DynamicDict >> rebuildWithTextLayoutFor: key [
|
|
| newLayout |
|
|
|
|
content := self newText text: (data at: key).
|
|
newLayout := SpecLayout composed
|
|
newRow: [:row |
|
|
row
|
|
add: #list right: 0.7;
|
|
add: #content left: 0.3];
|
|
yourself.
|
|
self needRebuild: false.
|
|
list needRebuild: false.
|
|
content needRebuild: true.
|
|
self buildWithSpecLayout: newLayout.
|
|
]
|
|
|
|
{ #category : #api }
|
|
DynamicDict >> title [
|
|
^'Dynamic UI | test'
|
|
]
|