Skip to content
Permalink
Browse files

Merge pull request #712 from jecisc/Remove-ComposablePresenter-refere…

…nces

Remove-ComposablePresenter-references
  • Loading branch information...
jecisc committed Aug 13, 2019
2 parents 4b6828b + 05efdf3 commit ef8c984ecb733783c4bd5f1306420d9a9a684440
@@ -8,9 +8,9 @@ Class {
}

{ #category : #initialization }
SpMorphicImageAdapter >> adapt: aComposablePresenter [
SpMorphicImageAdapter >> adapt: aPresenter [

super adapt: aComposablePresenter.
super adapt: aPresenter.
widget
on: #click
send: #click
@@ -5,17 +5,17 @@ Class {
}

{ #category : #'instance creation' }
SpMorphicMenuAdapter class >> adaptAsPopup: aComposablePresenter [
SpMorphicMenuAdapter class >> adaptAsPopup: aPresenter [
^ self new
adaptAsPopup: aComposablePresenter;
adaptAsPopup: aPresenter;
yourself
]

{ #category : #initialization }
SpMorphicMenuAdapter >> adaptAsPopup: aComposablePresenter [
SpMorphicMenuAdapter >> adaptAsPopup: aPresenter [

model := aComposablePresenter.
aComposablePresenter addDependent: self.
model := aPresenter.
aPresenter addDependent: self.
widget := self buildWidgetPopup.
]

@@ -32,21 +32,11 @@ ManifestSpec2Core class >> ruleLongMethodsRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#SpAbstractWidgetPresenter #initialize #false)) #'2016-07-01T15:56:13.356024+02:00') #(#(#RGMethodDefinition #(#SpPresenter #initialize #false)) #'2016-07-01T15:56:13.355982+02:00') )
]

{ #category : #'code-critics' }
ManifestSpec2Core class >> ruleRBEquivalentSuperclassMethodsRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#'ComposablePresenter class' #iconNamed: #true)) #'2018-11-07T10:48:10.451257+01:00') )
]

{ #category : #'code-critics' }
ManifestSpec2Core class >> ruleRBOverridesDeprecatedMethodRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#SpMenuItemPresenter #name #false)) #'2016-07-01T15:56:13.378417+02:00') )
]

{ #category : #'code-critics' }
ManifestSpec2Core class >> ruleSubclassResponsibilityNotDefinedRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#'ComposablePresenter class' #defaultSpec #true)) #'2016-07-01T15:56:13.461086+02:00') )
]

{ #category : #'code-critics' }
ManifestSpec2Core class >> ruleUsesTrueRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#'DiffPresenter class' #exampleWithOptions #true)) #'2016-07-01T15:56:13.475288+02:00') )
@@ -20,10 +20,10 @@ Class {
}

{ #category : #'instance creation' }
SpAbstractAdapter class >> adapt: aComposablePresenter [
SpAbstractAdapter class >> adapt: aPresenter [

^ self new
adapt: aComposablePresenter;
adapt: aPresenter;
yourself
]

@@ -55,10 +55,10 @@ SpAbstractAdapter class >> owner: anOwner [
]

{ #category : #initialization }
SpAbstractAdapter >> adapt: aComposablePresenter [
SpAbstractAdapter >> adapt: aPresenter [

model := aComposablePresenter.
aComposablePresenter addDependent: self.
model := aPresenter.
aPresenter addDependent: self.

widget := self buildWidget.
]
@@ -159,7 +159,7 @@ SpPresenter class >> newApplication: anApplication owner: anOwningPresenter mode
SpPresenter class >> on: aDomainObject [

"self
deprecated: 'ComposablePresenters are instantiated in the context of an application!'
deprecated: 'SpPresenters are instantiated in the context of an application!'
on: '2019-02-26'
in: #Pharo8."

@@ -187,7 +187,7 @@ SpPresenter class >> title [
{ #category : #TOREMOVE }
SpPresenter >> aboutText [
"DO NOT USE
With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
@@ -285,7 +285,7 @@ SpPresenter >> asPresenter [
{ #category : #TOREMOVE }
SpPresenter >> askOkToClose [
"DO NOT USE
With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
@@ -483,7 +483,7 @@ SpPresenter >> iconNamed: aSymbol [
SpPresenter >> initialExtent [

"DO NOT USE
With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
@@ -570,20 +570,20 @@ SpPresenter >> initializeWindow: aWindowPresenter [
]

{ #category : #'instance creation' }
SpPresenter >> instantiate: aComposablePresenterClass [
"Instantiate a ComposablePresenter subclass and set its instance owner"
^ aComposablePresenterClass owner: self
SpPresenter >> instantiate: aPresenterClass [
"Instantiate a SpPresenter subclass and set its instance owner"
^ aPresenterClass owner: self
]

{ #category : #'instance creation' }
SpPresenter >> instantiate: aComposablePresenterClass on: aModel [
"Instantiate a ComposablePresenter subclass and set its instance owner and model"
^ aComposablePresenterClass owner: self on: aModel
SpPresenter >> instantiate: aPresenterClass on: aModel [
"Instantiate a SpPresenter subclass and set its instance owner and model"
^ aPresenterClass owner: self on: aModel
]

{ #category : #'instance creation' }
SpPresenter >> instantiatePresenters: aCollectionOfPairs [
"instantiatePresenters: is legacy code in ComposablePresenter and must not be used. It will be deprecated and removed."
"instantiatePresenters: is legacy code in SpPresenter and must not be used. It will be deprecated and removed."

"Used to instantiate multiple sub widget at once. Take aCollectionOfPairs where each odd element is an inst var name and each even element is a class name, create an instance from the class name and store it into the inst var"

@@ -950,7 +950,7 @@ SpPresenter >> takeLastKeyboardFocus [
{ #category : #TOREMOVE }
SpPresenter >> title [
"DO NOT USE
With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
@@ -1036,7 +1036,7 @@ SpPresenter >> whenWindowChanged: aBlock [
{ #category : #TOREMOVE }
SpPresenter >> windowIcon [
"DO NOT USE
With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
@@ -13,10 +13,10 @@ SpMorphicTabAdapter class >> isDeprecated [
]

{ #category : #initialization }
SpMorphicTabAdapter >> adapt: aComposablePresenter [
widget := self buildWidgetWith: aComposablePresenter.
aComposablePresenter addDependent: widget.
self bindModel: aComposablePresenter andWidget: widget
SpMorphicTabAdapter >> adapt: aPresenter [
widget := self buildWidgetWith: aPresenter.
aPresenter addDependent: widget.
self bindModel: aPresenter andWidget: widget
]

{ #category : #updating }
@@ -4,7 +4,7 @@ Extension { #name : #SpPresenter }
SpPresenter >> aboutText: aString [
self
deprecated:
'With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
'With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.'.
@@ -15,7 +15,7 @@ SpPresenter >> aboutText: aString [
SpPresenter >> askOkToClose: aBoolean [
self
deprecated:
'With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
'With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.'.
@@ -130,7 +130,7 @@ SpPresenter >> specSpacer [
SpPresenter >> title: aString [
self
deprecated:
'With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
'With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.'.
@@ -151,7 +151,7 @@ SpPresenter >> widget [
SpPresenter >> windowIcon: aForm [
self
deprecated:
'With Spec 2, ComposablePresenter was refactored to move all window management to WindowPresenter.
'With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.'.
@@ -123,7 +123,7 @@ SpRadioButtonGroupPresenter >> default: aButton [
SpRadioButtonGroupPresenter >> defaultOnce: aButton [
aButton privateSetState: true.
self currentActivated: aButton.
"This method is used to avoid a problem of default: with a DynamicComposablePresenter but a fix would be better (if possible)"
"This method is used to avoid a problem of default: with a DynamicPresenter but a fix would be better (if possible)"
]

{ #category : #specs }
@@ -181,9 +181,9 @@ SpTabPresenter >> morphHolder [
]

{ #category : #api }
SpTabPresenter >> presenter: aComposablePresenter [
aComposablePresenter owner: self.
self retrievingBlock: [ aComposablePresenter buildWithSpec ]
SpTabPresenter >> presenter: aPresenter [
aPresenter owner: self.
self retrievingBlock: [ aPresenter buildWithSpec ]
]

{ #category : #api }
@@ -18,14 +18,14 @@ SpExamples class >> bookName [
SpExamples class >> firstExample [
^HelpTopic
title: 'A first example: ModelList'
contents: 'Creating a specific UI always starts with the subclassing of ComposablePresenter. Each sub widget is stored into an instance variable of the newly created class. All the code presented here is already in the image so you can simply do:
contents: 'Creating a specific UI always starts with the subclassing of SpPresenter. Each sub widget is stored into an instance variable of the newly created class. All the code presented here is already in the image so you can simply do:
ModelList browse
And follow the tutorial while browsing the code. So let''s subclass ComposablePresenter.
And follow the tutorial while browsing the code. So let''s subclass SpPresenter.
ComposablePresenter subclass: #ModelList
SpPresenter subclass: #ModelList
instanceVariableNames: ''list''
classVariableNames: ''
category: ''Spec-Examples''
@@ -116,9 +116,9 @@ SpExamples class >> secondExample [
a list
a label.
So again, we start by subclassing ComposablePresenter:
So again, we start by subclassing SpPresenter
ComposablePresenter subclass: #ProtocolList
SpPresenter subclass: #ProtocolList
instanceVariableNames: ''label protocols''
classVariableNames: ''
category: ''Spec-Examples''
@@ -20,7 +20,7 @@ SpHelpTopics class >> introduction [
title: 'About Spec'
contents: 'Spec has been originally developed by B. Van Ryseghem based on an idea of S. Ducasse. It is now maintained by the community and the pharo core team..

Spec is an attempt to support UI logic reuse. Spec is influenced by VisualWorks and Dolphin MVP in the sense that it recognizes the need for a Presenter or Application-Model class, in Spec called ComposablePresenter that manages the logic and the link between widgets and domain objects. Spec, following the tradition, uses value holders, simple object raising announcements when their values, often domain objects, change.'
Spec is an attempt to support UI logic reuse. Spec is influenced by VisualWorks and Dolphin MVP in the sense that it recognizes the need for a Presenter or Application-Model class, in Spec called SpPresenter that manages the logic and the link between widgets and domain objects. Spec, following the tradition, uses value holders, simple object raising announcements when their values, often domain objects, change.'
]

{ #category : #accessing }
@@ -84,7 +84,7 @@ And the same but for a column:
yourself
Note that it is generally considered a bad habit to hardcode the size of the widgets. Methods are available on ComposablePresenter providing sensible default sizes, like the width of a button. When specifying custom widget sizes, care should be taken to take in account the current font size.'
Note that it is generally considered a bad habit to hardcode the size of the widgets. Methods are available on SpPresenter providing sensible default sizes, like the width of a button. When specifying custom widget sizes, care should be taken to take in account the current font size.'



@@ -55,13 +55,13 @@ SpTheHeartOfSpec class >> intro [
title: 'The Heart of Spec'
contents: 'All user interfaces in Spec are constructed through the composition of existing user interfaces. To define a user interface, it is sufficient to define the model of the user interface. The UI elements that correspond to this model are instantiated by Spec, depending on the underlying UI framework.

It is the composition of this model and these UI elements that makes up the resulting widget that is shown to the user, i.e. the resulting user interface. Hence, since all UIs are constructed through composition of other UIs, and it is sufficient to define the model to define the UI, the root class of all UIs is named ComposablePresenter. So, to define a new user interface, a subclass of ComposablePresenter needs to be created.
It is the composition of this model and these UI elements that makes up the resulting widget that is shown to the user, i.e. the resulting user interface. Hence, since all UIs are constructed through composition of other UIs, and it is sufficient to define the model to define the UI, the root class of all UIs is named SpPresenter. So, to define a new user interface, a subclass of SpPresenter needs to be created.

Spec is inspired by the MVP pattern. It is built around three axes that materialize themselves as the following three methods:

ComposablePresenter>>#initializeWidgets
ComposablePresenter>>#initializePresenter
ComposablePresenter class>>#defaultSpec.
SpPresenter>>#initializeWidgets
SpPresenter>>#initializePresenter
SpPresenter class>>#defaultSpec.

These methods are hence typically found in the model for each user interface. In the following topics we describe the responsibility for each method, i.e. how these three work together to build the overall UI.'
]
@@ -111,7 +111,7 @@ Through the use of an creation method or through the use of the instantiate: met
for example newButton creates a button widget, and newList creates a list widget.
The complete list of available widget creation methods can be found in the class Composable-Model in the protocol widgets.

Considering the second option, to reuse any composite widgets, i.e. a subclass of ComposablePresenter, the widget needs to be initialized using the instantiate: method. For example, to reuse a Message-Browser widget, the code is:
Considering the second option, to reuse any composite widgets, i.e. a subclass of SpPresenter, the widget needs to be initialized using the instantiate: method. For example, to reuse a Message-Browser widget, the code is:

self instantiate: MessageBrowser.'
]
@@ -11,7 +11,7 @@ SpLabelledContainerTest >> classToTest [

{ #category : #running }
SpLabelledContainerTest >> initializeTestedInstance [
presenter content: SpTestingComposablePresenter.
presenter content: SpTestingPresenter
]

{ #category : #tests }
@@ -33,16 +33,16 @@ SpAbstractWidgetLayoutTest >> testDynamicBuild [
"Cyril: This is currently a duplicated of a test in SpecInterpreter, but this test is useful for more that the SpecInterpreter and since we plan to remove the interpreter I want to ensure we do not lose this test. This comment can be removed once the SpecInterpreter will be removed."

| model widget1 widget2 widget3 |
model := SpTestingComposablePresenter new.
model := SpTestingPresenter new.
model openWithSpec close.
widget1 := model list adapter.
model openWithSpec close.
widget2 := model list adapter.
self deny: widget1 == widget2.
self deny: widget1 identicalTo: widget2.
model list needRebuild: false.
model needRebuild: false.
model openWithSpec close.
widget3 := model list adapter.
self assert: widget2 == widget3.
self assert: widget2 identicalTo: widget3.
self assert: model needRebuild
]
@@ -16,7 +16,7 @@ SpComposablePresenterWithAdditionalSubpresentersTest >> setUp [
{ #category : #tests }
SpComposablePresenterWithAdditionalSubpresentersTest >> testOpening [
| aPresenter |
aPresenter := application newPresenter: SpTestingComposablePresenterWithAdditionalPresenters.
aPresenter := application newPresenter: SpTestingPresenterWithAdditionalPresenters.
aPresenter openWithSpec.

#(subpresenter1 subpresenter2 subpresenter3) do: [ :aKey | self assert: (aPresenter additionalSubpresentersMap at: aKey) owner equals: aPresenter ]
@@ -18,7 +18,7 @@ SpInterpreterTest >> setUp [
super setUp.
specInterpreterClass := SpInterpreter.
specInterpreter := specInterpreterClass new.
specInterpreter presenter: SpTestingComposablePresenter new
specInterpreter presenter: SpTestingPresenter new
]

{ #category : #running }
@@ -41,17 +41,17 @@ SpInterpreterTest >> testConvertRandomSymbolOfClassToInstance [
{ #category : #tests }
SpInterpreterTest >> testDynamicBuild [
| model widget1 widget2 widget3 |
model := SpTestingComposablePresenter new.
model := SpTestingPresenter new.
model openWithSpec close.
widget1 := model list adapter.
model openWithSpec close.
widget2 := model list adapter.
self deny: widget1 == widget2.
self deny: widget1 identicalTo: widget2.
model list needRebuild: false.
model needRebuild: false.
model openWithSpec close.
widget3 := model list adapter.
self assert: widget2 == widget3.
self assert: widget2 identicalTo: widget3.
self assert: model needRebuild
]

0 comments on commit ef8c984

Please sign in to comment.
You can’t perform that action at this time.