|
Hi,
Intending to do some dynamic surrogate view creation for my presenters
(which are not descendants of Shell), I found that #createView: could be
refactored, in order to let each presenter define how to create its
surrogate view.
Looking at Dolphin X6 implementation, it seems to be the same as in D5.
I've refactored it to be like the two methods attached, which allows to
do the mentioned above.
It's just a suggestion, of course. :-)
Presenter>>createView: aResourceNameString
"Private - Creates and connects a view for the receiver from the
resource identified
by aResourceNameString. Answers the new view created"
| parentView surrogateShellView |
parentView := self parentPresenter isNil
ifTrue: [self createSurrogateView]
ifFalse: [self parentPresenter view].
"Create the new view and validate the parent's layout"
self view: (self class loadViewResource: aResourceNameString inContext:
parentView).
surrogateShellView notNil ifTrue: [self onViewOpened].
parentView validateLayout.
^self view show
Presenter>>createSurrogateView
"Private - The receiver has no parent presenter
so create a basic ShellView to hold its view."
| surrogateShellView parentView|
surrogateShellView := ShellView new create.
parentView := surrogateShellView.
parentView
layoutManager: GridLayout new;
caption: self printString;
largeIcon: self icon;
show.
^parentView
|