From 5f5f6f12376572f2ff18f4d5b7894b7d41d8f0d8 Mon Sep 17 00:00:00 2001 From: DEMAREY Christophe Date: Fri, 5 Jul 2024 11:50:22 +0200 Subject: [PATCH] give application and parentWindow when using spec backend --- .../SpAbstractMessageDialog.extension.st | 6 ++++ .../SpConfirmDialog.extension.st | 2 +- .../SpInformDialog.extension.st | 4 +-- .../StFileSystemPresenter.extension.st | 2 +- src/Interactions/ITFileRequest.class.st | 8 ++++- src/Interactions/ITUserInteraction.class.st | 31 ++++++++++++++++++- 6 files changed, 47 insertions(+), 6 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..333fb41 100644 --- a/src/Interactions-Widgets/SpInformDialog.extension.st +++ b/src/Interactions-Widgets/SpInformDialog.extension.st @@ -2,8 +2,8 @@ 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