From 6e432bfa5f2eb9f471c5c888d15a91a604643d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 27 Dec 2023 17:35:27 +0100 Subject: [PATCH 1/2] introduce displayBlock and deprecate display. This is a block and not a display that we get! --- .../SpChooserPresenter.class.st | 2 +- .../SpFilteringListPresenter.class.st | 13 ++++++++++--- .../SpFilteringSelectableListPresenter.class.st | 8 +++++++- src/Spec2-Core/SpDropListPresenter.class.st | 10 +++++++++- src/Spec2-Core/SpDropListTableColumn.class.st | 8 +++++++- src/Spec2-Core/SpListPresenter.class.st | 16 ++++++++++++---- src/Spec2-Core/SpTreePresenter.class.st | 9 ++++++++- src/Spec2-Morphic/SpDatePresenter.class.st | 4 ++-- 8 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/Spec2-CommonWidgets/SpChooserPresenter.class.st b/src/Spec2-CommonWidgets/SpChooserPresenter.class.st index 9dfd0f99..2ff6c65a 100644 --- a/src/Spec2-CommonWidgets/SpChooserPresenter.class.st +++ b/src/Spec2-CommonWidgets/SpChooserPresenter.class.st @@ -211,7 +211,7 @@ SpChooserPresenter >> initializePresenters [ SpChooserPresenter >> initializeSortingBlocks [ | sortingBlock | - sortingBlock := sourceList display ascending. + sortingBlock := sourceList displayBlock ascending. sourceList sortingBlock: sortingBlock. targetList sortingBlock: sortingBlock ] diff --git a/src/Spec2-CommonWidgets/SpFilteringListPresenter.class.st b/src/Spec2-CommonWidgets/SpFilteringListPresenter.class.st index 85bbf06c..890b8b99 100644 --- a/src/Spec2-CommonWidgets/SpFilteringListPresenter.class.st +++ b/src/Spec2-CommonWidgets/SpFilteringListPresenter.class.st @@ -79,8 +79,9 @@ SpFilteringListPresenter >> defaultOutputPort [ { #category : 'api' } SpFilteringListPresenter >> display [ - - ^ self listPresenter display + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock'. + + ^ self listPresenter displayBlock ] { #category : 'api' } @@ -89,6 +90,12 @@ SpFilteringListPresenter >> display: aBlock [ self listPresenter display: aBlock ] +{ #category : 'api' } +SpFilteringListPresenter >> displayBlock [ + + ^ self listPresenter displayBlock +] + { #category : 'api' } SpFilteringListPresenter >> displayIcon: aBlock [ @@ -111,7 +118,7 @@ SpFilteringListPresenter >> filterListItems: pattern [ filteredItems := unfilteredItems select: [ :item | itemFilterBlock - value: (self display value: item) + value: (self displayBlock value: item) value: pattern ]. listPresenter items: filteredItems diff --git a/src/Spec2-CommonWidgets/SpFilteringSelectableListPresenter.class.st b/src/Spec2-CommonWidgets/SpFilteringSelectableListPresenter.class.st index 8e1861d6..04365aae 100644 --- a/src/Spec2-CommonWidgets/SpFilteringSelectableListPresenter.class.st +++ b/src/Spec2-CommonWidgets/SpFilteringSelectableListPresenter.class.st @@ -49,7 +49,7 @@ SpFilteringSelectableListPresenter >> deactivateItem: anObject [ { #category : 'api' } SpFilteringSelectableListPresenter >> display [ - + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock' . ^ displayBlock ] @@ -60,6 +60,12 @@ SpFilteringSelectableListPresenter >> display: aBlock [ listPresenter columns: self listColumns ] +{ #category : 'api' } +SpFilteringSelectableListPresenter >> displayBlock [ + + ^ displayBlock +] + { #category : 'api' } SpFilteringSelectableListPresenter >> displayIcon: aBlock [ diff --git a/src/Spec2-Core/SpDropListPresenter.class.st b/src/Spec2-Core/SpDropListPresenter.class.st index a9f83350..47e2fc90 100644 --- a/src/Spec2-Core/SpDropListPresenter.class.st +++ b/src/Spec2-Core/SpDropListPresenter.class.st @@ -83,7 +83,7 @@ SpDropListPresenter >> disableSelectionDuring: aBlock [ SpDropListPresenter >> display [ "Answer the formatting block to transform how the elements will be displayed. See also `SpDropListPresenter>>#display:`" - + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock'. ^ displayBlock ] @@ -97,6 +97,14 @@ SpDropListPresenter >> display: aBlock [ ] +{ #category : 'api' } +SpDropListPresenter >> displayBlock [ + "Answer the formatting block to transform how the elements will be displayed. + See also `SpDropListPresenter>>#display:`" + + ^ displayBlock +] + { #category : 'private' } SpDropListPresenter >> displayForItem: anItem [ "The order of the arguments may look weird, but then it seems more natural while using the widget" diff --git a/src/Spec2-Core/SpDropListTableColumn.class.st b/src/Spec2-Core/SpDropListTableColumn.class.st index ca734de3..8bfbc096 100644 --- a/src/Spec2-Core/SpDropListTableColumn.class.st +++ b/src/Spec2-Core/SpDropListTableColumn.class.st @@ -43,7 +43,7 @@ SpDropListTableColumn >> acceptColumnVisitor: aBuilder [ { #category : 'accessing' } SpDropListTableColumn >> display [ - + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock'. ^ display ] @@ -53,6 +53,12 @@ SpDropListTableColumn >> display: aBlock [ display := aBlock ] +{ #category : 'accessing' } +SpDropListTableColumn >> displayBlock [ + + ^ display +] + { #category : 'initialization' } SpDropListTableColumn >> initialize [ diff --git a/src/Spec2-Core/SpListPresenter.class.st b/src/Spec2-Core/SpListPresenter.class.st index 208d5add..afbd9071 100644 --- a/src/Spec2-Core/SpListPresenter.class.st +++ b/src/Spec2-Core/SpListPresenter.class.st @@ -51,10 +51,11 @@ SpListPresenter >> clickOnSelectedItem [ { #category : 'api' } SpListPresenter >> display [ - "Answer the display block that will transform the objects from `SpAbstractListPresenter>>#model` into a - displayable string." - - ^ display + "Answer the display block that will transform the objects from `SpAbstractListPresenter>>#model` into a displayable string." + + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock'. + ^ self displayBlock. + ] { #category : 'api' } @@ -74,6 +75,13 @@ SpListPresenter >> display: aBlock [ display := aBlock ] +{ #category : 'api' } +SpListPresenter >> displayBlock [ + "Answer the display block that will transform the objects from `SpAbstractListPresenter>>#model` into a displayable string." + + ^ display +] + { #category : 'api' } SpListPresenter >> displayIcon [ "Return the block used to return an icon that will be displayed in the list" diff --git a/src/Spec2-Core/SpTreePresenter.class.st b/src/Spec2-Core/SpTreePresenter.class.st index cd03a6e9..e2799316 100644 --- a/src/Spec2-Core/SpTreePresenter.class.st +++ b/src/Spec2-Core/SpTreePresenter.class.st @@ -67,7 +67,7 @@ SpTreePresenter >> beResizable [ { #category : 'api' } SpTreePresenter >> display [ "Answer the display block that will transform the model nodes into a displayable string." - + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock'. ^ displayBlock ] @@ -88,6 +88,13 @@ SpTreePresenter >> display: aBlock [ displayBlock := aBlock ] +{ #category : 'api' } +SpTreePresenter >> displayBlock [ + "Answer the display block that will transform the model nodes into a displayable string." + + ^ displayBlock +] + { #category : 'api' } SpTreePresenter >> displayIcon [ "Return the block used to return an icon that will be displayed in the tree" diff --git a/src/Spec2-Morphic/SpDatePresenter.class.st b/src/Spec2-Morphic/SpDatePresenter.class.st index d753b8fc..598a09e0 100644 --- a/src/Spec2-Morphic/SpDatePresenter.class.st +++ b/src/Spec2-Morphic/SpDatePresenter.class.st @@ -65,7 +65,7 @@ SpDatePresenter >> date: aDate [ | dateString | date := aDate. - dateString := self display value: date. + dateString := self displayBlock value: date. self dateModel text: dateString. ] @@ -84,7 +84,7 @@ SpDatePresenter >> defaultDate [ SpDatePresenter >> display [ "Return the one argument block used to wrap your domain specific items. The block should return something that can be displayed in a list - like a String or a Text" - + self deprecated: 'Please use displayBlock' transformWith: '`aRec display' -> '`aRec displayBlock'. ^ displayBlock ] From 6151ecf1ad085b6f4e6f3edb02d356897b62d270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 27 Dec 2023 18:40:42 +0100 Subject: [PATCH 2/2] Adding the missing accessor --- src/Spec2-Core/SpDropListPresenter.class.st | 2 +- src/Spec2-Morphic/SpDatePresenter.class.st | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Spec2-Core/SpDropListPresenter.class.st b/src/Spec2-Core/SpDropListPresenter.class.st index 47e2fc90..0e08ecd1 100644 --- a/src/Spec2-Core/SpDropListPresenter.class.st +++ b/src/Spec2-Core/SpDropListPresenter.class.st @@ -109,7 +109,7 @@ SpDropListPresenter >> displayBlock [ SpDropListPresenter >> displayForItem: anItem [ "The order of the arguments may look weird, but then it seems more natural while using the widget" - ^ self display cull: anItem model cull: anItem + ^ self displayBlock cull: anItem model cull: anItem ] { #category : 'api' } diff --git a/src/Spec2-Morphic/SpDatePresenter.class.st b/src/Spec2-Morphic/SpDatePresenter.class.st index 598a09e0..cfd3e4f6 100644 --- a/src/Spec2-Morphic/SpDatePresenter.class.st +++ b/src/Spec2-Morphic/SpDatePresenter.class.st @@ -95,6 +95,14 @@ SpDatePresenter >> display: aBlock [ displayBlock := aBlock ] +{ #category : 'api' } +SpDatePresenter >> displayBlock [ + "Return the one argument block used to wrap your domain specific items. + The block should return something that can be displayed in a list - like a String or a Text" + + ^ displayBlock +] + { #category : 'private' } SpDatePresenter >> iconMorph [