From f913a55850421ce116a82688efd1df3bbba1ed17 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 13 Dec 2024 09:25:02 +0100 Subject: [PATCH 1/4] do not display if I setup/bind --- src/Spec2-ListView/SpDropDownPresenter.class.st | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Spec2-ListView/SpDropDownPresenter.class.st b/src/Spec2-ListView/SpDropDownPresenter.class.st index c57f0e7c..b81c884d 100644 --- a/src/Spec2-ListView/SpDropDownPresenter.class.st +++ b/src/Spec2-ListView/SpDropDownPresenter.class.st @@ -32,7 +32,6 @@ SpDropDownPresenter class >> example [ items: self environment allClasses; setup: [ :aPresenter | aPresenter newLabel ]; bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; - display: [ :aClass | aClass name ]; open ] @@ -72,7 +71,6 @@ SpDropDownPresenter class >> exampleWithSelectedItem [ items: self environment allClassesAndTraits; setup: [ :aPresenter | aPresenter newLabel ]; bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; - display: [ :aClass | aClass name ]; selectItem: Object; whenSelectionChangedDo: [ :aSelection | aSelection selectedItem crTrace ]; open From f556b7e9164c876cb6ed1db1d224a945f52f8427 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 18 Dec 2024 10:15:55 +0100 Subject: [PATCH 2/4] restore spacing --- src/Spec2-ListView/SpDropDownPresenter.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-ListView/SpDropDownPresenter.class.st b/src/Spec2-ListView/SpDropDownPresenter.class.st index b81c884d..7c207299 100644 --- a/src/Spec2-ListView/SpDropDownPresenter.class.st +++ b/src/Spec2-ListView/SpDropDownPresenter.class.st @@ -48,7 +48,7 @@ SpDropDownPresenter class >> exampleWithIcons [ | presenter | (presenter := aPresenter newPresenter) layout: (SpBoxLayout newHorizontal - "spacing: 5;" + spacing: 5; add: presenter newImage expand: false; add: presenter newLabel; yourself); From 468c5ad04fe302be1da39684949bb99f31228811 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 18 Dec 2024 14:08:48 +0100 Subject: [PATCH 3/4] when triggering the ok button dialog needs to be ok :) --- src/Spec2-Core/SpAbstractPresenter.class.st | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Spec2-Core/SpAbstractPresenter.class.st b/src/Spec2-Core/SpAbstractPresenter.class.st index df2d016c..07e33b06 100644 --- a/src/Spec2-Core/SpAbstractPresenter.class.st +++ b/src/Spec2-Core/SpAbstractPresenter.class.st @@ -317,6 +317,7 @@ SpAbstractPresenter >> initializeDialogWindow: aDialogWindowPresenter [ presenter close ]; addDefaultButton: 'Ok' do: [ :presenter | presenter triggerOkAction. + presenter beOk. presenter close ] ] From 9a9ebea1e23c036ec164f6e118869a27730d5139 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 18 Dec 2024 16:10:25 +0100 Subject: [PATCH 4/4] add an example with a column for buttons (as this is a frequent need) --- .../SpColumnViewPresenter.class.st | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/Spec2-ListView/SpColumnViewPresenter.class.st b/src/Spec2-ListView/SpColumnViewPresenter.class.st index 0266acaf..6ed7648b 100644 --- a/src/Spec2-ListView/SpColumnViewPresenter.class.st +++ b/src/Spec2-ListView/SpColumnViewPresenter.class.st @@ -88,6 +88,58 @@ SpColumnViewPresenter class >> exampleWithIcons [ open ] +{ #category : 'examples' } +SpColumnViewPresenter class >> exampleWithIconsAndButtons [ + + ^ SpColumnViewPresenter new + addColumn: (SpColumnViewColumn new + title: 'Class'; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | + | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + yourself); + addColumn: (SpColumnViewColumn new + title: 'Actions'; + width: 60; + setup: [ :aPresenter | | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + hAlignCenter; + add: (presenter newButton + addStyle: 'small'; + yourself); + add: (presenter newButton + addStyle: 'small'; + icon: (presenter iconNamed: #smallDelete); + yourself); + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | button1 button2 | + button1 := aPresenter layout children first. + button1 + icon: (aPresenter iconNamed: aClass systemIconName); + action: [ Object inform: aClass name ]. + button2 := aPresenter layout children second. + button2 + action: [ Object inform: 'Will remove ', aClass name ] ]; + yourself); + items: Smalltalk allClassesAndTraits; + open +] + { #category : 'api' } SpColumnViewPresenter >> addColumn: aColumn [ "Add a column to the table. A column should be an instance of `SpTableColumn`"