From c9874d77b4a5b08e4a56c196e8736f7ce2d30e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 21 Nov 2023 10:15:13 +0100 Subject: [PATCH] Added helper methods in SpPresenter and SpApplication - started to reorganised the extensions (newInform was an extension but not its user method in SpApplication - we will have to look because in SpPresenter the newInform are not extensions so may be none of them should be extensions --- src/Spec2-Core/SpApplication.class.st | 54 --------------- src/Spec2-Core/SpPresenter.class.st | 7 ++ src/Spec2-Dialogs/SpApplication.extension.st | 70 ++++++++++++++++++++ 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/src/Spec2-Core/SpApplication.class.st b/src/Spec2-Core/SpApplication.class.st index 6c847e66..7ef709a6 100644 --- a/src/Spec2-Core/SpApplication.class.st +++ b/src/Spec2-Core/SpApplication.class.st @@ -109,16 +109,6 @@ SpApplication >> adapterBindings [ ^ self backend adapterBindings ] -{ #category : 'ui - dialogs' } -SpApplication >> alert: aString [ - "Displays an inform dialog, for more configurable version please use `self application newInform title: ....`." - - ^ self newAlert - title: 'Alert'; - label: aString; - openModal -] - { #category : 'accessing - backend' } SpApplication >> backend [ @@ -150,16 +140,6 @@ SpApplication >> configuration [ configuration ] ] -{ #category : 'ui - dialogs' } -SpApplication >> confirm: aString [ - "Displays a confirm dialog, for more configurable version please use `self application newConfirm title: ....`." - - ^ self newConfirm - title: 'Please confirm'; - label: aString; - openModal -] - { #category : 'showing' } SpApplication >> defaultBlockedDialogWindowPresenterClass [ @@ -251,16 +231,6 @@ SpApplication >> iconProvider: anIconProvider [ iconProvider := anIconProvider ] -{ #category : 'ui - dialogs' } -SpApplication >> inform: aString [ - "Displays an inform dialog, for more configurable version please use `self application newInform title: ....`." - - ^ self newInform - title: 'Alert'; - label: aString; - openModal -] - { #category : 'accessing' } SpApplication >> locale [ @@ -292,18 +262,6 @@ SpApplication >> notificationCenter [ ^ notificationCenter ifNil: [ notificationCenter := SpNotificationCenter new forApplication: self; yourself ] ] -{ #category : 'ui - dialogs' } -SpApplication >> notificationClass [ - - ^ SpNotificationItem -] - -{ #category : 'ui - dialogs' } -SpApplication >> notify: aString [ - - self notificationCenter add: (self notificationClass with: aString) -] - { #category : 'accessing - properties' } SpApplication >> properties [ @@ -386,18 +344,6 @@ SpApplication >> run [ self start ] -{ #category : 'ui - dialogs' } -SpApplication >> selectDirectoryTitle: aString [ - - ^ self backend selectDirectoryTitle: aString -] - -{ #category : 'ui - dialogs' } -SpApplication >> selectFileTitle: aString [ - - ^ self backend selectFileTitle: aString -] - { #category : 'ui' } SpApplication >> showWaitCursorWhile: aBlock [ diff --git a/src/Spec2-Core/SpPresenter.class.st b/src/Spec2-Core/SpPresenter.class.st index 60312d74..cbbe07f1 100644 --- a/src/Spec2-Core/SpPresenter.class.st +++ b/src/Spec2-Core/SpPresenter.class.st @@ -525,6 +525,13 @@ SpPresenter >> inform: aString [ ^ self application inform: aString ] +{ #category : 'simple dialog helpers' } +SpPresenter >> informUser: aString during: aBlock [ + "Displays a simple inform dialog while a task is perform without progress bar." + + ^ self application informUser: aString during: aBlock +] + { #category : 'TOREMOVE' } SpPresenter >> initialExtent [ diff --git a/src/Spec2-Dialogs/SpApplication.extension.st b/src/Spec2-Dialogs/SpApplication.extension.st index 9b6c0099..59115c33 100644 --- a/src/Spec2-Dialogs/SpApplication.extension.st +++ b/src/Spec2-Dialogs/SpApplication.extension.st @@ -1,5 +1,45 @@ Extension { #name : 'SpApplication' } +{ #category : '*Spec2-Dialogs' } +SpApplication >> alert: aString [ + "Displays an inform dialog, for more configurable version please use `self application newInform title: ....`." + + ^ self newAlert + title: 'Alert'; + label: aString; + openModal +] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> confirm: aString [ + "Displays a confirm dialog, for more configurable version please use `self application newConfirm title: ....`." + + ^ self newConfirm + title: 'Please confirm'; + label: aString; + openModal +] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> inform: aString [ + "Displays an inform dialog, for more configurable version please use `self application newInform title: ....`." + + ^ self newInform + title: 'Alert'; + label: aString; + openModal +] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> informUser: aString during: aBlock [ + "Displays an inform user dialog." + + ^ self newInformUser + title: aString; + informUserDuring: aBlock; + openModal +] + { #category : '*Spec2-Dialogs' } SpApplication >> newAlert [ @@ -18,6 +58,12 @@ SpApplication >> newInform [ ^ SpInformDialog newApplication: self ] +{ #category : '*Spec2-Dialogs' } +SpApplication >> newInformUser [ + + ^ SpInformUserDialog newApplication: self +] + { #category : '*Spec2-Dialogs' } SpApplication >> newJobList [ @@ -51,3 +97,27 @@ SpApplication >> newSelect [ ^ SpSelectDialog newApplication: self ] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> notificationClass [ + + ^ SpNotificationItem +] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> notify: aString [ + + self notificationCenter add: (self notificationClass with: aString) +] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> selectDirectoryTitle: aString [ + + ^ self backend selectDirectoryTitle: aString +] + +{ #category : '*Spec2-Dialogs' } +SpApplication >> selectFileTitle: aString [ + + ^ self backend selectFileTitle: aString +]