Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce inform during #1473

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/BaselineOfSpecCore/BaselineOfSpecCore.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BaselineOfSpecCore >> baseline: spec [
package: 'Spec2-Layout';
package: 'Spec2-Core' with: [ spec requires: #('Spec2-Layout') ];
package: 'Spec2-Dialogs' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Dialogs-Tests' with: [ spec requires: #('Spec2-Dialogs') ];
package: 'Spec2-CommandLine' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Commands';
package: 'Spec2-Transmission' with: [ spec requires: #('Spec2-Core') ];
Expand All @@ -32,7 +33,7 @@ BaselineOfSpecCore >> baseline: spec [
"Tests"
package: 'Spec2-Adapters-Stub' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Commander2-Tests' with: [ spec requires: #('Spec2-Commander2') ];
package: 'Spec2-Tests' with: [ spec requires: #('Spec2-Core' 'Spec2-Examples') ];
package: 'Spec2-Tests' with: [ spec requires: #('Spec2-Core' 'Spec2-Examples' 'Spec2-Dialogs-Tests') ];
package: 'Spec2-Code-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Code') ];
package: 'Spec2-Code-Diff-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Code-Diff') ];
"Examples"
Expand Down
54 changes: 0 additions & 54 deletions src/Spec2-Core/SpApplication.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down Expand Up @@ -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 [

Expand Down Expand Up @@ -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 [

Expand Down Expand Up @@ -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 [

Expand Down Expand Up @@ -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 [

Expand Down
7 changes: 7 additions & 0 deletions src/Spec2-Core/SpPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down
44 changes: 44 additions & 0 deletions src/Spec2-Dialogs-Tests/SpDialogTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Class {
#name : 'SpDialogTest',
#superclass : 'TestCase',
#category : 'Spec2-Dialogs-Tests',
#package : 'Spec2-Dialogs-Tests'
}

{ #category : 'tests - informUserDuring' }
SpDialogTest >> testInformUserDuring [

self shouldnt: [ SpInformUserDialog new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error
]

{ #category : 'tests - progress bar' }
SpDialogTest >> testInformUserDuringExecutesItsBlock [

| executed |
executed := false.
SpInformUserDialog new informUser: 'hello' during: [ executed := true ].
self assert: executed.
]

{ #category : 'tests - informUserDuring' }
SpDialogTest >> testInformUserDuringViaApplication [

self shouldnt: [ SpPresenter new application informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error.

]

{ #category : 'tests - informUserDuring' }
SpDialogTest >> testInformUserDuringViaPresenter [

self shouldnt: [ SpPresenter new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error.
self shouldnt: [ SpPresenter new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error
]

{ #category : 'tests - progress bar' }
SpDialogTest >> testProgressInformUserDuringExecutesItsBlock [

| executed |
executed := false.
SpProgressDialog new informUser: 'hello' during: [ executed := true. ].
self assert: executed.
]
1 change: 1 addition & 0 deletions src/Spec2-Dialogs-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'Spec2-Dialogs-Tests' }
70 changes: 70 additions & 0 deletions src/Spec2-Dialogs/SpApplication.extension.st
Original file line number Diff line number Diff line change
@@ -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 [

Expand All @@ -18,6 +58,12 @@ SpApplication >> newInform [
^ SpInformDialog newApplication: self
]

{ #category : '*Spec2-Dialogs' }
SpApplication >> newInformUser [

^ SpInformUserDialog newApplication: self
]

{ #category : '*Spec2-Dialogs' }
SpApplication >> newJobList [

Expand Down Expand Up @@ -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
]
Loading
Loading