function open(h)

%% Populates the calandar dialog with the month corresponding to the
%% current DateNum property and selected the current date within that month

import javax.swing.*;

%% Get the datavec for the current date
thisdatevec = datevec(h.DateNum);

%% Set the title for the correct type
if strcmp(h.Type,'start')
    set(h.Figure,'Name','Specify Start Date/Time')
elseif strcmp(h.Type,'end')
    set(h.Figure,'Name','Specify End Date/Time')
else
    set(h.Figure,'Name','Specify Date/Time')
end

%% Find the start and end data of the selected month
startDay = datestr(datenum([thisdatevec(1:2), 1, 0, 0, 0]),'ddd');
if thisdatevec(2)<12
   numDays = datenum( [thisdatevec(1), thisdatevec(2)+1, 1, 0, 0, 0])- ...
       datenum([thisdatevec(1), thisdatevec(2), 1, 0, 0, 0]);
else
   numDays = 31;
end

%% Build the data for the calendar table
days = {'Sun','Mon','Tue','Wed','Thu','Fri','Sat'};
startCol = find(strcmp(startDay,days))-1;
tableData = cell(7,6);
for k=1:numDays
     tableData{startCol+k} = sprintf('%d  ',k);
end
tableData = tableData';
if ~isequal(cell(h.Table.Data(2:end,:)),tableData)
    h.Table.setData([{'S','M','T','W','T','F','S'};...
                     tableData]);
end
currentDate = str2num(datestr(thisdatevec,'dd'));
awtinvoke(h.Table.getTable,'setColumnSelectionInterval(II)',...
    mod(currentDate+startCol-1,7),mod(currentDate+startCol-1,7));
awtinvoke(h.Table.getTable,'setRowSelectionInterval(II)',...
    floor((currentDate+startCol-1)/7)+1,floor((currentDate+startCol-1)/7)+1);

%% Select the current month in the month combo
set(h.Handles.monthCombo,'Value',thisdatevec(2))

%% Set the current time
set(h.Handles.EDITTime,'String',datestr(h.DateNum,'HH:MM:SS'))

%% Show calendar and bring to front
h.Visible = 'on';
figure(h.Figure)
