function viewstable(h,varargin)

import javax.swing.*;

%% Rebuld the views table. Additional argument is a view to be excluded
%% from the table because it is in the process of being removed.

%% Method which builds/populates the views table on the viewcontainer panel

if isempty(h.Handles) || isempty(h.Handles.PNLViews) || ...
        ~ishandle(h.Handles.PNLViews)
    return % No panel
end
 
%% Assemble the views table data by traversing each child of the
%% viewcontainer
if nargin>=2
    views = setdiff(h.getChildren,varargin{1});
else
    views = h.getChildren;
end

tableData = cell([length(views) 3]);
for k=1:length(views)
    if ~isempty(views(k).Plot)
        xlim = views(k).Plot.axesgrid.getxlim{1};
        tableData(k,:) = {views(k).Label,views(k).Plot.AxesGrid.Title,...
            sprintf('%0.2g-%0.2g',xlim(1),xlim(2))};
    else
        tableData(k,:) = {views(k).Label,'[empty]',''}; 
    end
end

%% Populate the table - if necessary creating it
if ~isfield(h.Handles,'viewsTable') || isempty(h.Handles.viewsTable)
    headings = {'Node Label','Title','Domain Limits'}; 
    % Parent figure passed as the first argument until uitables can
    % be parented directly to uipanels
    [h.Handles.viewsTable, h.Handles.PNLviewsTable] = ...
        tsuitable('Parent',ancestor(h.Handles.PNLViews,'figure'),'Position',[0 0 1 1]);
    h.Handles.viewsTable.Editable = false;
    tsCustomizeUitable(h.Handles.viewsTable);
    %set(h.Handles.viewsTable,'Visible',false)
    h.Handles.viewsTable.setData(tableData);
    h.Handles.viewsTable.setColumnNames(headings);
    set(h.Handles.PNLviewsTable,'Parent',h.Handles.PNLViews)

    % Row selection only
    awtinvoke(h.Handles.viewsTable.getTable,'setSelectionMode(I)',...
        ListSelectionModel.SINGLE_SELECTION);
    awtinvoke(h.Handles.viewsTable.getTable,'setCellSelectionEnabled(Z)',false);
    awtinvoke(h.Handles.viewsTable.getTable,'setRowSelectionAllowed(Z)',true);

    % Pack the table
    awtinvoke(h.Handles.viewsTable.getTable,'setAutoResizeMode(I)',...
        JTable.AUTO_RESIZE_ALL_COLUMNS)
    
    % Select the first table row. Selection callback will update time series table 
    if size(tableData,1)>0
        awtinvoke(h.Handles.viewsTable.getTable,'setRowSelectionInterval(II)',0,0);
    end
else
    if h.Handles.viewsTable.getNumRows==0 && size(tableData,1)>0
        h.Handles.viewsTable.setData(tableData);
        awtinvoke(h.Handles.viewsTable.getTable,'setRowSelectionInterval(II)',0,0);
    else
        awtinvoke(h.Handles.viewsTable.getTable,'clearSelection()');
        h.Handles.viewsTable.setNumRows(0);
        h.Handles.viewsTable.setData(tableData);
    end
end
