function initializeTimePanel(h)
% INITIALIZETIMEPANEL initializes the 'Define Time Vector' panel

% Author: Rong Chen 
% Revised: 
% Copyright 1986-2004 The MathWorks, Inc.

% -------------------------------------------------------------------------
%% Build time panel
% -------------------------------------------------------------------------
h.DefaultPos.TimePanelDefaultColor=h.DefaultPos.FigureDefaultColor;
h.Handles.PNLtime = uipanel('Parent',h.Figure,...
    'Units','Pixels',...
    'FontUnits','normalized',...
    'FontSize',9,...
    'FontWeight','bold', ...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'Title','2. Define Time Vector',...
    'Position',[h.DefaultPos.leftoffsetpnl ...
                h.DefaultPos.bottomoffsetTimepnl ...
                h.DefaultPos.widthpnl ...
                h.DefaultPos.heightTimepnl] ...
    );
% create sheet combobox controls whose values are based on the rawdata
h.Handles.TXTtimeSheet = uicontrol('Parent',h.Handles.PNLtime,...
    'style','text', ...
    'Units','Pixels',...
    'BackgroundColor',h.DefaultPos.TimePanelDefaultColor,...
    'String','Time is from : ',...
    'HorizontalAlignment','Right', ...
    'Position',[h.DefaultPos.TXTtimeSheetleftoffset ...
                h.DefaultPos.TXTtimeSheetbottomoffset ...
                h.DefaultPos.TXTtimeSheetwidth ...
                h.DefaultPos.heighttxt] ...
    );
h.Handles.COMBtimeSource = uicontrol('Parent',h.Handles.PNLtime,...
    'style','popupmenu',...
    'Units', 'Pixels',...
    'BackgroundColor',[1 1 1], ...
    'String',[{'current variable'},{'entering it manually'},{'another variable'}], ...
    'Value',1,...
    'TooltipString','The time vector can be obtained from different sources.  Use this drop-down list the select the type of source and configure the source below',...
    'Position',[h.DefaultPos.COMBtimeSheetleftoffset ...
                h.DefaultPos.TXTtimeSheetbottomoffset+4 ...
                h.DefaultPos.COMBtimeSheetwidth ...
                h.DefaultPos.heightcomb], ...
    'Callback',{@localSwitchSource h} ...
    );
% create dynamic panels
h.dynamicPanel_CurrentSheet;
h.dynamicPanel_ManualInput;
h.dynamicPanel_Workspace;
% initialize dynamic panels
set(h.Handles.COMBdataSample,'Value',1);
h.TimePanelUpdate('column');


% -------------------------------------------------------------------------
%% time vector source selection callbacks
% -------------------------------------------------------------------------
function localSwitchSource(eventSrc, eventData, h)
% callback for the sheet combobox in the time panel
ind = get(eventSrc,'Value');
if ind==3
    % from workspace
    set(h.Handles.PNLtimeCurrentSheet,'Visible','off');
    set(h.Handles.PNLtimeManual,'Visible','off');
    set(h.Handles.PNLtimeWorkspace,'Visible','on');
elseif ind==2
    % manual input
    set(h.Handles.PNLtimeCurrentSheet,'Visible','off');
    set(h.Handles.PNLtimeManual,'Visible','on');
    set(h.Handles.PNLtimeWorkspace,'Visible','off');
elseif ind==1
    % currentsheet
    set(h.Handles.PNLtimeCurrentSheet,'Visible','on');
    set(h.Handles.PNLtimeManual,'Visible','off');
    set(h.Handles.PNLtimeWorkspace,'Visible','off');
end


