From e110364b194e97d98c7bc87b9be1a2bbb063d67c Mon Sep 17 00:00:00 2001 From: DEMAREY Christophe Date: Fri, 5 Jul 2024 11:32:36 +0200 Subject: [PATCH] give application and parentWindow when using spec backend --- .../SpAbstractMessageDialog.extension.st | 6 ++++ .../SpConfirmDialog.extension.st | 2 +- .../SpInformDialog.extension.st | 2 +- .../StFileSystemPresenter.extension.st | 2 +- src/Interactions/ITFileRequest.class.st | 8 ++++- src/Interactions/ITUserInteraction.class.st | 31 ++++++++++++++++++- 6 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/Interactions-Tests/SpAbstractMessageDialog.extension.st diff --git a/src/Interactions-Tests/SpAbstractMessageDialog.extension.st b/src/Interactions-Tests/SpAbstractMessageDialog.extension.st new file mode 100644 index 0000000..e7691f6 --- /dev/null +++ b/src/Interactions-Tests/SpAbstractMessageDialog.extension.st @@ -0,0 +1,6 @@ +Extension { #name : 'SpAbstractMessageDialog' } + +{ #category : '*Interactions-Tests' } +SpAbstractMessageDialog >> label [ + ^ label text +] diff --git a/src/Interactions-Widgets/SpConfirmDialog.extension.st b/src/Interactions-Widgets/SpConfirmDialog.extension.st index a9f689c..f027c32 100644 --- a/src/Interactions-Widgets/SpConfirmDialog.extension.st +++ b/src/Interactions-Widgets/SpConfirmDialog.extension.st @@ -3,7 +3,7 @@ Extension { #name : 'SpConfirmDialog' } { #category : '*Interactions-Widgets' } SpConfirmDialog class >> for: aConfirmation [ - ^ self new + ^ (self newApplication: aConfirmation application owner: aConfirmation parentWindow) title: aConfirmation title; label: aConfirmation message; acceptLabel: aConfirmation yesLabel; diff --git a/src/Interactions-Widgets/SpInformDialog.extension.st b/src/Interactions-Widgets/SpInformDialog.extension.st index aa285c5..7a7ad7f 100644 --- a/src/Interactions-Widgets/SpInformDialog.extension.st +++ b/src/Interactions-Widgets/SpInformDialog.extension.st @@ -3,7 +3,7 @@ Extension { #name : 'SpInformDialog' } { #category : '*Interactions-Widgets' } SpInformDialog class >> for: anITInformation [ - ^ self new + ^ (self newApplication: anITInformation application owner: anITInformation parentWindow) title: anITInformation title; label: anITInformation message; yourself diff --git a/src/Interactions-Widgets/StFileSystemPresenter.extension.st b/src/Interactions-Widgets/StFileSystemPresenter.extension.st index 6e8ad25..384e9ba 100644 --- a/src/Interactions-Widgets/StFileSystemPresenter.extension.st +++ b/src/Interactions-Widgets/StFileSystemPresenter.extension.st @@ -9,7 +9,7 @@ StFileSystemPresenter >> doInteraction [ { #category : '*Interactions-Widgets' } StFileSystemPresenter class >> for: aFileRequest [ - ^ self new + ^ (self new"Application: aFileRequest application owner: aFileRequest parentWindow model: StFileSystemModel new") title: aFileRequest title; yourself ] diff --git a/src/Interactions/ITFileRequest.class.st b/src/Interactions/ITFileRequest.class.st index 62da44d..caade82 100644 --- a/src/Interactions/ITFileRequest.class.st +++ b/src/Interactions/ITFileRequest.class.st @@ -14,12 +14,18 @@ Class { #package : 'Interactions' } -{ #category : 'configuring' } +{ #category : 'private' } ITFileRequest >> beForFolderOpening [ isForFileOpening := false ] +{ #category : 'running' } +ITFileRequest >> chooseDirectory [ + self beForFolderOpening. + ^ self chooseFile +] + { #category : 'running' } ITFileRequest >> chooseFile [ diff --git a/src/Interactions/ITUserInteraction.class.st b/src/Interactions/ITUserInteraction.class.st index 39ba03c..da0672d 100644 --- a/src/Interactions/ITUserInteraction.class.st +++ b/src/Interactions/ITUserInteraction.class.st @@ -1,22 +1,51 @@ " I'm an abstraction of a user interaction. + +I may hold a reference to the application that triggered the interaction. +I may hold a reference to a parent window when intended to be used on a GUI backend. " Class { #name : 'ITUserInteraction', #superclass : 'Object', #instVars : [ - 'title' + 'title', + 'application', + 'parentWindow' ], #category : 'Interactions', #package : 'Interactions' } +{ #category : 'accessing' } +ITUserInteraction >> application [ + + ^ application +] + +{ #category : 'accessing' } +ITUserInteraction >> application: anObject [ + + application := anObject +] + { #category : 'private' } ITUserInteraction >> backend [ ^ SpecInteraction default ] +{ #category : 'accessing' } +ITUserInteraction >> parentWindow [ + + ^ parentWindow +] + +{ #category : 'accessing' } +ITUserInteraction >> parentWindow: anObject [ + + parentWindow := anObject +] + { #category : 'accessing' } ITUserInteraction >> title [ ^ title