From 5c3fc06c536a06de186b90d8f697c54c0bd491fc Mon Sep 17 00:00:00 2001 From: Christophe Demarey Date: Wed, 12 Sep 2018 15:02:19 +0200 Subject: [PATCH] fix #240 - command could fail if dialog canceled --- .../PhLCommand.class/instance/executeCommand.st | 5 +++++ .../PhLCommand.class/instance/executeIfApplicable.st | 2 +- .../PhLCommandCancellation.class/README.md | 1 + .../PhLCommandCancellation.class/properties.json | 11 +++++++++++ .../instance/createTemplate.st | 1 + .../instance/execute.st | 3 ++- 6 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/PharoLauncher-Core.package/PhLCommand.class/instance/executeCommand.st create mode 100644 src/PharoLauncher-Core.package/PhLCommandCancellation.class/README.md create mode 100644 src/PharoLauncher-Core.package/PhLCommandCancellation.class/properties.json diff --git a/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeCommand.st b/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeCommand.st new file mode 100644 index 00000000..d302014b --- /dev/null +++ b/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeCommand.st @@ -0,0 +1,5 @@ +action +executeCommand + [ self execute ] + on: PhLCommandCancellation + do: [ :ex | "Do nothing - user has cancelled the command" ]. \ No newline at end of file diff --git a/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeIfApplicable.st b/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeIfApplicable.st index e962e708..d9509185 100644 --- a/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeIfApplicable.st +++ b/src/PharoLauncher-Core.package/PhLCommand.class/instance/executeIfApplicable.st @@ -1,4 +1,4 @@ action executeIfApplicable self isApplicable ifTrue: [ - self validateModelIntegrity ifTrue: [self execute ]] \ No newline at end of file + self validateModelIntegrity ifTrue: [self executeCommand ]] \ No newline at end of file diff --git a/src/PharoLauncher-Core.package/PhLCommandCancellation.class/README.md b/src/PharoLauncher-Core.package/PhLCommandCancellation.class/README.md new file mode 100644 index 00000000..683bee5b --- /dev/null +++ b/src/PharoLauncher-Core.package/PhLCommandCancellation.class/README.md @@ -0,0 +1 @@ +Get notified if a user canceled an operation do not run following operations if any \ No newline at end of file diff --git a/src/PharoLauncher-Core.package/PhLCommandCancellation.class/properties.json b/src/PharoLauncher-Core.package/PhLCommandCancellation.class/properties.json new file mode 100644 index 00000000..86995139 --- /dev/null +++ b/src/PharoLauncher-Core.package/PhLCommandCancellation.class/properties.json @@ -0,0 +1,11 @@ +{ + "commentStamp" : "ChristopheDemarey 9/12/2018 12:27", + "super" : "Notification", + "category" : "PharoLauncher-Core-Model", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ ], + "name" : "PhLCommandCancellation", + "type" : "normal" +} \ No newline at end of file diff --git a/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageAndRemoveImageCommand.class/instance/createTemplate.st b/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageAndRemoveImageCommand.class/instance/createTemplate.st index 0018cc5b..1421229d 100644 --- a/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageAndRemoveImageCommand.class/instance/createTemplate.st +++ b/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageAndRemoveImageCommand.class/instance/createTemplate.st @@ -2,6 +2,7 @@ action createTemplate | name | name := self newTemplateName. + name ifNil: [ PhLCommandCancellation signal ]. self ensure: (self model isNewLocalTemplateNameValid: name). self model templateRepository diff --git a/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageCommand.class/instance/execute.st b/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageCommand.class/instance/execute.st index f2a4ac13..c7975d9d 100644 --- a/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageCommand.class/instance/execute.st +++ b/src/PharoLauncher-Core.package/PhLCreateTemplateFromImageCommand.class/instance/execute.st @@ -2,5 +2,6 @@ action execute | name | name := self newTemplateName. - self ensure: name isEmptyOrNil not. + name ifNil: [ PhLCommandCancellation signal ]. + self ensure: name isNotEmpty. self model templateRepository createLocalTemplateFrom: self model singleImage named: name \ No newline at end of file