Skip to content

Commit

Permalink
Merge pull request #1463 from hernanmd/component_list_mnu
Browse files Browse the repository at this point in the history
Fix MNU when using component list as input port in custom presenter
  • Loading branch information
Ducasse authored Oct 16, 2023
2 parents e0d6c92 + 61cd279 commit 4cfda80
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Spec2-Core/SpComponentListPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ SpComponentListPresenter >> presenters: aSequenceableCollection [
^ self items: aSequenceableCollection
]

{ #category : 'transmitting' }
SpComponentListPresenter >> transmitTo: aPresenter transform: aValuable [

^ self defaultOutputPort
transmitTo: aPresenter
transform: aValuable
]

{ #category : 'api - events' }
SpComponentListPresenter >> whenPresentersChangedDo: aBlock [
"Inform when the presenter list changed (See `SpComponentListPresenter>>#presenters:`.
Expand Down
46 changes: 46 additions & 0 deletions src/Spec2-Tests/SpComplexComponentListExample.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Class {
#name : 'SpComplexComponentListExample',
#superclass : 'SpPresenter',
#instVars : [
'leftPresenter',
'rightPresenter',
'toolbarPresenter'
],
#category : 'Spec2-Tests-Utils',
#package : 'Spec2-Tests',
#tag : 'Utils'
}

{ #category : 'instance creation' }
SpComplexComponentListExample class >> open [
<example>
^ self new open
]

{ #category : 'initialization' }
SpComplexComponentListExample >> connectPresenters [

leftPresenter
transmitTo: rightPresenter
transform: [ : item | { item label asNumber . (item label asNumber * 2) } ]
]

{ #category : 'layout' }
SpComplexComponentListExample >> defaultLayout [

^ SpBoxLayout newTopToBottom
add: toolbarPresenter expand: false;
add: (SpBoxLayout newLeftToRight
add: leftPresenter;
add: rightPresenter;
yourself);
yourself.
]

{ #category : 'initialization' }
SpComplexComponentListExample >> initializePresenters [

toolbarPresenter := self newToolbar.
leftPresenter := self instantiate: SpComplexComponentListLeftExample on: self.
rightPresenter := self instantiate: SpComplexComponentListRightExample on: self.
]
32 changes: 32 additions & 0 deletions src/Spec2-Tests/SpComplexComponentListLeftExample.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Class {
#name : 'SpComplexComponentListLeftExample',
#superclass : 'SpPresenter',
#instVars : [
'componentListPresenter'
],
#category : 'Spec2-Tests-Utils',
#package : 'Spec2-Tests',
#tag : 'Utils'
}

{ #category : 'layout' }
SpComplexComponentListLeftExample >> defaultLayout [

^ SpBoxLayout newTopToBottom
add: componentListPresenter expand: true;
yourself.
]

{ #category : 'ports' }
SpComplexComponentListLeftExample >> defaultOutputPort [

^ componentListPresenter
]

{ #category : 'initialization' }
SpComplexComponentListLeftExample >> initializePresenters [

componentListPresenter := self newComponentList
items: ((10 to: 20) asArray collect: #asPresenter);
yourself.
]
37 changes: 37 additions & 0 deletions src/Spec2-Tests/SpComplexComponentListRightExample.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Class {
#name : 'SpComplexComponentListRightExample',
#superclass : 'SpPresenter',
#instVars : [
'componentListPresenter',
'pageTitle'
],
#category : 'Spec2-Tests-Utils',
#package : 'Spec2-Tests',
#tag : 'Utils'
}

{ #category : 'transmission' }
SpComplexComponentListRightExample >> defaultInputPort [

^ SpListItemsPort newPresenter: componentListPresenter

]

{ #category : 'layout' }
SpComplexComponentListRightExample >> defaultLayout [

^ SpBoxLayout newTopToBottom
add: pageTitle expand: false;
add: componentListPresenter;
yourself.


]

{ #category : 'initialization' }
SpComplexComponentListRightExample >> initializePresenters [

pageTitle := self newLabel.
componentListPresenter := self newComponentList.

]
34 changes: 34 additions & 0 deletions src/Spec2-Tests/SpTransmissionWithComponentListTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : 'SpTransmissionWithComponentListTest',
#superclass : 'SpSmokeTest',
#category : 'Spec2-Tests-Examples',
#package : 'Spec2-Tests',
#tag : 'Examples'
}

{ #category : 'accessing' }
SpTransmissionWithComponentListTest >> classToTest [

^ SpComplexComponentListExample
]

{ #category : 'running' }
SpTransmissionWithComponentListTest >> setUp [

super setUp.
presenter := SpComplexComponentListExample new.

]

{ #category : 'running' }
SpTransmissionWithComponentListTest >> tearDown [

presenter delete.
super tearDown.
]

{ #category : 'tests' }
SpTransmissionWithComponentListTest >> testOpen [

self shouldnt: [ presenter open ] raise: MessageNotUnderstood.
]

0 comments on commit 4cfda80

Please sign in to comment.