From d206e4a32cb9b95461e5cc3e62cab6e7f76fdb7f Mon Sep 17 00:00:00 2001
From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de>
Date: Wed, 1 Dec 2021 07:45:52 +0100
Subject: [PATCH] Implements #92

---
 +PlotID/@userDLG/userDLG.m | 20 ++++++++++++++++++--
 +PlotID/Publish.m          |  7 ++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/+PlotID/@userDLG/userDLG.m b/+PlotID/@userDLG/userDLG.m
index 3e7cbf4..7b82f79 100644
--- a/+PlotID/@userDLG/userDLG.m
+++ b/+PlotID/@userDLG/userDLG.m
@@ -55,7 +55,7 @@ classdef userDLG
                  obj.error(errorMessage) 
               end           
        end
-       
+           
        function [] = userMSG(obj,message)
             %userMSG user message without priority
             %   MSG will only be displaye if ShowMessages is true
@@ -83,5 +83,21 @@ classdef userDLG
             end
         end
     end
-end
+    
+    methods(Static)
+       function [status] = userQuestion(dialogMessage)
+        %userQuestion displays Y/N user input
+          m = '';
+          while ~ismember(m,{'Y','y','n','N'})
+              m = input([dialogMessage,', Y/N [Y]? '],'s');
+          end
+          if ismember(m,{'Y','y'})
+              status = true;
+          else
+             status = false;
+          end           
+       end 
+    end %static 
+    
+end % class
 
diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m
index 3d1db28..f99bcff 100644
--- a/+PlotID/Publish.m
+++ b/+PlotID/Publish.m
@@ -138,7 +138,12 @@ if isfolder(fullfile(storPath,folderNameV))
    msg = ['Folder ',folderNameV, ' exists - Plot was already published '];
    disp(msg);
    dialogMsg = 'Do you want to overwrite the existing files';
-   overwriteDir = dlgObj.userDialog(dialogMsg, msg); 
+   overwriteDir = dlgObj.userQuestion(dialogMsg);
+   if ~overwriteDir % USR does not want to overwrite
+       warning('PlotID has finished without an export');
+       disp('rerun TagPlot if you need a new ID or consider overwriting.');
+       return; %terminate
+   end
 end
 % create folder
 if ~mkdir(fullfile(storPath,folderName))
-- 
GitLab