-
-
Save BenjaminVanRyseghem/cd02f2dc61f350a6495f to your computer and use it in GitHub Desktop.
An example of how to compose DynamicComposableModel instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m := DynamicComposableModel new. | |
m instantiateModels: #( list ListModel ). | |
m list items: (AbstractWidgetModel allSubclasses sorted: [:a :b | a name < b name ]). | |
m layout: (SpecLayout composed | |
add: #list; | |
yourself). | |
m openWithSpec. | |
m2 := DynamicComposableModel new. | |
m2 assign: m to: #classes. | |
m2 instantiateModels: #( methods ListModel ). | |
m list whenSelectedItemChanged: [ :item | | |
item | |
ifNil: [ m2 methods: #() ] | |
ifNotNil: [ m2 methods items: ((item selectorsInProtocol: 'protocol') sorted) ] ]. | |
m2 layout: (SpecLayout composed | |
newRow: [ :r | r add: #classes; add: #methods ]; | |
yourself). | |
m2 openWithSpec. | |
m3 := DynamicComposableModel new. | |
m3 assign: m2 to: #top. | |
m3 instantiateModels: #( text TextModel ). | |
m2 methods whenSelectedItemChanged: [ :selector | | |
selector ifNil: [ m3 text text: '' ] ifNotNil: [ m3 text text: (m list selectedItem >> selector ) sourceCode ] ]. | |
m3 layout: (SpecLayout composed | |
newColumn: [ :c | c add: #top; add: #text ]; | |
yourself). | |
m3 openWithSpec. | |
m3 title: 'Protocol browser' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment