function initialize(h,manager)

import javax.swing.*;

%% Builds the Descriptive Stats dialog

%% Main figure
h.Figure = figure('Units','Characters','Position',[103 31 77.2 30.6],'Toolbar',...
    'None','Numbertitle','off','Menubar','None','Name','Descriptive Statistics',...
    'Visible','off','closeRequestFcn',@(es,ed) set(h,'Visible','off'),...
    'HandleVisibility','callback');

%% Labels
LBLselts = uicontrol('Style','Text','Parent',h.Figure,'Units','Characters',...
    'Position',[2.8 27.61 17.8 1.154],'String','Select time series',...
    'HorizontalAlignment','Left');
LBLstats = uicontrol('Style','Text','Parent',h.Figure,'Units','Characters',...
    'Position',[2.8 14.154 55.2 1.154],'String',...
    'Descriptive statistics summary for selected time series',...
    'HorizontalAlignment','Left');

%% Build time series table
[h.Handles.tsTable, tsTablePanel] = tsuitable(cell(0,2), ...
    {'Time Series','Number of Columns'},'Parent',h.Figure);
h.Handles.tsTable.Editable = false;
tsCustomizeUitable(h.Handles.tsTable)
set(tsTablePanel,'Parent',h.Figure,'Units','Characters','Position',...
    [4 18 69.4 8.385])
awtinvoke(h.Handles.tsTable.getTable,'setSelectionMode(I)',...
    ListSelectionModel.SINGLE_SELECTION);
awtinvoke(h.Handles.tsTable.getTable,'setAutoResizeMode(I)',...
    JTable.AUTO_RESIZE_ALL_COLUMNS);
awtinvoke(h.Handles.tsTable.getTable,'setCellSelectionEnabled(Z)',false);
awtinvoke(h.Handles.tsTable.getTable,'setRowSelectionAllowed(Z)',true);

% List selection listener must update time series table chaned status
listSelectionListener = ...
    handle(h.Handles.tsTable.getTable.getSelectionModel,'callbackproperties');
listSelectionListener.ValueChangedCallback = {@localTsSelection h};

%% Stats table
[h.Handles.statsTable, statsTablePanel] = tsuitable(cell(0,6), ...
    {'Column #','Mean','Median','STD','Min','Max'},...
    'Parent',h.Figure);
h.Handles.statsTable.Editable = false;
tsCustomizeUitable(h.Handles.statsTable)
set(statsTablePanel,'Parent',h.Figure,'Units','Characters','Position',...
    [4 5 69.4 8.385])
awtinvoke(h.Handles.statsTable.getTable,'setAutoResizeMode(I)',...
    JTable.AUTO_RESIZE_ALL_COLUMNS);

%% Dialog buttons
BTNcancel = uicontrol('style','Pushbutton','Parent',h.Figure,'Units','Characters',...
    'Position',[59.8 0.769 13.8 1.769],'String','Close','Callback', ...
    @(es,ed) set(h,'Visible','off'));
set(h.Figure,'Color',get(BTNcancel,'BackgroundColor'));

%% Install general listeners
h.generic_listeners
manager.Listeners = [manager.Listeners; handle.listener(manager,manager.findprop('Visible'),...
    'PropertyPostSet',{@localHide h manager})];

function localTsSelection(eventSrc,eventData,h)

%% Callback for row selection in time series table
selectedRow = eventData.getSource.getMaxSelectionIndex+1;
if selectedRow>0
    tsname = h.Handles.tsTable.Data(selectedRow,1);
    tsnode = h.Srcnode.getChildren('Label',tsname);
    h.Timeseries = tsnode.Timeseries;
    h.updatestats
end

h.tslisteners = [handle.listener(h.Timeseries,'datachange', ...
    @(es,ed) updatestats(h))];

function localHide(es,ed,h,manager)

%% Listener to tree manager hide will hide the stats dlg
if strcmp(manager.Visible,'off')
    set(h,'Visible','off')
end