From d2401d14e9c5069a75c544a97edfe965b27ab709 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Mon, 22 Jul 2019 13:32:20 -0600
Subject: [PATCH] plot_shock_decomposition: plot_init_date, plot_end_date

---
 src/gui_plot_shock_decomposition.m | 68 ++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/src/gui_plot_shock_decomposition.m b/src/gui_plot_shock_decomposition.m
index d52ffcb..1a51d2d 100644
--- a/src/gui_plot_shock_decomposition.m
+++ b/src/gui_plot_shock_decomposition.m
@@ -104,6 +104,8 @@ handles.pushbuttonReset = uicontrol( ...
         handles.use_shock_groups.Value = 0;
         handles.fig_name.String = '';
         handles.vintage.String = '';
+        handles.plot_init_date.String = '';
+        handles.plot_end_date.String = '';
     end
 
 handles.pushbuttonCloseAll = uicontrol( ...
@@ -364,6 +366,44 @@ handles.pushbuttonClose = uicontrol( ...
             'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
             'Value', 0);
 
+        num = num + 1;
+        uicontrol( ...
+            'Parent', handles.uipanelResults, ...
+            'Tag', 'plot_init_date', ...
+            'Style', 'text', ...
+            'Units', 'normalized', ...
+            'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ...
+            'String', 'plot_init_date:', ...
+            'HorizontalAlignment', 'left');
+
+        handles.plot_init_date = uicontrol( ...
+            'Parent', handles.uipanelResults, ...
+            'Tag', 'plot_init_date', ...
+            'String', '', ...
+            'Style', 'edit', ...
+            'Units', 'normalized', ...
+            'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
+            'Value', 0);
+
+        num = num + 1;
+        uicontrol( ...
+            'Parent', handles.uipanelResults, ...
+            'Tag', 'plot_end_date', ...
+            'Style', 'text', ...
+            'Units', 'normalized', ...
+            'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ...
+            'String', 'plot_end_date:', ...
+            'HorizontalAlignment', 'left');
+
+        handles.plot_end_date = uicontrol( ...
+            'Parent', handles.uipanelResults, ...
+            'Tag', 'plot_end_date', ...
+            'String', '', ...
+            'Style', 'edit', ...
+            'Units', 'normalized', ...
+            'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
+            'Value', 0);
+
         num = num + 1;
         handles.use_shock_groups = uicontrol(...
             'Parent', handles.uipanelResults, ...
@@ -384,6 +424,34 @@ handles.pushbuttonClose = uicontrol( ...
             return
         end
         options_.plot_shock_decomp.vintage = str2double(handles.vintage.String);
+        
+        if ~isempty(handles.plot_init_date.String)
+            if isint(str2double(handles.plot_init_date.String))
+                options_.plot_shock_decomp.plot_init_date = str2double(handles.plot_init_date.String);
+            elseif isdate(handles.plot_init_date.String)
+                options_.plot_shock_decomp.plot_init_date = dates(handles.plot_init_date.String);
+            else
+                gui_tools.show_warning('Initial date must be an integer or a date');
+                uicontrol(hObject);
+                return
+            end
+        else
+            options_.plot_shock_decomp.plot_init_date = '';
+        end
+
+        if ~isempty(handles.plot_end_date.String)
+            if isint(str2double(handles.plot_end_date.String))
+                options_.plot_shock_decomp.plot_end_date = str2double(handles.plot_end_date.String);
+            elseif isdate(handles.plot_end_date.String)
+                options_.plot_shock_decomp.plot_end_date = dates(handles.plot_end_date.String);
+            else
+                gui_tools.show_warning('End date must be an integer or a date');
+                uicontrol(hObject);
+                return
+            end
+        else
+            options_.plot_shock_decomp.plot_end_date = '';
+        end
 
         if handles.colormap.Value ~= 1
             options_.plot_shock_decomp.colormap = handles.colormap.String{handles.colormap.Value};
-- 
GitLab